Merge "In Arista ML2 delete tenant without any resources"

This commit is contained in:
Jenkins 2015-03-10 08:20:40 +00:00 committed by Gerrit Code Review
commit f931369754
2 changed files with 9 additions and 10 deletions

View File

@ -155,8 +155,6 @@ class AristaDriver(driver_api.MechanismDriver):
with self.eos_sync_lock:
if db_lib.is_network_provisioned(tenant_id, network_id):
db_lib.forget_network(tenant_id, network_id)
# if necessary, delete tenant as well.
self.delete_tenant(tenant_id)
def delete_network_postcommit(self, context):
"""Send network delete request to Arista HW."""
@ -170,6 +168,8 @@ class AristaDriver(driver_api.MechanismDriver):
# alive.
try:
self.rpc.delete_network(tenant_id, network_id)
# if necessary, delete tenant as well.
self.delete_tenant(tenant_id)
except arista_exc.AristaRpcError:
LOG.info(EOS_UNREACHABLE_MSG)
raise ml2_exc.MechanismDriverError()
@ -324,8 +324,6 @@ class AristaDriver(driver_api.MechanismDriver):
network_id, tenant_id):
db_lib.forget_vm(device_id, host_id, port_id,
network_id, tenant_id)
# if necessary, delete tenant as well.
self.delete_tenant(tenant_id)
def delete_port_postcommit(self, context):
"""unPlug a physical host from a network.
@ -356,6 +354,8 @@ class AristaDriver(driver_api.MechanismDriver):
port_id,
network_id,
tenant_id)
# if necessary, delete tenant as well.
self.delete_tenant(tenant_id)
except arista_exc.AristaRpcError:
LOG.info(EOS_UNREACHABLE_MSG)
raise ml2_exc.MechanismDriverError()
@ -370,6 +370,11 @@ class AristaDriver(driver_api.MechanismDriver):
db_lib.num_vms_provisioned(tenant_id))
if not objects_for_tenant:
db_lib.forget_tenant(tenant_id)
try:
self.rpc.delete_tenant(tenant_id)
except arista_exc.AristaRpcError:
LOG.info(EOS_UNREACHABLE_MSG)
raise ml2_exc.MechanismDriverError()
def _host_name(self, hostname):
fqdns_used = cfg.CONF.ml2_arista['use_fqdn']

View File

@ -107,9 +107,6 @@ class AristaDriverTestCase(testlib_api.SqlTestCase):
expected_calls = [
mock.call.is_network_provisioned(tenant_id, network_id),
mock.call.forget_network(tenant_id, network_id),
mock.call.num_nets_provisioned(tenant_id),
mock.call.num_vms_provisioned(tenant_id),
mock.call.forget_tenant(tenant_id),
]
mechanism_arista.db_lib.assert_has_calls(expected_calls)
@ -224,9 +221,6 @@ class AristaDriverTestCase(testlib_api.SqlTestCase):
network_id, tenant_id),
mock.call.forget_vm(vm_id, host_id, port_id,
network_id, tenant_id),
mock.call.num_nets_provisioned(tenant_id),
mock.call.num_vms_provisioned(tenant_id),
mock.call.forget_tenant(tenant_id),
]
mechanism_arista.db_lib.assert_has_calls(expected_calls)