Merge "Manually disable IP version when creating network subnets."
This commit is contained in:
commit
819595415e
@ -333,27 +333,31 @@ class NetworkTests(test.TestCase):
|
||||
'subnet_create',
|
||||
'profile_list',)})
|
||||
def test_network_create_post_with_subnet(self,
|
||||
test_with_profile=False):
|
||||
test_with_profile=False,
|
||||
test_with_ipv6=True):
|
||||
network = self.networks.first()
|
||||
subnet = self.subnets.first()
|
||||
params = {'name': network.name,
|
||||
'admin_state_up': network.admin_state_up}
|
||||
subnet_params = {'network_id': network.id,
|
||||
'name': subnet.name,
|
||||
'cidr': subnet.cidr,
|
||||
'ip_version': subnet.ip_version,
|
||||
'gateway_ip': subnet.gateway_ip,
|
||||
'enable_dhcp': subnet.enable_dhcp}
|
||||
if test_with_profile:
|
||||
net_profiles = self.net_profiles.list()
|
||||
net_profile_id = self.net_profiles.first().id
|
||||
api.neutron.profile_list(IsA(http.HttpRequest),
|
||||
'network').AndReturn(net_profiles)
|
||||
params['net_profile_id'] = net_profile_id
|
||||
if not test_with_ipv6:
|
||||
subnet.ip_version = 4
|
||||
subnet_params['ip_version'] = subnet.ip_version
|
||||
api.neutron.network_create(IsA(http.HttpRequest),
|
||||
**params).AndReturn(network)
|
||||
api.neutron.subnet_create(IsA(http.HttpRequest),
|
||||
network_id=network.id,
|
||||
name=subnet.name,
|
||||
cidr=subnet.cidr,
|
||||
ip_version=subnet.ip_version,
|
||||
gateway_ip=subnet.gateway_ip,
|
||||
enable_dhcp=subnet.enable_dhcp)\
|
||||
.AndReturn(subnet)
|
||||
**subnet_params).AndReturn(subnet)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
form_data = {'net_name': network.name,
|
||||
@ -372,6 +376,10 @@ class NetworkTests(test.TestCase):
|
||||
def test_network_create_post_with_subnet_w_profile(self):
|
||||
self.test_network_create_post_with_subnet(test_with_profile=True)
|
||||
|
||||
@override_settings(OPENSTACK_NEUTRON_NETWORK={'enable_ipv6': False})
|
||||
def test_create_network_with_ipv6_disabled(self):
|
||||
self.test_network_create_post_with_subnet(test_with_ipv6=False)
|
||||
|
||||
@test.create_stubs({api.neutron: ('network_create',
|
||||
'profile_list',)})
|
||||
def test_network_create_post_network_exception(self,
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
import logging
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
import netaddr
|
||||
@ -23,6 +24,7 @@ from horizon import exceptions
|
||||
from horizon import forms
|
||||
from horizon import messages
|
||||
from horizon import workflows
|
||||
|
||||
from openstack_dashboard import api
|
||||
|
||||
|
||||
@ -117,6 +119,14 @@ class CreateSubnetInfoAction(workflows.Action):
|
||||
'specified. If you wish to create a network WITHOUT a '
|
||||
'subnet, uncheck the "Create Subnet" checkbox.')
|
||||
|
||||
def __init__(self, request, context, *args, **kwargs):
|
||||
super(CreateSubnetInfoAction, self).__init__(request, context, *args,
|
||||
**kwargs)
|
||||
if not getattr(settings, 'OPENSTACK_NEUTRON_NETWORK',
|
||||
{}).get('enable_ipv6', True):
|
||||
self.fields['ip_version'].widget = forms.HiddenInput()
|
||||
self.fields['ip_version'].initial = 4
|
||||
|
||||
def _check_subnet_data(self, cleaned_data, is_create=True):
|
||||
cidr = cleaned_data.get('cidr')
|
||||
ip_version = int(cleaned_data.get('ip_version'))
|
||||
|
@ -182,6 +182,7 @@ OPENSTACK_NEUTRON_NETWORK = {
|
||||
'enable_firewall': False,
|
||||
'enable_quotas': True,
|
||||
'enable_vpn': False,
|
||||
'enable_ipv6': True,
|
||||
# The profile_support option is used to detect if an external router can be
|
||||
# configured via the dashboard. When using specific plugins the
|
||||
# profile_support can be turned on if needed.
|
||||
|
Loading…
x
Reference in New Issue
Block a user