diff --git a/config.yaml b/config.yaml index 36ff290b..7e757614 100644 --- a/config.yaml +++ b/config.yaml @@ -153,8 +153,10 @@ options: type: string default: "physnet1:1000:2000" description: | - Space-delimited list of Neutron network-provider & vlan-id-ranges using - format ":: ...". + Space-delimited list of :: or + specifying physical_network names usable for VLAN + provider and tenant networks, as well as ranges of VLAN tags on each + available for allocation to tenant networks. # Network configuration options # by default all access is over 'private-address' os-data-network: diff --git a/hooks/charmhelpers/contrib/openstack/neutron.py b/hooks/charmhelpers/contrib/openstack/neutron.py index 02c92e9c..b3f4e2b7 100644 --- a/hooks/charmhelpers/contrib/openstack/neutron.py +++ b/hooks/charmhelpers/contrib/openstack/neutron.py @@ -256,11 +256,14 @@ def network_manager(): def parse_mappings(mappings): parsed = {} if mappings: - mappings = mappings.split(' ') + mappings = mappings.split() for m in mappings: p = m.partition(':') - if p[1] == ':': - parsed[p[0].strip()] = p[2].strip() + key = p[0].strip() + if p[1]: + parsed[key] = p[2].strip() + else: + parsed[key] = '' return parsed @@ -283,13 +286,13 @@ def parse_data_port_mappings(mappings, default_bridge='br-data'): Returns dict of the form {bridge:port}. """ _mappings = parse_mappings(mappings) - if not _mappings: + if not _mappings or _mappings.values() == ['']: if not mappings: return {} # For backwards-compatibility we need to support port-only provided in # config. - _mappings = {default_bridge: mappings.split(' ')[0]} + _mappings = {default_bridge: mappings.split()[0]} bridges = _mappings.keys() ports = _mappings.values() @@ -309,6 +312,8 @@ def parse_vlan_range_mappings(mappings): Mappings must be a space-delimited list of provider:start:end mappings. + The start:end range is optional and may be omitted. + Returns dict of the form {provider: (start, end)}. """ _mappings = parse_mappings(mappings) diff --git a/unit_tests/test_neutron_utils.py b/unit_tests/test_neutron_utils.py index befa9eb3..96254bcd 100644 --- a/unit_tests/test_neutron_utils.py +++ b/unit_tests/test_neutron_utils.py @@ -930,7 +930,8 @@ class TestQuantumAgentReallocation(CharmTestCase): 'process_name': 'neutron-nvsd-agent', 'executable_name': '/usr/local/bin/neutron-nvsd-agent', 'config_files': ['/etc/neutron/neutron.conf', - '/etc/neutron/plugins/oneconvergence/nvsdplugin.ini'], + '/etc/neutron/plugins/oneconvergence/' + 'nvsdplugin.ini'], 'log_file': '/var/log/neutron/nvsd-agent.log', } neutron_plugin_openflow_context = {