186 Commits

Author SHA1 Message Date
Brian Cain
851422ee55
Ensure extra_disk_data is skipped if nil
This commit skips over adding any extra_disk_data to the storage
controller data structure in case it's nil.
2020-07-24 15:50:23 -07:00
Brian Cain
f33d513969
Include detailed info about each disk in attachment structure
This commit includes all detailed disk information from VirtualBox
inside its storage structure in Vagrant. This gives Vagrant more
detailed access for a disk beyond its uuid and port/device such as its
capacity and the type of disk it's classified as.
2020-07-13 17:06:23 -07:00
Brian Cain
a6e8c21af8
Update virtualbox to only obtain guest disks instead of all disks
This commit updates how the virtualbox provider obtains `all_disks`.
Instead of using the `list_hdds` driver method, which lists al known
harddisks for an entire VirtualBox installation, it instead uses that
array of disks to filter out the proper disks associated with the guest,
given its existance inside the guests controller attachments.
2020-07-13 16:00:40 -07:00
Jeff Bonhag
8c58e3f6f6
Refactor out method for getting the primary disk 2020-07-09 15:10:50 -04:00
Jeff Bonhag
423e212f58
Create Storage Controller array
This is an array-like object that's useful for answer questions about
the storage controllers arragement as a whole.
2020-07-09 15:09:10 -04:00
Jeff Bonhag
84d2c38cc2
Disallow multiple copies of the same ISO
This makes disk/dvd behavior more consistent, and makes it easier to
determine whether a dvd is already attached.
2020-07-09 15:09:10 -04:00
Jeff Bonhag
724687a601
Fix stale controller state
This was causing multiple dvds to be attached to the same port/device.
2020-07-09 15:09:10 -04:00
Jeff Bonhag
3c0021aac3
Use #read_storage_controllers for #get_port_and_device
This preserves the existing behavior of the method but changes the
implementation to use #read_storage_controllers. The caps that call a
mix of #get_port_and_device and #read_storage_controllers may be a
candidate for further refactoring, but this makes sure that we're
fetching storage attachments consistently.
2020-07-09 15:09:10 -04:00
Jeff Bonhag
a4a082e70e
Prevent multiple calls to #read_storage_controllers 2020-07-09 15:09:09 -04:00
Jeff Bonhag
f72ae72aaa
Change method signature
This commit changes the method signature of the VirtualBox driver
methods so they mirror the underlying VBoxManage command.
2020-07-09 15:09:09 -04:00
Jeff Bonhag
dfd3bc915c
Remove disks based on metadata
This commit changes the disk_cleanup behavior to remove disks based on
what has been recorded in the disk_meta file.
2020-07-09 15:09:07 -04:00
Jeff Bonhag
e01b51fa43
Disk management with a single controller
.configure_disks is responsible for determining the disk controller(s)
to use, given the machine configuration and the current disk config.
When a machine has a single controller, use it for all attachments.

When a machine has multiple controllers, attach disks to the SATA
controller and DVDs to the IDE controller.

This commit also returns additional attachment information
(controller/port/device) with the disk metadata.
2020-07-09 15:07:49 -04:00
Jeff Bonhag
61f43fb59f
Require controller name for #remove_disk
Also use #get_controller methods when attaching a disk.
2020-07-09 15:07:48 -04:00
Jeff Bonhag
4736fbc88f
Require storage controller for .get_next_port
This also includes #get_controller refactorings and cleanup for the
cleanup_disks capabaility.
2020-07-09 15:07:48 -04:00
Jeff Bonhag
958023dbb9
Create #get_controller method in driver
This makes it easier to check if the required controller can be found,
and automatically raise an error if it is not.

Add a #storage_bus method to the StorageController class as a shorthand
way to check the general storage controller type.
2020-07-09 15:07:48 -04:00
Jeff Bonhag
5abde797e4
Forward #storage_controller to driver 2020-07-09 15:07:47 -04:00
Jeff Bonhag
61f59de69b
Extract StorageController object 2020-07-09 15:07:47 -04:00
Jeff Bonhag
8407d79100
Refactor disk configuration to use dynamic names
This commit adds a new VirtualBox provider helper method to return a
list of storage controllers so Vagrant can find a storage controller
with the desired characteristics (type IDE or SATA).

This still needs to get wired up to the disk cleanup method.
2020-07-09 15:07:46 -04:00
Jeff Bonhag
c52eb1b44c
Feature: ISO attachment for VirtualBox
This builds on the existing disk functionality, and adds some special
IDE controller-related flavor.

Considerations for IDE controllers:
- Primary/secondary attachments, so that each port can have two devices
  attached
- Adding the ability to address a specific controller name for disk
  attachment

This also prevents a user from attaching multiple instances of the same
ISO file, because VirtualBox will assign each of these the same UUID
which makes disconnection difficult. However, if multiple copies of the
ISO are attached to different devices, removing the DVD config will
cause the duplicate devices to be removed.

We may want to consider additional work to make the storage controllers
truly generic.
2020-07-09 15:07:27 -04:00
Jeff Bonhag
f593bb54d2
Fix #8704: Raise an error if the guest IP ends with .1 (#11500)
If the VirtualBox guest property /VirtualBox/GuestInfo/Net/1/V4/IP
returns an IP address ending in .1, raise an error.

