ed3c69cb45
Deprecated in Pike: I660e0316b11afcad65c0fe7bd167ddcec9239a8b This filter relies on the flavor.id primary key which will change as (1) flavors were migrated to the API database and (2) when a flavor is changed by deleting and re-creating the flavor. Also, as noted in blueprint put-host-manager-instance-info-on-a-diet, this is one step forward in getting us to a point where the only thing that the in-tree filters care about in the HostState.instances dict is the instance uuid (for the affinity filters). Which means we can eventually stop RPC casting all instance information from all nova-compute services to the scheduler for every instance create, delete, move or periodic sync task - we only would need to send the list of instance UUIDs. That should help with RPC traffic in a large and busy deployment. Change-Id: Icb43fe2ef5252d2838f6f8572c7497840a9797a1
44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
# Copyright (c) 2012 The Cloudscaling Group, Inc.
|
|
#
|
|
# All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
from nova.scheduler import filters
|
|
from nova.scheduler.filters import utils
|
|
|
|
|
|
class AggregateTypeAffinityFilter(filters.BaseHostFilter):
|
|
"""AggregateTypeAffinityFilter limits instance_type by aggregate
|
|
|
|
return True if no instance_type key is set or if the aggregate metadata
|
|
key 'instance_type' has the instance_type name as a value
|
|
"""
|
|
|
|
# Aggregate data does not change within a request
|
|
run_filter_once_per_request = True
|
|
|
|
RUN_ON_REBUILD = False
|
|
|
|
def host_passes(self, host_state, spec_obj):
|
|
instance_type = spec_obj.flavor
|
|
|
|
aggregate_vals = utils.aggregate_values_from_key(
|
|
host_state, 'instance_type')
|
|
|
|
for val in aggregate_vals:
|
|
if (instance_type.name in
|
|
[x.strip() for x in val.split(',')]):
|
|
return True
|
|
return not aggregate_vals
|