diff options
Diffstat (limited to 'apex/virtual')
-rwxr-xr-x | apex/virtual/configure_vm.py | 9 | ||||
-rw-r--r-- | apex/virtual/exceptions.py | 12 | ||||
-rw-r--r-- | apex/virtual/utils.py | 36 |
3 files changed, 50 insertions, 7 deletions
diff --git a/apex/virtual/configure_vm.py b/apex/virtual/configure_vm.py index 3b2c4462..9d47bf03 100755 --- a/apex/virtual/configure_vm.py +++ b/apex/virtual/configure_vm.py @@ -102,6 +102,10 @@ def create_vm(name, image, diskbus='sata', baremetal_interfaces=['admin'], with open(os.path.join(template_dir, 'domain.xml'), 'r') as f: source_template = f.read() imagefile = os.path.realpath(image) + + if arch == 'aarch64' and diskbus == 'sata': + diskbus = 'virtio' + memory = int(memory) * 1024 params = { 'name': name, @@ -118,9 +122,6 @@ def create_vm(name, image, diskbus='sata', baremetal_interfaces=['admin'], 'user_interface': '', } - # assign scsi as default for aarch64 - if arch == 'aarch64' and diskbus == 'sata': - diskbus = 'scsi' # Configure the bus type for the target disk device params['diskbus'] = diskbus nicparams = { @@ -171,7 +172,7 @@ def create_vm(name, image, diskbus='sata', baremetal_interfaces=['admin'], """ params['user_interface'] = """ <controller type='virtio-serial' index='0'> - <address type='virtio-mmio'/> + <address type='pci'/> </controller> <serial type='pty'> <target port='0'/> diff --git a/apex/virtual/exceptions.py b/apex/virtual/exceptions.py new file mode 100644 index 00000000..e3dff51a --- /dev/null +++ b/apex/virtual/exceptions.py @@ -0,0 +1,12 @@ +############################################################################## +# Copyright (c) 2018 Tim Rozet (trozet@redhat.com) and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +class ApexVirtualException(Exception): + pass diff --git a/apex/virtual/utils.py b/apex/virtual/utils.py index 226af1b5..8b24bc40 100644 --- a/apex/virtual/utils.py +++ b/apex/virtual/utils.py @@ -18,6 +18,8 @@ import xml.etree.ElementTree as ET from apex.common import utils as common_utils from apex.virtual import configure_vm as vm_lib +from apex.virtual import exceptions as exc +from time import sleep from virtualbmc import manager as vbmc_lib DEFAULT_RAM = 8192 @@ -131,11 +133,39 @@ def host_setup(node): chain.insert_rule(rule) try: subprocess.check_call(['vbmc', 'start', name]) - logging.debug("Started vbmc for domain {}".format(name)) + logging.debug("Started VBMC for domain {}".format(name)) except subprocess.CalledProcessError: - logging.error("Failed to start vbmc for {}".format(name)) + logging.error("Failed to start VBMC for {}".format(name)) raise - logging.debug('vmbcs setup: {}'.format(vbmc_manager.list())) + + logging.info("Checking VBMC {} is up".format(name)) + is_running = False + for x in range(0, 4): + logging.debug("Polling to see if VBMC is up, attempt {}".format(x)) + try: + output = subprocess.check_output(['vbmc', 'show', name], + stderr=subprocess.STDOUT) + except subprocess.CalledProcessError: + logging.warning('Unable to issue "vbmc show" cmd') + continue + for line in output.decode('utf-8').split('\n'): + if 'status' in line: + if 'running' in line: + is_running = True + break + else: + logging.debug('VBMC status is not "running"') + break + if is_running: + break + sleep(1) + if is_running: + logging.info("VBMC {} is up and running".format(name)) + else: + logging.error("Failed to verify VBMC is running") + raise exc.ApexVirtualException("Failed to bring up vbmc " + "{}".format(name)) + logging.debug('VBMCs setup: {}'.format(vbmc_manager.list())) def virt_customize(ops, target): |