Exemplo n.º 1
0
 def describe_hosts(self, context, **_kwargs):
     """Returns status info for all nodes. Includes:
         * Hostname
         * Compute (up, down, None)
         * Instance count
         * Volume (up, down, None)
         * Volume Count
     """
     services = db.service_get_all(context, False)
     now = utils.utcnow()
     hosts = []
     rv = []
     for host in [service['host'] for service in services]:
         if not host in hosts:
             hosts.append(host)
     for host in hosts:
         compute = [s for s in services if s['host'] == host \
                                        and s['binary'] == 'nova-compute']
         if compute:
             compute = compute[0]
         instances = db.instance_get_all_by_host(context, host)
         volume = [s for s in services if s['host'] == host \
                                        and s['binary'] == 'nova-volume']
         if volume:
             volume = volume[0]
         volumes = db.volume_get_all_by_host(context, host)
         rv.append(host_dict(host, compute, instances, volume, volumes,
                             now))
     return {'hosts': rv}
Exemplo n.º 2
0
 def describe_hosts(self, context, **_kwargs):
     """Returns status info for all nodes. Includes:
         * Hostname
         * Compute (up, down, None)
         * Instance count
         * Volume (up, down, None)
         * Volume Count
     """
     services = db.service_get_all(context, False)
     now = utils.utcnow()
     hosts = []
     rv = []
     for host in [service['host'] for service in services]:
         if not host in hosts:
             hosts.append(host)
     for host in hosts:
         compute = [s for s in services if s['host'] == host \
                                        and s['binary'] == 'nova-compute']
         if compute:
             compute = compute[0]
         instances = db.instance_get_all_by_host(context, host)
         volume = [s for s in services if s['host'] == host \
                                        and s['binary'] == 'nova-volume']
         if volume:
             volume = volume[0]
         volumes = db.volume_get_all_by_host(context, host)
         rv.append(host_dict(host, compute, instances, volume, volumes,
                             now))
     return {'hosts': rv}