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>
This commit is contained in:
parent
c5da0d7b07
commit
da996317f8
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
||||
######################
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue