def create_networks(self, dns_nameservers=None, **kwargs): namestart = 'lbv1-ops' routers_client = self.routers_client networks_client = self.networks_client subnets_client = self.subnets_client router_kwargs = dict(client=routers_client, namestart=namestart) for k in kwargs.keys(): if k in ('distributed', 'router_type', 'router_size'): router_kwargs[k] = kwargs.pop(k) router = self._create_router(**router_kwargs) HELO.router_gateway_set(self, router['id'], CONF.network.public_network_id) network = self._create_network(routers_client=routers_client, networks_client=networks_client, namestart=namestart) subnet_kwargs = dict(network=network, namestart=namestart, subnets_client=subnets_client) # use explicit check because empty list is a valid option if dns_nameservers is not None: subnet_kwargs['dns_nameservers'] = dns_nameservers subnet = self._create_subnet(**subnet_kwargs) HELO.router_interface_add(self, router['id'], subnet['id'], routers_client) return network, subnet, router
def create_router_and_add_interfaces(self, router_type, net_list, client_mgr=None): client_mgr = client_mgr or self.admin_manager routers_client = client_mgr.routers_client router = self.create_router_by_type(router_type, client=routers_client) for (network, subnet, dns_search_domain) in net_list: HELO.router_interface_add(self, router['id'], subnet['id'], client=routers_client) return router
def create_router_and_add_interfaces(self, router_type, subnet_list): routers_client = self.cmgr_adm.routers_client router = self.create_router_by_type(router_type) for subnet in subnet_list: HELO.router_interface_add(self, router['id'], subnet['id'], client=routers_client) # check interfaces/subnets are added to router router_port_list = self.get_router_port_list(self.cmgr_adm, router['id']) for subnet in subnet_list: added = self.rports_have_subnet_id(router_port_list, subnet['id']) self.assertTrue( added, "subnet_id:%s is not added to router" % subnet['id']) return router
def test_dvr_connectivity_between_vms_on_different_networks(self): """ For a freshly-booted VM with an IP address ("port") on a given network: - the Tempest host can ping the IP address. - the Tempest host can ssh into the VM via the IP address and successfully execute the following: - ping an external IP address, implying external connectivity. - ping an external hostname, implying that dns is correctly configured. - ping an internal IP address, implying connectivity to another VM on the same network. - Create another network on the same tenant with subnet, create an VM on the new network. - Ping the new VM from previous VM failed since the new network was not attached to router yet. - Attach the new network to the router, Ping the new VM from previous VM succeed. """ self._setup_network_and_servers(distributed=True) LOG.debug("Sleeping %ss after associate floating ip %s" % (FIP_OPS_TIMEOUT, self.floating_ip_tuple)) time.sleep(FIP_OPS_TIMEOUT) self.check_public_network_connectivity(should_connect=True) self._check_network_internal_connectivity(network=self.network) self._check_network_external_connectivity() self._create_new_network(create_gateway=True) name = data_utils.rand_name('server-smoke') self._create_server(name, self.new_net) self._check_network_internal_connectivity(network=self.new_net, should_connect=False) HELO.router_interface_add(self, self.router['id'], self.new_subnet['id']) self._check_network_internal_connectivity(network=self.new_net, should_connect=True)
def create_router_and_add_interfaces(self, router_type, nets, client_mgr=None): client_mgr = client_mgr or self.admin_manager routers_client = client_mgr.routers_client router = self.create_router_by_type(router_type, client=routers_client) if router_type == 'exclusive': router_nsxv_name = '%s-%s' % (router['name'], router['id']) exc_edge = self.vsm.get_edge(router_nsxv_name) self.assertIsNotNone(exc_edge) self.assertEqual(exc_edge['edgeType'], 'gatewayServices') for net_id, (s_id, network, subnet, sg) in six.iteritems(nets): # import pdb; pdb.set_trace() HELO.router_interface_add(self, router['id'], subnet['id'], client=routers_client) return router
def router_interface_add(self, router_id, subnet_id, client=None): routers_client = client or self.routers_client return HELO.router_interface_add(self, router_id, subnet_id, routers_client)
def _router_add_interface(self, net_router, net_subnet, client_mgr): routers_client = client_mgr.routers_client return HELO.router_interface_add(self, net_router['id'], net_subnet['id'], routers_client)
def _create_firewall_basic_topo(self, router_type, protocol_name, policy=None): self.keypairs = {} router = self.create_router_by_type(router_type) self.addCleanup(self._delete_router_if_exists, router) body = self.fwaasv1_client.create_firewall_rule( name=data_utils.rand_name("fw-rule"), action="allow", protocol=protocol_name) fw_rule_id1 = body['firewall_rule']['id'] firewall_name = self._create_firewall_rule_name(body) self.addCleanup(self._delete_rule_if_exists, fw_rule_id1) # Create firewall policy if not policy: body = self.fwaasv1_client.create_firewall_policy( name=data_utils.rand_name("fw-policy")) fw_policy_id = body['firewall_policy']['id'] self.addCleanup(self._delete_policy_if_exists, fw_policy_id) # Insert rule to firewall policy self.fwaasv1_client.insert_firewall_rule_in_policy( fw_policy_id, fw_rule_id1, '', '') else: fw_policy_id = policy # Create firewall firewall_1 = self.fwaasv1_client.create_firewall( name=data_utils.rand_name("firewall"), firewall_policy_id=fw_policy_id, router_ids=[router['id']]) created_firewall = firewall_1['firewall'] self.addCleanup(self._delete_firewall_if_exists, created_firewall['id']) # Wait for the firewall resource to become ready self._wait_until_ready(created_firewall['id']) sg_name = data_utils.rand_name('sg') sg_desc = sg_name + " description" t_security_group = \ self.compute_security_groups_client.create_security_group( name=sg_name, description=sg_desc)['security_group'] self.addCleanup( test_utils.call_and_ignore_notfound_exc, self.compute_security_groups_client.delete_security_group, t_security_group['id']) rule = {'direction': 'ingress', 'protocol': 'tcp'} self._create_security_group_rule(secgroup=t_security_group, **rule) rule = {'direction': 'ingress'} rule_id = self._create_security_group_rule(secgroup=t_security_group, **rule)['id'] keypair = self.create_keypair() self.keypairs[keypair['name']] = keypair client_mgr = self.manager tenant_id = t_security_group['tenant_id'] network, subnet = self.create_network_subnet(client_mgr=client_mgr, tenant_id=tenant_id, cidr_offset=0) subnet_id = subnet['id'] router_id = router['id'] routers_client = client_mgr.routers_client NAM.router_interface_add(self, router_id, subnet_id, routers_client) self.username, self.password = self.get_image_userpass() security_groups = [{'name': t_security_group['id']}] key_name = keypair['name'] t_serv1 = self.create_server_on_network( network, security_groups, key_name=key_name, image=self.get_server_image(), flavor=self.get_server_flavor(), name=network['name']) self.check_server_connected(t_serv1) t_floatingip = self.create_floatingip_for_server(t_serv1, client_mgr=client_mgr) msg = ("Associate t_floatingip[%s] to server[%s]" % (t_floatingip, t_serv1['name'])) self._check_floatingip_connectivity(t_floatingip, t_serv1, should_connect=True, msg=msg) firewall_topo = dict(router=router, firewall_name=firewall_name, fw_policy_id=fw_policy_id, fw_rule_id1=fw_rule_id1, firewall_id=created_firewall['id'], security_group=t_security_group, network=network, subnet=subnet, client_mgr=client_mgr, serv1=t_serv1, fip1=t_floatingip, rule_id=rule_id) return firewall_topo