def wait_for_load_balancers_status(self, load_balancer_id, provisioning_status='ACTIVE', operating_status='ONLINE', is_delete_op=False): """Must have utility method for load-balancer CRUD operation. This is the method you must call to make sure load_balancer_id is in provisioning_status=ACTIVE and opration_status=ONLINE status before manipulating any lbaas resource under load_balancer_id. """ interval_time = self.build_interval timeout = self.build_timeout end_time = time.time() + timeout lb = None while time.time() < end_time: try: lb = self.show_load_balancer(load_balancer_id) if not lb: if is_delete_op: break else: raise Exception( LB_NOTFOUND.format(lb_id=load_balancer_id)) lb = lb.get(self.resource, lb) if (lb.get('provisioning_status') == provisioning_status and lb.get('operating_status') == operating_status): break time.sleep(interval_time) except exceptions.NotFound as e: if is_delete_op: break else: raise e else: if is_delete_op: raise exceptions.TimeoutException( _("Waited for load balancer {lb_id} to be deleted for " "{timeout} seconds but can still observe that it " "exists.").format( lb_id=load_balancer_id, timeout=timeout)) else: raise exceptions.TimeoutException( _("Wait for load balancer ran for {timeout} seconds and " "did not observe {lb_id} reach {provisioning_status} " "provisioning status and {operating_status} " "operating status.").format( timeout=timeout, lb_id=load_balancer_id, provisioning_status=provisioning_status, operating_status=operating_status)) return lb
def wait_for_load_balancer_status(self, load_balancer_id, provisioning_status='ACTIVE', operating_status='ONLINE', is_delete_op=False): """Must have utility method for load-balancer CRUD operation. This is the method you must call to make sure load_balancer_id is in provisioning_status=ACTIVE and opration_status=ONLINE status before manipulating any lbaas resource under load_balancer_id. """ interval_time = self.build_interval timeout = self.build_timeout end_time = time.time() + timeout lb = None while time.time() < end_time: try: lb = self.show_load_balancer(load_balancer_id) if not lb: if is_delete_op: break else: raise Exception( LB_NOTFOUND.format(lb_id=load_balancer_id)) lb = lb.get(self.resource, lb) if (lb.get('provisioning_status') == provisioning_status and lb.get('operating_status') == operating_status): break time.sleep(interval_time) except exceptions.NotFound as e: if is_delete_op: break else: raise e else: if is_delete_op: raise exceptions.TimeoutException( _("Waited for load balancer {lb_id} to be deleted for " "{timeout} seconds but can still observe that it " "exists.").format(lb_id=load_balancer_id, timeout=timeout)) else: raise exceptions.TimeoutException( _("Wait for load balancer ran for {timeout} seconds and " "did not observe {lb_id} reach {provisioning_status} " "provisioning status and {operating_status} " "operating status.").format( timeout=timeout, lb_id=load_balancer_id, provisioning_status=provisioning_status, operating_status=operating_status)) return lb
def _wait_for_load_balancer_status(cls, load_balancer_id, provisioning_status='ACTIVE', operating_status='ONLINE', delete=False): interval_time = 1 timeout = 600 end_time = time.time() + timeout lb = {} while time.time() < end_time: try: lb = cls.load_balancers_client.show_load_balancer( load_balancer_id) if not lb: # loadbalancer not found if delete: break else: raise Exception( _("loadbalancer {lb_id} not" " found").format(lb_id=load_balancer_id)) lb = lb.get('loadbalancer', lb) if (lb.get('provisioning_status') == provisioning_status and lb.get('operating_status') == operating_status): break time.sleep(interval_time) except exceptions.NotFound as e: # if wait is for delete operation do break if delete: break else: # raise original exception raise e else: if delete: raise exceptions.TimeoutException( _("Waited for load balancer {lb_id} to be deleted for " "{timeout} seconds but can still observe that it " "exists.").format(lb_id=load_balancer_id, timeout=timeout)) else: raise exceptions.TimeoutException( _("Wait for load balancer ran for {timeout} seconds and " "did not observe {lb_id} reach {provisioning_status} " "provisioning status and {operating_status} " "operating status.").format( timeout=timeout, lb_id=load_balancer_id, provisioning_status=provisioning_status, operating_status=operating_status)) return lb
def nsx_bridge_cluster_info(self): """ Collect the device and interface name of the nsx brdige cluster. :return: nsx bridge id and display name. """ response = self.nsxv3_client_obj.get_bridge_cluster_info() if len(response) == 0: raise RuntimeError(_("NSX bridge cluster information is null")) return [(x.get("id"), x.get("display_name")) for x in response]
def is_resource_deleted(self, resource_type, id, client=None): if client is None: client = self method = 'show_' + resource_type try: getattr(client, method)(id) except AttributeError: raise Exception(_("Unknown resource type %s ") % resource_type) except lib_exc.NotFound: return True return False
def resource_setup(cls): """setup default values for filtering tests.""" super(NetworkTagFilterTest, cls).resource_setup() cls.a_b_c = ['a', 'ab', 'abc'] cls.not_tagged_tags = ['talking-head', 'spinning-tail'] cls._tags = (['east', 'gold', 'production'], ['west', 'silver', 'development'], ['north', 'brown', 'development', 'abc'], ['south', 'brown', 'testing', 'a'], ['west', 'gold', 'production', 'ab'], ['east', 'silver', 'testing'], ['north', 'gold', 'production'], ['south', 'silver', 'testing']) cls.QQ = {'router:external': False} cls.GG = {} for ix in range(0, len(cls._tags)): net = cls.create_network() tags = cls._tags[ix] net = cls.tag_replace(net['id'], tags=tags) if not (set(net['tags']) == set(cls._tags[ix])): raise Exception( _("tags[%s] are not tag-replace successfully.") % tags) net_id = net['id'] cls.GG[net_id] = set(net['tags'])
def check_matched_search_list(self, matched_nets, m_net_list, title): LOG.info(_("Expected_nets[{0}]: {1}").format(title, m_net_list)) LOG.info(_("Number of matched_nets: {0}").format(len(matched_nets))) self.assertEqual(len(matched_nets), len(m_net_list)) for net in matched_nets: self.assertIn(net['id'], m_net_list)