diff --git a/doc/source/usage.rst b/doc/source/usage.rst index 78f4fd6..b6aef6d 100644 --- a/doc/source/usage.rst +++ b/doc/source/usage.rst @@ -168,13 +168,19 @@ Where /tmp/ctlplane-dc contains:: "cidr": "192.0.2.0/24", "allocation_end": "192.0.2.20", "allocation_start": "192.0.2.2", - "name": "ctlplane", + "name": "public", + "physical_network": "ctlplane", "segmentation_id": 25 } } -This creates a Neutron datacentre 'net' using VLAN tag 25, with the same -details as the flat network created above. +This creates a Neutron 'net' called ``public`` using VLAN tag 25, that uses +the existing 'net' called ``ctlplane`` as a physical transport. + + .. note:: + + The key ``physical_network`` is required when creating a network that + specifies a ``segmentation_id``, and it must reference an existing net. setup-neutron can also create two networks suitable for workload clouds:: diff --git a/os_cloud_config/neutron.py b/os_cloud_config/neutron.py index 1b4e9de..28e2a72 100644 --- a/os_cloud_config/neutron.py +++ b/os_cloud_config/neutron.py @@ -88,9 +88,10 @@ def _create_net(neutron, network_desc, network_type, admin_tenant): network['router:external'] = True if type_desc.get('segmentation_id'): vlan_tag = type_desc['segmentation_id'] + physical_network = type_desc['physical_network'] network.update({'provider:network_type': 'vlan', 'provider:segmentation_id': vlan_tag, - 'provider:physical_network': 'datacentre'}) + 'provider:physical_network': physical_network}) return neutron.create_network({'network': network}) diff --git a/os_cloud_config/tests/test_neutron.py b/os_cloud_config/tests/test_neutron.py index 6917c79..c409ab0 100644 --- a/os_cloud_config/tests/test_neutron.py +++ b/os_cloud_config/tests/test_neutron.py @@ -41,12 +41,14 @@ class NeutronTest(base.TestCase): def test_create_net_physical_vlan_tag(self): client = mock.MagicMock() - network = {'physical': {'name': 'ctlplane', 'segmentation_id': '123'}} + network = {'physical': {'name': 'public', + 'segmentation_id': '123', + 'physical_network': 'ctlplane'}} neutron._create_net(client, network, 'physical', 'admin_tenant') physical_call = {'network': {'tenant_id': 'admin_tenant', 'provider:network_type': 'vlan', - 'name': 'ctlplane', - 'provider:physical_network': 'datacentre', + 'name': 'public', + 'provider:physical_network': 'ctlplane', 'provider:segmentation_id': '123', 'admin_state_up': True}} client.create_network.assert_called_once_with(physical_call)