Commit Graph

253 Commits

Author SHA1 Message Date
Cole Robinson 8fe0a208db Move virt-* code into their modules
This layout is closer to what most python modules have nowadays.
It also simplifies testing and static analysis setup.

Keep virt-* wrappers locally, for ease of running these commands
from a git checkout.

Adjust the wrapper binaries we install on via packaging to be
pure python, which makes things like running gdb easier.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-01-26 18:27:20 -05:00
Cole Robinson d0d672e6d5 virt-install: Change PXE warning to be less authoritative
https://bugzilla.redhat.com/show_bug.cgi?id=1693891

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-01-26 14:26:19 -05:00
Cole Robinson 5e63e87a8a cli: Default lxc:/// memory to 1024, and print it
My previous patch was misguided as pointed out by Pavel:
https://github.com/virt-manager/virt-manager/issues/73#issuecomment-574680435

And it was setting incorrect memory, which I missed because the tests
are busted here. Add a hack to work around that

Bump up the default to 1024, and print it, so the user can tell if
the default is not to their liking

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-01-15 11:07:42 -05:00
Cole Robinson 925948a19e virt-install: Add some coverage exclusions
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-01-15 11:00:21 -05:00
Cole Robinson e4f68764b0 virt-install: Set default memory to appease lxc:///
AFAICT the driver doesn't really do anything with it, but libvirt
XML requires it. So just default to --memory 64

Fixes: #73

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-01-14 13:10:03 -05:00
Cole Robinson 6bec5474db virt-install: Check --transient status in domain --wait
Otherwise when the VM shuts down, we will report an error, because
the VM doesn't exist anymore. The check_domain_inactive() helper
already handles this case, we just weren't using it in the --wait loop.

https://bugzilla.redhat.com/show_bug.cgi?id=1785643

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-12-22 18:03:19 -05:00
Cole Robinson 747c1e9d11 virt-install: Move cloudinit password printing before guest start
Otherwise if the timeout is hit, the user may miss VM boot output

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-25 14:03:49 -05:00
Cole Robinson da996317f8 cli: cloudinit: default to --autoconsole text with --cloud-init
Cloud images all work nicely with text output, and it's likely
the preferred native way to connect to the guest vs graphical.
Plus it simplifies generated password copy+paste

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-25 14:03:49 -05:00
Cole Robinson c5da0d7b07 virt-install: Don't pause for cloudinit pass if stdin is closed
Like if run in a script without any stdin open. Have the test suite
actually hit this path

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-25 14:03:49 -05:00
Cole Robinson 85a33caa76 cli: Expose default console handling through _AutoconsoleData
Rework all console queries to go through that object API

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-25 06:20:42 -05:00
Cole Robinson 44c519200c cli: Add _AutoconsoleData and use it
This will be expanded later to track explicit requests for certain
console types

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-24 18:12:06 -05:00
Cole Robinson 1676f05a59 virt-install: Split out show_console_warnings
And only call it once console handling is in play

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-24 18:12:06 -05:00
Cole Robinson 4ef519229d virt-install: Drop warning about '--console none'
This should be rarely if ever used, don't warn the user about this
case

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-24 17:25:51 -05:00
Athina Plaskasoviti 7ae6a60086 cloudinit: Move random password printing and sleeping to virt-install
Fixed:
- Added a do_log flag to print_stdout(), to avoid logging of printed random password.
- Excluded timeout in virt-install from testing

Signed-off-by: Athina Plaskasoviti <athina.plaskasoviti@gmail.com>
2019-11-20 16:41:10 -05:00
Athina Plaskasoviti 19317024cc Introduction of cloud-init configuration in virt-install
Usage:
--cloud-init

Signed-off-by: Athina Plaskasoviti <athina.plaskasoviti@gmail.com>
2019-11-20 16:41:05 -05:00
Fabiano Fidêncio b78b8a96cf virt-install: Respect --os-variant
When the user explicitly passes --os-variant via command line, its value
must be respected, always.

