Coverage for nova/scheduler/client/query.py: 100%
16 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-04-24 11:16 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-04-24 11:16 +0000
1# Copyright (c) 2014 Red Hat, Inc.
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
16from nova.scheduler import rpcapi as scheduler_rpcapi
19class SchedulerQueryClient(object):
20 """Client class for querying to the scheduler."""
22 def __init__(self):
23 self.scheduler_rpcapi = scheduler_rpcapi.SchedulerAPI()
25 def select_destinations(self, context, spec_obj, instance_uuids,
26 return_objects=False, return_alternates=False):
27 """Returns destinations(s) best suited for this request_spec and
28 filter_properties.
30 When return_objects is False, the result will be the "old-style" list
31 of dicts with 'host', 'nodename' and 'limits' as keys. The value of
32 return_alternates is ignored.
34 When return_objects is True, the result will be a list of lists of
35 Selection objects, with one list per instance. Each instance's list
36 will contain a Selection representing the selected (and claimed) host,
37 and, if return_alternates is True, zero or more Selection objects that
38 represent alternate hosts. The number of alternates returned depends on
39 the configuration setting `CONF.scheduler.max_attempts`.
40 """
41 return self.scheduler_rpcapi.select_destinations(context, spec_obj,
42 instance_uuids, return_objects, return_alternates)
44 def update_aggregates(self, context, aggregates):
45 """Updates HostManager internal aggregates information.
47 :param aggregates: Aggregate(s) to update
48 :type aggregates: :class:`nova.objects.Aggregate`
49 or :class:`nova.objects.AggregateList`
50 """
51 self.scheduler_rpcapi.update_aggregates(context, aggregates)
53 def delete_aggregate(self, context, aggregate):
54 """Deletes HostManager internal information about a specific aggregate.
56 :param aggregate: Aggregate to delete
57 :type aggregate: :class:`nova.objects.Aggregate`
58 """
59 self.scheduler_rpcapi.delete_aggregate(context, aggregate)
61 def update_instance_info(self, context, host_name, instance_info):
62 """Updates the HostManager with the current information about the
63 instances on a host.
65 :param context: local context
66 :param host_name: name of host sending the update
67 :param instance_info: an InstanceList object.
68 """
69 self.scheduler_rpcapi.update_instance_info(context, host_name,
70 instance_info)
72 def delete_instance_info(self, context, host_name, instance_uuid):
73 """Updates the HostManager with the current information about an
74 instance that has been deleted on a host.
76 :param context: local context
77 :param host_name: name of host sending the update
78 :param instance_uuid: the uuid of the deleted instance
79 """
80 self.scheduler_rpcapi.delete_instance_info(context, host_name,
81 instance_uuid)
83 def sync_instance_info(self, context, host_name, instance_uuids):
84 """Notifies the HostManager of the current instances on a host by
85 sending a list of the uuids for those instances. The HostManager can
86 then compare that with its in-memory view of the instances to detect
87 when they are out of sync.
89 :param context: local context
90 :param host_name: name of host sending the update
91 :param instance_uuids: a list of UUID strings representing the current
92 instances on the specified host
93 """
94 self.scheduler_rpcapi.sync_instance_info(context, host_name,
95 instance_uuids)