Move _delete_port

Pluggable ipam implementation will do additional actions on port
deletion (deallocate ip using ipam driver).
Existing _delete_port code will be resused.
Moving _delete_port to ipam_backend_mixin to make this code
accessible and extendable by both backends (pluggable and non
pluggable).

This commit is a preparation step before pluggable ipam implementation
can be used.

Partially-Implements: blueprint neutron-ipam

Change-Id: If6cd623aad9e5501a26e5fb8cdecd5f55e85cd05
This commit is contained in:
Pavel Bondar 2015-06-18 15:24:44 +03:00
parent c0ef7a8f45
commit 29bb401973
2 changed files with 7 additions and 7 deletions

View File

@ -1078,13 +1078,6 @@ class NeutronDbPluginV2(ipam_non_pluggable_backend.IpamNonPluggableBackend,
"The port has already been deleted.",
port_id)
def _delete_port(self, context, id):
query = (context.session.query(models_v2.Port).
enable_eagerloads(False).filter_by(id=id))
if not context.is_admin:
query = query.filter_by(tenant_id=context.tenant_id)
query.delete()
def get_port(self, context, id, fields=None):
port = self._get_port(context, id)
return self._make_port_dict(port, fields)

View File

@ -252,3 +252,10 @@ class IpamBackendMixin(db_base_plugin_common.DbBasePluginCommon):
return self.Changes(add=new_ips,
original=prev_ips,
remove=original_ips)
def _delete_port(self, context, port_id):
query = (context.session.query(models_v2.Port).
enable_eagerloads(False).filter_by(id=port_id))
if not context.is_admin:
query = query.filter_by(tenant_id=context.tenant_id)
query.delete()