From be56441e555e457777ab5c6edb59791644ceb52b Mon Sep 17 00:00:00 2001 From: aditi Date: Fri, 8 Dec 2017 11:48:27 +0530 Subject: [PATCH] Fix 'unable to exclude instance' Change-Id: I1599a86a2ba7d3af755fb1412a5e38516c736957 Closes-Bug: #1736129 --- watcher/decision_engine/scope/compute.py | 8 ++++++-- watcher/tests/decision_engine/scope/fake_scopes.py | 9 +++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/watcher/decision_engine/scope/compute.py b/watcher/decision_engine/scope/compute.py index 41a4028e4..bba182e0c 100644 --- a/watcher/decision_engine/scope/compute.py +++ b/watcher/decision_engine/scope/compute.py @@ -147,12 +147,16 @@ class ComputeScope(base.BaseScope): nodes_to_remove = set() instances_to_exclude = [] instance_metadata = [] + compute_scope = [] model_hosts = list(cluster_model.get_all_compute_nodes().keys()) - if not self.scope: + for scope in self.scope: + compute_scope = scope.get('compute') + + if not compute_scope: return cluster_model - for rule in self.scope: + for rule in compute_scope: if 'host_aggregates' in rule: self._collect_aggregates(rule['host_aggregates'], allowed_nodes) diff --git a/watcher/tests/decision_engine/scope/fake_scopes.py b/watcher/tests/decision_engine/scope/fake_scopes.py index 00c5e87ed..aab3cba8d 100644 --- a/watcher/tests/decision_engine/scope/fake_scopes.py +++ b/watcher/tests/decision_engine/scope/fake_scopes.py @@ -14,10 +14,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -fake_scope_1 = [{'availability_zones': [{'name': 'AZ1'}]}, - {'exclude': - [{'instances': - [{'uuid': 'INSTANCE_6'}]}] +fake_scope_1 = [{'compute': [{'availability_zones': [{'name': 'AZ1'}]}, + {'exclude': [ + {'instances': [ + {'uuid': 'INSTANCE_6'}]}, + ]}] } ]