示例#1
0
    def delete_containers(cls, container_client=None,
                          object_client=None):
        """Remove containers and all objects in them.

        The containers should be visible from the container_client given.
        Will not throw any error if the containers don't exist.
        Will not check that object and container deletions succeed.

        :param container_client: if None, use cls.container_client, this means
            that the default testing user will be used (see 'username' in
            'etc/tempest.conf')
        :param object_client: if None, use cls.object_client
        """
        if container_client is None:
            container_client = cls.container_client
        if object_client is None:
            object_client = cls.object_client
        for cont in cls.containers:
            try:
                params = {'limit': 9999, 'format': 'json'}
                resp, objlist = container_client.list_container_contents(
                    cont, params)
                # delete every object in the container
                for obj in objlist:
                    test_utils.call_and_ignore_notfound_exc(
                        object_client.delete_object, cont, obj['name'])
                container_client.delete_container(cont)
            except lib_exc.NotFound:
                pass
示例#2
0
    def resource_cleanup(cls):

        for lb_id in cls._lbs_to_delete:
            try:
                lb = cls.load_balancers_client.get_load_balancer_status_tree(
                    lb_id).get('loadbalancer')
            except exceptions.NotFound:
                continue
            for listener in lb.get('listeners'):
                for pool in listener.get('pools'):
                    hm = pool.get('healthmonitor')
                    if hm:
                        test_utils.call_and_ignore_notfound_exc(
                            cls.health_monitors_client.delete_health_monitor,
                            pool.get('healthmonitor').get('id'))
                        cls._wait_for_load_balancer_status(lb_id)
                    test_utils.call_and_ignore_notfound_exc(
                        cls.pools_client.delete_pool,
                        pool.get('id'))
                    cls._wait_for_load_balancer_status(lb_id)
                    health_monitor = pool.get('healthmonitor')
                    if health_monitor:
                        test_utils.call_and_ignore_notfound_exc(
                            cls.health_monitors_client.delete_health_monitor,
                            health_monitor.get('id'))
                    cls._wait_for_load_balancer_status(lb_id)
                test_utils.call_and_ignore_notfound_exc(
                    cls.listeners_client.delete_listener,
                    listener.get('id'))
                cls._wait_for_load_balancer_status(lb_id)
            test_utils.call_and_ignore_notfound_exc(
                cls._delete_load_balancer, lb_id)

        super(BaseTestCase, cls).resource_cleanup()
示例#3
0
文件: base.py 项目: masayukig/tempest
    def clear_volume_type(cls, vol_type_id):
        test_utils.call_and_ignore_notfound_exc(
            cls.admin_volume_types_client.delete_volume_type, vol_type_id)

        test_utils.call_and_ignore_notfound_exc(
            cls.admin_volume_types_client.wait_for_resource_deletion,
            vol_type_id)
示例#4
0
 def tearDown(self):
     for obj in self.objects:
         test_utils.call_and_ignore_notfound_exc(
             self.object_client.delete_object,
             self.container_name, obj)
     self.container_client.delete_container(self.container_name)
     super(ObjectSloTest, self).tearDown()
示例#5
0
 def tearDown(self):
     try:
         test_utils.call_and_ignore_notfound_exc(
             self.client.delete_agent, self.agent_id)
     except Exception:
         LOG.exception('Exception raised deleting agent %s', self.agent_id)
     super(AgentsAdminTestJSON, self).tearDown()
示例#6
0
文件: base.py 项目: Juniper/tempest
def delete_containers(containers, container_client, object_client):
    """Remove containers and all objects in them.

    The containers should be visible from the container_client given.
    Will not throw any error if the containers don't exist.
    Will not check that object and container deletions succeed.
    After delete all the objects from a container, it will wait 2
    seconds before delete the container itself, in order to deployments
    using HA proxy sync the deletion properly, otherwise, the container
    might fail to be deleted because it's not empty.

    :param containers: List of containers to be deleted
    :param container_client: Client to be used to delete containers
    :param object_client: Client to be used to delete objects
    """
    for cont in containers:
        try:
            params = {'limit': 9999, 'format': 'json'}
            _, objlist = container_client.list_container_objects(cont, params)
            # delete every object in the container
            for obj in objlist:
                test_utils.call_and_ignore_notfound_exc(
                    object_client.delete_object, cont, obj['name'])
            # sleep 2 seconds to sync the deletion of the objects
            # in HA deployment
            time.sleep(2)
            container_client.delete_container(cont)
        except lib_exc.NotFound:
            pass
示例#7
0
 def clear_images(cls):
     LOG.debug('Clearing images: %s', ','.join(cls.images))
     for image_id in cls.images:
         try:
             test_utils.call_and_ignore_notfound_exc(
                 cls.compute_images_client.delete_image, image_id)
         except Exception:
             LOG.exception('Exception raised deleting image %s' % image_id)
示例#8
0
文件: base.py 项目: ssameerr/tempest
    def resource_cleanup(cls):
        for image_id in cls.created_images:
            test_utils.call_and_ignore_notfound_exc(
                cls.client.delete_image, image_id)

        for image_id in cls.created_images:
                cls.client.wait_for_resource_deletion(image_id)
        super(BaseImageTest, cls).resource_cleanup()
示例#9
0
 def delete_router(cls, router):
     body = cls.ports_client.list_ports(device_id=router["id"])
     interfaces = body["ports"]
     for i in interfaces:
         test_utils.call_and_ignore_notfound_exc(
             cls.routers_client.remove_router_interface, router["id"], subnet_id=i["fixed_ips"][0]["subnet_id"]
         )
     cls.routers_client.delete_router(router["id"])
示例#10
0
    def clear_qos_specs(cls):
        for qos_id in cls.qos_specs:
            test_utils.call_and_ignore_notfound_exc(
                cls.admin_volume_qos_client.delete_qos, qos_id)

        for qos_id in cls.qos_specs:
            test_utils.call_and_ignore_notfound_exc(
                cls.admin_volume_qos_client.wait_for_resource_deletion, qos_id)
示例#11
0
文件: base.py 项目: fnaval/tempest
 def delete_router(cls, router):
     body = cls.ports_client.list_ports(device_id=router['id'])
     interfaces = body['ports']
     for i in interfaces:
         test_utils.call_and_ignore_notfound_exc(
             cls.routers_client.remove_router_interface, router['id'],
             subnet_id=i['fixed_ips'][0]['subnet_id'])
     cls.routers_client.delete_router(router['id'])
 def _delete_router(self, router):
     body = self.ports_client.list_ports(device_id=router['id'])
     interfaces = body['ports']
     for i in interfaces:
         test_utils.call_and_ignore_notfound_exc(
             self.routers_client.remove_router_interface,
             router['id'],
             subnet_id=i['fixed_ips'][0]['subnet_id'])
     self.routers_client.delete_router(router['id'])
示例#13
0
文件: base.py 项目: Nick1211/tempest
    def clear_snapshots(cls):
        for snapshot in cls.snapshots:
            test_utils.call_and_ignore_notfound_exc(
                cls.snapshots_client.delete_snapshot, snapshot['id'])

        for snapshot in cls.snapshots:
            test_utils.call_and_ignore_notfound_exc(
                cls.snapshots_client.wait_for_resource_deletion,
                snapshot['id'])
示例#14
0
    def clear_snapshots(cls):
        for snapshot in cls.snapshots:
            test_utils.call_and_ignore_notfound_exc(
                cls.snapshots_client.delete_snapshot, snapshot['id'])

        for snapshot in cls.snapshots:
            test_utils.call_and_ignore_notfound_exc(
                cls.snapshots_client.wait_for_resource_deletion,
                snapshot['id'])
示例#15
0
def trunks_cleanup(client, trunks):
    for trunk in trunks:
        subports = test_utils.call_and_ignore_notfound_exc(
            client.get_subports, trunk['id'])
        if subports:
            client.remove_subports(
                trunk['id'], subports['sub_ports'])
        test_utils.call_and_ignore_notfound_exc(
            client.delete_trunk, trunk['id'])
示例#16
0
    def _clear_stacks(cls):
        for stack_identifier in cls.stacks:
            test_utils.call_and_ignore_notfound_exc(cls.client.delete_stack,
                                                    stack_identifier)

        for stack_identifier in cls.stacks:
            test_utils.call_and_ignore_notfound_exc(
                cls.client.wait_for_stack_status, stack_identifier,
                'DELETE_COMPLETE')
示例#17
0
def trunks_cleanup(client, trunks):
    for trunk in trunks:
        subports = test_utils.call_and_ignore_notfound_exc(
            client.get_subports, trunk['id'])
        if subports:
            client.remove_subports(
                trunk['id'], subports['sub_ports'])
        test_utils.call_and_ignore_notfound_exc(
            client.delete_trunk, trunk['id'])
示例#18
0
    def clear_volume_types(cls):
        for vol_type in cls.volume_types:
            test_utils.call_and_ignore_notfound_exc(
                cls.admin_volume_types_client.delete_volume_type, vol_type)

        for vol_type in cls.volume_types:
            test_utils.call_and_ignore_notfound_exc(
                cls.admin_volume_types_client.wait_for_resource_deletion,
                vol_type)
示例#19
0
 def _delete_router(self, router):
     body = self.ports_client.list_ports(device_id=router["id"])
     interfaces = body["ports"]
     for interface in interfaces:
         test_utils.call_and_ignore_notfound_exc(
             self.routers_client.remove_router_interface,
             router["id"],
             subnet_id=interface["fixed_ips"][0]["subnet_id"])
     self.routers_client.delete_router(router["id"])
示例#20
0
文件: base.py 项目: kakawxy/tempest
    def clear_volume_types(cls):
        for vol_type in cls.volume_types:
            test_utils.call_and_ignore_notfound_exc(
                cls.admin_volume_types_client.delete_volume_type, vol_type)

        for vol_type in cls.volume_types:
            test_utils.call_and_ignore_notfound_exc(
                cls.admin_volume_types_client.wait_for_resource_deletion,
                vol_type)
 def resource_cleanup(cls):
     test_utils.call_and_ignore_notfound_exc(cls._delete_load_balancer,
                                             cls.load_balancer['id'])
     cls._wait_for_load_balancer_status(
         load_balancer_id=cls.load_balancer['id'], delete=True)
     test_utils.call_and_ignore_notfound_exc(cls._delete_load_balancer,
                                             cls.tenant_load_balancer['id'])
     cls._wait_for_load_balancer_status(
         load_balancer_id=cls.tenant_load_balancer['id'], delete=True)
示例#22
0
    def _clear_stacks(cls):
        for stack_identifier in cls.stacks:
            test_utils.call_and_ignore_notfound_exc(
                cls.client.delete_stack, stack_identifier)

        for stack_identifier in cls.stacks:
            test_utils.call_and_ignore_notfound_exc(
                cls.client.wait_for_stack_status, stack_identifier,
                'DELETE_COMPLETE')
示例#23
0
 def clear_server_groups(cls):
     LOG.debug('Clearing server groups: %s', ','.join(cls.server_groups))
     for server_group_id in cls.server_groups:
         try:
             test_utils.call_and_ignore_notfound_exc(
                 cls.server_groups_client.delete_server_group,
                 server_group_id)
         except Exception:
             LOG.exception('Exception raised deleting server-group %s',
                           server_group_id)
 def clear_router_gateway_and_interfaces(self, router, nets, client=None):
     routers_client = client or self.manager.routers_client
     HELO.router_gateway_clear(self, router['id'], client=routers_client)
     for net_id, (s_id, network, subnet, sg) in six.iteritems(nets):
         test_utils.call_and_ignore_notfound_exc(
             HELO.router_interface_delete,
             self,
             router['id'],
             subnet['id'],
             client=routers_client)
示例#25
0
    def resource_cleanup(cls):
        for tenant in cls.tenants:
            test_utils.call_and_ignore_notfound_exc(
                cls.tenants_client.delete_tenant, tenant['id'])

        for token in cls.tokens:
            test_utils.call_and_ignore_notfound_exc(
                cls.client.delete_token, token)

        super(BaseIdentityV2AdminRbacTest, cls).resource_cleanup()
示例#26
0
 def delete_floatingips_and_servers(self):
     for net_floatingip in self.my_network['floatingips']:
         test_utils.call_and_ignore_notfound_exc(
             self.floating_ips_client.delete_floatingip,
             net_floatingip['id'])
     fip_list = self.floating_ips_client.list_floatingips()['floatingips']
     if len(fip_list) > 0:
         time.sleep(dmgr.WAITTIME_AFTER_DISASSOC_FLOATINGIP)
     self.my_network['floatingips'] = []
     dmgr.delete_all_servers(self.servers_client)
示例#27
0
 def resource_cleanup(cls):
     if CONF.service_available.neutron:
         for netwk_info in cls.admin_netwk_info:
             net_client, network = netwk_info
             try:
                 test_utils.call_and_ignore_notfound_exc(
                     net_client.delete_network, network['id'])
             except Exception:
                 pass
     super(BaseAdminNetworkTest, cls).resource_cleanup()
示例#28
0
 def delete_router(cls, router):
     body = cls.admin_ports_client.list_ports(device_id=router['id'])
     interfaces = body['ports']
     for i in interfaces:
         if i['device_owner'] == 'network:router_interface':
             test_utils.call_and_ignore_notfound_exc(
                 cls.admin_routers_client.remove_router_interface,
                 router['id'],
                 subnet_id=i['fixed_ips'][0]['subnet_id'])
     cls.admin_routers_client.delete_router(router['id'])
示例#29
0
def trunks_cleanup(client, trunks):
    for trunk in trunks:
        # NOTE(armax): deleting a trunk with subports is permitted, however
        # for testing purposes it is safer to be explicit and clean all the
        # resources associated with the trunk beforehand.
        subports = test_utils.call_and_ignore_notfound_exc(
            client.get_subports, trunk['id'])
        if subports:
            client.remove_subports(trunk['id'], subports['sub_ports'])
        test_utils.call_and_ignore_notfound_exc(client.delete_trunk,
                                                trunk['id'])
示例#30
0
文件: base.py 项目: vedujoshi/tempest
 def clear_resources(cls, resource_name, resources, resource_del_func):
     LOG.debug('Clearing %s: %s', resource_name,
               ','.join(map(str, resources)))
     for res_id in resources:
         try:
             test_utils.call_and_ignore_notfound_exc(
                 resource_del_func, res_id)
         except Exception as exc:
             LOG.exception('Exception raised deleting %s: %s',
                           resource_name, res_id)
             LOG.exception(exc)
示例#31
0
 def clear_security_groups(cls):
     LOG.debug('Clearing security groups: %s', ','.join(
         str(sg['id']) for sg in cls.security_groups))
     for sg in cls.security_groups:
         try:
             test_utils.call_and_ignore_notfound_exc(
                 cls.security_groups_client.delete_security_group, sg['id'])
         except Exception as exc:
             LOG.info('Exception raised deleting security group %s',
                      sg['id'])
             LOG.exception(exc)
示例#32
0
 def clear_server_groups(cls):
     LOG.debug('Clearing server groups: %s', ','.join(cls.server_groups))
     for server_group_id in cls.server_groups:
         try:
             test_utils.call_and_ignore_notfound_exc(
                 cls.server_groups_client.delete_server_group,
                 server_group_id
             )
         except Exception:
             LOG.exception('Exception raised deleting server-group %s',
                           server_group_id)
示例#33
0
 def clear_security_groups(cls):
     LOG.debug('Clearing security groups: %s',
               ','.join(str(sg['id']) for sg in cls.security_groups))
     for sg in cls.security_groups:
         try:
             test_utils.call_and_ignore_notfound_exc(
                 cls.security_groups_client.delete_security_group, sg['id'])
         except Exception as exc:
             LOG.info('Exception raised deleting security group %s',
                      sg['id'])
             LOG.exception(exc)
 def resource_cleanup(cls):
     test_utils.call_and_ignore_notfound_exc(
         cls._delete_load_balancer,
         cls.load_balancer['id'])
     cls._wait_for_load_balancer_status(
         load_balancer_id=cls.load_balancer['id'], delete=True)
     test_utils.call_and_ignore_notfound_exc(
         cls._delete_load_balancer,
         cls.tenant_load_balancer['id'])
     cls._wait_for_load_balancer_status(
         load_balancer_id=cls.tenant_load_balancer['id'], delete=True)
示例#35
0
 def clear_resources(cls, resource_name, resources, resource_del_func):
     LOG.debug('Clearing %s: %s', resource_name,
               ','.join(map(str, resources)))
     for res_id in resources:
         try:
             test_utils.call_and_ignore_notfound_exc(
                 resource_del_func, res_id)
         except Exception as exc:
             LOG.exception('Exception raised deleting %s: %s',
                           resource_name, res_id)
             LOG.exception(exc)
示例#36
0
    def clear_volume_types(cls):
        for vol_type in cls.volume_types:
            test_utils.call_and_ignore_notfound_exc(
                cls.admin_volume_types_client.delete_volume_type, vol_type)

        for vol_type in cls.volume_types:
            # Resource dictionary uses for is_resource_deleted method,
            # to distinguish between volume-type to encryption-type.
            resource = {'id': vol_type, 'type': 'volume-type'}
            test_utils.call_and_ignore_notfound_exc(
                cls.admin_volume_types_client.wait_for_resource_deletion,
                resource)
示例#37
0
    def clear_volume_types(cls):
        for vol_type in cls.volume_types:
            test_utils.call_and_ignore_notfound_exc(
                cls.admin_volume_types_client.delete_volume_type, vol_type)

        for vol_type in cls.volume_types:
            # Resource dictionary uses for is_resource_deleted method,
            # to distinguish between volume-type to encryption-type.
            resource = {'id': vol_type, 'type': 'volume-type'}
            test_utils.call_and_ignore_notfound_exc(
                cls.admin_volume_types_client.wait_for_resource_deletion,
                resource)
示例#38
0
def trunks_cleanup(client, trunks):
    for trunk in trunks:
        # NOTE(armax): deleting a trunk with subports is permitted, however
        # for testing purposes it is safer to be explicit and clean all the
        # resources associated with the trunk beforehand.
        subports = test_utils.call_and_ignore_notfound_exc(
            client.get_subports, trunk['id'])
        if subports:
            client.remove_subports(
                trunk['id'], subports['sub_ports'])
        test_utils.call_and_ignore_notfound_exc(
            client.delete_trunk, trunk['id'])
示例#39
0
 def resource_cleanup(cls):
     test_utils.call_and_ignore_notfound_exc(cls._delete_load_balancer,
                                             cls.load_balancer['id'])
     cls._wait_for_load_balancer_status(
         load_balancer_id=cls.load_balancer['id'], delete=True)
     cls._wait_for_neutron_port_delete(cls.load_balancer['vip_port_id'])
     test_utils.call_and_ignore_notfound_exc(cls._delete_load_balancer,
                                             cls.tenant_load_balancer['id'])
     cls._wait_for_load_balancer_status(
         load_balancer_id=cls.tenant_load_balancer['id'], delete=True)
     cls._wait_for_neutron_port_delete(
         cls.tenant_load_balancer['vip_port_id'])
     super(LoadBalancersTestAdmin, cls).resource_cleanup()
示例#40
0
    def resource_cleanup(cls):
        """
        Cleanup the lb resources first and then call resource_cleanup
        in BaseNetworkTest to cleanup other network resources. NSX-v
        plugin requires the lb resources to be deleted before we can
        delete subnet or remove interface from router.
        """
        # Cleanup lb health monitors
        if cls.health_monitor:
            test_utils.call_and_ignore_notfound_exc(
                cls.lbv1_client.delete_health_monitor,
                cls.health_monitor['id'])
            cls.health_monitor = None

        # Cleanup members
        if cls.member:
            test_utils.call_and_ignore_notfound_exc(
                cls.lbv1_client.delete_member, cls.member['id'])
            cls.member = None

        # Cleanup vips
        if cls.vip:
            test_utils.call_and_ignore_notfound_exc(cls.lbv1_client.delete_vip,
                                                    cls.vip['id'])
            cls.vip = None

        # Cleanup pool
        if cls.pool:
            test_utils.call_and_ignore_notfound_exc(
                cls.lbv1_client.delete_pool, cls.pool['id'])
            cls.pool = None

        super(LoadBalancerTestJSON, cls).resource_cleanup()
 def resource_cleanup(cls):
     test_utils.call_and_ignore_notfound_exc(
         cls._delete_load_balancer,
         cls.load_balancer['id'])
     cls._wait_for_load_balancer_status(
         load_balancer_id=cls.load_balancer['id'], delete=True)
     cls._wait_for_neutron_port_delete(cls.load_balancer['vip_port_id'])
     test_utils.call_and_ignore_notfound_exc(
         cls._delete_load_balancer,
         cls.tenant_load_balancer['id'])
     cls._wait_for_load_balancer_status(
         load_balancer_id=cls.tenant_load_balancer['id'], delete=True)
     cls._wait_for_neutron_port_delete(
         cls.tenant_load_balancer['vip_port_id'])
     super(LoadBalancersTestAdmin, cls).resource_cleanup()
