which api to be used to get uuid of compute host?
I have a openstack setup with one controller and couple of compute host. is there any compute-api which can provide uuid of the host.
First time here? Check out the FAQ!
I have a openstack setup with one controller and couple of compute host. is there any compute-api which can provide uuid of the host.
You can even get host using same program:
def _get_host_id(instance):
host = instance.get("host")
project = str(instance.get("project_id"))
if host:
sha_hash = hashlib.sha224(project + host) # pylint: disable=E1101
return sha_hash.hexdigest()
Alternative way to get list of host using single api call using dashboard api: https://github.com/openstack/horizon/... link
def hypervisor_list(request):
return novaclient(request).hypervisors.list()
def hypervisor_stats(request): return novaclient(request).hypervisors.statistics()
def hypervisor_search(request, query, servers=True): return novaclient(request).hypervisors.search(query, servers)
The function _get_host_id function is taking project id as well for generation id for host. so it defeats the purpose for me because host will be shared across tenants/projects and this code will generate different ids at cloud level for same host. so it can not be considered as UUID for host of a cloud. Can you point me to script which is called for "/v2/<tenant-id>/os-hypervisors/detail" api call.
Yes, please look into below nova api code to get uuid of the instance. nova api link
def show(self, request, instance):
"""Detailed view of a single instance."""
ip_v4 = instance.get('access_ip_v4')
ip_v6 = instance.get('access_ip_v6')
server = {
"server": {
"id": instance["uuid"],
"name": instance["display_name"],
"status": self._get_vm_status(instance),
"tenant_id": instance.get("project_id") or "",
"user_id": instance.get("user_id") or "",
"metadata": self._get_metadata(instance),
"hostId": self._get_host_id(instance) or "",
"image": self._get_image(request, instance),
"flavor": self._get_flavor(request, instance),
"created": timeutils.isotime(instance["created_at"]),
"updated": timeutils.isotime(instance["updated_at"]),
"addresses": self._get_addresses(request, instance),
"accessIPv4": str(ip_v4) if ip_v4 is not None else '',
"accessIPv6": str(ip_v6) if ip_v6 is not None else '',
"links": self._get_links(request,
instance["uuid"],
self._collection_name),
},
Thanks.
Thanks for reply,
The code snippet you have provided is for VM/instance, what i am looking for is hypervisor uuid. But when i am running /v2/<tenant-id>/os-hypervisors/detail command it is displaying host name instead of uuid. { "service": { "host": "cognac", "id": 7 }, }
here in this output value o host should be uuid as per the documentation.
Thanks again Ganesh for reply but here i will get the host uuid while querying for VMs. Actually what my requirement, i want to get information about all the compute hosts using one api call. So when i request hypervisor details the response should include uuid of host as well along with name. is there existing api which provide this information. The curl command which i mention should provide same as per documentation ( http://docs.openstack.org/api/opensta... ) but it isn't.
Asked: 2014-05-08 00:56:55 -0600
Seen: 3,624 times
Last updated: May 08 '14
OCATA- Unable to delete host aggregate
error when running nova boot-no valid host was found
how to set a host for an instance?
Guest to Host works but host to guest does not
Is there a character or size limit to Availability Zone or Host Aggregate names?
Unable to launch instances (Unexpected vif_type=binding failed)