def get_vn_obj_if_present(self, vn_name, project_id=None): if not project_id: project_id = get_dashed_uuid(self.project_id) try: net_rsp = self.obj.list_networks() for (x, y, z) in [(network['name'], network['id'], network['tenant_id']) for network in net_rsp['networks']]: dashed_tenant_id = get_dashed_uuid(z) if vn_name == x and project_id in dashed_tenant_id: net_id = y return self.obj.show_network(network=net_id) except CommonNetworkClientException, e: self.logger.exception( "Some exception while doing Quantum net-list") raise NetworkClientException(message=str(e))
def setUp(self): super(UserFixture, self).setUp() try: ks_project = self.keystone.tenants.find(name=self.inputs.project_name) if ks_project: self.project_id = get_dashed_uuid(ks_project.id) self.logger.debug( 'Project %s already present. Check user %s exist' % (self.inputs.project_name, self.username)) if self.get_user_dct(self.username): self.logger.info('User %s already exist, skip creation' % self.username) self.already_present = True else: try: self.create_user( self.username, self.password, email=self.email, tenant_name=self.inputs.project_name, enabled=True) assert self.verify_on_setup() except Exception as e: self.logger.warn('User creation failed for exception %s...' % (e)) #if test tenant already created, associate user to tenant if self.tenant: if get_tenant_dct(self.tenant): self.logger.info('Tenant %s exists, associate user %s..' % (self.teannt, self,username)) self.add_user_to_tenant(self.tenant, self.username, self.role) except ks_exceptions.NotFound, e: self.logger.info('Project %s not found, skip creating user %s' % ( self.project_name, self.username))
def __init__(self, inputs, project_name=None, username=None, password=None): self.inputs = inputs project_name = project_name or self.inputs.project_name username = username or self.inputs.stack_user password = password or self.inputs.stack_password self.keystone_ip = inputs.keystone_ip self.ks_client = ks_client.Client( username=username, password=password, tenant_name=project_name, auth_url='http://%s:5000/v2.0/' % ( self.keystone_ip) ) self.project_id = get_dashed_uuid(self.ks_client.tenant_id) if self.inputs.webui_verification_flag: self.os_type = self.inputs.os_type self.webui_ip = self.inputs.webui_ip self.os_name = self.os_type[self.webui_ip] self.start_virtual_display() if self.inputs.webui_verification_flag == 'firefox': self.browser = webdriver.Firefox() self.browser_openstack = webdriver.Firefox() elif self.inputs.webui_verification_flag == 'chrome': self.browser = webdriver.Chrome() self.browser_openstack = webdriver.Chrome() self.delay = 30 self.frequency = 1 self.login_webui(project_name, username, password) self.login_openstack(project_name, username, password) self.quantum_fixture = QuantumFixture( username=username, inputs=self.inputs, project_id=self.project_id, password=password, cfgm_ip=self.inputs.cfgm_ip, openstack_ip=self.inputs.openstack_ip) self.quantum_fixture.setUp() inputs.openstack_ip = self.inputs.openstack_ip self.vnc_lib_fixture = VncLibFixture( username=username, password=password, domain=self.inputs.domain_name, project=project_name, inputs=self.inputs, cfgm_ip=self.inputs.cfgm_ip, api_port=self.inputs.api_server_port) self.vnc_lib_fixture.setUp() self.vnc_lib = self.vnc_lib_fixture.get_handle() self.nova_fixture = NovaFixture(inputs=inputs, project_name=project_name, username=username, password=password) self.nova_fixture.setUp() self.api_server_inspects = {} for cfgm_ip in self.inputs.cfgm_ips: self.api_server_inspects[cfgm_ip] = VNCApiInspect(cfgm_ip, args=self.inputs, logger=self.inputs.logger) self.api_server_inspect = VNCApiInspect(cfgm_ip, args=self.inputs, logger=self.inputs.logger) self.cn_inspect = {} for bgp_ip in self.inputs.bgp_ips: self.cn_inspect[bgp_ip] = ControlNodeInspect(bgp_ip, logger=self.inputs.logger) self.agent_inspect = {} for compute_ip in self.inputs.compute_ips: self.agent_inspect[compute_ip] = AgentInspect(compute_ip, logger=self.inputs.logger) self.dnsagent_inspect = {} for bgp_ip in self.inputs.bgp_ips: self.dnsagent_inspect[bgp_ip] = DnsAgentInspect( bgp_ip, logger=self.inputs.logger) self.ops_inspects = {} for collector_ip in self.inputs.collector_ips: self.ops_inspects[collector_ip] = VerificationOpsSrv(collector_ip, logger=self.inputs.logger) self.ops_inspect = VerificationOpsSrv(self.inputs.collector_ip, logger=self.inputs.logger) for collector_name in self.inputs.collector_names: self.ops_inspects[collector_name] = VerificationOpsSrv( collector_ip, logger=self.inputs.logger) self.analytics_obj = AnalyticsVerification( self.inputs, self.api_server_inspect, self.cn_inspect, self.agent_inspect, self.ops_inspects, logger=self.inputs.logger) self.ds_inspect = {} for ds_ip in self.inputs.ds_server_ip: self.ds_inspect[ds_ip] = VerificationDsSrv( ds_ip, logger=self.inputs.logger) self.ds_verification_obj = DiscoveryVerification( self.inputs, self.api_server_inspect, self.cn_inspect, self.agent_inspect, self.ops_inspects, self.ds_inspect, logger=self.inputs.logger)