Merge "Use instance variables for subnet tests"
This commit is contained in:
commit
e22fc1fb6b
@ -38,160 +38,165 @@ class TestSubnet(network_fakes.TestNetworkV2):
|
|||||||
|
|
||||||
class TestCreateSubnet(TestSubnet):
|
class TestCreateSubnet(TestSubnet):
|
||||||
|
|
||||||
project = identity_fakes_v3.FakeProject.create_one_project()
|
def _init_subnet_variables(self):
|
||||||
domain = identity_fakes_v3.FakeDomain.create_one_domain()
|
self.project = identity_fakes_v3.FakeProject.create_one_project()
|
||||||
# An IPv4 subnet to be created with mostly default values
|
self.domain = identity_fakes_v3.FakeDomain.create_one_domain()
|
||||||
_subnet = network_fakes.FakeSubnet.create_one_subnet(
|
# An IPv4 subnet to be created with mostly default values
|
||||||
attrs={
|
self._subnet = network_fakes.FakeSubnet.create_one_subnet(
|
||||||
'tenant_id': project.id,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Subnet pool to be used to create a subnet from a pool
|
|
||||||
_subnet_pool = network_fakes.FakeSubnetPool.create_one_subnet_pool()
|
|
||||||
|
|
||||||
# An IPv4 subnet to be created using a specific subnet pool
|
|
||||||
_subnet_from_pool = network_fakes.FakeSubnet.create_one_subnet(
|
|
||||||
attrs={
|
|
||||||
'tenant_id': project.id,
|
|
||||||
'subnetpool_id': _subnet_pool.id,
|
|
||||||
'dns_nameservers': ['8.8.8.8',
|
|
||||||
'8.8.4.4'],
|
|
||||||
'host_routes': [{'destination': '10.20.20.0/24',
|
|
||||||
'nexthop': '10.20.20.1'},
|
|
||||||
{'destination': '10.30.30.0/24',
|
|
||||||
'nexthop': '10.30.30.1'}],
|
|
||||||
'service_types': ['network:router_gateway',
|
|
||||||
'network:floatingip_agent_gateway'],
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
# An IPv6 subnet to be created with most options specified
|
|
||||||
_subnet_ipv6 = network_fakes.FakeSubnet.create_one_subnet(
|
|
||||||
attrs={
|
|
||||||
'tenant_id': project.id,
|
|
||||||
'cidr': 'fe80:0:0:a00a::/64',
|
|
||||||
'enable_dhcp': True,
|
|
||||||
'dns_nameservers': ['fe80:27ff:a00a:f00f::ffff',
|
|
||||||
'fe80:37ff:a00a:f00f::ffff'],
|
|
||||||
'allocation_pools': [{'start': 'fe80::a00a:0:c0de:0:100',
|
|
||||||
'end': 'fe80::a00a:0:c0de:0:f000'},
|
|
||||||
{'start': 'fe80::a00a:0:c0de:1:100',
|
|
||||||
'end': 'fe80::a00a:0:c0de:1:f000'}],
|
|
||||||
'host_routes': [{'destination': 'fe80:27ff:a00a:f00f::/64',
|
|
||||||
'nexthop': 'fe80:27ff:a00a:f00f::1'},
|
|
||||||
{'destination': 'fe80:37ff:a00a:f00f::/64',
|
|
||||||
'nexthop': 'fe80:37ff:a00a:f00f::1'}],
|
|
||||||
'ip_version': 6,
|
|
||||||
'gateway_ip': 'fe80::a00a:0:c0de:0:1',
|
|
||||||
'ipv6_address_mode': 'slaac',
|
|
||||||
'ipv6_ra_mode': 'slaac',
|
|
||||||
'subnetpool_id': 'None',
|
|
||||||
'service_types': ['network:router_gateway',
|
|
||||||
'network:floatingip_agent_gateway'],
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
# The network to be returned from find_network
|
|
||||||
_network = network_fakes.FakeNetwork.create_one_network(
|
|
||||||
attrs={
|
|
||||||
'id': _subnet.network_id,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
# The network segment to be returned from find_segment
|
|
||||||
_network_segment = \
|
|
||||||
network_fakes.FakeNetworkSegment.create_one_network_segment(
|
|
||||||
attrs={
|
attrs={
|
||||||
'network_id': _subnet.network_id,
|
'tenant_id': self.project.id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
columns = (
|
# Subnet pool to be used to create a subnet from a pool
|
||||||
'allocation_pools',
|
self._subnet_pool = \
|
||||||
'cidr',
|
network_fakes.FakeSubnetPool.create_one_subnet_pool()
|
||||||
'description',
|
|
||||||
'dns_nameservers',
|
|
||||||
'enable_dhcp',
|
|
||||||
'gateway_ip',
|
|
||||||
'host_routes',
|
|
||||||
'id',
|
|
||||||
'ip_version',
|
|
||||||
'ipv6_address_mode',
|
|
||||||
'ipv6_ra_mode',
|
|
||||||
'name',
|
|
||||||
'network_id',
|
|
||||||
'project_id',
|
|
||||||
'segment_id',
|
|
||||||
'service_types',
|
|
||||||
'subnetpool_id',
|
|
||||||
'tags',
|
|
||||||
)
|
|
||||||
|
|
||||||
data = (
|
# An IPv4 subnet to be created using a specific subnet pool
|
||||||
subnet_v2._format_allocation_pools(_subnet.allocation_pools),
|
self._subnet_from_pool = network_fakes.FakeSubnet.create_one_subnet(
|
||||||
_subnet.cidr,
|
attrs={
|
||||||
_subnet.description,
|
'tenant_id': self.project.id,
|
||||||
utils.format_list(_subnet.dns_nameservers),
|
'subnetpool_id': self._subnet_pool.id,
|
||||||
_subnet.enable_dhcp,
|
'dns_nameservers': ['8.8.8.8',
|
||||||
_subnet.gateway_ip,
|
'8.8.4.4'],
|
||||||
subnet_v2._format_host_routes(_subnet.host_routes),
|
'host_routes': [{'destination': '10.20.20.0/24',
|
||||||
_subnet.id,
|
'nexthop': '10.20.20.1'},
|
||||||
_subnet.ip_version,
|
{'destination': '10.30.30.0/24',
|
||||||
_subnet.ipv6_address_mode,
|
'nexthop': '10.30.30.1'}],
|
||||||
_subnet.ipv6_ra_mode,
|
'service_types': ['network:router_gateway',
|
||||||
_subnet.name,
|
'network:floatingip_agent_gateway'],
|
||||||
_subnet.network_id,
|
}
|
||||||
_subnet.project_id,
|
)
|
||||||
_subnet.segment_id,
|
|
||||||
utils.format_list(_subnet.service_types),
|
|
||||||
_subnet.subnetpool_id,
|
|
||||||
utils.format_list(_subnet.tags),
|
|
||||||
)
|
|
||||||
|
|
||||||
data_subnet_pool = (
|
# An IPv6 subnet to be created with most options specified
|
||||||
subnet_v2._format_allocation_pools(_subnet_from_pool.allocation_pools),
|
self._subnet_ipv6 = network_fakes.FakeSubnet.create_one_subnet(
|
||||||
_subnet_from_pool.cidr,
|
attrs={
|
||||||
_subnet_from_pool.description,
|
'tenant_id': self.project.id,
|
||||||
utils.format_list(_subnet_from_pool.dns_nameservers),
|
'cidr': 'fe80:0:0:a00a::/64',
|
||||||
_subnet_from_pool.enable_dhcp,
|
'enable_dhcp': True,
|
||||||
_subnet_from_pool.gateway_ip,
|
'dns_nameservers': ['fe80:27ff:a00a:f00f::ffff',
|
||||||
subnet_v2._format_host_routes(_subnet_from_pool.host_routes),
|
'fe80:37ff:a00a:f00f::ffff'],
|
||||||
_subnet_from_pool.id,
|
'allocation_pools': [{'start': 'fe80::a00a:0:c0de:0:100',
|
||||||
_subnet_from_pool.ip_version,
|
'end': 'fe80::a00a:0:c0de:0:f000'},
|
||||||
_subnet_from_pool.ipv6_address_mode,
|
{'start': 'fe80::a00a:0:c0de:1:100',
|
||||||
_subnet_from_pool.ipv6_ra_mode,
|
'end': 'fe80::a00a:0:c0de:1:f000'}],
|
||||||
_subnet_from_pool.name,
|
'host_routes': [{'destination': 'fe80:27ff:a00a:f00f::/64',
|
||||||
_subnet_from_pool.network_id,
|
'nexthop': 'fe80:27ff:a00a:f00f::1'},
|
||||||
_subnet_from_pool.project_id,
|
{'destination': 'fe80:37ff:a00a:f00f::/64',
|
||||||
_subnet_from_pool.segment_id,
|
'nexthop': 'fe80:37ff:a00a:f00f::1'}],
|
||||||
utils.format_list(_subnet_from_pool.service_types),
|
'ip_version': 6,
|
||||||
_subnet_from_pool.subnetpool_id,
|
'gateway_ip': 'fe80::a00a:0:c0de:0:1',
|
||||||
utils.format_list(_subnet.tags),
|
'ipv6_address_mode': 'slaac',
|
||||||
)
|
'ipv6_ra_mode': 'slaac',
|
||||||
|
'subnetpool_id': 'None',
|
||||||
|
'service_types': ['network:router_gateway',
|
||||||
|
'network:floatingip_agent_gateway'],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
data_ipv6 = (
|
# The network to be returned from find_network
|
||||||
subnet_v2._format_allocation_pools(_subnet_ipv6.allocation_pools),
|
self._network = network_fakes.FakeNetwork.create_one_network(
|
||||||
_subnet_ipv6.cidr,
|
attrs={
|
||||||
_subnet_ipv6.description,
|
'id': self._subnet.network_id,
|
||||||
utils.format_list(_subnet_ipv6.dns_nameservers),
|
}
|
||||||
_subnet_ipv6.enable_dhcp,
|
)
|
||||||
_subnet_ipv6.gateway_ip,
|
|
||||||
subnet_v2._format_host_routes(_subnet_ipv6.host_routes),
|
# The network segment to be returned from find_segment
|
||||||
_subnet_ipv6.id,
|
self._network_segment = \
|
||||||
_subnet_ipv6.ip_version,
|
network_fakes.FakeNetworkSegment.create_one_network_segment(
|
||||||
_subnet_ipv6.ipv6_address_mode,
|
attrs={
|
||||||
_subnet_ipv6.ipv6_ra_mode,
|
'network_id': self._subnet.network_id,
|
||||||
_subnet_ipv6.name,
|
}
|
||||||
_subnet_ipv6.network_id,
|
)
|
||||||
_subnet_ipv6.project_id,
|
|
||||||
_subnet_ipv6.segment_id,
|
self.columns = (
|
||||||
utils.format_list(_subnet_ipv6.service_types),
|
'allocation_pools',
|
||||||
_subnet_ipv6.subnetpool_id,
|
'cidr',
|
||||||
utils.format_list(_subnet.tags),
|
'description',
|
||||||
)
|
'dns_nameservers',
|
||||||
|
'enable_dhcp',
|
||||||
|
'gateway_ip',
|
||||||
|
'host_routes',
|
||||||
|
'id',
|
||||||
|
'ip_version',
|
||||||
|
'ipv6_address_mode',
|
||||||
|
'ipv6_ra_mode',
|
||||||
|
'name',
|
||||||
|
'network_id',
|
||||||
|
'project_id',
|
||||||
|
'segment_id',
|
||||||
|
'service_types',
|
||||||
|
'subnetpool_id',
|
||||||
|
'tags',
|
||||||
|
)
|
||||||
|
|
||||||
|
self.data = (
|
||||||
|
subnet_v2._format_allocation_pools(self._subnet.allocation_pools),
|
||||||
|
self._subnet.cidr,
|
||||||
|
self._subnet.description,
|
||||||
|
utils.format_list(self._subnet.dns_nameservers),
|
||||||
|
self._subnet.enable_dhcp,
|
||||||
|
self._subnet.gateway_ip,
|
||||||
|
subnet_v2._format_host_routes(self._subnet.host_routes),
|
||||||
|
self._subnet.id,
|
||||||
|
self._subnet.ip_version,
|
||||||
|
self._subnet.ipv6_address_mode,
|
||||||
|
self._subnet.ipv6_ra_mode,
|
||||||
|
self._subnet.name,
|
||||||
|
self._subnet.network_id,
|
||||||
|
self._subnet.project_id,
|
||||||
|
self._subnet.segment_id,
|
||||||
|
utils.format_list(self._subnet.service_types),
|
||||||
|
self._subnet.subnetpool_id,
|
||||||
|
utils.format_list(self._subnet.tags),
|
||||||
|
)
|
||||||
|
|
||||||
|
self.data_subnet_pool = (
|
||||||
|
subnet_v2._format_allocation_pools(
|
||||||
|
self._subnet_from_pool.allocation_pools),
|
||||||
|
self._subnet_from_pool.cidr,
|
||||||
|
self._subnet_from_pool.description,
|
||||||
|
utils.format_list(self._subnet_from_pool.dns_nameservers),
|
||||||
|
self._subnet_from_pool.enable_dhcp,
|
||||||
|
self._subnet_from_pool.gateway_ip,
|
||||||
|
subnet_v2._format_host_routes(self._subnet_from_pool.host_routes),
|
||||||
|
self._subnet_from_pool.id,
|
||||||
|
self._subnet_from_pool.ip_version,
|
||||||
|
self._subnet_from_pool.ipv6_address_mode,
|
||||||
|
self._subnet_from_pool.ipv6_ra_mode,
|
||||||
|
self._subnet_from_pool.name,
|
||||||
|
self._subnet_from_pool.network_id,
|
||||||
|
self._subnet_from_pool.project_id,
|
||||||
|
self._subnet_from_pool.segment_id,
|
||||||
|
utils.format_list(self._subnet_from_pool.service_types),
|
||||||
|
self._subnet_from_pool.subnetpool_id,
|
||||||
|
utils.format_list(self._subnet.tags),
|
||||||
|
)
|
||||||
|
|
||||||
|
self.data_ipv6 = (
|
||||||
|
subnet_v2._format_allocation_pools(
|
||||||
|
self._subnet_ipv6.allocation_pools),
|
||||||
|
self._subnet_ipv6.cidr,
|
||||||
|
self._subnet_ipv6.description,
|
||||||
|
utils.format_list(self._subnet_ipv6.dns_nameservers),
|
||||||
|
self._subnet_ipv6.enable_dhcp,
|
||||||
|
self._subnet_ipv6.gateway_ip,
|
||||||
|
subnet_v2._format_host_routes(self._subnet_ipv6.host_routes),
|
||||||
|
self._subnet_ipv6.id,
|
||||||
|
self._subnet_ipv6.ip_version,
|
||||||
|
self._subnet_ipv6.ipv6_address_mode,
|
||||||
|
self._subnet_ipv6.ipv6_ra_mode,
|
||||||
|
self._subnet_ipv6.name,
|
||||||
|
self._subnet_ipv6.network_id,
|
||||||
|
self._subnet_ipv6.project_id,
|
||||||
|
self._subnet_ipv6.segment_id,
|
||||||
|
utils.format_list(self._subnet_ipv6.service_types),
|
||||||
|
self._subnet_ipv6.subnetpool_id,
|
||||||
|
utils.format_list(self._subnet.tags),
|
||||||
|
)
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
self._init_subnet_variables()
|
||||||
super(TestCreateSubnet, self).setUp()
|
super(TestCreateSubnet, self).setUp()
|
||||||
|
|
||||||
# Get the command object to test
|
# Get the command object to test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user