Merge "Revert "Adds Calipso scenario""
authorTim Rozet <trozet@redhat.com>
Thu, 21 Sep 2017 19:05:03 +0000 (19:05 +0000)
committerGerrit Code Review <gerrit@opnfv.org>
Thu, 21 Sep 2017 19:05:03 +0000 (19:05 +0000)
apex/clean.py
apex/inventory/inventory.py
apex/overcloud/overcloud_deploy.py
apex/tests/test_apex_clean.py

index 9d0e648..0b1be86 100644 (file)
@@ -87,12 +87,36 @@ def clean_vms():
 
 def clean_ssh_keys(key_file='/root/.ssh/authorized_keys'):
     logging.info('Removing any stack pub keys from root authorized keys')
+    if not os.path.isfile(key_file):
+        logging.warning("Key file does not exist: ".format(key_file))
+        return
     for line in fileinput.input(key_file, inplace=True):
         line = line.strip('\n')
         if 'stack@undercloud' not in line:
             print(line)
 
 
+def clean_networks():
+    logging.debug('Cleaning all network config')
+    for network in constants.OPNFV_NETWORK_TYPES:
+        logging.info("Cleaning Jump Host Network config for network "
+                     "{}".format(network))
+        jumphost.detach_interface_from_ovs(network)
+        jumphost.remove_ovs_bridge(network)
+
+    conn = libvirt.open('qemu:///system')
+    if not conn:
+        raise ApexCleanException('Unable to open libvirt connection')
+    logging.debug('Destroying all virsh networks')
+    for network in conn.listNetworks():
+        if network in constants.OPNFV_NETWORK_TYPES:
+            virsh_net = conn.networkLookupByName(network)
+            logging.debug("Destroying virsh network: {}".format(network))
+            if virsh_net.isActive():
+                virsh_net.destroy()
+            virsh_net.undefine()
+
+
 def main():
     clean_parser = argparse.ArgumentParser()
     clean_parser.add_argument('-i',
@@ -123,11 +147,7 @@ def main():
     # Delete vbmc
     clean_vbmcs()
     # Clean network config
-    for network in constants.ADMIN_NETWORK, constants.EXTERNAL_NETWORK:
-        logging.info("Cleaning Jump Host Network config for network "
-                     "{}".format(network))
-        jumphost.detach_interface_from_ovs(network)
-        jumphost.remove_ovs_bridge(network)
+    clean_networks()
 
     # clean pub keys from root's auth keys
     clean_ssh_keys()
index dd731a8..71f8e52 100644 (file)
@@ -48,6 +48,10 @@ class Inventory(dict):
             if 'cpus' in node:
                 node['cpu'] = node['cpus']
 
+            # aarch64 is always uefi
+            if 'arch' in node and node['arch'] == 'aarch64':
+                node['capabilities'] += ',boot_mode:uefi'
+
             for i in ('ipmi_ip', 'ipmi_pass', 'ipmi_user', 'mac_address',
                       'disk_device'):
                 if i == 'disk_device' and 'disk_device' in node.keys():
@@ -69,7 +73,6 @@ class Inventory(dict):
                                      'for non-HA baremetal deployment')
 
         if virtual:
-            self['arch'] = platform.machine()
             self['host-ip'] = '192.168.122.1'
             self['power_manager'] = \
                 'nova.virt.baremetal.virtual_power_driver.VirtualPowerManager'
index d37d73c..f7a8b95 100644 (file)
@@ -122,9 +122,9 @@ def create_deploy_cmd(ds, ns, inv, tmp_dir,
     num_control = 0
     num_compute = 0
     for node in nodes:
-        if node['capabilities'] == 'profile:control':
+        if 'profile:control' in node['capabilities']:
             num_control += 1
-        elif node['capabilities'] == 'profile:compute':
+        elif 'profile:compute' in node['capabilities']:
             num_compute += 1
         else:
             # TODO(trozet) do we want to allow capabilities to not exist?
index b6b9d42..b3ead6f 100644 (file)
@@ -100,3 +100,15 @@ class TestClean:
         ml.listDefinedDomains.return_value = ['undercloud']
         ml.lookupByName.return_value = dummy_domain()
         assert clean.clean_vms() is None
+
+    @patch('apex.network.jumphost.detach_interface_from_ovs')
+    @patch('apex.network.jumphost.remove_ovs_bridge')
+    @patch('libvirt.open')
+    def test_clean_networks(self, mock_libvirt, mock_jumphost_ovs_remove,
+                            mock_jumphost_detach):
+        ml = mock_libvirt.return_value
+        ml.listNetworks.return_value = ['admin', 'external', 'tenant', 'blah']
+        mock_net = ml.networkLookupByName.return_value
+        mock_net.isActive.return_value = True
+        clean.clean_networks()
+        assert_equal(mock_net.destroy.call_count, 3)