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>
This commit is contained in:
parent
1676f05a59
commit
44c519200c
18
virt-convert
18
virt-convert
|
@ -77,6 +77,15 @@ def parse_args():
|
|||
# Functional handlers #
|
||||
#######################
|
||||
|
||||
def start_convert(guest, installer, options):
|
||||
autoconsole = cli.parse_autoconsole(options.autoconsole)
|
||||
if autoconsole.is_default():
|
||||
conscb = cli.get_console_cb(guest)
|
||||
print_stdout(_("Creating guest '%s'.") % guest.name)
|
||||
domain = installer.start_install(guest)
|
||||
cli.connect_console(guest, domain, conscb, True, False)
|
||||
|
||||
|
||||
def main(conn=None):
|
||||
cli.earlyLogging()
|
||||
options = parse_args()
|
||||
|
@ -86,7 +95,6 @@ def main(conn=None):
|
|||
if options.xmlonly:
|
||||
options.dry = True
|
||||
options.quiet = True
|
||||
options.autoconsole = False
|
||||
|
||||
print_cb = print_stdout
|
||||
if options.quiet:
|
||||
|
@ -102,17 +110,11 @@ def main(conn=None):
|
|||
installer = Installer(guest.conn)
|
||||
installer.set_install_defaults(guest)
|
||||
|
||||
conscb = None
|
||||
if options.autoconsole:
|
||||
conscb = cli.get_console_cb(guest) or None
|
||||
|
||||
if options.xmlonly:
|
||||
print_stdout(installer.start_install(guest, return_xml=True)[1],
|
||||
do_force=True)
|
||||
elif not options.dry or cli.in_testsuite():
|
||||
print_stdout(_("Creating guest '%s'.") % guest.name)
|
||||
domain = installer.start_install(guest)
|
||||
cli.connect_console(guest, domain, conscb, True, False)
|
||||
start_convert(guest, installer, options)
|
||||
except Exception: # pragma: no cover
|
||||
converter.cleanup()
|
||||
raise
|
||||
|
|
|
@ -634,9 +634,10 @@ class WaitHandler:
|
|||
|
||||
def start_install(guest, installer, options):
|
||||
show_console_warnings(options, guest, installer)
|
||||
autoconsole = cli.parse_autoconsole(options.autoconsole)
|
||||
|
||||
conscb = None
|
||||
if options.autoconsole:
|
||||
if autoconsole.is_default():
|
||||
conscb = cli.get_console_cb(guest)
|
||||
if not conscb and options.wait is None:
|
||||
# If there isn't any console to actually connect up,
|
||||
|
|
|
@ -1722,6 +1722,24 @@ def parse_os_variant(optstr):
|
|||
return OSVariantData(optstr)
|
||||
|
||||
|
||||
###########################
|
||||
# --noautoconsole parsing #
|
||||
###########################
|
||||
|
||||
class _AutoconsoleData(object):
|
||||
def __init__(self, autoconsole):
|
||||
self._autoconsole = autoconsole
|
||||
|
||||
def is_none(self):
|
||||
return self._autoconsole is False
|
||||
def is_default(self):
|
||||
return self._autoconsole is True
|
||||
|
||||
|
||||
def parse_autoconsole(optstr):
|
||||
return _AutoconsoleData(optstr)
|
||||
|
||||
|
||||
######################
|
||||
# --metadata parsing #
|
||||
######################
|
||||
|
|
Loading…
Reference in New Issue