

@extensions.expected_errors(())
def index(self, req):
    "Returns a dict in the format\n\n        |   {'hosts': [{'host_name': 'some.host.name',\n        |     'service': 'cells',\n        |     'zone': 'internal'},\n        |    {'host_name': 'some.other.host.name',\n        |     'service': 'cells',\n        |     'zone': 'internal'},\n        |    {'host_name': 'some.celly.host.name',\n        |     'service': 'cells',\n        |     'zone': 'internal'},\n        |    {'host_name': 'console1.host.com',\n        |     'service': 'consoleauth',\n        |     'zone': 'internal'},\n        |    {'host_name': 'network1.host.com',\n        |     'service': 'network',\n        |     'zone': 'internal'},\n        |    {'host_name': 'netwwork2.host.com',\n        |     'service': 'network',\n        |     'zone': 'internal'},\n        |    {'host_name': 'compute1.host.com',\n        |     'service': 'compute',\n        |     'zone': 'nova'},\n        |    {'host_name': 'compute2.host.com',\n        |     'service': 'compute',\n        |     'zone': 'nova'},\n        |    {'host_name': 'sched1.host.com',\n        |     'service': 'scheduler',\n        |     'zone': 'internal'},\n        |    {'host_name': 'sched2.host.com',\n        |     'service': 'scheduler',\n        |     'zone': 'internal'},\n        |    {'host_name': 'vol1.host.com',\n        |     'service': 'volume',\n        |     'zone': 'internal'}]}\n\n        "
    context = req.environ['nova.context']
    authorize(context)
    filters = {
        'disabled': False,
    }
    zone = req.GET.get('zone', None)
    if zone:
        filters['availability_zone'] = zone
    services = self.api.service_get_all(context, filters=filters, set_zones=True)
    hosts = []
    api_services = ('nova-osapi_compute', 'nova-ec2', 'nova-metadata')
    for service in services:
        if (service.binary not in api_services):
            hosts.append({
                'host_name': service['host'],
                'service': service['topic'],
                'zone': service['availability_zone'],
            })
    return {
        'hosts': hosts,
    }

dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/api/openstack/compute/hosts.py HostController.index/original