This addresses an issue that was revealed as an NFS error, where Vagrant
was creating an exports file with the wrong IP address. This was thought
to be caused by the presence of a docker0 interface, but it manifested
itself even without Docker installed.

This issue is difficult to reproduce, but hopefully this PR will get us
closer to the root cause.
2020-04-20 13:28:37 -04:00
Jeff Bonhag
a10b2c3108
Fix #11403: Parse list dhcpservers output on VirtualBox 6.1 (#11404)
This commit creates a custom `read_dhcp_servers` method in the
VirtualBox 6.1 driver to handle changes made in the ouput of
`VBoxManage list dhcpservers`.

Tests for VirtualBox 6.1+ can no longer use the shared examples for the
VirtualBox 4.x driver, because the `read_dhcp_servers` change is not
backwards compatible.

This commit also creates the boilerplate for a VirtualBox 6.x shared
example in case we want to put tests there in the future.
2020-02-18 15:14:31 -05:00
Brian Cain
4866709c67
Move disk cloning to virtualbox driver 5 2020-02-10 15:17:23 -08:00
Brian Cain
b2a89f8711
Remove old comment on vbox driver disk method 2020-02-10 12:58:11 -08:00
Brian Cain
773a3aeb7e
Add optional hash arguments to driver methods 2020-02-10 12:58:11 -08:00
Brian Cain
b9a72ce8ff
Make get_port_and_device disk method a driver method instead 2020-02-10 12:58:11 -08:00
Brian Cain
9a5ce8381b
Add comment field for new disks 2020-02-10 12:58:11 -08:00
Brian Cain
17b75db35b
Move disk driver methods into virtualbox version 5 2020-02-10 12:58:11 -08:00
Brian Cain
1e2570a599
Add methods for controller attaching 2020-02-10 12:58:11 -08:00
Brian Cain
7215764130
Remove medium vars from base driver 2020-02-10 12:58:11 -08:00
Brian Cain
e31b013df8
Ensure vmdk disks that are resized stay in original format 2020-02-10 12:58:11 -08:00
Brian Cain
16c38ed9f4
Fix params for attach_disk driver call 2020-02-10 12:58:11 -08:00
Brian Cain
4d4844fdef
Simplify params for virtualbox driver attach_disk 2020-02-10 12:58:11 -08:00
Brian Cain
6ba621ac92
Add ability to cleanup and close mediums for a guest 2020-02-10 12:58:11 -08:00
Brian Cain
0dfde12e9a
Add clone_disk method to virtualbox driver 2020-02-10 12:58:11 -08:00
Brian Cain
2e884207df
Rename disk_size variable
Use bytes instead of mb to align with flag used
2020-02-10 12:58:11 -08:00
Brian Cain
fcc9c55fa0
Begin to add code for resizing VMDK type disks 2020-02-10 12:58:11 -08:00
Brian Cain
4df346c5c6
Add resize for disks
Also add warnings in case disk resize request is smaller than original
disk size.
2020-02-10 12:58:11 -08:00
Brian Cain
7e686e6f70
Attach harddisk after creation 2020-02-10 12:58:11 -08:00
Brian Cain
2a3f9dad29
Remove uuid from params
No need to pass in machine uuid as it is a class variable already for the driver
2020-02-10 12:58:11 -08:00
Brian Cain
259cb5fcca
Attempt to create and attach disk to guest 2020-02-10 12:58:11 -08:00
Brian Cain
35c8db56ec
Add handling for configuring and creating disks with vbox provider 2020-02-10 12:58:11 -08:00
Brian Cain
cac56c983c
Add extra key for vbox driver with listing hdds 2020-02-10 12:58:11 -08:00
Brian Cain
5be7989f2d
Add basic driver methods for disk operations 2020-02-10 12:58:11 -08:00
Brian Cain
16cccd504a
Add virtualbox driver method for obtaining vm information 2020-02-10 12:58:11 -08:00
Brian Cain
fb4e6985e1
Fixes #11249: Add VirtualBox provider support for version 6.1.x
This commit adds support for VirtualBox version 6.1.x. It simply
inherits from the base 6.0.x provider class.
2019-12-11 13:25:11 -08:00
Chris Roberts
cf99438f1f Update base path on windows to use common file separator
On Windows the File::SEPARATOR ends up being `/` which causes
issues with the new way the path is being extracted from the
vbox information. When on Windows (even with WSL), automatically
convert the path to use common forward slash separator. This
fixes path modifications used for storing guest disks.
2019-01-29 11:09:25 -08:00
Chris Roberts
b8f5752a82 Update VM import for VirtualBox 6 driver
The dry run import with VirtualBox 6 no longer provides full paths
for disks. Extract base path from suggested settings file location
and use that to generate full path name using provided disk base
name.
2018-11-15 11:04:08 -08:00
Chris Roberts
c7721f619b Update VirtualBox driver ssh_port helper
Be more restrictive when matching the port forward used for
SSH. Allow matching simply on the guest port, but also include
extra matching criteria for cases where multiple results may
be returned.
2018-11-13 15:04:12 -08:00
Chris Roberts
9d728682c4 Add vbox provider driver for 6.0 2018-11-06 16:50:17 -08:00
Chris Roberts
de42681742 Inherit from common base since 5.1 driver has no changes 2018-11-06 16:50:17 -08:00