From 04f62ad8d874d7e9541bd26b379d5232992f12dd Mon Sep 17 00:00:00 2001 From: Edgar Magana Date: Thu, 22 Aug 2013 18:42:04 -0700 Subject: [PATCH] Support for Floating IPs in PLUMgrid plugin Implements blueprint plumgrid-plugin-floatingip Include operations supporting create, update and delete of Floating IPs Drivers been updated properly Change-Id: I8ed5e620e45f026e0673be78971329a93353370d --- .../plugins/plumgrid/drivers/fake_plumlib.py | 9 +++ neutron/plugins/plumgrid/drivers/plumlib.py | 9 +++ .../plumgrid_plugin/plumgrid_plugin.py | 67 +++++++++++++++++++ 3 files changed, 85 insertions(+) diff --git a/neutron/plugins/plumgrid/drivers/fake_plumlib.py b/neutron/plugins/plumgrid/drivers/fake_plumlib.py index 20dc8c39a2..3a6445ca5b 100644 --- a/neutron/plugins/plumgrid/drivers/fake_plumlib.py +++ b/neutron/plugins/plumgrid/drivers/fake_plumlib.py @@ -77,3 +77,12 @@ class Plumlib(): def remove_router_interface(self, tenant_id, net_id, router_id): pass + + def create_floatingip(self, net_db, floating_ip): + pass + + def update_floatingip(self, net_db, floating_ip, id): + pass + + def delete_floatingip(self, net_db, floating_ip_org, id): + pass diff --git a/neutron/plugins/plumgrid/drivers/plumlib.py b/neutron/plugins/plumgrid/drivers/plumlib.py index e9ea6c50c6..03aaafa4b4 100644 --- a/neutron/plugins/plumgrid/drivers/plumlib.py +++ b/neutron/plugins/plumgrid/drivers/plumlib.py @@ -83,3 +83,12 @@ class Plumlib(object): def remove_router_interface(self, tenant_id, net_id, router_id): self.plumlib.remove_router_interface(tenant_id, net_id, router_id) + + def create_floatingip(self, net_db, floating_ip): + self.plumlib.create_floatingip(net_db, floating_ip) + + def update_floatingip(self, net_db, floating_ip): + self.plumlib.update_floatingip(net_db, floating_ip, id) + + def delete_floatingip(self, net_db, floating_ip_org, id): + self.plumlib.delete_floatingip(net_db, floating_ip_org, id) diff --git a/neutron/plugins/plumgrid/plumgrid_plugin/plumgrid_plugin.py b/neutron/plugins/plumgrid/plumgrid_plugin/plumgrid_plugin.py index cd33b707d7..1dddf6fb68 100644 --- a/neutron/plugins/plumgrid/plumgrid_plugin/plumgrid_plugin.py +++ b/neutron/plugins/plumgrid/plumgrid_plugin/plumgrid_plugin.py @@ -241,6 +241,7 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2, # Plugin DB - Port Create and Return port port_db = super(NeutronPluginPLUMgridV2, self).get_port(context, port_id) + self.disassociate_floatingips(context, port_id) super(NeutronPluginPLUMgridV2, self).delete_port(context, port_id) if port_db["device_owner"] == "network:router_gateway": @@ -483,6 +484,72 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2, return del_int_router + def create_floatingip(self, context, floatingip): + LOG.debug(_("Neutron PLUMgrid Director: create_floatingip() called")) + + with context.session.begin(subtransactions=True): + + floating_ip = super(NeutronPluginPLUMgridV2, + self).create_floatingip(context, floatingip) + + net_id = floating_ip['floating_network_id'] + net_db = super(NeutronPluginPLUMgridV2, + self).get_network(context, net_id) + + try: + LOG.debug(_("PLUMgrid Library: create_floatingip() called")) + self._plumlib.create_floatingip(net_db, floating_ip) + + except Exception: + LOG.error(ERR_MESSAGE) + raise plum_excep.PLUMgridException(err_msg=ERR_MESSAGE) + + return floating_ip + + def update_floatingip(self, context, id, floatingip): + LOG.debug(_("Neutron PLUMgrid Director: update_floatingip() called")) + + with context.session.begin(subtransactions=True): + + floating_ip = super(NeutronPluginPLUMgridV2, + self).update_floatingip(context, id, + floatingip) + + net_id = floating_ip['floating_network_id'] + net_db = super(NeutronPluginPLUMgridV2, + self).get_network(context, net_id) + + try: + LOG.debug(_("PLUMgrid Library: update_floatingip() called")) + self._plumlib.update_floatingip(net_db, floating_ip, id) + + except Exception: + LOG.error(ERR_MESSAGE) + raise plum_excep.PLUMgridException(err_msg=ERR_MESSAGE) + + return floating_ip + + def delete_floatingip(self, context, id): + LOG.debug(_("Neutron PLUMgrid Director: delete_floatingip() called")) + + with context.session.begin(subtransactions=True): + + floating_ip_org = super(NeutronPluginPLUMgridV2, + self).get_floatingip(context, id) + + net_id = floating_ip_org['floating_network_id'] + net_db = super(NeutronPluginPLUMgridV2, + self).get_network(context, net_id) + super(NeutronPluginPLUMgridV2, self).delete_floatingip(context, id) + + try: + LOG.debug(_("PLUMgrid Library: delete_floatingip() called")) + self._plumlib.delete_floatingip(net_db, floating_ip_org, id) + + except Exception: + LOG.error(ERR_MESSAGE) + raise plum_excep.PLUMgridException(err_msg=ERR_MESSAGE) + """ Internal PLUMgrid Fuctions """