Skip to content

Commit

Permalink
Openstack port-create with pre-existing mac-address is not denied
Browse files Browse the repository at this point in the history
There should not be two ports with the same mac-address in the same network.

Change-Id: I77287d9fe2fbc87d339c480abc0a13f1b078c84c
Closes-bug: #1400683
  • Loading branch information
anbu-enovance committed Dec 9, 2014
1 parent 6d36150 commit f139d35
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/config/vnc_openstack/vnc_openstack/neutron_plugin_db.py
Expand Up @@ -3424,6 +3424,18 @@ def port_create(self, context, port_q):
tenant_id = self._get_tenant_id_for_create(context, port_q);
proj_id = str(uuid.UUID(tenant_id))

# if mac-address is specified, check against the exisitng ports
# to see if there exists a port with the same mac-address
if 'mac_address' in port_q:
ports = self._vnc_lib.virtual_machine_interfaces_list(
parent_id=proj_id, back_ref_id=net_id, detail=True)
for port in ports:
macs = port.get_virtual_machine_interface_mac_addresses()
for mac in macs.get_mac_address():
if mac == port_q['mac_address']:
raise self._raise_contrail_exception("MacAddressInUse",
net_id=net_id, mac=port_q['mac_address'])

# initialize port object
port_obj = self._port_neutron_to_vnc(port_q, net_obj, CREATE)

Expand Down

0 comments on commit f139d35

Please sign in to comment.