示例#42
0
    def clear_volumes(cls):
        LOG.debug('Clearing volumes: %s', ','.join(
            volume['id'] for volume in cls.volumes))
        for volume in cls.volumes:
            try:
                test_utils.call_and_ignore_notfound_exc(
                    cls.volumes_client.delete_volume, volume['id'])
            except Exception:
                LOG.exception('Deleting volume %s failed', volume['id'])

        for volume in cls.volumes:
            try:
                cls.volumes_client.wait_for_resource_deletion(volume['id'])
            except Exception:
                LOG.exception('Waiting for deletion of volume %s failed',
                              volume['id'])
示例#43
0
    def clear_volumes(cls):
        LOG.debug('Clearing volumes: %s',
                  ','.join(volume['id'] for volume in cls.volumes))
        for volume in cls.volumes:
            try:
                test_utils.call_and_ignore_notfound_exc(
                    cls.volumes_client.delete_volume, volume['id'])
            except Exception:
                LOG.exception('Deleting volume %s failed', volume['id'])

        for volume in cls.volumes:
            try:
                cls.volumes_client.wait_for_resource_deletion(volume['id'])
            except Exception:
                LOG.exception('Waiting for deletion of volume %s failed',
                              volume['id'])
示例#44
0
    def resource_cleanup(cls):
        """Deletes any auto_allocated_network and it's associated resources."""

        # Find the auto-allocated router for the tenant.
        # This is a bit hacky since we don't have a great way to find the
        # auto-allocated router given the private tenant network we have.
        routers = cls.routers_client.list_routers().get('routers', [])
        if len(routers) > 1:
            # This indicates a race where nova is concurrently calling the
            # neutron auto-allocated-topology API for multiple server builds
            # at the same time (it's called from nova-compute when setting up
            # networking for a server). Neutron will detect duplicates and
            # automatically clean them up, but there is a window where the API
            # can return multiple and we don't have a good way to filter those
            # out right now, so we'll just handle them.
            LOG.info('(%s) Found more than one router for tenant.',
                     test_utils.find_test_caller())

        # Remove any networks, duplicate or otherwise, that these tests
        # created. All such networks will be in the current tenant. Neutron
        # will cleanup duplicate resources automatically, so ignore 404s.
        search_opts = {'tenant_id': cls.networks_client.tenant_id}
        networks = cls.networks_client.list_networks(**search_opts).get(
            'networks', [])

        for router in routers:
            # Disassociate the subnets from the router. Because of the race
            # mentioned above the subnets might not be associated with the
            # router so ignore any 404.
            for network in networks:
                for subnet_id in network['subnets']:
                    test_utils.call_and_ignore_notfound_exc(
                        cls.routers_client.remove_router_interface,
                        router['id'],
                        subnet_id=subnet_id)

            # Delete the router.
            cls.routers_client.delete_router(router['id'])

        for network in networks:
            # Get and delete the ports for the given network.
            ports = cls.ports_client.list_ports(network_id=network['id']).get(
                'ports', [])
            for port in ports:
                test_utils.call_and_ignore_notfound_exc(
                    cls.ports_client.delete_port, port['id'])

            # Delete the subnets.
            for subnet_id in network['subnets']:
                test_utils.call_and_ignore_notfound_exc(
                    cls.subnets_client.delete_subnet, subnet_id)

            # Delete the network.
            test_utils.call_and_ignore_notfound_exc(
                cls.networks_client.delete_network, network['id'])

        super(AutoAllocateNetworkTest, cls).resource_cleanup()
示例#45
0
    def clear_servers(cls):
        LOG.debug('Clearing servers: %s',
                  ','.join(server['id'] for server in cls.servers))
        for server in cls.servers:
            try:
                test_utils.call_and_ignore_notfound_exc(
                    cls.servers_client.delete_server, server['id'])
            except Exception:
                LOG.exception('Deleting server %s failed', server['id'])

        for server in cls.servers:
            try:
                waiters.wait_for_server_termination(cls.servers_client,
                                                    server['id'])
            except Exception:
                LOG.exception('Waiting for deletion of server %s failed',
                              server['id'])
    def resource_cleanup(cls):
        """Deletes any auto_allocated_network and it's associated resources."""

        # Find the auto-allocated router for the tenant.
        # This is a bit hacky since we don't have a great way to find the
        # auto-allocated router given the private tenant network we have.
        routers = cls.routers_client.list_routers().get('routers', [])
        if len(routers) > 1:
            # This indicates a race where nova is concurrently calling the
            # neutron auto-allocated-topology API for multiple server builds
            # at the same time (it's called from nova-compute when setting up
            # networking for a server). Neutron will detect duplicates and
            # automatically clean them up, but there is a window where the API
            # can return multiple and we don't have a good way to filter those
            # out right now, so we'll just handle them.
            LOG.info('(%s) Found more than one router for tenant.',
                     test_utils.find_test_caller())

        # Remove any networks, duplicate or otherwise, that these tests
        # created. All such networks will be in the current tenant. Neutron
        # will cleanup duplicate resources automatically, so ignore 404s.
        search_opts = {'tenant_id': cls.networks_client.tenant_id}
        networks = cls.networks_client.list_networks(
            **search_opts).get('networks', [])

        for router in routers:
            # Disassociate the subnets from the router. Because of the race
            # mentioned above the subnets might not be associated with the
            # router so ignore any 404.
            for network in networks:
                for subnet_id in network['subnets']:
                    test_utils.call_and_ignore_notfound_exc(
                        cls.routers_client.remove_router_interface,
                        router['id'], subnet_id=subnet_id)

            # Delete the router.
            cls.routers_client.delete_router(router['id'])

        for network in networks:
            # Get and delete the ports for the given network.
            ports = cls.ports_client.list_ports(
                network_id=network['id']).get('ports', [])
            for port in ports:
                test_utils.call_and_ignore_notfound_exc(
                    cls.ports_client.delete_port, port['id'])

            # Delete the subnets.
            for subnet_id in network['subnets']:
                test_utils.call_and_ignore_notfound_exc(
                    cls.subnets_client.delete_subnet, subnet_id)

            # Delete the network.
            test_utils.call_and_ignore_notfound_exc(
                cls.networks_client.delete_network, network['id'])

        super(AutoAllocateNetworkTest, cls).resource_cleanup()
