From c1cb8839c438e704ffd54001c23cbf6cba07f81a Mon Sep 17 00:00:00 2001 From: Edward Hope-Morley Date: Tue, 3 Mar 2015 13:48:05 +0800 Subject: [PATCH] more --- hooks/charmhelpers/contrib/openstack/neutron.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/hooks/charmhelpers/contrib/openstack/neutron.py b/hooks/charmhelpers/contrib/openstack/neutron.py index 76a90011..818ece57 100644 --- a/hooks/charmhelpers/contrib/openstack/neutron.py +++ b/hooks/charmhelpers/contrib/openstack/neutron.py @@ -264,8 +264,19 @@ def parse_bridge_mappings(mappings): def parse_data_port_mappings(mappings): """Parse data port mappings. - Mappings must be a space-delimited list of provider:port mappings. + Mappings must be a space-delimited list of bridge:port mappings. - Returns dict of the form {provider:port}. + Returns dict of the form {bridge:port}. """ - return parse_mappings(mappings) + mappings = parse_mappings(mappings) + bridges = mappings.keys() + ports = mappings.values() + if len(set(bridges)) != len(bridges): + raise Exception("It is not allowed to have more than one port " + "configured on the same bridge") + + if len(set(ports)) != len(ports): + raise Exception("It is not allowed to have the same port configured " + "on more than one bridge") + + return mappings