Merge "Disable introspection extras"
[apex.git] / apex / undercloud / undercloud.py
index 513c419..013570d 100644 (file)
@@ -15,7 +15,7 @@ import shutil
 import subprocess
 import time
 
-from apex.virtual import virtual_utils as virt_utils
+from apex.virtual import utils as virt_utils
 from apex.virtual import configure_vm as vm_lib
 from apex.common import constants
 from apex.common import utils
@@ -30,13 +30,15 @@ class Undercloud:
     This class represents an Apex Undercloud VM
     """
     def __init__(self, image_path, template_path,
-                 root_pw=None, external_network=False):
+                 root_pw=None, external_network=False,
+                 image_name='undercloud.qcow2'):
         self.ip = None
         self.root_pw = root_pw
         self.external_net = external_network
         self.volume = os.path.join(constants.LIBVIRT_VOLUME_PATH,
                                    'undercloud.qcow2')
         self.image_path = image_path
+        self.image_name = image_name
         self.template_path = template_path
         self.vm = None
         if Undercloud._get_vm():
@@ -58,11 +60,13 @@ class Undercloud:
         networks = ['admin']
         if self.external_net:
             networks.append('external')
+        console = 'ttyAMA0' if platform.machine() == 'aarch64' else 'ttyS0'
+
         self.vm = vm_lib.create_vm(name='undercloud',
                                    image=self.volume,
                                    baremetal_interfaces=networks,
                                    direct_boot='overcloud-full',
-                                   kernel_args=['console=ttyS0',
+                                   kernel_args=['console={}'.format(console),
                                                 'root=/dev/sda'],
                                    default_network=True,
                                    template_dir=self.template_path)
@@ -132,20 +136,25 @@ class Undercloud:
 
     def setup_volumes(self):
         for img_file in ('overcloud-full.vmlinuz', 'overcloud-full.initrd',
-                         'undercloud.qcow2'):
+                         self.image_name):
             src_img = os.path.join(self.image_path, img_file)
-            dest_img = os.path.join(constants.LIBVIRT_VOLUME_PATH, img_file)
+            if img_file == self.image_name:
+                dest_img = os.path.join(constants.LIBVIRT_VOLUME_PATH,
+                                        'undercloud.qcow2')
+            else:
+                dest_img = os.path.join(constants.LIBVIRT_VOLUME_PATH,
+                                        img_file)
             if not os.path.isfile(src_img):
                 raise ApexUndercloudException(
                     "Required source file does not exist:{}".format(src_img))
             if os.path.exists(dest_img):
                 os.remove(dest_img)
             shutil.copyfile(src_img, dest_img)
-
+            shutil.chown(dest_img, user='qemu', group='qemu')
+            os.chmod(dest_img, 0o0744)
         # TODO(trozet):check if resize needed right now size is 50gb
         # there is a lib called vminspect which has some dependencies and is
         # not yet available in pip.  Consider switching to this lib later.
-        # execute ansible playbook
 
     def inject_auth(self):
         virt_ops = list()
@@ -184,6 +193,7 @@ class Undercloud:
             "enable_ui false",
             "undercloud_update_packages false",
             "undercloud_debug false",
+            "inspection_extras false",
             "undercloud_hostname undercloud.{}".format(ns['dns-domain']),
             "local_ip {}/{}".format(str(ns_admin['installer_vm']['ip']),
                                     str(ns_admin['cidr']).split('/')[1]),