By setting the os name earlier, we force the os-variant to be respected
when the installer creates the Distro Store.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
2019-11-20 16:04:09 -05:00
Fabiano Fidêncio b6e4e4538d virt-install: Use virtio-win drivers if possible
Let's ensure the Windows guests being installed through unattended
installations, which are able to have pre installable drivers intalled,
will use virtio devices when possible.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
2019-10-02 11:58:34 -04:00
Fabiano Fidêncio d6d97c6587 osdict: Choose the most appropriate tree when a profile is set
As some OSes, as Fedora, have variants (which we rely to be standardised
on osinfo-db side), let's select the most appropriate variant according
to the selected profile of the unattended installation.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
2019-09-11 16:22:40 -04:00
Fabiano Fidêncio 414ffa5ef8 virt-install: Use minutes instead of seconds on get_time_string()
get_time_string() currently uses self._wait_secs, while it should use
self._wait_mins, resulting on confusing messages when using `--wait`
option, as shown below:

fidencio@laerte ~/src/upstream/virt-manager $ ./virt-install --install fedora30 --unattended --wait 20
 ...
Waiting 1200 minutes for installation to complete.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
2019-07-25 19:13:13 -04:00
Cole Robinson 5312a9611b virt-install: Revive --wait 0 as alias for --noautoconsole
This was the behavior prior to last release, and we received
a bug report about it. Revive it, but warn about the recommended way
to do it

https://bugzilla.redhat.com/show_bug.cgi?id=1724287
2019-07-03 13:12:19 -04:00
Cole Robinson edfb749f91 man: virt-install: Big update
- Document --install
- Document --unattended
- Modernize EXAMPLES section
- Deprecate --livecd
- Tweak the intro describing VM defaults
2019-06-17 00:12:32 -04:00
Cole Robinson 16362671e9 virt-install: Add --install no_install=yes|no
This just formalizes the behavior of things like --import and
--livecd
2019-06-17 00:12:32 -04:00
Cole Robinson 230545bdb3 virt-install: Make bare '--wait' mean 'wait indefinitely' 2019-06-17 00:12:32 -04:00
Cole Robinson f107e39989 Switch to more traditional logging structure
Init a shared log instance in virtinst/logger.py, and use that
throughout the code base, so we aren't calling directly into
'logging'. This helps protect our logging output from being
cluttered with other library output, as happens with some
'requests' usage
2019-06-17 00:12:31 -04:00
Cole Robinson fbe388b26a virt-install: Warn if mem less than OS recommended
And if mem is abnormally low, like it appears user tried to specify
GiB not MiB
2019-06-14 11:24:10 -04:00
Cole Robinson 17ac0d017c virt-install: Drop --os-variant suboption parsing
Not sure I want to go down that route if we can avoid it. Instead
just fold the full_id support into the existing option handling.
Streamline the OSVariantData usage throughout the cli tools
2019-06-13 21:25:05 -04:00
Cole Robinson 21723706f5 virt-install: Add --install OSNAME
Replace the unreleased --os-variant OSNAME,install=location with just

  --install OSNAME

Unwind the --unattended dependency on upfront --os-variant while
we are at it, since they are all intertwined. Now we can just do:

  virt-install --install OSNAME
and
  virt-install --install OSNAME --unattended
