Skip to content

Commit

Permalink
plugin/nec: Make sure resources on OFC is globally unique.
Browse files Browse the repository at this point in the history
V3 and V4 of NEC ProgrammableFlow controller (PFC) generates a network ID
unique inside a tenant. On the other hand, ID mapping table in NEC plugin
expects ID on OFC is globally unique. As a result creation of a network
will fail. To fix it, quantum network ID is passed as ID on OFC.
The same issue happens in port creation too.

In Grizzly this bug was fixed in another way (to support shared network),
but this change is quite big and it cannot be backported.
The minimum way to fix this bug is to specify OFC network ID from Quantum.

Since V3 of PFC does not return network/port ID in the response when ID is
passed in the request, create_network/port is changed to return an ID
passed to the controller instead of extracting ID from the response.

Fixes bug #1127664

Change-Id: Iad1961ee2469b547598e87e63a4a3dc4ac9c6e97
  • Loading branch information
amotoki committed Apr 10, 2013
1 parent a109f7e commit a31069a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
18 changes: 8 additions & 10 deletions quantum/plugins/nec/drivers/pfc.py
Expand Up @@ -57,13 +57,12 @@ def delete_tenant(self, ofc_tenant_id):
path = TENANT_PATH % ofc_tenant_id
return self.client.delete(path)

def create_network(self, ofc_tenant_id, description, network_id=None):
def create_network(self, ofc_tenant_id, description, network_id):
path = NETWORKS_PATH % ofc_tenant_id
body = {'description': description}
if network_id:
body.update({'id': network_id})
ofc_network_id = network_id
body = {'description': description,
'id': ofc_network_id}
res = self.client.post(path, body=body)
ofc_network_id = res['id']
return ofc_network_id

def update_network(self, ofc_tenant_id, ofc_network_id, description):
Expand All @@ -76,15 +75,14 @@ def delete_network(self, ofc_tenant_id, ofc_network_id):
return self.client.delete(path)

def create_port(self, ofc_tenant_id, ofc_network_id, portinfo,
port_id=None):
port_id):
path = PORTS_PATH % (ofc_tenant_id, ofc_network_id)
ofc_port_id = port_id
body = {'datapath_id': portinfo.datapath_id,
'port': str(portinfo.port_no),
'vid': str(portinfo.vlan_id)}
if port_id:
body.update({'id': port_id})
'vid': str(portinfo.vlan_id),
'id': ofc_port_id}
res = self.client.post(path, body=body)
ofc_port_id = res['id']
return ofc_port_id

def update_port(self, ofc_tenant_id, ofc_network_id, portinfo, port_id):
Expand Down
10 changes: 5 additions & 5 deletions quantum/tests/unit/nec/test_pfc_driver.py
Expand Up @@ -35,7 +35,7 @@ class TestConfig(object):

def _ofc(id):
"""OFC ID converter"""
return "ofc-%s" % id
return id


class PFCDriverTestBase(unittest.TestCase):
Expand Down Expand Up @@ -99,8 +99,8 @@ def testd_create_network(self):
description = "desc of %s" % n

path = "/tenants/%s/networks" % _ofc(t)
body = {'id': n, 'description': description}
network = {'id': _ofc(n)}
body = {'id': _ofc(n), 'description': description}
network = {}
ofc.OFCClient.do_request("POST", path, body=body).AndReturn(network)
self.mox.ReplayAll()

Expand Down Expand Up @@ -134,11 +134,11 @@ def testg_create_port(self):
t, n, p = self.get_ofc_item_random_params()

path = "/tenants/%s/networks/%s/ports" % (_ofc(t), _ofc(n))
body = {'id': p.id,
body = {'id': _ofc(p.id),
'datapath_id': p.datapath_id,
'port': str(p.port_no),
'vid': str(p.vlan_id)}
port = {'id': _ofc(p.id)}
port = {}
ofc.OFCClient.do_request("POST", path, body=body).AndReturn(port)
self.mox.ReplayAll()

Expand Down

0 comments on commit a31069a

Please sign in to comment.