From 1bfd2b3faa3d3b130e8032c934c1aeee6febe906 Mon Sep 17 00:00:00 2001 From: AJAY KALAMBUR Date: Tue, 7 Apr 2015 11:19:11 -0700 Subject: [PATCH] Skip hosts where compute agent is down Change-Id: I8dfe82102d771fc4b687bc59c17a56962af50919 --- compute.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compute.py b/compute.py index 6e01121..13dadbf 100644 --- a/compute.py +++ b/compute.py @@ -312,7 +312,7 @@ class Compute(object): host_list = [] try: - host_list = self.novaclient.hosts.list() + host_list = self.novaclient.services.list() except novaclient.exceptions.Forbidden: print ('Warning: Operation Forbidden: could not retrieve list of hosts' ' (likely no permission)') @@ -338,14 +338,14 @@ class Compute(object): else: for host in host_list: # this host must be a compute node - if host._info['service'] != 'compute': + if host.binary != 'nova-compute' or host.state != 'up': continue candidate = None if self.config.availability_zone: if host.zone == self.config.availability_zone: - candidate = self.normalize_az_host(None, host.host_name) + candidate = self.normalize_az_host(None, host.host) else: - candidate = self.normalize_az_host(host.zone, host.host_name) + candidate = self.normalize_az_host(host.zone, host.host) if candidate: avail_list.append(candidate) # pick first 2 matches at most