SDK for Neutron networks and subnets
Depends-On: https://review.opendev.org/c/909656 Related-Bug: #1999774 Change-Id: Ic454dcb06b9efe2a4735637bd804d8a337c394cd
This commit is contained in:
parent
c0d558c65f
commit
a2d84f10e0
@ -425,9 +425,15 @@ class Column(html.HTMLElement):
|
||||
display_value = None
|
||||
|
||||
if self.display_choices:
|
||||
display_value = [display for (value, display) in
|
||||
self.display_choices
|
||||
if value.lower() == (data or '').lower()]
|
||||
display_value = []
|
||||
for (value, display) in self.display_choices:
|
||||
data_lower = ''
|
||||
try:
|
||||
data_lower = (data or '').lower()
|
||||
if value.lower() == data_lower:
|
||||
display_value.append(display)
|
||||
except AttributeError:
|
||||
continue
|
||||
|
||||
if display_value:
|
||||
data = display_value[0]
|
||||
|
@ -22,14 +22,23 @@ from collections.abc import Sequence
|
||||
import copy
|
||||
import itertools
|
||||
import logging
|
||||
import types
|
||||
|
||||
import netaddr
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from keystoneauth1 import exceptions as ks_exceptions
|
||||
from keystoneauth1 import session
|
||||
from keystoneauth1 import token_endpoint
|
||||
from neutronclient.common import exceptions as neutron_exc
|
||||
from neutronclient.v2_0 import client as neutron_client
|
||||
from novaclient import exceptions as nova_exc
|
||||
import openstack
|
||||
from openstack import exceptions as sdk_exceptions
|
||||
import requests
|
||||
|
||||
from openstack_auth import utils as auth_utils
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import messages
|
||||
@ -67,6 +76,11 @@ VNIC_TYPES = [
|
||||
class NeutronAPIDictWrapper(base.APIDictWrapper):
|
||||
|
||||
def __init__(self, apidict):
|
||||
if 'is_admin_state_up' in apidict:
|
||||
if apidict['is_admin_state_up']:
|
||||
apidict['admin_state'] = 'UP'
|
||||
else:
|
||||
apidict['admin_state'] = 'DOWN'
|
||||
if 'admin_state_up' in apidict:
|
||||
if apidict['admin_state_up']:
|
||||
apidict['admin_state'] = 'UP'
|
||||
@ -665,6 +679,7 @@ class FloatingIpManager(object):
|
||||
def __init__(self, request):
|
||||
self.request = request
|
||||
self.client = neutronclient(request)
|
||||
self.net_client = networkclient(request)
|
||||
|
||||
@profiler.trace
|
||||
def list_pools(self):
|
||||
@ -674,7 +689,7 @@ class FloatingIpManager(object):
|
||||
"""
|
||||
search_opts = {'router:external': True}
|
||||
return [FloatingIpPool(pool) for pool
|
||||
in self.client.list_networks(**search_opts).get('networks')]
|
||||
in self.net_client.networks(**search_opts)]
|
||||
|
||||
def _get_instance_type_from_device_owner(self, device_owner):
|
||||
for key, value in self.device_owner_map.items():
|
||||
@ -817,8 +832,8 @@ class FloatingIpManager(object):
|
||||
if p.device_id in gw_routers)
|
||||
# we have to include any shared subnets as well because we may not
|
||||
# have permission to see the router interface to infer connectivity
|
||||
shared = set(s.id for n in network_list(self.request, shared=True)
|
||||
for s in n.subnets)
|
||||
shared = set(s.id for n in network_list(self.request, is_shared=True)
|
||||
for s in n['subnets'])
|
||||
return reachable_subnets | shared
|
||||
|
||||
@profiler.trace
|
||||
@ -942,6 +957,35 @@ def neutronclient(request):
|
||||
return c
|
||||
|
||||
|
||||
@memoized
|
||||
def networkclient(request):
|
||||
token_id, neutron_url, auth_url = get_auth_params_from_request(request)
|
||||
|
||||
insecure = settings.OPENSTACK_SSL_NO_VERIFY
|
||||
cacert = settings.OPENSTACK_SSL_CACERT
|
||||
verify = cacert if not insecure else False
|
||||
|
||||
token_auth = token_endpoint.Token(
|
||||
endpoint=neutron_url,
|
||||
token=token_id)
|
||||
k_session = session.Session(
|
||||
auth=token_auth,
|
||||
original_ip=auth_utils.get_client_ip(request),
|
||||
verify=verify,
|
||||
# TODO(lajoskatona): cert should be None of a tuple in the form of
|
||||
# (cert, key).
|
||||
# In a devstack with enable_service tls-proxy:
|
||||
# cert=('/path/to/devstack-cert.crt', '/path/to/devstack-cert.key')
|
||||
# For this new horizon cfg option should be added.
|
||||
)
|
||||
c = openstack.connection.Connection(
|
||||
session=k_session,
|
||||
region_name=request.user.services_region,
|
||||
app_name='horizon', app_version='1.0'
|
||||
)
|
||||
return c.network
|
||||
|
||||
|
||||
@profiler.trace
|
||||
def list_resources_with_long_filters(list_method,
|
||||
filter_attr, filter_values, **params):
|
||||
@ -1154,23 +1198,57 @@ def _network_list_paged(request, page_data, params):
|
||||
@profiler.trace
|
||||
def network_list(request, single_page=False, **params):
|
||||
LOG.debug("network_list(): params=%s", params)
|
||||
list_values = []
|
||||
if 'id' in params and isinstance(params['id'], frozenset):
|
||||
list_values = list(params['id'])
|
||||
if 'id' in params and isinstance(params['id'], list):
|
||||
list_values = params['id']
|
||||
if single_page is True:
|
||||
params['retrieve_all'] = False
|
||||
result = neutronclient(request).list_networks(**params)
|
||||
if single_page is True:
|
||||
result = result.next()
|
||||
networks = result.get('networks')
|
||||
|
||||
networks = []
|
||||
if 'tenant_id' in params:
|
||||
params['project_id'] = params.pop('tenant_id')
|
||||
for value in list_values:
|
||||
params['id'] = value
|
||||
for net in networkclient(request).networks(**params):
|
||||
networks.append(net)
|
||||
if not list_values:
|
||||
networks = networkclient(request).networks(**params)
|
||||
|
||||
# Get subnet list to expand subnet info in network list.
|
||||
subnets = subnet_list(request)
|
||||
subnet_dict = dict((s['id'], s) for s in subnets)
|
||||
|
||||
if not isinstance(networks, (list, types.GeneratorType)):
|
||||
networks = [networks]
|
||||
nets_with_subnet = []
|
||||
net_ids = set()
|
||||
|
||||
# Expand subnet list from subnet_id to values.
|
||||
for n in networks:
|
||||
# Due to potential timing issues, we can't assume the subnet_dict data
|
||||
# is in sync with the network data.
|
||||
n['subnets'] = [subnet_dict[s] for s in n.get('subnets', []) if
|
||||
s in subnet_dict]
|
||||
return [Network(n) for n in networks]
|
||||
subnet_l_ready = False
|
||||
runs = 0
|
||||
max_runs = 3
|
||||
while not subnet_l_ready and runs < max_runs:
|
||||
networks, cp_nets = itertools.tee(networks, 2)
|
||||
try:
|
||||
for n in cp_nets:
|
||||
# Due to potential timing issues, we can't assume the
|
||||
# subnet_dict data is in sync with the network data.
|
||||
net_dict = n.to_dict()
|
||||
net_dict['subnets'] = [
|
||||
subnet_dict[s] for s in net_dict.get('subnet_ids', [])
|
||||
if s in subnet_dict
|
||||
]
|
||||
if net_dict['id'] not in net_ids:
|
||||
nets_with_subnet.append(net_dict)
|
||||
net_ids.add(net_dict['id'])
|
||||
subnet_l_ready = True
|
||||
except (requests.exceptions.SSLError, ks_exceptions.SSLError):
|
||||
LOG.warning('Retry due to SSLError')
|
||||
runs += 1
|
||||
continue
|
||||
return [Network(n) for n in nets_with_subnet]
|
||||
|
||||
|
||||
def _is_auto_allocated_network_supported(request):
|
||||
@ -1381,9 +1459,9 @@ def _query_nets_for_tenant(request, include_external, tenant_id, page_data,
|
||||
|
||||
def _configure_marker_type(marker_net, tenant_id=None):
|
||||
if marker_net:
|
||||
if marker_net['shared'] is True:
|
||||
if marker_net['is_shared'] is True:
|
||||
return 'shr'
|
||||
if (marker_net['router:external'] is True and
|
||||
if (marker_net['is_router_external'] is True and
|
||||
marker_net['tenant_id'] != tenant_id):
|
||||
return 'ext'
|
||||
return 'proj'
|
||||
@ -1565,8 +1643,8 @@ def network_list_for_tenant(request, tenant_id, include_external=False,
|
||||
def network_get(request, network_id, expand_subnet=True, **params):
|
||||
LOG.debug("network_get(): netid=%(network_id)s, params=%(params)s",
|
||||
{'network_id': network_id, 'params': params})
|
||||
network = neutronclient(request).show_network(network_id,
|
||||
**params).get('network')
|
||||
network = networkclient(request).get_network(network_id,
|
||||
**params).to_dict()
|
||||
if expand_subnet:
|
||||
# NOTE(amotoki): There are some cases where a user has no permission
|
||||
# to get subnet details, but the condition is complicated. We first
|
||||
@ -1582,8 +1660,8 @@ def network_get(request, network_id, expand_subnet=True, **params):
|
||||
# call subnet_get() for each subnet instead of calling
|
||||
# subnet_list() once.
|
||||
network['subnets'] = [subnet_get(request, sid)
|
||||
for sid in network['subnets']]
|
||||
except neutron_exc.NotFound:
|
||||
for sid in network['subnet_ids']]
|
||||
except sdk_exceptions.ResourceNotFound:
|
||||
pass
|
||||
return Network(network)
|
||||
|
||||
@ -1600,8 +1678,7 @@ def network_create(request, **kwargs):
|
||||
LOG.debug("network_create(): kwargs = %s", kwargs)
|
||||
if 'tenant_id' not in kwargs:
|
||||
kwargs['tenant_id'] = request.user.project_id
|
||||
body = {'network': kwargs}
|
||||
network = neutronclient(request).create_network(body=body).get('network')
|
||||
network = networkclient(request).create_network(**kwargs).to_dict()
|
||||
return Network(network)
|
||||
|
||||
|
||||
@ -1609,16 +1686,15 @@ def network_create(request, **kwargs):
|
||||
def network_update(request, network_id, **kwargs):
|
||||
LOG.debug("network_update(): netid=%(network_id)s, params=%(params)s",
|
||||
{'network_id': network_id, 'params': kwargs})
|
||||
body = {'network': kwargs}
|
||||
network = neutronclient(request).update_network(network_id,
|
||||
body=body).get('network')
|
||||
network = networkclient(request).update_network(network_id,
|
||||
**kwargs).to_dict()
|
||||
return Network(network)
|
||||
|
||||
|
||||
@profiler.trace
|
||||
def network_delete(request, network_id):
|
||||
LOG.debug("network_delete(): netid=%s", network_id)
|
||||
neutronclient(request).delete_network(network_id)
|
||||
networkclient(request).delete_network(network_id)
|
||||
request.session['network_deleted'] = network_id
|
||||
|
||||
|
||||
@ -1626,16 +1702,17 @@ def network_delete(request, network_id):
|
||||
@memoized
|
||||
def subnet_list(request, **params):
|
||||
LOG.debug("subnet_list(): params=%s", params)
|
||||
subnets = neutronclient(request).list_subnets(**params).get('subnets')
|
||||
return [Subnet(s) for s in subnets]
|
||||
subnets = networkclient(request).subnets(**params)
|
||||
ret_val = [Subnet(s.to_dict()) for s in subnets]
|
||||
return ret_val
|
||||
|
||||
|
||||
@profiler.trace
|
||||
def subnet_get(request, subnet_id, **params):
|
||||
LOG.debug("subnet_get(): subnetid=%(subnet_id)s, params=%(params)s",
|
||||
{'subnet_id': subnet_id, 'params': params})
|
||||
subnet = neutronclient(request).show_subnet(subnet_id,
|
||||
**params).get('subnet')
|
||||
subnet = networkclient(request).get_subnet(subnet_id,
|
||||
**params).to_dict()
|
||||
return Subnet(subnet)
|
||||
|
||||
|
||||
@ -1660,11 +1737,11 @@ def subnet_create(request, network_id, **kwargs):
|
||||
"""
|
||||
LOG.debug("subnet_create(): netid=%(network_id)s, kwargs=%(kwargs)s",
|
||||
{'network_id': network_id, 'kwargs': kwargs})
|
||||
body = {'subnet': {'network_id': network_id}}
|
||||
body = {'network_id': network_id}
|
||||
if 'tenant_id' not in kwargs:
|
||||
kwargs['tenant_id'] = request.user.project_id
|
||||
body['subnet'].update(kwargs)
|
||||
subnet = neutronclient(request).create_subnet(body=body).get('subnet')
|
||||
body.update(kwargs)
|
||||
subnet = networkclient(request).create_subnet(**body).to_dict()
|
||||
return Subnet(subnet)
|
||||
|
||||
|
||||
@ -1672,16 +1749,15 @@ def subnet_create(request, network_id, **kwargs):
|
||||
def subnet_update(request, subnet_id, **kwargs):
|
||||
LOG.debug("subnet_update(): subnetid=%(subnet_id)s, kwargs=%(kwargs)s",
|
||||
{'subnet_id': subnet_id, 'kwargs': kwargs})
|
||||
body = {'subnet': kwargs}
|
||||
subnet = neutronclient(request).update_subnet(subnet_id,
|
||||
body=body).get('subnet')
|
||||
subnet = networkclient(request).update_subnet(subnet_id,
|
||||
**kwargs).to_dict()
|
||||
return Subnet(subnet)
|
||||
|
||||
|
||||
@profiler.trace
|
||||
def subnet_delete(request, subnet_id):
|
||||
LOG.debug("subnet_delete(): subnetid=%s", subnet_id)
|
||||
neutronclient(request).delete_subnet(subnet_id)
|
||||
networkclient(request).delete_subnet(subnet_id)
|
||||
|
||||
|
||||
@profiler.trace
|
||||
|
@ -137,7 +137,7 @@ class NetworkSubnetTests(test.BaseAdminViewTests):
|
||||
cidr=subnet.cidr,
|
||||
ip_version=subnet.ip_version,
|
||||
gateway_ip=subnet.gateway_ip,
|
||||
enable_dhcp=subnet.enable_dhcp,
|
||||
enable_dhcp=subnet.is_dhcp_enabled,
|
||||
allocation_pools=subnet.allocation_pools,
|
||||
tenant_id=subnet.tenant_id)
|
||||
|
||||
@ -194,7 +194,7 @@ class NetworkSubnetTests(test.BaseAdminViewTests):
|
||||
cidr=subnet.cidr,
|
||||
ip_version=subnet.ip_version,
|
||||
gateway_ip=subnet.gateway_ip,
|
||||
enable_dhcp=subnet.enable_dhcp,
|
||||
enable_dhcp=subnet.is_dhcp_enabled,
|
||||
tenant_id=subnet.tenant_id)
|
||||
|
||||
@test.create_mocks({api.neutron: ('network_get',
|
||||
@ -278,7 +278,7 @@ class NetworkSubnetTests(test.BaseAdminViewTests):
|
||||
self.mock_subnet_update.assert_called_once_with(
|
||||
test.IsHttpRequest(), subnet.id,
|
||||
name=subnet.name,
|
||||
enable_dhcp=subnet.enable_dhcp,
|
||||
enable_dhcp=subnet.is_dhcp_enabled,
|
||||
dns_nameservers=[],
|
||||
host_routes=[])
|
||||
|
||||
|
@ -84,15 +84,15 @@ class NetworksTable(tables.DataTable):
|
||||
verbose_name=_("Subnets Associated"),)
|
||||
num_agents = tables.Column("num_agents",
|
||||
verbose_name=_("DHCP Agents"))
|
||||
shared = tables.Column("shared", verbose_name=_("Shared"),
|
||||
shared = tables.Column("is_shared", verbose_name=_("Shared"),
|
||||
filters=(filters.yesno, filters.capfirst))
|
||||
external = tables.Column("router:external",
|
||||
external = tables.Column("is_router_external",
|
||||
verbose_name=_("External"),
|
||||
filters=(filters.yesno, filters.capfirst))
|
||||
status = tables.Column(
|
||||
"status", verbose_name=_("Status"),
|
||||
display_choices=project_tables.STATUS_DISPLAY_CHOICES)
|
||||
admin_state = tables.Column("admin_state",
|
||||
admin_state = tables.Column("is_admin_state_up",
|
||||
verbose_name=_("Admin State"),
|
||||
display_choices=DISPLAY_CHOICES)
|
||||
availability_zones = tables.Column(get_availability_zones,
|
||||
|
@ -409,7 +409,7 @@ class NetworkTests(test.BaseAdminViewTests):
|
||||
|
||||
form_data = {'tenant_id': tenant_id,
|
||||
'name': network.name,
|
||||
'admin_state': network.admin_state_up,
|
||||
'admin_state': network.is_admin_state_up,
|
||||
'external': True,
|
||||
'shared': True,
|
||||
'network_type': 'local'}
|
||||
@ -423,7 +423,7 @@ class NetworkTests(test.BaseAdminViewTests):
|
||||
self.mock_subnetpool_list.assert_called_once_with(test.IsHttpRequest())
|
||||
params = {'name': network.name,
|
||||
'tenant_id': tenant_id,
|
||||
'admin_state_up': network.admin_state_up,
|
||||
'admin_state_up': network.is_admin_state_up,
|
||||
'router:external': True,
|
||||
'shared': True,
|
||||
'provider:network_type': 'local'}
|
||||
@ -456,7 +456,7 @@ class NetworkTests(test.BaseAdminViewTests):
|
||||
|
||||
form_data = {'tenant_id': tenant_id,
|
||||
'name': network.name,
|
||||
'admin_state': network.admin_state_up,
|
||||
'admin_state': network.is_admin_state_up,
|
||||
'external': True,
|
||||
'shared': True,
|
||||
'network_type': 'local',
|
||||
@ -478,7 +478,7 @@ class NetworkTests(test.BaseAdminViewTests):
|
||||
self.mock_subnetpool_list.assert_called_once_with(test.IsHttpRequest())
|
||||
params = {'name': network.name,
|
||||
'tenant_id': tenant_id,
|
||||
'admin_state_up': network.admin_state_up,
|
||||
'admin_state_up': network.is_admin_state_up,
|
||||
'router:external': True,
|
||||
'shared': True,
|
||||
'provider:network_type': 'local',
|
||||
@ -505,7 +505,7 @@ class NetworkTests(test.BaseAdminViewTests):
|
||||
|
||||
form_data = {'tenant_id': tenant_id,
|
||||
'name': network.name,
|
||||
'admin_state': network.admin_state_up,
|
||||
'admin_state': network.is_admin_state_up,
|
||||
'external': True,
|
||||
'shared': True,
|
||||
'mtu': 1450,
|
||||
@ -520,7 +520,7 @@ class NetworkTests(test.BaseAdminViewTests):
|
||||
self.mock_subnetpool_list.assert_called_once_with(test.IsHttpRequest())
|
||||
params = {'name': network.name,
|
||||
'tenant_id': tenant_id,
|
||||
'admin_state_up': network.admin_state_up,
|
||||
'admin_state_up': network.is_admin_state_up,
|
||||
'router:external': True,
|
||||
'shared': True,
|
||||
'mtu': 1450,
|
||||
@ -554,7 +554,7 @@ class NetworkTests(test.BaseAdminViewTests):
|
||||
|
||||
form_data = {'tenant_id': tenant_id,
|
||||
'name': network.name,
|
||||
'admin_state': network.admin_state_up,
|
||||
'admin_state': network.is_admin_state_up,
|
||||
'external': True,
|
||||
'shared': True,
|
||||
'network_type': 'local',
|
||||
@ -574,7 +574,7 @@ class NetworkTests(test.BaseAdminViewTests):
|
||||
self.mock_subnetpool_list.assert_called_once_with(test.IsHttpRequest())
|
||||
params = {'name': network.name,
|
||||
'tenant_id': tenant_id,
|
||||
'admin_state_up': network.admin_state_up,
|
||||
'admin_state_up': network.is_admin_state_up,
|
||||
'router:external': True,
|
||||
'shared': True,
|
||||
'provider:network_type': 'local'}
|
||||
@ -584,7 +584,7 @@ class NetworkTests(test.BaseAdminViewTests):
|
||||
'name': subnet.name,
|
||||
'network_id': subnet.network_id,
|
||||
'cidr': subnet.cidr,
|
||||
'enable_dhcp': subnet.enable_dhcp,
|
||||
'enable_dhcp': subnet.is_dhcp_enabled,
|
||||
'gateway_ip': subnet.gateway_ip,
|
||||
'ip_version': subnet.ip_version}
|
||||
self.mock_subnet_create.assert_called_once_with(test.IsHttpRequest(),
|
||||
@ -609,7 +609,7 @@ class NetworkTests(test.BaseAdminViewTests):
|
||||
|
||||
form_data = {'tenant_id': tenant_id,
|
||||
'name': network.name,
|
||||
'admin_state': network.admin_state_up,
|
||||
'admin_state': network.is_admin_state_up,
|
||||
'external': True,
|
||||
'shared': False,
|
||||
'network_type': 'local'}
|
||||
@ -627,7 +627,7 @@ class NetworkTests(test.BaseAdminViewTests):
|
||||
self.mock_subnetpool_list.assert_called_once_with(test.IsHttpRequest())
|
||||
params = {'name': network.name,
|
||||
'tenant_id': tenant_id,
|
||||
'admin_state_up': network.admin_state_up,
|
||||
'admin_state_up': network.is_admin_state_up,
|
||||
'router:external': True,
|
||||
'shared': False,
|
||||
'provider:network_type': 'local'}
|
||||
@ -649,7 +649,7 @@ class NetworkTests(test.BaseAdminViewTests):
|
||||
|
||||
form_data = {'tenant_id': tenant_id,
|
||||
'name': network.name,
|
||||
'admin_state': network.admin_state_up,
|
||||
'admin_state': network.is_admin_state_up,
|
||||
'external': True,
|
||||
'shared': False,
|
||||
'network_type': 'vlan',
|
||||
@ -682,7 +682,7 @@ class NetworkTests(test.BaseAdminViewTests):
|
||||
|
||||
form_data = {'tenant_id': tenant_id,
|
||||
'name': network.name,
|
||||
'admin_state': network.admin_state_up,
|
||||
'admin_state': network.is_admin_state_up,
|
||||
'external': True,
|
||||
'shared': False,
|
||||
'network_type': 'gre',
|
||||
@ -718,7 +718,7 @@ class NetworkTests(test.BaseAdminViewTests):
|
||||
|
||||
form_data = {'tenant_id': tenant_id,
|
||||
'name': network.name,
|
||||
'admin_state': network.admin_state_up,
|
||||
'admin_state': network.is_admin_state_up,
|
||||
'external': True,
|
||||
'shared': False,
|
||||
'network_type': 'vxlan',
|
||||
@ -834,7 +834,7 @@ class NetworkTests(test.BaseAdminViewTests):
|
||||
form_data = {'network_id': network.id,
|
||||
'name': network.name,
|
||||
'tenant_id': network.tenant_id,
|
||||
'admin_state': network.admin_state_up,
|
||||
'admin_state': network.is_admin_state_up,
|
||||
'shared': True,
|
||||
'external': True}
|
||||
url = reverse('horizon:admin:networks:update', args=[network.id])
|
||||
@ -844,7 +844,7 @@ class NetworkTests(test.BaseAdminViewTests):
|
||||
|
||||
params = {'name': network.name,
|
||||
'shared': True,
|
||||
'admin_state_up': network.admin_state_up,
|
||||
'admin_state_up': network.is_admin_state_up,
|
||||
'router:external': True}
|
||||
self.mock_network_update.assert_called_once_with(test.IsHttpRequest(),
|
||||
network.id,
|
||||
@ -859,7 +859,7 @@ class NetworkTests(test.BaseAdminViewTests):
|
||||
network = self.networks.first()
|
||||
params = {'name': network.name,
|
||||
'shared': False,
|
||||
'admin_state_up': network.admin_state_up,
|
||||
'admin_state_up': network.is_admin_state_up,
|
||||
'router:external': False}
|
||||
self.mock_network_update.side_effect = self.exceptions.neutron
|
||||
self.mock_network_get.return_value = network
|
||||
@ -867,7 +867,7 @@ class NetworkTests(test.BaseAdminViewTests):
|
||||
form_data = {'network_id': network.id,
|
||||
'name': network.name,
|
||||
'tenant_id': network.tenant_id,
|
||||
'admin_state': network.admin_state_up,
|
||||
'admin_state': network.is_admin_state_up,
|
||||
'shared': False,
|
||||
'external': False}
|
||||
url = reverse('horizon:admin:networks:update', args=[network.id])
|
||||
|
@ -160,9 +160,9 @@ class UpdateView(user_views.UpdateView):
|
||||
return {'network_id': network['id'],
|
||||
'tenant_id': network['tenant_id'],
|
||||
'name': network['name'],
|
||||
'admin_state': network['admin_state_up'],
|
||||
'shared': network['shared'],
|
||||
'external': network['router__external']}
|
||||
'admin_state': network['is_admin_state_up'],
|
||||
'shared': network['is_shared'],
|
||||
'external': network['is_router_external']}
|
||||
|
||||
|
||||
class NetworkDetailsTabs(tabs.DetailTabsGroup):
|
||||
@ -204,5 +204,5 @@ class DetailView(tabs.TabbedTableView):
|
||||
context["actions"] = table.render_row_actions(network)
|
||||
choices = networks_tables.DISPLAY_CHOICES
|
||||
network.admin_state_label = (
|
||||
filters.get_display_label(choices, network.admin_state))
|
||||
filters.get_display_label(choices, network.is_admin_state_up))
|
||||
return context
|
||||
|
@ -3075,7 +3075,7 @@ class ConsoleManagerTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
|
||||
def test_interface_attach_get(self):
|
||||
server = self.servers.first()
|
||||
tenant_networks = [net for net in self.networks.list()
|
||||
if not net['router:external']]
|
||||
if not net['is_router_external']]
|
||||
net1 = tenant_networks[0]
|
||||
self.mock_network_list_for_tenant.return_value = tenant_networks
|
||||
ports = self.ports.list()
|
||||
|
@ -107,7 +107,7 @@ def network_field_data(request, include_empty_option=False, with_cidr=False,
|
||||
|
||||
_networks = []
|
||||
for n in networks:
|
||||
if not n['subnets']:
|
||||
if not n['subnet_ids']:
|
||||
continue
|
||||
v = n.name_or_id
|
||||
if with_cidr:
|
||||
|
@ -60,9 +60,9 @@ class NetworkTopologyTests(test.TestCase):
|
||||
self.mock_server_list.return_value = [self.servers.list(), False]
|
||||
|
||||
tenant_networks = [net for net in self.networks.list()
|
||||
if not net['router:external']]
|
||||
if not net['is_router_external']]
|
||||
external_networks = [net for net in self.networks.list()
|
||||
if net['router:external']]
|
||||
if net['is_router_external']]
|
||||
self.mock_network_list_for_tenant.return_value = tenant_networks
|
||||
|
||||
# router1 : gateway port not in the port list
|
||||
@ -117,7 +117,7 @@ class NetworkTopologyTests(test.TestCase):
|
||||
'id': net.id,
|
||||
'url': '/project/networks/%s/detail' % net.id,
|
||||
'name': net.name,
|
||||
'router:external': net.router__external,
|
||||
'router:external': net.is_router_external,
|
||||
'status': net.status.title(),
|
||||
'original_status': net.status,
|
||||
'subnets': [{
|
||||
@ -130,7 +130,7 @@ class NetworkTopologyTests(test.TestCase):
|
||||
'id': net.id,
|
||||
'url': '/project/networks/%s/detail' % net.id,
|
||||
'name': net.name,
|
||||
'router:external': net.router__external,
|
||||
'router:external': net.is_router_external,
|
||||
'status': net.status.title(),
|
||||
'allow_delete_subnet': True,
|
||||
'original_status': net.status,
|
||||
|
@ -284,7 +284,7 @@ class JSONView(View):
|
||||
'status': self.trans.network[network.status],
|
||||
'allow_delete_subnet': allow_delete_subnet,
|
||||
'original_status': network.status,
|
||||
'router:external': network['router:external']}
|
||||
'router:external': network['is_router_external']}
|
||||
self.add_resource_url('horizon:project:networks:subnets:detail',
|
||||
obj['subnets'])
|
||||
networks.append(obj)
|
||||
@ -315,7 +315,7 @@ class JSONView(View):
|
||||
'subnets': subnets,
|
||||
'status': self.trans.network[publicnet.status],
|
||||
'original_status': publicnet.status,
|
||||
'router:external': publicnet['router:external']})
|
||||
'router:external': publicnet['is_router_external']})
|
||||
|
||||
self.add_resource_url('horizon:project:networks:detail',
|
||||
networks)
|
||||
|
@ -176,7 +176,7 @@ class NetworkSubnetTests(test.TestCase):
|
||||
cidr=subnet.cidr,
|
||||
ip_version=subnet.ip_version,
|
||||
gateway_ip=subnet.gateway_ip,
|
||||
enable_dhcp=subnet.enable_dhcp,
|
||||
enable_dhcp=subnet.is_dhcp_enabled,
|
||||
allocation_pools=subnet.allocation_pools)
|
||||
|
||||
@test.create_mocks({api.neutron: ('network_get',
|
||||
@ -212,7 +212,7 @@ class NetworkSubnetTests(test.TestCase):
|
||||
cidr=subnet.cidr,
|
||||
ip_version=subnet.ip_version,
|
||||
gateway_ip=subnet.gateway_ip,
|
||||
enable_dhcp=subnet.enable_dhcp,
|
||||
enable_dhcp=subnet.is_dhcp_enabled,
|
||||
allocation_pools=subnet.allocation_pools,
|
||||
dns_nameservers=subnet.dns_nameservers,
|
||||
host_routes=subnet.host_routes)
|
||||
@ -250,7 +250,7 @@ class NetworkSubnetTests(test.TestCase):
|
||||
cidr=subnet.cidr,
|
||||
ip_version=subnet.ip_version,
|
||||
gateway_ip=None,
|
||||
enable_dhcp=subnet.enable_dhcp,
|
||||
enable_dhcp=subnet.is_dhcp_enabled,
|
||||
allocation_pools=subnet.allocation_pools)
|
||||
|
||||
@test.create_mocks({api.neutron: ('network_get',)})
|
||||
@ -311,7 +311,7 @@ class NetworkSubnetTests(test.TestCase):
|
||||
cidr=subnet.cidr,
|
||||
ip_version=subnet.ip_version,
|
||||
gateway_ip=subnet.gateway_ip,
|
||||
enable_dhcp=subnet.enable_dhcp)
|
||||
enable_dhcp=subnet.is_dhcp_enabled)
|
||||
|
||||
@test.create_mocks({api.neutron: ('network_get',
|
||||
'is_extension_supported',
|
||||
@ -640,7 +640,7 @@ class NetworkSubnetTests(test.TestCase):
|
||||
cidr=subnet.cidr,
|
||||
ip_version=subnet.ip_version,
|
||||
gateway_ip=subnet.gateway_ip,
|
||||
enable_dhcp=subnet.enable_dhcp,
|
||||
enable_dhcp=subnet.is_dhcp_enabled,
|
||||
allocation_pools=subnet.allocation_pools)
|
||||
|
||||
@test.create_mocks({api.neutron: ('network_get',
|
||||
@ -676,7 +676,7 @@ class NetworkSubnetTests(test.TestCase):
|
||||
cidr=subnet.cidr,
|
||||
ip_version=subnet.ip_version,
|
||||
gateway_ip=subnet.gateway_ip,
|
||||
enable_dhcp=subnet.enable_dhcp,
|
||||
enable_dhcp=subnet.is_dhcp_enabled,
|
||||
allocation_pools=subnet.allocation_pools,
|
||||
ipv6_address_mode='slaac',
|
||||
ipv6_ra_mode='slaac')
|
||||
@ -711,7 +711,7 @@ class NetworkSubnetTests(test.TestCase):
|
||||
test.IsHttpRequest(),
|
||||
subnet.id,
|
||||
name=subnet.name,
|
||||
enable_dhcp=subnet.enable_dhcp,
|
||||
enable_dhcp=subnet.is_dhcp_enabled,
|
||||
dns_nameservers=[],
|
||||
host_routes=[])
|
||||
|
||||
@ -748,7 +748,7 @@ class NetworkSubnetTests(test.TestCase):
|
||||
subnet.id,
|
||||
name=subnet.name,
|
||||
gateway_ip=gateway_ip,
|
||||
enable_dhcp=subnet.enable_dhcp,
|
||||
enable_dhcp=subnet.is_dhcp_enabled,
|
||||
dns_nameservers=[],
|
||||
host_routes=[])
|
||||
|
||||
@ -784,7 +784,7 @@ class NetworkSubnetTests(test.TestCase):
|
||||
subnet.id,
|
||||
name=subnet.name,
|
||||
gateway_ip=None,
|
||||
enable_dhcp=subnet.enable_dhcp,
|
||||
enable_dhcp=subnet.is_dhcp_enabled,
|
||||
dns_nameservers=[],
|
||||
host_routes=[])
|
||||
|
||||
|
@ -78,7 +78,7 @@ class UpdateView(workflows.WorkflowView):
|
||||
initial['subnet_id'] = subnet['id']
|
||||
initial['subnet_name'] = subnet['name']
|
||||
|
||||
for key in ('cidr', 'ip_version', 'enable_dhcp'):
|
||||
for key in ('cidr', 'ip_version', 'is_dhcp_enabled'):
|
||||
initial[key] = subnet[key]
|
||||
|
||||
initial['gateway_ip'] = subnet['gateway_ip'] or ''
|
||||
|
@ -146,7 +146,7 @@ class CreateSubnet(subnet_tables.SubnetPolicyTargetMixin, tables.LinkAction):
|
||||
|
||||
def get_subnets(network):
|
||||
template_name = 'project/networks/_network_ips.html'
|
||||
context = {"subnets": network.subnets}
|
||||
context = {"subnets": network.to_dict()['subnets']}
|
||||
return template.loader.render_to_string(template_name, context)
|
||||
|
||||
|
||||
@ -193,13 +193,13 @@ class NetworksTable(tables.DataTable):
|
||||
link=get_network_link)
|
||||
subnets = tables.Column(get_subnets,
|
||||
verbose_name=_("Subnets Associated"),)
|
||||
shared = tables.Column("shared", verbose_name=_("Shared"),
|
||||
shared = tables.Column("is_shared", verbose_name=_("Shared"),
|
||||
filters=(filters.yesno, filters.capfirst))
|
||||
external = tables.Column("router:external", verbose_name=_("External"),
|
||||
external = tables.Column("is_router_external", verbose_name=_("External"),
|
||||
filters=(filters.yesno, filters.capfirst))
|
||||
status = tables.Column("status", verbose_name=_("Status"),
|
||||
display_choices=STATUS_DISPLAY_CHOICES)
|
||||
admin_state = tables.Column("admin_state",
|
||||
admin_state = tables.Column("is_admin_state_up",
|
||||
verbose_name=_("Admin State"),
|
||||
display_choices=DISPLAY_CHOICES)
|
||||
availability_zones = tables.Column(get_availability_zones,
|
||||
|
@ -49,7 +49,7 @@ class OverviewTab(tabs.Tab):
|
||||
filters.get_display_label(choices, network.status))
|
||||
choices = project_tables.DISPLAY_CHOICES
|
||||
network.admin_state_label = (
|
||||
filters.get_display_label(choices, network.admin_state))
|
||||
filters.get_display_label(choices, network.is_admin_state_up))
|
||||
except Exception:
|
||||
msg = _('Unable to retrieve details for network "%s".') \
|
||||
% (network_id)
|
||||
|
@ -13,9 +13,9 @@
|
||||
<dt title="{% trans 'Admin State' %}">{% trans "Admin State" %}</dt>
|
||||
<dd>{{ network.admin_state_label|default:_("Unknown") }}</dd>
|
||||
<dt title="{% trans 'Shared' %}">{% trans "Shared" %}</dt>
|
||||
<dd>{{ network.shared|yesno|capfirst }}</dd>
|
||||
<dd>{{ network.is_shared|yesno|capfirst }}</dd>
|
||||
<dt title="{% trans 'External Network' %}">{% trans "External Network" %}</dt>
|
||||
<dd>{{ network.router__external|yesno|capfirst }}</dd>
|
||||
<dd>{{ network.is_router_external|yesno|capfirst }}</dd>
|
||||
<dt title="{% trans 'MTU' %}">{% trans "MTU" %}</dt>
|
||||
<dd>{{ network.mtu|default:_("Unknown") }}</dd>
|
||||
{% if network.provider__network_type %}
|
||||
|
@ -52,7 +52,7 @@ def form_data_subnet(subnet,
|
||||
data['gateway_ip'] = gateway_ip or ''
|
||||
data['no_gateway'] = no_gateway or (gateway_ip is None)
|
||||
|
||||
data['enable_dhcp'] = get_value(enable_dhcp, subnet.enable_dhcp)
|
||||
data['enable_dhcp'] = get_value(enable_dhcp, subnet.is_dhcp_enabled)
|
||||
if data['ip_version'] == 6:
|
||||
data['ipv6_modes'] = subnet.ipv6_modes
|
||||
|
||||
@ -72,7 +72,7 @@ def form_data_no_subnet():
|
||||
'ip_version': 4,
|
||||
'gateway_ip': '',
|
||||
'no_gateway': False,
|
||||
'enable_dhcp': True,
|
||||
'is_dhcp_enabled': True,
|
||||
'allocation_pools': '',
|
||||
'dns_nameservers': '',
|
||||
'host_routes': ''}
|
||||
@ -103,13 +103,13 @@ class NetworkStubMixin(object):
|
||||
all_networks = self.networks.list()
|
||||
self.mock_network_list.side_effect = [
|
||||
[network for network in all_networks
|
||||
if network.get('shared') is True],
|
||||
if network.get('is_shared') is True],
|
||||
[network for network in all_networks
|
||||
if network['tenant_id'] == self.tenant.id and
|
||||
network.get('shared') is False],
|
||||
network.get('is_shared') is False],
|
||||
[network for network in all_networks
|
||||
if network.get('router:external') is True and
|
||||
network.get('shared') is False],
|
||||
if network.get('is_router_external') is True and
|
||||
network.get('is_shared') is False],
|
||||
]
|
||||
|
||||
def _check_net_list(self):
|
||||
@ -398,7 +398,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
def test_network_create_post(self):
|
||||
network = self.networks.first()
|
||||
params = {'name': network.name,
|
||||
'admin_state_up': network.admin_state_up,
|
||||
'admin_state_up': network.is_admin_state_up,
|
||||
'shared': False}
|
||||
self._stub_is_extension_supported({'network_availability_zone': False,
|
||||
'subnet_allocation': True})
|
||||
@ -406,7 +406,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
self.mock_network_create.return_value = network
|
||||
|
||||
form_data = {'net_name': network.name,
|
||||
'admin_state': network.admin_state_up,
|
||||
'admin_state': network.is_admin_state_up,
|
||||
'shared': False,
|
||||
'with_subnet': False}
|
||||
form_data.update(form_data_no_subnet())
|
||||
@ -429,7 +429,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
def test_network_create_post_with_az(self):
|
||||
network = self.networks.first()
|
||||
params = {'name': network.name,
|
||||
'admin_state_up': network.admin_state_up,
|
||||
'admin_state_up': network.is_admin_state_up,
|
||||
'shared': False,
|
||||
'availability_zone_hints': ['nova']}
|
||||
|
||||
@ -441,7 +441,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
self.mock_network_create.return_value = network
|
||||
|
||||
form_data = {'net_name': network.name,
|
||||
'admin_state': network.admin_state_up,
|
||||
'admin_state': network.is_admin_state_up,
|
||||
'shared': False,
|
||||
'with_subnet': False,
|
||||
'az_hints': ['nova']}
|
||||
@ -466,7 +466,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
def test_network_create_post_with_mtu(self):
|
||||
network = self.networks.first()
|
||||
params = {'name': network.name,
|
||||
'admin_state_up': network.admin_state_up,
|
||||
'admin_state_up': network.is_admin_state_up,
|
||||
'shared': False,
|
||||
'mtu': 1450}
|
||||
self._stub_is_extension_supported({'network_availability_zone': False,
|
||||
@ -475,7 +475,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
self.mock_network_create.return_value = network
|
||||
|
||||
form_data = {'net_name': network.name,
|
||||
'admin_state': network.admin_state_up,
|
||||
'admin_state': network.is_admin_state_up,
|
||||
'shared': False,
|
||||
'with_subnet': False,
|
||||
'mtu': 1450}
|
||||
@ -498,7 +498,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
def test_network_create_post_with_shared(self):
|
||||
network = self.networks.first()
|
||||
params = {'name': network.name,
|
||||
'admin_state_up': network.admin_state_up,
|
||||
'admin_state_up': network.is_admin_state_up,
|
||||
'shared': True}
|
||||
self._stub_is_extension_supported({'network_availability_zone': False,
|
||||
'subnet_allocation': True})
|
||||
@ -506,7 +506,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
self.mock_network_create.return_value = network
|
||||
|
||||
form_data = {'net_name': network.name,
|
||||
'admin_state': network.admin_state_up,
|
||||
'admin_state': network.is_admin_state_up,
|
||||
'shared': True,
|
||||
'with_subnet': False}
|
||||
form_data.update(form_data_no_subnet())
|
||||
@ -530,7 +530,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
network = self.networks.first()
|
||||
subnet = self.subnets.first()
|
||||
params = {'name': network.name,
|
||||
'admin_state_up': network.admin_state_up,
|
||||
'admin_state_up': network.is_admin_state_up,
|
||||
'shared': False}
|
||||
subnet_params = {'network_id': network.id,
|
||||
'tenant_id': network.tenant_id,
|
||||
@ -538,7 +538,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
'cidr': subnet.cidr,
|
||||
'ip_version': subnet.ip_version,
|
||||
'gateway_ip': subnet.gateway_ip,
|
||||
'enable_dhcp': subnet.enable_dhcp}
|
||||
'enable_dhcp': subnet.is_dhcp_enabled}
|
||||
if not test_with_ipv6:
|
||||
subnet.ip_version = 4
|
||||
subnet_params['ip_version'] = subnet.ip_version
|
||||
@ -550,7 +550,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
self.mock_subnet_create.return_value = subnet
|
||||
|
||||
form_data = {'net_name': network.name,
|
||||
'admin_state': network.admin_state_up,
|
||||
'admin_state': network.is_admin_state_up,
|
||||
'shared': False,
|
||||
'with_subnet': True}
|
||||
form_data.update(form_data_subnet(subnet, allocation_pools=[]))
|
||||
@ -579,14 +579,14 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
network = self.networks.first()
|
||||
params = {'name': network.name,
|
||||
'shared': False,
|
||||
'admin_state_up': network.admin_state_up}
|
||||
'admin_state_up': network.is_admin_state_up}
|
||||
self._stub_is_extension_supported({'network_availability_zone': False,
|
||||
'subnet_allocation': True})
|
||||
self.mock_subnetpool_list.return_value = self.subnetpools.list()
|
||||
self.mock_network_create.side_effect = self.exceptions.neutron
|
||||
|
||||
form_data = {'net_name': network.name,
|
||||
'admin_state': network.admin_state_up,
|
||||
'admin_state': network.is_admin_state_up,
|
||||
'shared': False,
|
||||
'with_subnet': False}
|
||||
form_data.update(form_data_no_subnet())
|
||||
@ -610,14 +610,14 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
subnet = self.subnets.first()
|
||||
params = {'name': network.name,
|
||||
'shared': False,
|
||||
'admin_state_up': network.admin_state_up}
|
||||
'admin_state_up': network.is_admin_state_up}
|
||||
self._stub_is_extension_supported({'network_availability_zone': False,
|
||||
'subnet_allocation': True})
|
||||
self.mock_subnetpool_list.return_value = self.subnetpools.list()
|
||||
self.mock_network_create.side_effect = self.exceptions.neutron
|
||||
|
||||
form_data = {'net_name': network.name,
|
||||
'admin_state': network.admin_state_up,
|
||||
'admin_state': network.is_admin_state_up,
|
||||
'shared': False,
|
||||
'with_subnet': True}
|
||||
form_data.update(form_data_subnet(subnet, allocation_pools=[]))
|
||||
@ -643,7 +643,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
subnet = self.subnets.first()
|
||||
params = {'name': network.name,
|
||||
'shared': False,
|
||||
'admin_state_up': network.admin_state_up}
|
||||
'admin_state_up': network.is_admin_state_up}
|
||||
self._stub_is_extension_supported({'network_availability_zone': False,
|
||||
'subnet_allocation': True})
|
||||
self.mock_subnetpool_list.return_value = self.subnetpools.list()
|
||||
@ -652,7 +652,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
self.mock_network_delete.return_value = None
|
||||
|
||||
form_data = {'net_name': network.name,
|
||||
'admin_state': network.admin_state_up,
|
||||
'admin_state': network.is_admin_state_up,
|
||||
'shared': False,
|
||||
'with_subnet': True}
|
||||
form_data.update(form_data_subnet(subnet, allocation_pools=[]))
|
||||
@ -675,7 +675,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
cidr=subnet.cidr,
|
||||
ip_version=subnet.ip_version,
|
||||
gateway_ip=subnet.gateway_ip,
|
||||
enable_dhcp=subnet.enable_dhcp)
|
||||
enable_dhcp=subnet.is_dhcp_enabled)
|
||||
self.mock_network_delete.assert_called_once_with(
|
||||
test.IsHttpRequest(), network.id)
|
||||
|
||||
@ -690,7 +690,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
self.mock_subnetpool_list.side_effect = self.exceptions.neutron
|
||||
|
||||
form_data = {'net_name': network.name,
|
||||
'admin_state': network.admin_state_up,
|
||||
'admin_state': network.is_admin_state_up,
|
||||
'shared': False,
|
||||
'with_subnet': True}
|
||||
if test_with_snpool:
|
||||
@ -726,7 +726,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
|
||||
form_data = {'net_name': network.name,
|
||||
'shared': False,
|
||||
'admin_state': network.admin_state_up,
|
||||
'admin_state': network.is_admin_state_up,
|
||||
'with_subnet': True}
|
||||
if test_with_subnetpool:
|
||||
subnetpool = self.subnetpools.first()
|
||||
@ -763,7 +763,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
|
||||
form_data = {'net_name': network.name,
|
||||
'shared': False,
|
||||
'admin_state': network.admin_state_up,
|
||||
'admin_state': network.is_admin_state_up,
|
||||
'with_subnet': True}
|
||||
if test_with_subnetpool:
|
||||
subnetpool = self.subnetpools.first()
|
||||
@ -804,7 +804,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
|
||||
form_data = {'net_name': network.name,
|
||||
'shared': False,
|
||||
'admin_state': network.admin_state_up,
|
||||
'admin_state': network.is_admin_state_up,
|
||||
'with_subnet': True}
|
||||
if test_with_subnetpool:
|
||||
subnetpool = self.subnetpools.first()
|
||||
@ -840,7 +840,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
cidr = '30.30.30.0/24'
|
||||
gateway_ip = '30.30.30.1'
|
||||
params = {'name': network.name,
|
||||
'admin_state_up': network.admin_state_up,
|
||||
'admin_state_up': network.is_admin_state_up,
|
||||
'shared': False}
|
||||
subnet_params = {'network_id': network.id,
|
||||
'tenant_id': network.tenant_id,
|
||||
@ -848,7 +848,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
'cidr': cidr,
|
||||
'ip_version': subnet.ip_version,
|
||||
'gateway_ip': gateway_ip,
|
||||
'enable_dhcp': subnet.enable_dhcp}
|
||||
'enable_dhcp': subnet.is_dhcp_enabled}
|
||||
|
||||
self._stub_is_extension_supported({'network_availability_zone': False,
|
||||
'subnet_allocation': True})
|
||||
@ -857,7 +857,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
self.mock_subnet_create.return_value = subnet
|
||||
|
||||
form_data = {'net_name': network.name,
|
||||
'admin_state': network.admin_state_up,
|
||||
'admin_state': network.is_admin_state_up,
|
||||
'shared': False,
|
||||
'with_subnet': True}
|
||||
|
||||
@ -893,7 +893,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
cidr = '2001:0DB8:0:CD30:123:4567:89AB:CDEF/60'
|
||||
form_data = {'net_name': network.name,
|
||||
'shared': False,
|
||||
'admin_state': network.admin_state_up,
|
||||
'admin_state': network.is_admin_state_up,
|
||||
'with_subnet': True}
|
||||
if test_with_subnetpool:
|
||||
subnetpool = self.subnetpools.first()
|
||||
@ -929,7 +929,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
gateway_ip = '2001:0DB8:0:CD30:123:4567:89AB:CDEF'
|
||||
form_data = {'net_name': network.name,
|
||||
'shared': False,
|
||||
'admin_state': network.admin_state_up,
|
||||
'admin_state': network.is_admin_state_up,
|
||||
'with_subnet': True}
|
||||
if test_with_subnetpool:
|
||||
subnetpool = self.subnetpools.first()
|
||||
@ -959,7 +959,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
network = self.networks.first()
|
||||
subnet = self.subnets.first()
|
||||
params = {'name': network.name,
|
||||
'admin_state_up': network.admin_state_up,
|
||||
'admin_state_up': network.is_admin_state_up,
|
||||
'shared': False}
|
||||
|
||||
self._stub_is_extension_supported({'network_availability_zone': False,
|
||||
@ -969,7 +969,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
self.mock_subnet_create.return_value = subnet
|
||||
|
||||
form_data = {'net_name': network.name,
|
||||
'admin_state': network.admin_state_up,
|
||||
'admin_state': network.is_admin_state_up,
|
||||
'shared': False,
|
||||
'with_subnet': True}
|
||||
subnet_params = {'network_id': network.id,
|
||||
@ -978,7 +978,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
'cidr': subnet.cidr,
|
||||
'ip_version': subnet.ip_version,
|
||||
'gateway_ip': None,
|
||||
'enable_dhcp': subnet.enable_dhcp}
|
||||
'enable_dhcp': subnet.is_dhcp_enabled}
|
||||
form_data.update(form_data_subnet(subnet, allocation_pools=[],
|
||||
no_gateway=True, gateway_ip="."))
|
||||
url = reverse('horizon:project:networks:create')
|
||||
@ -1031,7 +1031,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
form_data = {'network_id': network.id,
|
||||
'shared': False,
|
||||
'name': network.name,
|
||||
'admin_state': network.admin_state_up,
|
||||
'admin_state': network.is_admin_state_up,
|
||||
'tenant_id': network.tenant_id}
|
||||
url = reverse('horizon:project:networks:update', args=[network.id])
|
||||
res = self.client.post(url, form_data)
|
||||
@ -1040,7 +1040,8 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
|
||||
self.mock_network_update.assert_called_once_with(
|
||||
test.IsHttpRequest(), network.id, name=network.name,
|
||||
admin_state_up=network.admin_state_up, shared=network.shared)
|
||||
admin_state_up=network.is_admin_state_up,
|
||||
shared=network.is_shared)
|
||||
self.mock_network_get.assert_called_once_with(
|
||||
test.IsHttpRequest(), network.id, expand_subnet=False)
|
||||
|
||||
@ -1054,7 +1055,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||