Add --headless argument in Parser.py
Allow user to choose a headless start for the VMs Story: 2005051 Task: 47899 Change-Id: Iec6ab9ea2a2b0544f99cd6a4028173706a9c4896 Signed-off-by: Daniel Caires <daniel.caires@encora.com>
This commit is contained in:
parent
0fce663636
commit
252481411f
@ -414,3 +414,11 @@ def parse_other(parser: ArgumentParser):
|
||||
Turn on host i/o caching
|
||||
""",
|
||||
action='store_true')
|
||||
parser.add_argument("--headless", help=
|
||||
"""
|
||||
Instructs VirtualBox to start virtual machines
|
||||
without a graphical user interface (GUI).
|
||||
Especially useful in non-GUI systems
|
||||
""",
|
||||
action='store_true')
|
||||
return parser
|
||||
|
@ -792,7 +792,7 @@ def vboxmanage_createmedium(hostname=None, disk_list=None, vbox_home_dir="/home"
|
||||
time.sleep(5)
|
||||
|
||||
|
||||
def vboxmanage_startvm(hostname=None, force=False):
|
||||
def vboxmanage_startvm(hostname=None, headless=False, force=False):
|
||||
"""
|
||||
This allows you to power on a VM.
|
||||
"""
|
||||
@ -805,12 +805,16 @@ def vboxmanage_startvm(hostname=None, force=False):
|
||||
else:
|
||||
running_vms = []
|
||||
|
||||
interface_type = "gui"
|
||||
if headless:
|
||||
interface_type = "headless"
|
||||
|
||||
if hostname.encode("utf-8") in running_vms:
|
||||
LOG.info("Host %s is already started", hostname)
|
||||
else:
|
||||
LOG.info("Powering on VM %s", hostname)
|
||||
result = subprocess.check_output(
|
||||
["vboxmanage", "startvm", hostname], stderr=subprocess.STDOUT
|
||||
["vboxmanage", "startvm", hostname, "--type", interface_type], stderr=subprocess.STDOUT
|
||||
)
|
||||
LOG.info(result)
|
||||
|
||||
|
@ -898,7 +898,7 @@ def stage_install_controller0():
|
||||
ctrlr0 = V_BOX_OPTIONS.labname + "-controller-0"
|
||||
assert ctrlr0 in node_list, "controller-0 not in vm list. Stopping installation."
|
||||
|
||||
vboxmanage.vboxmanage_startvm(ctrlr0)
|
||||
vboxmanage.vboxmanage_startvm(ctrlr0, V_BOX_OPTIONS.headless)
|
||||
|
||||
sock = serial.connect(ctrlr0, 10000, getpass.getuser())
|
||||
cont0_stream = streamexpect.wrap(sock, echo=True, close_stream=False)
|
||||
@ -1261,7 +1261,7 @@ def stage_install_nodes(ssh_client):
|
||||
LOG.info("#### Powered off VMs: %s", powered_off)
|
||||
for virtual_machine in powered_off:
|
||||
LOG.info("#### Powering on VM: %s", virtual_machine)
|
||||
vboxmanage.vboxmanage_startvm(virtual_machine, force=True)
|
||||
vboxmanage.vboxmanage_startvm(virtual_machine, V_BOX_OPTIONS.headless, force=True)
|
||||
LOG.info("Give VM 20s to boot.")
|
||||
time.sleep(20)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user