示例#47
0
    def clear_servers(cls):
        LOG.debug('Clearing servers: %s', ','.join(
            server['id'] for server in cls.servers))
        for server in cls.servers:
            try:
                test_utils.call_and_ignore_notfound_exc(
                    cls.servers_client.delete_server, server['id'])
            except Exception:
                LOG.exception('Deleting server %s failed' % server['id'])

        for server in cls.servers:
            try:
                waiters.wait_for_server_termination(cls.servers_client,
                                                    server['id'])
            except Exception:
                LOG.exception('Waiting for deletion of server %s failed'
                              % server['id'])
示例#48
0
 def resource_cleanup(cls):
     for lb_id in cls._lbs_to_delete:
         try:
             statuses = cls._show_load_balancer_status_tree(lb_id)
             lb = statuses.get('loadbalancer')
         except exceptions.NotFound:
             continue
         for listener in lb.get('listeners', []):
             for policy in listener.get('l7policies'):
                 test_utils.call_and_ignore_notfound_exc(
                     cls.l7policies_client.delete_l7policy,
                     policy.get('id'))
                 cls._wait_for_load_balancer_status(lb_id)
             for pool in listener.get('pools'):
                 cls.delete_lb_pool_resources(lb_id, pool)
             # delete listener
             test_utils.call_and_ignore_notfound_exc(
                 cls.listeners_client.delete_listener,
                 listener.get('id'))
             cls._wait_for_load_balancer_status(lb_id)
         # delete pools not attached to listener, but loadbalancer
         for pool in lb.get('pools', []):
             cls.delete_lb_pool_resources(lb_id, pool)
         # delete load-balancer
         test_utils.call_and_ignore_notfound_exc(
             cls._delete_load_balancer, lb_id)
     # NSX-v: delete exclusive router
     cls.delete_router(cls.router)
     super(BaseTestCase, cls).resource_cleanup()
    def delete_loadbalancer_resources(self, lb_id):
        """Deletion of lbaas resources.

        :param lb_id: Load Balancer ID.

        """
        lb_client = self.load_balancers_client
        statuses = lb_client.show_load_balancer_status_tree(lb_id)
        statuses = statuses.get('statuses', statuses)
        lb = statuses.get('loadbalancer')
        for listener in lb.get('listeners', []):
            for policy in listener.get('l7policies'):
                test_utils.call_and_ignore_notfound_exc(
                    self.l7policies_client.delete_policy, policy.get('id'))
            for pool in listener.get('pools'):
                self.delete_lb_pool_resources(lb_id, pool)
            test_utils.call_and_ignore_notfound_exc(
                self.listeners_client.delete_listener, listener.get('id'))
            self.wait_for_load_balancer_status(lb_id)
        # delete pools not attached to listener, but loadbalancer
        for pool in lb.get('pools', []):
            self.delete_lb_pool_resources(lb_id, pool)
        test_utils.call_and_ignore_notfound_exc(lb_client.delete_load_balancer,
                                                lb_id)
        self.load_balancers_client.wait_for_load_balancer_status(
            lb_id, is_delete_op=True)
        lbs = lb_client.list_load_balancers()['loadbalancers']
        self.assertEqual(0, len(lbs))
示例#50
0
 def resource_cleanup(cls):
     for lb_id in cls._lbs_to_delete:
         try:
             statuses = cls._show_load_balancer_status_tree(lb_id)
             lb = statuses.get('loadbalancer')
         except exceptions.NotFound:
             continue
         for listener in lb.get('listeners', []):
             for pool in listener.get('pools'):
                 # delete pool's health-monitor
                 hm = pool.get('healthmonitor')
                 if hm:
                     test_utils.call_and_ignore_notfound_exc(
                         cls.health_monitors_client.delete_health_monitor,
                         pool.get('healthmonitor').get('id'))
                     cls._wait_for_load_balancer_status(lb_id)
                 # delete pool's members
                 members = pool.get('members', [])
                 for member in members:
                     test_utils.call_and_ignore_notfound_exc(
                         cls.members_client.delete_member, pool.get('id'),
                         member.get('id'))
                     cls._wait_for_load_balancer_status(lb_id)
                 # delete pool
                 test_utils.call_and_ignore_notfound_exc(
                     cls.pools_client.delete_pool, pool.get('id'))
                 cls._wait_for_load_balancer_status(lb_id)
             # delete listener
             test_utils.call_and_ignore_notfound_exc(
                 cls.listeners_client.delete_listener, listener.get('id'))
             cls._wait_for_load_balancer_status(lb_id)
         # delete load-balancer
         test_utils.call_and_ignore_notfound_exc(cls._delete_load_balancer,
                                                 lb_id)
     # NSX-v: delete exclusive router
     cls.delete_router(cls.router)
     super(BaseTestCase, cls).resource_cleanup()
