def get_vim_descriptor(self): """"Create VIM descriptor to be used for onboarding""" self.logger.info("Building VIM descriptor with PoP creds: %s", self.creds) # Depending on API version either tenant ID or project name must be # used if os_utils.is_keystone_v3(): self.logger.info( "Using v3 API of OpenStack... -> Using OS_PROJECT_ID") project_id = os_utils.get_tenant_id(os_utils.get_keystone_client(), self.creds.get("project_name")) else: self.logger.info( "Using v2 API of OpenStack... -> Using OS_TENANT_NAME") project_id = self.creds.get("tenant_name") self.logger.debug("VIM project/tenant id: %s", project_id) vim_json = { "name": "vim-instance", "authUrl": self.creds.get("auth_url"), "tenant": project_id, "username": self.creds.get("username"), "password": self.creds.get("password"), "securityGroups": [self.mano['details']['sec_group']], "type": "openstack", "location": { "name": "opnfv", "latitude": "52.525876", "longitude": "13.314400" } } self.logger.info("Built VIM descriptor: %s", vim_json) return vim_json
def configure_tempest_update_params(tempest_conf_file, IMAGE_ID=None, FLAVOR_ID=None): """ Add/update needed parameters into tempest.conf file """ logger.debug("Updating selected tempest.conf parameters...") config = ConfigParser.RawConfigParser() config.read(tempest_conf_file) config.set( 'compute', 'fixed_network_name', CONST.__getattribute__('tempest_private_net_name')) config.set('compute', 'volume_device_name', CONST.__getattribute__('tempest_volume_device_name')) if CONST.__getattribute__('tempest_use_custom_images'): if IMAGE_ID is not None: config.set('compute', 'image_ref', IMAGE_ID) if IMAGE_ID_ALT is not None: config.set('compute', 'image_ref_alt', IMAGE_ID_ALT) if CONST.__getattribute__('tempest_use_custom_flavors'): if FLAVOR_ID is not None: config.set('compute', 'flavor_ref', FLAVOR_ID) if FLAVOR_ID_ALT is not None: config.set('compute', 'flavor_ref_alt', FLAVOR_ID_ALT) config.set('identity', 'tenant_name', CONST.__getattribute__('tempest_identity_tenant_name')) config.set('identity', 'username', CONST.__getattribute__('tempest_identity_user_name')) config.set('identity', 'password', CONST.__getattribute__('tempest_identity_user_password')) config.set('identity', 'region', 'RegionOne') if os_utils.is_keystone_v3(): auth_version = 'v3' else: auth_version = 'v2' config.set('identity', 'auth_version', auth_version) config.set( 'validation', 'ssh_timeout', CONST.__getattribute__('tempest_validation_ssh_timeout')) config.set('object-storage', 'operator_role', CONST.__getattribute__('tempest_object_storage_operator_role')) if CONST.__getattribute__('OS_ENDPOINT_TYPE') is not None: sections = config.sections() if os_utils.is_keystone_v3(): config.set('identity', 'v3_endpoint_type', CONST.__getattribute__('OS_ENDPOINT_TYPE')) if 'identity-feature-enabled' not in sections: config.add_section('identity-feature-enabled') config.set('identity-feature-enabled', 'api_v2', False) config.set('identity-feature-enabled', 'api_v2_admin', False) services_list = ['compute', 'volume', 'image', 'network', 'data-processing', 'object-storage', 'orchestration'] for service in services_list: if service not in sections: config.add_section(service) config.set(service, 'endpoint_type', CONST.__getattribute__('OS_ENDPOINT_TYPE')) with open(tempest_conf_file, 'wb') as config_file: config.write(config_file) backup_tempest_config(tempest_conf_file)
def deploy_vnf(self): self.logger.info("Starting vIMS Deployment...") self.main_agent = MainAgent(nfvo_ip=self.ob_ip, nfvo_port=self.ob_port, https=self.ob_https, version=1, username=self.ob_username, password=self.ob_password) self.logger.info( "Check if openims Flavor is available, if not create one") flavor_exist, flavor_id = os_utils.get_or_create_flavor("m1.small", "2048", '20', '1', public=True) self.logger.debug("Flavor id: %s", flavor_id) self.logger.info("Getting project 'default'...") project_agent = self.main_agent.get_agent("project", self.ob_projectid) for p in json.loads(project_agent.find()): if p.get("name") == "default": self.ob_projectid = p.get("id") self.logger.info("Found project 'default': %s", p) break self.logger.debug("project id: %s", self.ob_projectid) if self.ob_projectid == "": self.logger.error("Default project id was not found!") creds = os_utils.get_credentials() self.logger.info("PoP creds: %s", creds) if os_utils.is_keystone_v3(): self.logger.info( "Using v3 API of OpenStack... -> Using OS_PROJECT_ID") project_id = os_utils.get_tenant_id(os_utils.get_keystone_client(), creds.get("project_name")) else: self.logger.info( "Using v2 API of OpenStack... -> Using OS_TENANT_NAME") project_id = creds.get("tenant_name") self.logger.debug("project id: %s", project_id) vim_json = { "name": "vim-instance", "authUrl": creds.get("auth_url"), "tenant": project_id, "username": creds.get("username"), "password": creds.get("password"), "securityGroups": ["default", "orchestra-sec-group"], "type": "openstack", "location": { "name": "opnfv", "latitude": "52.525876", "longitude": "13.314400" } } self.logger.debug("Registering VIM: %s", vim_json) self.main_agent.get_agent( "vim", project_id=self.ob_projectid).create(entity=json.dumps(vim_json)) market_agent = self.main_agent.get_agent("market", project_id=self.ob_projectid) nsd = {} try: self.logger.info("sending: %s", self.market_link) nsd = market_agent.create(entity=self.market_link) self.logger.info("Onboarded NSD: " + nsd.get("name")) except NfvoException as e: self.logger.error(e.message) nsr_agent = self.main_agent.get_agent("nsr", project_id=self.ob_projectid) nsd_id = nsd.get('id') if nsd_id is None: self.logger.error("NSD not onboarded correctly") try: self.nsr = nsr_agent.create(nsd_id) except NfvoException as e: self.logger.error(e.message) if self.nsr.get('code') is not None: self.logger.error("vIMS cannot be deployed: %s -> %s", self.nsr.get('code'), self.nsr.get('message')) self.logger.error("vIMS cannot be deployed") i = 0 self.logger.info("Waiting for NSR to go to ACTIVE...") while self.nsr.get("status") != 'ACTIVE' and self.nsr.get( "status") != 'ERROR': i += 1 if i == 150: self.logger.error("INACTIVE NSR after %s sec..", 5 * i) time.sleep(5) self.nsr = json.loads(nsr_agent.find(self.nsr.get('id'))) if self.nsr.get("status") == 'ACTIVE': self.details["vnf"] = {'status': "PASS", 'result': self.nsr} self.logger.info("Deploy VNF: OK") else: self.details["vnf"] = {'status': "FAIL", 'result': self.nsr} self.logger.error(self.nsr) self.logger.error("Deploy VNF: ERROR") return False self.ob_nsr_id = self.nsr.get("id") self.logger.info( "Sleep for 60s to ensure that all services are up and running...") time.sleep(60) return True