Example #1
0
 def _cleanup_projects(self):
     exception_list = list()
     for p in self.operator_cloud.list_projects():
         if p['name'].startswith(self.new_project_name):
             try:
                 self.operator_cloud.delete_project(p['id'])
             except Exception as e:
                 exception_list.append(str(e))
                 continue
     if exception_list:
         raise OpenStackCloudException('\n'.join(exception_list))
Example #2
0
    def _cleanup_subnets(self):
        exception_list = list()
        for subnet in self.operator_cloud.list_subnets():
            if subnet['name'].startswith(self.subnet_prefix):
                try:
                    self.operator_cloud.delete_subnet(subnet['id'])
                except Exception as e:
                    exception_list.append(str(e))
                    continue

        if exception_list:
            raise OpenStackCloudException('\n'.join(exception_list))
Example #3
0
    def _cleanup_networks(self):
        exception_list = list()
        for network in self.operator_cloud.list_networks():
            if network['name'].startswith(self.network_prefix):
                try:
                    self.operator_cloud.delete_network(network['name'])
                except Exception as e:
                    exception_list.append(str(e))
                    continue

        if exception_list:
            raise OpenStackCloudException('\n'.join(exception_list))
Example #4
0
    def _cleanup_routers(self):
        exception_list = list()
        for router in self.operator_cloud.list_routers():
            if router['name'].startswith(self.router_prefix):
                try:
                    self.operator_cloud.delete_router(router['name'])
                except Exception as e:
                    exception_list.append(str(e))
                    continue

        if exception_list:
            raise OpenStackCloudException('\n'.join(exception_list))
Example #5
0
    def _cleanup_policies(self):
        exception_list = list()
        for policy in self.operator_cloud.list_qos_policies():
            if policy['name'].startswith(self.policy_name):
                try:
                    self.operator_cloud.delete_qos_policy(policy['id'])
                except Exception as e:
                    exception_list.append(str(e))
                    continue

        if exception_list:
            raise OpenStackCloudException('\n'.join(exception_list))
Example #6
0
 def _cleanup_flavors(self):
     exception_list = list()
     for f in self.operator_cloud.list_flavors(get_extra=False):
         if f['name'].startswith(self.new_item_name):
             try:
                 self.operator_cloud.delete_flavor(f['id'])
             except Exception as e:
                 # We were unable to delete a flavor, let's try with next
                 exception_list.append(str(e))
                 continue
     if exception_list:
         # Raise an error: we must make users aware that something went
         # wrong
         raise OpenStackCloudException('\n'.join(exception_list))
Example #7
0
    def _cleanup_groups(self):
        exception_list = list()
        for group in self.operator_cloud.list_groups():
            if group['name'].startswith(self.group_prefix):
                try:
                    self.operator_cloud.delete_group(group['id'])
                except Exception as e:
                    exception_list.append(str(e))
                    continue

        if exception_list:
            # Raise an error: we must make users aware that something went
            # wrong
            raise OpenStackCloudException('\n'.join(exception_list))
 def _cleanup_services(self):
     exception_list = list()
     for s in self.operator_cloud.list_services():
         if s['name'] is not None and \
                 s['name'].startswith(self.new_item_name):
             try:
                 self.operator_cloud.delete_service(name_or_id=s['id'])
             except Exception as e:
                 # We were unable to delete a service, let's try with next
                 exception_list.append(str(e))
                 continue
     if exception_list:
         # Raise an error: we must make users aware that something went
         # wrong
         raise OpenStackCloudException('\n'.join(exception_list))
    def _cleanup_servers(self):
        exception_list = list()

        # Delete stale servers as well as server created for this test
        for i in self.user_cloud.list_servers(bare=True):
            if i.name.startswith(self.new_item_name):
                try:
                    self.user_cloud.delete_server(i, wait=True)
                except Exception as e:
                    exception_list.append(str(e))
                    continue

        if exception_list:
            # Raise an error: we must make users aware that something went
            # wrong
            raise OpenStackCloudException('\n'.join(exception_list))
Example #10
0
    def _cleanup_ports(self):
        exception_list = list()

        for p in self.operator_cloud.list_ports():
            if p['name'].startswith(self.new_port_name):
                try:
                    self.operator_cloud.delete_port(name_or_id=p['id'])
                except Exception as e:
                    # We were unable to delete this port, let's try with next
                    exception_list.append(str(e))
                    continue

        if exception_list:
            # Raise an error: we must make users aware that something went
            # wrong
            raise OpenStackCloudException('\n'.join(exception_list))
    def _cleanup_ips(self, server):

        exception_list = list()

        fixed_ip = meta.get_server_private_ip(server)

        for ip in self.user_cloud.list_floating_ips():
            if (ip.get('fixed_ip', None) == fixed_ip
                    or ip.get('fixed_ip_address', None) == fixed_ip):
                try:
                    self.user_cloud.delete_floating_ip(ip)
                except Exception as e:
                    exception_list.append(str(e))
                    continue

        if exception_list:
            # Raise an error: we must make users aware that something went
            # wrong
            raise OpenStackCloudException('\n'.join(exception_list))
    def _cleanup_network(self):
        exception_list = list()

        # Delete stale networks as well as networks created for this test
        if self.user_cloud.has_service('network'):
            # Delete routers
            for r in self.user_cloud.list_routers():
                try:
                    if r['name'].startswith(self.new_item_name):
                        self.user_cloud.update_router(r['id'],
                                                      ext_gateway_net_id=None)
                        for s in self.user_cloud.list_subnets():
                            if s['name'].startswith(self.new_item_name):
                                try:
                                    self.user_cloud.remove_router_interface(
                                        r, subnet_id=s['id'])
                                except Exception:
                                    pass
                        self.user_cloud.delete_router(name_or_id=r['id'])
                except Exception as e:
                    exception_list.append(str(e))
                    continue
            # Delete subnets
            for s in self.user_cloud.list_subnets():
                if s['name'].startswith(self.new_item_name):
                    try:
                        self.user_cloud.delete_subnet(name_or_id=s['id'])
                    except Exception as e:
                        exception_list.append(str(e))
                        continue
            # Delete networks
            for n in self.user_cloud.list_networks():
                if n['name'].startswith(self.new_item_name):
                    try:
                        self.user_cloud.delete_network(name_or_id=n['id'])
                    except Exception as e:
                        exception_list.append(str(e))
                        continue

        if exception_list:
            # Raise an error: we must make users aware that something went
            # wrong
            raise OpenStackCloudException('\n'.join(exception_list))
Example #13
0
 def _cleanup_qos_policy(self):
     try:
         self.operator_cloud.delete_qos_policy(self.policy['id'])
     except Exception as e:
         raise OpenStackCloudException(e)