示例#51
0
 def resource_cleanup(cls):
     if CONF.service_available.neutron:
         # Clean up floating IPs
         for floating_ip in cls.floating_ips:
             test_utils.call_and_ignore_notfound_exc(
                 cls.floating_ips_client.delete_floatingip,
                 floating_ip['id'])
         # Clean up ports
         for port in cls.ports:
             test_utils.call_and_ignore_notfound_exc(
                 cls.ports_client.delete_port, port['id'])
         # Clean up routers
         for router in cls.routers:
             test_utils.call_and_ignore_notfound_exc(
                 cls.delete_router, router)
         # Clean up subnets
         for subnet in cls.subnets:
             test_utils.call_and_ignore_notfound_exc(
                 cls.subnets_client.delete_subnet, subnet['id'])
         # Clean up networks
         for network in cls.networks:
             test_utils.call_and_ignore_notfound_exc(
                 cls.networks_client.delete_network, network['id'])
     super(BaseNetworkTest, cls).resource_cleanup()
示例#52
0
文件: base.py 项目: Juniper/tempest
 def resource_cleanup(cls):
     if CONF.service_available.neutron:
         # Clean up floating IPs
         for floating_ip in cls.floating_ips:
             test_utils.call_and_ignore_notfound_exc(
                 cls.floating_ips_client.delete_floatingip,
                 floating_ip['id'])
         # Clean up ports
         for port in cls.ports:
             test_utils.call_and_ignore_notfound_exc(
                 cls.ports_client.delete_port, port['id'])
         # Clean up routers
         for router in cls.routers:
             test_utils.call_and_ignore_notfound_exc(
                 cls.delete_router, router)
         # Clean up subnets
         for subnet in cls.subnets:
             test_utils.call_and_ignore_notfound_exc(
                 cls.subnets_client.delete_subnet, subnet['id'])
         # Clean up networks
         for network in cls.networks:
             test_utils.call_and_ignore_notfound_exc(
                 cls.networks_client.delete_network, network['id'])
     super(BaseNetworkTest, cls).resource_cleanup()
示例#53
0
    def resource_cleanup(cls):
        for endpoint in cls.endpoints:
            test_utils.call_and_ignore_notfound_exc(
                cls.endpoints_client.delete_endpoint, endpoint['id'])

        for role in cls.roles:
            test_utils.call_and_ignore_notfound_exc(
                cls.roles_client.delete_role, role['id'])

        for service in cls.services:
            test_utils.call_and_ignore_notfound_exc(
                cls.services_client.delete_service, service['id'])

        for user in cls.users:
            test_utils.call_and_ignore_notfound_exc(
                cls.users_client.delete_user, user['id'])

        super(BaseIdentityRbacTest, cls).resource_cleanup()
示例#54
0
 def resource_cleanup(cls):
     """cleanup resources before handing over to framework."""
     for network in cls.networks:
         # network cannot be deleted if its ports have policy associated.
         port_list = cls.admin_mgr.ports_client.list_ports(
             network_id=network['id'])['ports']
         for port in port_list:
             test_utils.call_and_ignore_notfound_exc(
                 cls.delete_port, port['id'])
         test_utils.call_and_ignore_notfound_exc(
             cls.delete_network, network['id'])
     for policy in cls.policies_created:
         test_utils.call_and_ignore_notfound_exc(
             cls.adm_qos_client.delete_policy, policy['id'])
     super(BaseQosTest, cls).resource_cleanup()
示例#55
0
 def delete_lb_pool_resources(self, lb_id, pool):
     pool_id = pool.get('id')
     hm = pool.get('healthmonitor')
     if hm:
         test_utils.call_and_ignore_notfound_exc(
             self.health_monitors_client.delete_health_monitor,
             pool.get('healthmonitor').get('id'))
         self.wait_for_load_balancer_status(lb_id)
     test_utils.call_and_ignore_notfound_exc(self.pools_client.delete_pool,
                                             pool.get('id'))
     self.wait_for_load_balancer_status(lb_id)
     for member in pool.get('members', []):
         test_utils.call_and_ignore_notfound_exc(
             self.members_client.delete_member, pool_id, member.get('id'))
         self.wait_for_load_balancer_status(lb_id)
    def resource_cleanup(cls):
        print("Resource cleanup: starting")
        for lb_id in cls._lbs_to_delete:
            try:
                lb = cls.load_balancers_client.get_load_balancer_status_tree(
                    lb_id).get('loadbalancer')
            except exceptions.NotFound:
                continue

            for pool in lb.get('pools'):
                print("Resource cleanup: deleting POOL")
                test_utils.call_and_ignore_notfound_exc(
                    cls.pools_client.delete_pool,
                    pool.get('id'))
                print("Resource cleanup: waiting for POOL to be deleted...")
                cls._wait_for_load_balancer_status(lb_id)

            for listener in lb.get('listeners'):
                print("Resource cleanup: deleting LISTENER")
                test_utils.call_and_ignore_notfound_exc(
                    cls.listeners_client.delete_listener,
                    listener.get('id'))
                print("Resource cleanup: waiting for LISTENER to be deleted...")
                cls._wait_for_load_balancer_status(lb_id)

            print("Resource cleanup: deleting LB")
            test_utils.call_and_ignore_notfound_exc(
                cls.load_balancers_client.delete_load_balancer, lb_id)

            timer = 1000
            while timer > 0:
                try:
                    lb = cls.load_balancers_client.get_load_balancer_status_tree(
                        lb_id).get('loadbalancer')
                    time.sleep(10)
                    timer = timer-10
                except exceptions.NotFound as e:
                    print("Resource cleanup: finished:")
                    break

        import vdirect_cfg.lib.vdirect_client as VD
        config = VD.load_config('/home/radware/scripts/vdirect_cfg/test.cfg')
        rest_client = VD.vDirectClient(server=config['vdirect_ip'],
                                       user=config['vdirect_user'],
                                       password=config['vdirect_password'])
        VD.delete_service(rest_client, 'srv_' + cls.network['id'])
        super(RadwareMembersTest, cls).resource_cleanup()
