VMware Cloud Community
StardustECR
Contributor
Contributor

How to fetch the esx host from a call or a command to vSphere 6.0.0, Linux from the VM name ?

Hi,

I wonder how can I discover  the esx host from a call or a command to vSphere 6.0.0, Linux from the VM name.

Possibly via vSphere API, govc, pyvmomi, perl SDK Smiley Wink

Regards, GQ

Reply
0 Kudos
7 Replies
daphnissov
Immortal
Immortal

I don't understand what exactly you're asking here. There are multiple ways to discover ESXi hosts through vCenter. You need to be much more specific as to what you're trying to do, with what, and how.

Reply
0 Kudos
StardustECR
Contributor
Contributor

Sorry, I forgot to said from a VM name

an expected input/output :

-------8<-----------------------

any_command --vm VM-NAME --server vc1.example.com

[...]

esx42.example.com
[...]

-------8<-----------------------

Reply
0 Kudos
daphnissov
Immortal
Immortal

Sure, from PowerCLI it's as easy as a

get-vm -name <name> | Get-VMHost

Reply
0 Kudos
StardustECR
Contributor
Contributor

But I said from a Linux box Smiley Wink

Reply
0 Kudos
daphnissov
Immortal
Immortal

Reply
0 Kudos
StardustECR
Contributor
Contributor

No, never, any good pointer link ?

Found myself :

text: govc  vm.info  VM

json: govc  vm.info -json=true VM  > /tmp/file.json

Reply
0 Kudos
daphnissov
Immortal
Immortal

No, never, any good pointer link ?

Maybe click the link in my previous reply?

Reply
0 Kudos