diff --git a/tests/clitest.py b/tests/clitest.py index 7406b9180..398f470e8 100644 --- a/tests/clitest.py +++ b/tests/clitest.py @@ -879,7 +879,6 @@ c.add_compare("--disk %(EXISTIMG1)s --os-variant fedora28 --cloud-init root-pass c.add_compare("--disk %(EXISTIMG1)s --os-variant fedora28 --cloud-init root-password-file=%(ADMIN-PASSWORD-FILE)s,disable=no", "cloud-init-options") # --cloud-init root-password-file c.add_compare("--disk %(EXISTIMG1)s --os-variant fedora28 --cloud-init ssh-key=%(XMLDIR)s/cloudinit/ssh-key.txt", "cloud-init-options") # --cloud-init ssh-key c.add_compare("--disk %(EXISTIMG1)s --os-variant fedora28 --cloud-init user-data=%(XMLDIR)s/cloudinit/user-data.txt,meta-data=%(XMLDIR)s/cloudinit/meta-data.txt", "cloud-init-options") # --cloud-init user-data=,meta-data= -c.add_valid("--connect %(URI-KVM)s --disk %(EXISTIMG1)s --install fedora28 --cloud-init", grep="Password for first root login") # make sure we print the root login password c.add_valid("--panic help --disk=? --check=help", grep="path_in_use") # Make sure introspection doesn't blow up c.add_valid("--connect test:///default --test-stub-command", use_default_args=False) # --test-stub-command c.add_valid("--nodisks --pxe", grep="VM performance may suffer") # os variant warning @@ -1104,6 +1103,8 @@ c.add_valid("--nographics --console none --location %(TREEDIR)s", grep="Director c.add_valid("--pxe --nographics --transient", grep="testsuite console command: ['virsh'") # --transient handling c.add_valid("--pxe --nographics --autoconsole graphical", grep="testsuite console command: ['virt-viewer'") # force --autoconsole graphical c.add_valid("--pxe --autoconsole text", grep="testsuite console command: ['virsh'") # force --autoconsole text +c.add_valid("--connect %(URI-KVM)s --install fedora28 --cloud-init", grep="Password for first root login") # make sure we print the root login password +c.add_valid("--connect %(URI-KVM)s --install fedora28 --cloud-init", grep="testsuite console command: ['virsh'") # make sure we notify about text console c.add_invalid("--pxe --autoconsole badval") # bad --autoconsole value diff --git a/virt-convert b/virt-convert index bd1b9fa29..7c68862e8 100755 --- a/virt-convert +++ b/virt-convert @@ -78,7 +78,7 @@ def parse_args(): ####################### def start_convert(guest, installer, options): - autoconsole = cli.parse_autoconsole(options, guest) + autoconsole = cli.parse_autoconsole(options, guest, installer) conscb = autoconsole.get_console_cb() print_stdout(_("Creating guest '%s'.") % guest.name) domain = installer.start_install(guest) diff --git a/virt-install b/virt-install index 0bec5f3e2..b8c5a78bc 100755 --- a/virt-install +++ b/virt-install @@ -655,9 +655,8 @@ def _print_cloudinit_passwd(installer): def start_install(guest, installer, options): - autoconsole = cli.parse_autoconsole(options, guest) + autoconsole = cli.parse_autoconsole(options, guest, installer) show_console_warnings(installer, autoconsole) - conscb = autoconsole.get_console_cb() conscb = autoconsole.get_console_cb() if autoconsole.is_default() and not conscb and options.wait is None: diff --git a/virtinst/cli.py b/virtinst/cli.py index a4cc889e4..05f91625e 100644 --- a/virtinst/cli.py +++ b/virtinst/cli.py @@ -1701,12 +1701,16 @@ def parse_os_variant(optstr): # --noautoconsole parsing # ########################### -def _determine_default_autoconsole_type(guest): +def _determine_default_autoconsole_type(guest, installer): """ Determine the default console for the passed guest config :returns: 'text', 'graphical', or None """ + if installer.has_cloudinit(): + log.info("--cloud-init specified, defaulting to --autoconsole text") + return "text" + gdevs = guest.devices.graphics if not gdevs: return "text" @@ -1734,14 +1738,14 @@ def _determine_default_autoconsole_type(guest): class _AutoconsoleData(object): - def __init__(self, autoconsole, guest): + def __init__(self, autoconsole, guest, installer): self._autoconsole = autoconsole if self._autoconsole not in ["none", "default", "text", "graphical"]: fail(_("Unknown autoconsole type '%s'") % self._autoconsole) self._is_default = self._autoconsole == "default" if self._is_default: - default = _determine_default_autoconsole_type(guest) + default = _determine_default_autoconsole_type(guest, installer) self._autoconsole = default or "none" def is_text(self): @@ -1759,8 +1763,8 @@ class _AutoconsoleData(object): return None -def parse_autoconsole(options, guest): - return _AutoconsoleData(options.autoconsole, guest) +def parse_autoconsole(options, guest, installer): + return _AutoconsoleData(options.autoconsole, guest, installer) ###################### diff --git a/virtinst/install/installer.py b/virtinst/install/installer.py index e0d82fd7d..0de714c5e 100644 --- a/virtinst/install/installer.py +++ b/virtinst/install/installer.py @@ -438,6 +438,9 @@ class Installer(object): self._tmpfiles.append(iso) self._add_unattended_install_cdrom_device(guest, iso) + def has_cloudinit(self): + return bool(self._cloudinit_data) + def get_generated_password(self): if self._cloudinit_data: return self._cloudinit_data.get_password_if_generated()