def delete_vims(): t = os_sfc_utils.get_tacker_client() vims = os_sfc_utils.list_vims(t) if vims is None: return for vim in vims: logger.info("Removing vim: {0}".format(vim)) os_sfc_utils.delete_vim(t, vim_id=vim)
def delete_vnffgds(): t = os_sfc_utils.get_tacker_client() vnffgds = os_sfc_utils.list_vnffgds(t) if vnffgds is None: return for vnffgd in vnffgds: logger.info("Removing vnffgd: {0}".format(vnffgd)) os_sfc_utils.delete_vnffgd(t, vnffgd_id=vnffgd)
def delete_vnfs(): t = os_sfc_utils.get_tacker_client() vnfs = os_sfc_utils.list_vnfs(t) if vnfs is None: return for vnf in vnfs: logger.info("Removing vnf: {0}".format(vnf)) os_sfc_utils.delete_vnf(t, vnf_id=vnf)
def delete_vnffgs(): t = os_sfc_utils.get_tacker_client() vnffgs = os_sfc_utils.list_vnffgs(t) if vnffgs is None: return for vnffg in reversed(vnffgs): logger.info("Removing vnffg: {0}".format(vnffg)) os_sfc_utils.delete_vnffg(t, vnffg_id=vnffg)
def prepare_env(self, testcase_config, supported_installers, vnfs): """Prepare the testcase environment and the components that the test scenario is going to use later on. :param testcase_config: the input test config file :param supported_installers: the supported installers for this tc :param vnfs: the names of vnfs :return: Environment preparation """ deployment_handler = DeploymentFactory.get_handler( COMMON_CONFIG.installer_type, COMMON_CONFIG.installer_ip, COMMON_CONFIG.installer_user, COMMON_CONFIG.installer_password, COMMON_CONFIG.installer_key_file) installer_type = os.environ.get("INSTALLER_TYPE") if installer_type not in supported_installers: raise Exception( '\033[91mYour installer is not supported yet\033[0m') installer_ip = os.environ.get("INSTALLER_IP") if not installer_ip: logger.error( '\033[91minstaller ip is not set\033[0m') raise Exception( '\033[91mexport INSTALLER_IP=<ip>\033[0m') cluster = COMMON_CONFIG.installer_cluster openstack_nodes = (deployment_handler.get_nodes({'cluster': cluster}) if cluster is not None else deployment_handler.get_nodes()) self.compute_nodes = [node for node in openstack_nodes if node.is_compute()] for compute in self.compute_nodes: logger.info("This is a compute: %s" % compute.ip) results.add_to_summary(0, "=") results.add_to_summary(2, "STATUS", "SUBTEST") results.add_to_summary(0, "=") custom_flv = openstack_sfc.create_flavor( COMMON_CONFIG.flavor, COMMON_CONFIG.ram_size_in_mb, COMMON_CONFIG.disk_size_in_gb, COMMON_CONFIG.vcpu_count) if not custom_flv: raise Exception("Failed to create custom flavor") controller_nodes = [node for node in openstack_nodes if node.is_controller()] self.controller_clients = test_utils.get_ssh_clients(controller_nodes) self.compute_clients = test_utils.get_ssh_clients(self.compute_nodes) self.tacker_client = os_sfc_utils.get_tacker_client() os_sfc_utils.register_vim(self.tacker_client, vim_file=COMMON_CONFIG.vim_file) self.ovs_logger = ovs_log.OVSLogger( os.path.join(COMMON_CONFIG.sfc_test_dir, 'ovs-logs'), COMMON_CONFIG.functest_results_dir) self.network, self.router = openstack_sfc.\ create_network_infrastructure(testcase_config.net_name, testcase_config.subnet_name, testcase_config.subnet_cidr, testcase_config.router_name) self.sg = openstack_sfc.create_security_group( testcase_config.secgroup_name) # Image for the vnf is registered self.vnf_image_creator = openstack_sfc.register_glance_image( COMMON_CONFIG.vnf_image_name, COMMON_CONFIG.vnf_image_url, COMMON_CONFIG.vnf_image_format, 'public') # Image for the client/server is registered self.image_creator = openstack_sfc.register_glance_image( COMMON_CONFIG.image_name, COMMON_CONFIG.image_url, COMMON_CONFIG.image_format, 'public') self.creators = openstack_sfc.creators self.odl_ip, self.odl_port = odl_utils.get_odl_ip_port(openstack_nodes) self.default_param_file = os.path.join( COMMON_CONFIG.sfc_test_dir, COMMON_CONFIG.vnfd_dir, COMMON_CONFIG.vnfd_default_params_file) self.topo_seed = topo_shuffler.get_seed() self.test_topology = topo_shuffler.topology(vnfs, openstack_sfc, seed=self.topo_seed) logger.info('This test is run with the topology {0}' .format(self.test_topology['id'])) logger.info('Topology description: {0}' .format(self.test_topology['description'])) self.server_instance, self.server_creator = \ openstack_sfc.create_instance(SERVER, COMMON_CONFIG.flavor, self.image_creator, self.network, self.sg, av_zone=self.test_topology['server']) self.client_instance, self.client_creator = \ openstack_sfc.create_instance(CLIENT, COMMON_CONFIG.flavor, self.image_creator, self.network, self.sg, av_zone=self.test_topology['client']) logger.info('This test is run with the topology {0}'.format( self.test_topology['id'])) logger.info('Topology description: {0}'.format( self.test_topology['description'])) self.server_ip = self.server_instance.ports[0].ips[0]['ip_address'] logger.info("Server instance received private ip [{}]".format( self.server_ip))