2019-06-13 20:26:26 -04:00
Cole Robinson 839eea3587 virt-install: Split build_installer out a bit 2019-06-13 18:46:58 -04:00
Cole Robinson ee119c3bb2 guest: Add skip_default_osinfo
We set this to True in virt-install, which will cause an explicit
error to be thrown if some part of the cli parser tries to access
osinfo before it's been set, because then we have a circular dependency
between cli config -> installer -> osinfo -> cli config
2019-06-13 18:29:39 -04:00
Cole Robinson f36e8b36bc virt-install: Rework install option detection a bit
Add an explicit no_install to Installer to encode that the user is
not expecting an install phase. Use that to determine later if any
install options were specified. This saves later code from having
to deal with installer=None, and is the basis for further clarifications
2019-06-13 16:36:21 -04:00
Cole Robinson 3b396e8321 virt-install: Split out --wait handling into a helper class
And add much more clitest coverage
2019-06-13 16:02:58 -04:00
Cole Robinson 8234b55fe8 tests: clitest: Fill in much more virt-install coverage 2019-06-13 16:02:52 -04:00
Cole Robinson 3cc42c2f24 virt-install: Drop install option collision errors
It's getting hard to track this correctly with the addition of
--install. Drop it. The important thing is validating when no install
options were specified
2019-06-13 14:13:29 -04:00
Cole Robinson c5bbf2f48d virt-install: Drop --transient and --noreboot rejection
It's a nonsensical request but it should be obscure enough to not
warrant explicit validation
2019-06-13 14:05:22 -04:00
Cole Robinson 19bcec651c virt-install: Push validation down into the installer
It's hard to validate whether something like --extra-args or
--initrd-inject is supported based on the command line arguments. It's
easier to let the installer.py figure it out because it's the
authoritative source
2019-06-13 14:00:04 -04:00
Cole Robinson b746d919a9 virt-install: Add --install kernel_args=X,kernel_args_overwrite=yes|no
--install kernel_args=X acts like --extra-args. If
kernel_args_overwrite=yes is also specified, it overwrites whatever
default kernel args we would have used for the install method.
2019-06-13 14:00:04 -04:00
Cole Robinson 1f4a5a1b43 cli: Add --install bootdev=X,kernel=X,initrd=Z
This is the beginning of a big --install option, which will be used
for tweaking less common elements of the install process
2019-06-11 17:55:09 -04:00
Cole Robinson 436c471b15 virt-install: Drop the serial extra_args warnings
There's been multiple reports that these aren't really valid nowadays.
systemd is smart enough to make this work automagically. So just drop
it
2019-06-11 17:55:09 -04:00
Cole Robinson de90716eb4 unattended: Choose a default profile name if none specified
We default to 'desktop' if none specified, otherwise we choose the
first alphabetical profile available. Make bare '--unattended' a
valid option
2019-06-11 17:55:09 -04:00
Cole Robinson 13b3790829 virt-install: Print when we set default memory and disk
Since we never defaulted here before, print out the values we are
setting. Users can see right away if they actually want those values
or not.
2019-06-11 17:55:09 -04:00
Cole Robinson b3e6ebe28b virt-install: Generate default --name
This uses the same logic as virt-manager. The name is mostly
derived from --os-variant naming, but we have fallback defaults too.

Print the name to stdout so users are informed about what we are
doing.
2019-06-11 17:55:05 -04:00
Cole Robinson 01a07a1051 virt-install: Share required option logic for resources
There's some cases we were incorrectly setting osinfo defaults, when
mem or storage values had already been specified elsewhere
2019-06-11 17:54:45 -04:00
Cole Robinson 17d157820f guest: move libosinfo resource setting to virt-install
This puts all the default resource setting in one place, and the
only place that was depending on it, as virt-manager explicitly sets
the values on its own. This will be used in future patches to add
more default setup and report the values to the user
2019-06-11 17:51:25 -04:00
Cole Robinson cc366fff7d cli: Add more code coverage 2019-06-11 17:51:25 -04:00
Cole Robinson 203c0d4a6c virt-install: Call install.get_search_paths
Similar to what we do via create.py
2019-06-11 17:51:25 -04:00
Cole Robinson 635361f0bd tests: Add osinfo URL and URL unattended tests 2019-06-08 10:20:36 -04:00
Cole Robinson 388850f04e virtinst: Rename util to xmlutil
The only functions left in there are largely for xml handling, so
make it explicit
2019-06-07 18:21:24 -04:00
Cole Robinson c0ddb86918 tests: clitest: define XML generated from compare tests
All our virt-install/virt-clone compare tests aren't actually
attempting to define the XML, meaning we could be generating bogus
output. Enable it, then fix the fallout, mostly some places we are
triggering libvirt XML validation
2019-05-14 11:57:50 -04:00
Cole Robinson 12440b00c1 osdict: return _OsResources to callers
Use the class helper routines to save some tedious dict management
2019-05-12 17:25:47 -04:00
Cole Robinson 2a30a5f0bf cli: make parse() guest argument optional
Because the non-guest parsers don't need it.
2019-05-12 17:22:13 -04:00