def test_get_external_network(self): network = stacks.get_external_network() self.assertTrue(network['id']) self.assertIs(True, network['router:external']) self.assertEqual('ACTIVE', network['status']) subnets = neutron.list_subnets(network_id=network['id']) self.assertNotEqual([], subnets)
def test_list_subnets(self): subnets = neutron.list_subnets() subnets_ids = {s['id'] for s in subnets} if self.stack.has_ipv4: self.assertIn(self.stack.ipv4_subnet_id, subnets_ids) if self.stack.has_ipv6: self.assertIn(self.stack.ipv6_subnet_id, subnets_ids)
def test_find_port_address_with_subnet_id(self): port = neutron.find_port(device_id=self.stack.server_id) for subnet in neutron.list_subnets(network_id=port['network_id']): port_address = neutron.find_port_ip_address( port=port, subnet_id=subnet['id'], unique=True) cidr = netaddr.IPNetwork(subnet['cidr']) self.assertIn(port_address, cidr)
def external_network(self) -> typing.Optional[NeutronNetworkType]: external_network = self._external_network if external_network is None: subnet_parameters = {} if self.subnet_enable_dhcp is not None: subnet_parameters['enable_dhcp'] = self.subnet_enable_dhcp for network in list_external_networks(name=self.external_name): if not network['subnets']: LOG.debug(f"Network '{network['id']}' has any subnet") continue subnets = neutron.list_subnets(network_id=network['id'], **subnet_parameters) if not subnets: LOG.debug(f"Network '{network['id']}' has any valid " f"subnet: {subnet_parameters}") continue network_dump = json.dumps(network, indent=4, sort_keys=True) LOG.debug(f"Found external network for {self.fixture_name}:\n" f"{network_dump}") subnets_dump = json.dumps(subnets, indent=4, sort_keys=True) LOG.debug(f"External subnets for {self.fixture_name}:\n" f"{subnets_dump}") self._external_network = external_network = network break else: LOG.warning("No external network found for " f"'{self.fixture_name}':\n" f" - name or ID: {self.external_name}\n" f" - subnet attributes: {subnet_parameters}\n") return external_network
def test_ping_subnet_gateways(self): network_id = self.stack.network_stack.network_id subnets = neutron.list_subnets(network_id=network_id) gateway_ips = [ netaddr.IPAddress(subnet['gateway_ip']) for subnet in subnets ] ping.assert_reachable_hosts(gateway_ips, ssh_client=self.stack.ssh_client)
def test_ping_subnet_gateways(self): """Checks server can ping its gateway IPs""" network_id = self.stack.network_stack.network_id subnets = neutron.list_subnets(network_id=network_id) LOG.debug("Subnets enabled are:\n" f"{json.dumps(subnets, indent=4, sort_keys=True)}") gateway_ips = [ netaddr.IPAddress(subnet['gateway_ip']) for subnet in subnets ] LOG.debug(f"Gateway IPs are: {gateway_ips}") ping.assert_reachable_hosts(gateway_ips, ssh_client=self.stack.ssh_client)