From e83a8439412f2f7ac3ff0da4e3a6bf99507d60c4 Mon Sep 17 00:00:00 2001 From: Edgar Magana Date: Sun, 25 Aug 2013 13:11:27 -0700 Subject: [PATCH] Enable authentication between PLUMgrid Director and Plugin Implements blueprint plumgrid-plugin-rest-access Change-Id: I0f9a6c39c09f756ee5fc7c9d6993e59b1e6be639 --- neutron/plugins/plumgrid/drivers/fake_plumlib.py | 3 ++- neutron/plugins/plumgrid/drivers/plumlib.py | 7 +++++-- .../plugins/plumgrid/plumgrid_plugin/plumgrid_plugin.py | 5 ++++- neutron/tests/unit/plumgrid/test_plumgrid_plugin.py | 8 +++++++- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/neutron/plugins/plumgrid/drivers/fake_plumlib.py b/neutron/plugins/plumgrid/drivers/fake_plumlib.py index 20dc8c39a2..933b942202 100644 --- a/neutron/plugins/plumgrid/drivers/fake_plumlib.py +++ b/neutron/plugins/plumgrid/drivers/fake_plumlib.py @@ -32,7 +32,8 @@ class Plumlib(): LOG.info('Python PLUMgrid Fake Library Started ') pass - def director_conn(self, director_plumgrid, director_port, timeout): + def director_conn(self, director_plumgrid, director_port, timeout, + director_admin, director_password): LOG.info('Fake Director: %s', director_plumgrid + ':' + director_port) pass diff --git a/neutron/plugins/plumgrid/drivers/plumlib.py b/neutron/plugins/plumgrid/drivers/plumlib.py index e9ea6c50c6..5d6bc96293 100644 --- a/neutron/plugins/plumgrid/drivers/plumlib.py +++ b/neutron/plugins/plumgrid/drivers/plumlib.py @@ -37,10 +37,13 @@ class Plumlib(object): def __init__(self): LOG.info('Python PLUMgrid Library Started ') - def director_conn(self, director_plumgrid, director_port, timeout): + def director_conn(self, director_plumgrid, director_port, timeout, + director_admin, director_password): self.plumlib = plumlib.Plumlib(director_plumgrid, director_port, - timeout) + timeout, + director_admin, + director_password) def create_network(self, tenant_id, net_db): self.plumlib.create_network(tenant_id, net_db) diff --git a/neutron/plugins/plumgrid/plumgrid_plugin/plumgrid_plugin.py b/neutron/plugins/plumgrid/plumgrid_plugin/plumgrid_plugin.py index cd33b707d7..89191995ee 100644 --- a/neutron/plugins/plumgrid/plumgrid_plugin/plumgrid_plugin.py +++ b/neutron/plugins/plumgrid/plumgrid_plugin/plumgrid_plugin.py @@ -78,12 +78,15 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2, """PLUMgrid initialization.""" director_plumgrid = cfg.CONF.PLUMgridDirector.director_server director_port = cfg.CONF.PLUMgridDirector.director_server_port + director_admin = cfg.CONF.PLUMgridDirector.username + director_password = cfg.CONF.PLUMgridDirector.password timeout = cfg.CONF.PLUMgridDirector.servertimeout # PLUMgrid Director info validation LOG.info(_('Neutron PLUMgrid Director: %s'), director_plumgrid) self._plumlib = importutils.import_object(PLUM_DRIVER) - self._plumlib.director_conn(director_plumgrid, director_port, timeout) + self._plumlib.director_conn(director_plumgrid, director_port, timeout, + director_admin, director_password) def create_network(self, context, network): """Create Neutron network. diff --git a/neutron/tests/unit/plumgrid/test_plumgrid_plugin.py b/neutron/tests/unit/plumgrid/test_plumgrid_plugin.py index 69650f36c7..92f020b3de 100644 --- a/neutron/tests/unit/plumgrid/test_plumgrid_plugin.py +++ b/neutron/tests/unit/plumgrid/test_plumgrid_plugin.py @@ -32,6 +32,8 @@ from neutron.tests.unit import test_db_plugin as test_plugin PLUM_DRIVER = ('neutron.plugins.plumgrid.drivers.fake_plumlib.Plumlib') FAKE_DIRECTOR = '1.1.1.1' FAKE_PORT = '1234' +FAKE_USERNAME = 'fake_admin' +FAKE_PASSWORD = 'fake_password' FAKE_TIMEOUT = '0' @@ -43,10 +45,14 @@ class PLUMgridPluginV2TestCase(test_plugin.NeutronDbPluginV2TestCase): def mocked_plumlib_init(self): director_plumgrid = FAKE_DIRECTOR director_port = FAKE_PORT + director_username = FAKE_USERNAME + director_password = FAKE_PASSWORD timeout = FAKE_TIMEOUT self._plumlib = importutils.import_object(PLUM_DRIVER) self._plumlib.director_conn(director_plumgrid, - director_port, timeout) + director_port, timeout, + director_username, + director_password) with mock.patch.object(plumgrid_plugin.NeutronPluginPLUMgridV2, 'plumgrid_init', new=mocked_plumlib_init):