def create_subnet(self, sub_db, net_db, ipnet):
pass
- def update_subnet(self, org_sub_db, new_sub_db, ipnet):
+ def update_subnet(self, orig_sub_db, new_sub_db, ipnet):
pass
def delete_subnet(self, tenant_id, net_db, net_id):
def remove_router_interface(self, tenant_id, net_id, router_id):
pass
- def create_floatingip(self, net_db, floating_ip):
+ def create_floatingip(self, floating_ip):
pass
- def update_floatingip(self, net_db, floating_ip, id):
+ def update_floatingip(self, floating_ip_orig, floating_ip, id):
pass
- def delete_floatingip(self, net_db, floating_ip_org, id):
+ def delete_floatingip(self, floating_ip_orig, id):
pass
+
+ def disassociate_floatingips(self, fip, port_id):
+ return dict((key, fip[key]) for key in ("id", "floating_network_id",
+ "floating_ip_address"))
def create_subnet(self, sub_db, net_db, ipnet):
self.plumlib.create_subnet(sub_db, net_db, ipnet)
- def update_subnet(self, org_sub_db, new_sub_db, ipnet):
- self.plumlib.update_subnet(org_sub_db, new_sub_db, ipnet)
+ def update_subnet(self, orig_sub_db, new_sub_db, ipnet):
+ self.plumlib.update_subnet(orig_sub_db, new_sub_db, ipnet)
def delete_subnet(self, tenant_id, net_db, net_id):
self.plumlib.delete_subnet(tenant_id, net_db, net_id)
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 create_floatingip(self, floating_ip):
+ self.plumlib.create_floatingip(floating_ip)
- def update_floatingip(self, net_db, floating_ip, id):
- self.plumlib.update_floatingip(net_db, floating_ip, id)
+ def update_floatingip(self, floating_ip_orig, floating_ip, id):
+ self.plumlib.update_floatingip(floating_ip_orig, floating_ip, id)
- def delete_floatingip(self, net_db, floating_ip_org, id):
- self.plumlib.delete_floatingip(net_db, floating_ip_org, id)
+ def delete_floatingip(self, floating_ip_orig, id):
+ self.plumlib.delete_floatingip(floating_ip_orig, id)
+
+ def disassociate_floatingips(self, floating_ip, port_id):
+ self.plumlib.disassociate_floatingips(floating_ip, port_id)
import netaddr
from oslo.config import cfg
+from sqlalchemy.orm import exc as sa_exc
from neutron.api.v2 import attributes
from neutron.common import constants
LOG.debug(_("update_subnet() called"))
# Collecting subnet info
- org_sub_db = self._get_subnet(context, subnet_id)
+ orig_sub_db = self._get_subnet(context, subnet_id)
with context.session.begin(subtransactions=True):
# Plugin DB - Subnet Update
try:
# PLUMgrid Server does not support updating resources yet
LOG.debug(_("PLUMgrid Library: update_network() called"))
- self._plumlib.update_subnet(org_sub_db, new_sub_db, ipnet)
+ self._plumlib.update_subnet(orig_sub_db, new_sub_db, ipnet)
except Exception as err_message:
raise plum_excep.PLUMgridException(err_msg=err_message)
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)
+ self._plumlib.create_floatingip(floating_ip)
except Exception as err_message:
raise plum_excep.PLUMgridException(err_msg=err_message)
LOG.debug(_("Neutron PLUMgrid Director: update_floatingip() called"))
with context.session.begin(subtransactions=True):
-
+ floating_ip_orig = super(NeutronPluginPLUMgridV2,
+ self).get_floatingip(context, id)
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)
+ self._plumlib.update_floatingip(floating_ip_orig, floating_ip,
+ id)
except Exception as err_message:
raise plum_excep.PLUMgridException(err_msg=err_message)
with context.session.begin(subtransactions=True):
- floating_ip_org = super(NeutronPluginPLUMgridV2,
- self).get_floatingip(context, id)
+ floating_ip_orig = 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)
+ self._plumlib.delete_floatingip(floating_ip_orig, id)
except Exception as err_message:
raise plum_excep.PLUMgridException(err_msg=err_message)
+ def disassociate_floatingips(self, context, port_id):
+ LOG.debug(_("Neutron PLUMgrid Director: disassociate_floatingips() "
+ "called"))
+
+ try:
+ fip_qry = context.session.query(l3_db.FloatingIP)
+ floating_ip = fip_qry.filter_by(fixed_port_id=port_id).one()
+
+ LOG.debug(_("PLUMgrid Library: disassociate_floatingips()"
+ " called"))
+ self._plumlib.disassociate_floatingips(floating_ip, port_id)
+
+ except sa_exc.NoResultFound:
+ pass
+
+ except Exception as err_message:
+ raise plum_excep.PLUMgridException(err_msg=err_message)
+
+ super(NeutronPluginPLUMgridV2,
+ self).disassociate_floatingips(context, port_id)
+
"""
Internal PLUMgrid Fuctions
"""
self.assertEqual(net['network'][provider.NETWORK_TYPE], 'vlan')
self.assertEqual(net['network'][provider.SEGMENTATION_ID], 3333)
self.assertEqual(net['network'][provider.PHYSICAL_NETWORK], 'phy3333')
+
+
+class TestDisassociateFloatingIP(PLUMgridPluginV2TestCase):
+
+ def test_disassociate_floating_ip(self):
+ port_id = "abcdefgh"
+ tenant_id = "94eb42de4e331"
+ fip_net_id = "b843d18245678"
+ fip_addr = "10.0.3.44"
+ fip_id = "e623679734051"
+ fip = {"router_id": "94eb42de4e331",
+ "tenant_id": tenant_id,
+ "floating_network_id": fip_net_id,
+ "fixed_ip_address": "192.168.8.2",
+ "floating_ip_address": fip_addr,
+ "port_id": port_id,
+ "id": fip_id}
+ plumlib = importutils.import_object(PLUM_DRIVER)
+ fip_res = plumlib.disassociate_floatingips(fip, port_id)
+ self.assertEqual(fip_res["id"], fip_id)
+ self.assertEqual(fip_res["floating_ip_address"], fip_addr)
+ self.assertEqual(fip_res["floating_network_id"], fip_net_id)