From 40fcbcb8852cad03eec345106772292fa08b25dc Mon Sep 17 00:00:00 2001 From: Édouard Thuleau Date: Tue, 27 Nov 2012 17:15:34 +0100 Subject: Remove unused bridge interfaces If a network gateway of multi hosted network is unsed by any VM on the host, we tear down it. It is implemented only with the VLAN manager. Fixes LP bug #1084651 Change-Id: Ia7e399de5b8ddf6ec252d38dfbb8762c4f14e3a5 --- nova/db/api.py | 4 ++++ nova/db/sqlalchemy/api.py | 5 +++++ 2 files changed, 9 insertions(+) (limited to 'nova/db') diff --git a/nova/db/api.py b/nova/db/api.py index cfa6a6487..67d8e7618 100644 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -809,6 +809,10 @@ def network_get_all_by_uuids(context, network_uuids, # pylint: disable=C0103 +def network_in_use_on_host(context, network_id, host=None): + """Indicates if a network is currently in use on host.""" + return IMPL.network_in_use_on_host(context, network_id, host) + def network_get_associated_fixed_ips(context, network_id, host=None): """Get all network's ips that have been associated.""" diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 4155fdc3d..e1e2ede84 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -2236,6 +2236,11 @@ def network_get_associated_fixed_ips(context, network_id, host=None): return data +def network_in_use_on_host(context, network_id, host): + fixed_ips = network_get_associated_fixed_ips(context, network_id, host) + return len(fixed_ips) > 0 + + @require_admin_context def _network_get_query(context, session=None): return model_query(context, models.Network, session=session, -- cgit