This adds in a ShutdownDomain action which allows for the
GracefulHalt action to attempt to shutdown the domain. If
it does not transition to domain successfully to a shutoff
state, the ShutdownDomain action is used to "nicely" shutdown
the domain. Likewise, if that action fails to transition the
domain, the HaltDomain action will be used to forcibly stop it.
Updates the halt action to use the GracefulHalt builtin action.
If the GracefulHalt builtin action fails to properly transition
the state of the guest, it will use the HaltDomain action to
forcibly stop it.
Vagrant recently bumped its minimum rspec version to 3.10. This commit
unrestricts the version so that the requirements from old and new vagrant
versions can be accommodated.
To handle where the ~/.vagrant.d global state directory for a user
doesn't exist, and thus specifying it as part of the docker run command
will result in the docker daemon creating it with root ownership.
Switch to using the working directory for user/group resolution,
searching for the Vagrantfile in the starting path and then working
up the tree. If it's not found default to the original starting path.
Combined with checking if the mounted vdir is empty, use the resolved
user/group based on the Vagrantfile and working directory to modify the
newly created directory to belong to the running user. Subsequently
ensure that the directories referenced via symlinks are created if they
don't exist.
Fixes: #1191Closes: #1254
Restructure action to remove custom handling around packaging of the
box and instead use more of the built-in provided actions instead.
Includes some packaging tests to cover both simple where the public
key is retained (can't modify the tinycore VM without more complex
provisioning steps), and a more complex one that utilizes a script
and supports triggering regenerating the hosts on subsequent boots.
The use of the upstream packaging helpers means that when the
default insecure ssh key has been replaced, the packaging process
will automatically include the generated key.
Fixes: #759Fixes: #765Fixes: #1013Fixes: #994
Switch to publishing the image containing all of the libraries and build
dependencies needed to support the plugin being reinstalled as that is
the default behaviour when vagrant installs a new plugin.
This should allow the default image to be extended with additional
plugins and if needed, the authors of the new image may follow and use
the slim version as a base to provide a reduced size docker image.
Fixes: #1198
Testing has shown that most boxes do not have the hosts keys removed as
it is non trivial to get them to regenerate on subsequent bring up.
Additionally vagrant uses `StrictHostKeyChecking=no` to ignore the host
keys so relying on them to provide any kind of security or identity of a
VM is pointless.
In the few cases where it is possible to have keys regenerate it should
be managed by how the box is cleaned up, and otherwise forced by a
provision script on first boot of the VM.
While it is possible to have a script executed via sysprep modify the
boot of the machine to ensure the keys are regenerated on the next boot,
this should either be built-in to occur automatically, and there by
assume the responsibility for ensuring host keys are replaced for each
VM packaged by vagrant-libvirt, or should default to the same behaviour
that appears to be common for many debian based boxes and simply not
attempt to remove the host keys. If removal is useful, it may be
re-enabled as needed. See #851 for a script that can be used to have
openssh-server reconfigured to trigger regenerating the keys.
A number of people have tried to fixed this previously and I failed to
understand then that they were correct. Have attributed co authorship of
this to all of the PRs authors that attempted to fix this over the
years.
Related: #759
Related: #873
Related: #955
Related: #994
Co-authored-by: Guillaume Penaud <gpenaud@xilopix.com>
Co-authored-by: Zak B. Elep <zakame@zakame.net>
To ensure the tests can be run across multiple vagrant releases, must
allow newer rspec minor releases. As these are for development, it
should be alright to allow a wider range.
Uses the json output of qemu-img info for read virtual size of disk.
Adds new ByteNumber for convert the virtual size to gygabyte, byte
and megabyte. Internally virtual size is now byte and not gigabyte.
Depending on load order of libraries as well as version of ruby, need to
require open3 before attempting to reference `Open3`.
There is an additional dependency on qemu-utils to dynamically retrieve
the image information to provide the virtual size and format
automatically. Add this to the docker image to ensure it's available for
users of this distribution format.
Fixes: #1305
Simple integration test for vagrant package to ensure the execution
completes successfully to allow for some refactoring to be performed.
Ensure libguestfs-tools installed to provide virt-sysprep for tests and
update docs to reflect.
Ensure the machine data_dir is recreated after removal because vagrant
up expects the directory to exist even if there has been an exception
and the machine has been deleted subsequently.
Ensure the source Vagrantfile appears in the virtual machine description
to help people using virsh/virt-manager subsequently to understand where
machines have come from.
Fixes: #496
If the keyfile is specified as part of the URI provided, extract it and
set the appropriate option so that it can be provided to the proxy
command subsequently.
Extract the port number from the parsed URI as part of finalizing the
uri and associated options. Don't expose this as a separate item to be
set as it can be passed in as part of the host entry.
Closes: #789
when use a public_network in vagrant, this is how libvirt domain xml looks like (notice that the interface type is 'direct'):
<interface type="direct">
<mac address="08:00:27:00:00:01"/>
<source dev="br-rpi" mode="bridge"/>
<model type="virtio"/>
<boot order="2"/> <!-- this boot xml node will be inserted with this commit -->
<address type="pci" domain="0x0000" bus="0x00" slot="0x05" function="0x0"/>
</interface>
Ensure the path attribute for disks in the new format is required to
ensure there is always one parameter required for the hash element in
the array of disks. This avoids a certain amount of magical behaviour.
Identify that the name attribute is optional, however add checks for
collisions in volume names generated, as well as ensuring the volumes
are still prefixed in a way to prevent accidental collisions between
boxes utilizing the same names.
Add notes to the README identifying the format as experimental, with
notes on how the format should appear.
Vagrant relies on the side effect of checking the machine state to
trigger updating of the state in the global machine index. As a
consequence any action should not inspect the domain state directly and
instead should access the machine state.
Additionally as part of the up/start actions should switch to built-in
WaitForCommunicator which will inspect the machine states by default to
align with the expected state updating side effects that would be in
effect for any internal provider shipped with vagrant.
Closes: #948
Partial-Fix: #193
Multi machines environments will result in collisions until auto
correction is implemented. Therefore invert to keep the forwarding of
the default ssh port disabled by default initially until can handle the
port collisions detection and resolving.
Relates: #1012
Provides an option to disable the forwarding in case it causes issues.
However based on original PRs adding the forwarded behaviour, it does
not appear to be intentional to exclude it permanently.
Closes: #1011Closes: #1012
Some build environments may have this environment variable set to a
different default value than is expected by the tests. Have rspec delete
it from the environment before starting the test run to ensure that only
the tests that explicitly set it or other config values need expect
different behaviour.
Closes: #1255
Adds some basic unit spec tests to validate the main behaviours around
the port forwarding to allow for subsequent behaviour changes.
Additionally removes the dependency on the instance variable @env for
internal functions to allow testing some of the internal functions
without needing to inject an instance variable that is not set on
initialization.
Includes a file contents matcher lifted from the cucumber/aruba project
on github, with some minor modifications instead of including the entire
gem.
When uploading disks to libvirt storage it is unnecessary to require
that the virtual size or the format be provided as these can be
retrieved by calling qemu-img on the box files to retrieve the required
information.
Update the handle box image support to separate the handling of the two
different formats and remove the need to specify the additional settings
in the case of the V2 format for multi disk boxes.
For additional disk image created by
`lib/vagrant-libvirt/action/create_domain.rb`, it is now incorrectly
hard-coded with `group: storage_uid(env)`, so even QEMU process is
running with `root:libvirt` but file is still owned by `root:root`.
Signed-off-by: Wong Hoi Sing Edison <hswong3i@pantarei-design.com>