示例#57
0
 def delete_lb_pool_resources(cls, lb_id, pool):
     # delete pool's health-monitor
     hm = pool.get('healthmonitor')
     if hm:
         test_utils.call_and_ignore_notfound_exc(
             cls.health_monitors_client.delete_health_monitor,
             pool.get('healthmonitor').get('id'))
         cls._wait_for_load_balancer_status(lb_id)
     # delete pool's members
     members = pool.get('members', [])
     for member in members:
         test_utils.call_and_ignore_notfound_exc(
             cls.members_client.delete_member,
             pool.get('id'), member.get('id'))
         cls._wait_for_load_balancer_status(lb_id)
     # delete pool
     test_utils.call_and_ignore_notfound_exc(
         cls.pools_client.delete_pool, pool.get('id'))
     cls._wait_for_load_balancer_status(lb_id)
示例#58
0
    def resource_cleanup(cls):

        for lb_id in cls._lbs_to_delete:
            try:
                lb = cls.load_balancers_client.get_load_balancer_status_tree(lb_id).get("loadbalancer")
            except exceptions.NotFound:
                continue
            for listener in lb.get("listeners"):
                for pool in listener.get("pools"):
                    # delete pool's health-monitor
                    hm = pool.get("healthmonitor")
                    if hm:
                        test_utils.call_and_ignore_notfound_exc(
                            cls.health_monitors_client.delete_health_monitor, pool.get("healthmonitor").get("id")
                        )
                        cls._wait_for_load_balancer_status(lb_id)
                    test_utils.call_and_ignore_notfound_exc(cls.pools_client.delete_pool, pool.get("id"))
                    cls._wait_for_load_balancer_status(lb_id)
                    # delete pool's members
                    members = pool.get("members", [])
                    for member in members:
                        test_utils.call_and_ignore_notfound_exc(
                            cls.members_client.delete_member, pool.get("id"), member.get("id")
                        )
                        cls._wait_for_load_balancer_status(lb_id)
                    # delete pool
                    test_utils.call_and_ignore_notfound_exc(cls.pools_client.delete_pool, pool.get("id"))
                    cls._wait_for_load_balancer_status(lb_id)
                # delete listener
                test_utils.call_and_ignore_notfound_exc(cls.listeners_client.delete_listener, listener.get("id"))
                cls._wait_for_load_balancer_status(lb_id)
            # delete load-balancer
            test_utils.call_and_ignore_notfound_exc(cls._delete_load_balancer, lb_id)

        super(BaseTestCase, cls).resource_cleanup()
示例#59
0
 def _cleanup_health_monitor(self, hm_id, load_balancer_id=None):
     test_utils.call_and_ignore_notfound_exc(
         self.health_monitors_client.delete_health_monitor, hm_id)
     if load_balancer_id:
         self._wait_for_load_balancer_status(load_balancer_id, delete=True)
示例#60
0
    def resource_cleanup(cls):
        if CONF.service_available.neutron:
            # Clean up floating IPs
            for floating_ip in cls.floating_ips:
                test_utils.call_and_ignore_notfound_exc(cls.floating_ips_client.delete_floatingip, floating_ip["id"])

            # Clean up metering label rules
            # Not all classes in the hierarchy have the client class variable
            if len(cls.metering_label_rules) > 0:
                label_rules_client = cls.admin_metering_label_rules_client
            for metering_label_rule in cls.metering_label_rules:
                test_utils.call_and_ignore_notfound_exc(
                    label_rules_client.delete_metering_label_rule, metering_label_rule["id"]
                )
            # Clean up metering labels
            for metering_label in cls.metering_labels:
                test_utils.call_and_ignore_notfound_exc(
                    cls.admin_metering_labels_client.delete_metering_label, metering_label["id"]
                )
            # Clean up ports
            for port in cls.ports:
                test_utils.call_and_ignore_notfound_exc(cls.ports_client.delete_port, port["id"])
            # Clean up routers
            for router in cls.routers:
                test_utils.call_and_ignore_notfound_exc(cls.delete_router, router)
            # Clean up subnets
            for subnet in cls.subnets:
                test_utils.call_and_ignore_notfound_exc(cls.subnets_client.delete_subnet, subnet["id"])
            # Clean up networks
            for network in cls.networks:
                test_utils.call_and_ignore_notfound_exc(cls.networks_client.delete_network, network["id"])
        super(BaseNetworkTest, cls).resource_cleanup()