diff --git a/nova/compute/api.py b/nova/compute/api.py index a9d0a1bdde2b..061e8e6b28f6 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -91,7 +91,6 @@ compute_opts = [ CONF = cfg.CONF CONF.register_opts(compute_opts) CONF.import_opt('compute_topic', 'nova.compute.rpcapi') -CONF.import_opt('consoleauth_topic', 'nova.consoleauth') CONF.import_opt('enable', 'nova.cells.opts', group='cells') MAX_USERDATA_SIZE = 65535 @@ -902,9 +901,9 @@ class API(base.Base): def trigger_provider_fw_rules_refresh(self, context): """Called when a rule is added/removed from a provider firewall.""" - host_names = [x['host'] for (x, idx) - in self.db.service_get_all_compute_sorted(context)] - for host_name in host_names: + for service in self.db.service_get_all_by_topic(context, + CONF.compute_topic): + host_name = service['host'] self.compute_rpcapi.refresh_provider_fw_rules(context, host_name) def update_state(self, context, instance, new_state): diff --git a/nova/db/api.py b/nova/db/api.py index 3c1425691816..8d3f0fa4d646 100644 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -132,15 +132,6 @@ def service_get_all(context, disabled=None): return IMPL.service_get_all(context, disabled) -def service_does_host_exist(context, host_name, include_disabled=False): - """Returns True if 'host_name' is found in the services table, False - otherwise - :param: host_name - the name of the host we want to check if it exists - :param: include_disabled - Set to True to include hosts from disabled - services""" - return IMPL.service_does_host_exist(context, host_name, include_disabled) - - def service_get_all_by_topic(context, topic): """Get all services for a given topic.""" return IMPL.service_get_all_by_topic(context, topic) @@ -159,15 +150,6 @@ def service_get_by_compute_host(context, host): return IMPL.service_get_by_compute_host(context, host) -def service_get_all_compute_sorted(context): - """Get all compute services sorted by instance count. - - :returns: a list of (Service, instance_count) tuples. - - """ - return IMPL.service_get_all_compute_sorted(context) - - def service_get_by_args(context, host, binary): """Get the state of a service by node name and binary.""" return IMPL.service_get_by_args(context, host, binary) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 7ba4c73f5eef..61538fcdf34a 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -396,45 +396,6 @@ def service_get_by_compute_host(context, host): return result -@require_admin_context -def _service_get_all_topic_subquery(context, session, topic, subq, label): - sort_value = getattr(subq.c, label) - return model_query(context, models.Service, - func.coalesce(sort_value, 0), - session=session, read_deleted="no").\ - filter_by(topic=topic).\ - filter_by(disabled=False).\ - outerjoin((subq, models.Service.host == subq.c.host)).\ - order_by(sort_value).\ - all() - - -@require_admin_context -def service_get_all_compute_sorted(context): - session = get_session() - with session.begin(): - # NOTE(vish): The intended query is below - # SELECT services.*, COALESCE(inst_cores.instance_cores, - # 0) - # FROM services LEFT OUTER JOIN - # (SELECT host, SUM(instances.vcpus) AS instance_cores - # FROM instances GROUP BY host) AS inst_cores - # ON services.host = inst_cores.host - topic = CONF.compute_topic - label = 'instance_cores' - subq = model_query(context, models.Instance.host, - func.sum(models.Instance.vcpus).label(label), - base_model=models.Instance, session=session, - read_deleted="no").\ - group_by(models.Instance.host).\ - subquery() - return _service_get_all_topic_subquery(context, - session, - topic, - subq, - label) - - @require_admin_context def service_get_by_args(context, host, binary): result = model_query(context, models.Service).\ diff --git a/nova/network/manager.py b/nova/network/manager.py index 161bf421bb85..0bd652cdd3da 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -298,8 +298,6 @@ class NetworkManager(manager.SchedulerDependentManager): self.network_api = network_api.API() self.network_rpcapi = network_rpcapi.NetworkAPI() self.security_group_api = compute_api.SecurityGroupAPI() - self.compute_api = compute_api.API( - security_group_api=self.security_group_api) self.servicegroup_api = servicegroup.API() # NOTE(tr3buchet: unless manager subclassing NetworkManager has