Provide available physical networks on create network modal
Added setting physical_networks to provide users list of available physical networks to choose from on the admin create network modal. Default to an empty list and the physical network field is a regular input field where users can type in the name of the physical network to be used. If it's set to a list of physical network names, the physical network field is a dropdown menu where users can choose a physical network to use. Closes-bug: #1485144 Change-Id: I342b3776a52179d5b4a704fb984912878ff3dc81
This commit is contained in:
parent
0e0172ef38
commit
31f4aa9767
@ -1220,6 +1220,7 @@ Default::
|
||||
'enable_ipv6': True,
|
||||
'enable_lb', True,
|
||||
'default_dns_nameservers': [],
|
||||
'physical_networks': [],
|
||||
}
|
||||
|
||||
A dictionary of settings which can be used to enable optional services provided
|
||||
@ -1417,6 +1418,8 @@ Example::
|
||||
``enable_fip_topology_check``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. versionadded:: 8.0.0(Liberty)
|
||||
|
||||
Default: ``True``
|
||||
|
||||
The Default Neutron implementation needs a router with a gateway to associate a
|
||||
@ -1429,8 +1432,6 @@ Some Neutron vendors do not require it. Some can even attach a FIP to any port
|
||||
Set to False if you want to be able to associate a FIP to an instance on a
|
||||
subnet with no router if your Neutron backend allows it.
|
||||
|
||||
.. versionadded:: 8.0.0(Liberty)
|
||||
|
||||
``default_dns_nameservers``:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@ -1443,6 +1444,23 @@ only a default. Users can still choose a different list of dns servers.
|
||||
|
||||
Example: ``["8.8.8.8", "8.8.4.4", "208.67.222.222"]``
|
||||
|
||||
``physical_networks``:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. versionadded:: 12.0.0(Pike)
|
||||
|
||||
Default: ``[]``
|
||||
|
||||
Default to an empty list and the physical network field on the admin create
|
||||
network modal will be a regular input field where users can type in the name
|
||||
of the physical network to be used.
|
||||
If it is set to a list of available physical networks, the physical network
|
||||
field will be shown as a dropdown menu where users can select a physical
|
||||
network to be used.
|
||||
|
||||
Example: ``['default', 'test']``
|
||||
|
||||
|
||||
``OPENSTACK_SSL_CACERT``
|
||||
------------------------
|
||||
|
||||
|
@ -219,6 +219,21 @@ class CreateNetwork(forms.SelfHandlingForm):
|
||||
for network_type in self.nettypes_with_seg_id)
|
||||
self.fields['segmentation_id'].widget.attrs.update(attrs)
|
||||
|
||||
physical_networks = getattr(settings,
|
||||
'OPENSTACK_NEUTRON_NETWORK', {}
|
||||
).get('physical_networks', [])
|
||||
|
||||
if physical_networks:
|
||||
self.fields['physical_network'] = forms.ThemableChoiceField(
|
||||
label=_("Physical Network"),
|
||||
choices=[(net, net) for net in physical_networks],
|
||||
widget=forms.ThemableSelectWidget(attrs={
|
||||
'class': 'switched',
|
||||
'data-switch-on': 'network_type',
|
||||
}),
|
||||
help_text=_("The name of the physical network over "
|
||||
"which the virtual network is implemented."),)
|
||||
|
||||
# Register network types which require physical network
|
||||
attrs = dict(('data-network_type-%s' % network_type,
|
||||
_('Physical Network'))
|
||||
|
@ -15,11 +15,12 @@
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django import http
|
||||
|
||||
from django.utils.http import urlunquote
|
||||
|
||||
from mox3.mox import IsA # noqa
|
||||
|
||||
from horizon import forms
|
||||
|
||||
from openstack_dashboard import api
|
||||
from openstack_dashboard.dashboards.project.networks import tests
|
||||
from openstack_dashboard.test import helpers as test
|
||||
@ -844,3 +845,38 @@ class NetworkTests(test.BaseAdminViewTests):
|
||||
self.assertTemplateUsed(res, INDEX_TEMPLATE)
|
||||
networks = res.context['networks_table'].data
|
||||
self.assertItemsEqual(networks, [])
|
||||
|
||||
@test.create_stubs({api.neutron: ('is_extension_supported',),
|
||||
api.keystone: ('tenant_list',)})
|
||||
def test_network_create_without_physical_networks(self):
|
||||
tenants = self.tenants.list()
|
||||
api.keystone.tenant_list(IsA(http.HttpRequest)).AndReturn([tenants,
|
||||
False])
|
||||
api.neutron.is_extension_supported(IsA(http.HttpRequest), 'provider').\
|
||||
AndReturn(True)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
url = reverse('horizon:admin:networks:create')
|
||||
res = self.client.get(url)
|
||||
physical_network = res.context['form'].fields['physical_network']
|
||||
self.assertEqual(type(physical_network), forms.CharField)
|
||||
|
||||
@test.create_stubs({api.neutron: ('is_extension_supported',),
|
||||
api.keystone: ('tenant_list',)})
|
||||
@test.update_settings(
|
||||
OPENSTACK_NEUTRON_NETWORK={
|
||||
'physical_networks': ['default', 'test']})
|
||||
def test_network_create_with_physical_networks(self):
|
||||
tenants = self.tenants.list()
|
||||
api.keystone.tenant_list(IsA(http.HttpRequest)).AndReturn([tenants,
|
||||
False])
|
||||
api.neutron.is_extension_supported(IsA(http.HttpRequest), 'provider').\
|
||||
AndReturn(True)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
url = reverse('horizon:admin:networks:create')
|
||||
res = self.client.get(url)
|
||||
physical_network = res.context['form'].fields['physical_network']
|
||||
self.assertEqual(type(physical_network), forms.ThemableChoiceField)
|
||||
self.assertListEqual(list(physical_network.choices),
|
||||
[('default', 'default'), ('test', 'test')])
|
||||
|
@ -330,6 +330,13 @@ OPENSTACK_NEUTRON_NETWORK = {
|
||||
# VNIC types include 'normal', 'macvtap' and 'direct'.
|
||||
# Set to empty list or None to disable VNIC type selection.
|
||||
'supported_vnic_types': ['*'],
|
||||
|
||||
# Set list of available physical networks to be selected in the physical
|
||||
# network field on the admin create network modal. If it's set to an empty
|
||||
# list, the field will be a regular input field.
|
||||
# e.g. ['default', 'test']
|
||||
'physical_networks': [],
|
||||
|
||||
}
|
||||
|
||||
# The OPENSTACK_HEAT_STACK settings can be used to disable password
|
||||
|
Loading…
x
Reference in New Issue
Block a user