

@extensions.expected_errors(404)
def show(self, req, id):
    "Shows the physical/usage resource given by hosts.\n\n        :param id: hostname\n        :returns: expected to use HostShowTemplate.\n            ex.::\n\n                {'host': {'resource':D},..}\n                D: {'host': 'hostname','project': 'admin',\n                    'cpu': 1, 'memory_mb': 2048, 'disk_gb': 30}\n        "
    context = req.environ['nova.context']
    authorize(context)
    host_name = id
    try:
        compute_node = objects.ComputeNode.get_first_node_by_host_for_old_compat(context, host_name)
    except exception.ComputeHostNotFound as e:
        raise webob.exc.HTTPNotFound(explanation=e.format_message())
    instances = self.api.instance_get_all_by_host(context, host_name)
    resources = [self._get_total_resources(host_name, compute_node)]
    resources.append(self._get_used_now_resources(host_name, compute_node))
    resources.append(self._get_resource_totals_from_instances(host_name, instances))
    by_proj_resources = self._get_resources_by_project(host_name, instances)
    for resource in six.itervalues(by_proj_resources):
        resources.append({
            'resource': resource,
        })
    return {
        'host': resources,
    }

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