diff --git a/code/daisy/daisy/api/backends/common.py b/code/daisy/daisy/api/backends/common.py index 62c49361..18b18260 100755 --- a/code/daisy/daisy/api/backends/common.py +++ b/code/daisy/daisy/api/backends/common.py @@ -985,11 +985,11 @@ def check_vlan_nic_and_join_vlan_network(req, cluster_id, # physical nic name. vlan_id = nic_name_list[len(nic_name_list) - 1] nic_name = interface_info['name'][: -len(vlan_id) - 1] - exclude_networks = ['DATAPLANE', 'EXTERNAL'] + exclude_networks = ['EXTERNAL'] use_share_disk = if_used_shared_storage(req, cluster_id) if not use_share_disk: - exclude_networks.append('STORAGE') - + #exclude_networks.append('STORAGE') + pass for network in networks: if network['network_type'] in exclude_networks: continue @@ -1070,11 +1070,12 @@ def check_bond_or_ether_nic_and_join_network(req, % host_info_ip LOG.error(msg) raise exception.Forbidden(msg) - exclude_networks = ['DATAPLANE', 'EXTERNAL'] + exclude_networks = ['EXTERNAL'] use_share_disk = if_used_shared_storage(req, cluster_id) if not use_share_disk: - exclude_networks.append('STORAGE') + #exclude_networks.append('STORAGE') + pass for network in networks: if network['network_type'] in exclude_networks: continue diff --git a/code/daisy/daisy/api/backends/kolla/uninstall.py b/code/daisy/daisy/api/backends/kolla/uninstall.py index 43d22d1b..ec128394 100755 --- a/code/daisy/daisy/api/backends/kolla/uninstall.py +++ b/code/daisy/daisy/api/backends/kolla/uninstall.py @@ -25,6 +25,7 @@ import daisy.api.backends.common as daisy_cmn import daisy.api.backends.kolla.common as kolla_cmn import daisy.registry.client.v1.api as registry from threading import Thread +import threading from daisy.common import exception @@ -35,6 +36,7 @@ _LI = i18n._LI _LW = i18n._LW kolla_state = kolla_cmn.KOLLA_STATE +thread_flag = {} def update_all_host_progress_to_db(req, hosts_id_list, role_host_meta={}): @@ -94,6 +96,46 @@ def _calc_uninstall_progress(log_file): return progress +def remove_registry(req, hosts_id_list, host_ip, log_file): + LOG.info(_("begin to remove docker images on host %s" % host_ip)) + try: + check_docker_container_cmd = \ + "ssh -o StrictHostKeyChecking=no %s \ + docker ps |grep registry:2 |awk -F ' ' '{print $2}'" % (host_ip) + docker_container_result = \ + subprocess.check_output(check_docker_container_cmd, + shell=True, + stderr=subprocess.STDOUT) + + stop_docker_container_cmd = \ + 'ssh -o StrictHostKeyChecking=no %s \ + "docker stop registry"' % (host_ip) + remove_docker_container_cmd = \ + 'ssh -o StrictHostKeyChecking=no %s \ + "docker rm registry"' % (host_ip) + remove_docker_images_cmd = \ + 'ssh -o StrictHostKeyChecking=no %s \ + "docker rmi -f registry:2"' % (host_ip) + + if "registry:2" in docker_container_result: + daisy_cmn.subprocess_call(stop_docker_container_cmd, log_file) + daisy_cmn.subprocess_call(remove_docker_container_cmd, log_file) + daisy_cmn.subprocess_call(remove_docker_images_cmd, log_file) + + except Exception as e: + message = "remove docker images failed on host %s!" % host_ip + LOG.error(message) + thread_flag['flag'] = False + update_all_host_progress_to_db(req, hosts_id_list, + {'progress': 90, + 'status': kolla_state[ + 'UNINSTALL_FAILED'], + 'messages': message}) + raise exception.UninstallException(message) + else: + LOG.info(_("remove docker images on host %s successfully!" % host_ip)) + + class KOLLAUninstallTask(Thread): """ Class for kolla uninstall openstack. @@ -180,32 +222,55 @@ class KOLLAUninstallTask(Thread): update_all_host_progress_to_db( self.req, hosts_id_list, {'progress': self.progress, - 'status': kolla_state[ - 'UNINSTALLING'], + 'status': kolla_state['UNINSTALLING'], 'messages': self.message}) execute_times += 1 if self.progress == 90: - LOG.info(_("openstack uninstall successfully")) - self.message = "openstack uninstall successfully" - update_all_host_progress_to_db(self.req, hosts_id_list, - {'progress': 100, - 'status': kolla_state[ - 'INIT'], - 'messages': self.message}) - for host_id in hosts_id_list: - daisy_cmn.update_db_host_status( - self.req, host_id, {'tecs_version_id': '', - 'tecs_patch_id': ''}) + threads = [] + for host_ip in hosts_ip_set: + t = threading.Thread(target=remove_registry, + args=(self.req, hosts_id_list, + host_ip, fp)) + t.setDaemon(True) + t.start() + threads.append(t) + try: + LOG.info(_("remove registry uninstall threads " + "have started, please waiting....")) + for t in threads: + t.join() + except: + LOG.error("join remove registry uninstall " + "thread %s failed!" % t) - cluster_meta = {} - cluster_meta['tecs_version_id'] = '' - cluster_meta = registry.update_cluster_metadata( - self.req.context, self.cluster_id, cluster_meta) + if thread_flag.get('flag', None) is not None and \ + thread_flag['flag'] == False: + self.message = "remove registry uninstall "\ + " threads failed!" + LOG.error(self.message) + raise exception.UninstallException(self.message) + else: + LOG.info(_("openstack uninstall successfully")) + self.message = "openstack uninstall successfully" + update_all_host_progress_to_db( + self.req, hosts_id_list, + {'progress': 100, + 'status': kolla_state['INIT'], + 'messages': self.message}) + for host_id in hosts_id_list: + daisy_cmn.update_db_host_status( + self.req, host_id, {'tecs_version_id': '', + 'tecs_patch_id': ''}) - LOG.info(_("openstack uninstalled for " - "cluster %s successfully." - % self.cluster_id)) + cluster_meta = {} + cluster_meta['tecs_version_id'] = '' + cluster_meta = registry.update_cluster_metadata( + self.req.context, self.cluster_id, cluster_meta) + + LOG.info(_("openstack uninstalled for " + "cluster %s successfully." + % self.cluster_id)) except subprocess.CalledProcessError as e: LOG.error("kolla-ansible destory failed!") diff --git a/test/tempest/tempest/api/daisy/v1/test_cinder_volume.py b/test/tempest/tempest/api/daisy/v1/test_cinder_volume.py index 78bcdab4..57899589 100755 --- a/test/tempest/tempest/api/daisy/v1/test_cinder_volume.py +++ b/test/tempest/tempest/api/daisy/v1/test_cinder_volume.py @@ -177,10 +177,10 @@ class DaisyCinderVolumeTest(base.BaseDaisyTest): 'af47d81c-7ae4-4148-a801-b4a5c6a52074' self.assertRaisesMessage(client_exc.HTTPNotFound, - "404 Not Found: The resource could not be " - "found.: Role with identifier " + "404 Not Found\nThe resource could not be " + "found.\n Role with identifier " "af47d81c-7ae4-4148-a801-b4a5c6a52074 not " - "found (HTTP 404)", + "found (HTTP 404)", self.add_cinder_volume, **self.cinder_volume_add_meta) del self.cinder_volume_add_meta['role_id'] @@ -195,8 +195,8 @@ class DaisyCinderVolumeTest(base.BaseDaisyTest): 'test_driver' self.assertRaisesMessage(client_exc.HTTPBadRequest, - "400 Bad Request: volume_driver test_driver " - "is not supported (HTTP 400)", + "400 Bad Request\nvolume_driver test_driver " + "is not supported\n (HTTP 400)", self.add_cinder_volume, **self.cinder_volume_add_meta) del self.cinder_volume_add_meta['role_id'] @@ -264,8 +264,8 @@ class DaisyCinderVolumeTest(base.BaseDaisyTest): update_meta = {'volume_driver': 'test_driver'} self.assertRaisesMessage( client_exc.HTTPBadRequest, - "400 Bad Request: volume_driver test_driver is not supported" - " (HTTP 400)", + "400 Bad Request\nvolume_driver test_driver is not supported\n" + " (HTTP 400)", self.update_cinder_volume, cinder_volume_info.id, **update_meta) self.delete_cinder_volume(cinder_volume_info.id) diff --git a/test/tempest/tempest/api/daisy/v1/test_logical_network.py b/test/tempest/tempest/api/daisy/v1/test_logical_network.py index 483929cf..d7cbdff5 100755 --- a/test/tempest/tempest/api/daisy/v1/test_logical_network.py +++ b/test/tempest/tempest/api/daisy/v1/test_logical_network.py @@ -96,8 +96,8 @@ class TecsLogicalNetworkTest(base.BaseDaisyTest): self.assertRaisesMessage( client_exc.HTTPBadRequest, - "400 Bad Request: " - "Logic_network flat1 is not valid range. (HTTP 400)", + "400 Bad Request\n" + "Logic_network flat1 is not valid range.\n (HTTP 400)", self.add_cluster, **fake_cluster) # STC-F-Daisy_Logical_Network-0002 @@ -148,8 +148,8 @@ class TecsLogicalNetworkTest(base.BaseDaisyTest): 'routers': fake_router}) self.assertRaisesMessage( client_exc.HTTPBadRequest, - "400 Bad Request: Logic network's subnets is all related " - "with a router, it's not allowed. (HTTP 400)", + "400 Bad Request\nLogic network's subnets is all related " + "with a router, it's not allowed.\n (HTTP 400)", self.add_cluster, **fake_cluster) tmp_fake_router1 = copy.deepcopy(fake_router) @@ -157,8 +157,8 @@ class TecsLogicalNetworkTest(base.BaseDaisyTest): fake_cluster.update({'routers': tmp_fake_router1}) self.assertRaisesMessage( client_exc.HTTPBadRequest, - "400 Bad Request: Logic network's subnets is all related with a " - "router, it's not allowed. (HTTP 400)", + "400 Bad Request\nLogic network's subnets is all related with a " + "router, it's not allowed.\n (HTTP 400)", self.add_cluster, **fake_cluster) tmp_fake_router2 = copy.deepcopy(fake_router) @@ -166,8 +166,8 @@ class TecsLogicalNetworkTest(base.BaseDaisyTest): fake_cluster.update({'routers': tmp_fake_router2}) self.assertRaisesMessage( client_exc.HTTPBadRequest, - "400 Bad Request: " - "Logic_network test is not valid range. (HTTP 400)", + "400 Bad Request\n" + "Logic_network test is not valid range.\n (HTTP 400)", self.add_cluster, **fake_cluster) tmp_fake_router3 = copy.deepcopy(fake_router) @@ -175,7 +175,7 @@ class TecsLogicalNetworkTest(base.BaseDaisyTest): fake_cluster.update({'routers': tmp_fake_router3}) self.assertRaisesMessage( client_exc.HTTPBadRequest, - "400 Bad Request: Subnet test is not valid range. (HTTP 400)", + "400 Bad Request\nSubnet test is not valid range.\n (HTTP 400)", self.add_cluster, **fake_cluster) self.private_network_delete() @@ -194,8 +194,8 @@ class TecsLogicalNetworkTest(base.BaseDaisyTest): 'logic_networks': tmp_fake_logical1}) self.assertRaisesMessage( client_exc.HTTPBadRequest, - "400 Bad Request: " - "Between floating ip range can not be overlap. (HTTP 400)", + "400 Bad Request\n" + "Between floating ip range can not be overlap.\n (HTTP 400)", self.add_cluster, **fake_cluster) tmp_fake_logical2 = copy.deepcopy( @@ -208,7 +208,8 @@ class TecsLogicalNetworkTest(base.BaseDaisyTest): fake_cluster.update({'logic_networks': tmp_fake_logical2}) self.assertRaisesMessage( client_exc.HTTPBadRequest, - "400 Bad Request: Subnet name segment is repetition. (HTTP 400)", + "400 Bad Request\nSubnet name segment is repetition.\n " + "(HTTP 400)", self.add_cluster, **fake_cluster) self.private_network_delete() diff --git a/tools/daisy-compile-rpm.sh b/tools/daisy-compile-rpm.sh index ff04e828..4d1c2e0e 100755 --- a/tools/daisy-compile-rpm.sh +++ b/tools/daisy-compile-rpm.sh @@ -41,4 +41,8 @@ yum -y install \ python-lesscpy \ python-migrate \ python-pint \ - python-routes + python-routes \ + gcc \ + autoconf \ + automake \ + glibc-devel