Discussion:
[libvirt-users] virsh and bash scripts
Hetz Ben Hamo
2018-01-06 15:27:52 UTC
Permalink
Hi,

I'm looking for a way to use virsh to connect to vCenter/VCSA and do some
simple management of the VM's in case of power loss (I'm planning to run
the script upon UPS/apcd event of power failure).

Looking through the virsh documentation, I didn't find 2 things:

1. Login through a script (I don't see any user/password, specially since
VCSA for example requires to use ***@vsphere.local [or your AD domain
insteadd of vsphere.local if you connected it to your AD domain])
2. Get all the VMs running on the vCenter, not just specific hosts.

Any suggestion?

Thanks
Erik Skultety
2018-01-08 15:07:12 UTC
Permalink
Post by Hetz Ben Hamo
Hi,
I'm looking for a way to use virsh to connect to vCenter/VCSA and do some
simple management of the VM's in case of power loss (I'm planning to run
the script upon UPS/apcd event of power failure).
I'm not familiar with the VCSA solution topology, but virsh is just cli
frontend to libvirt APIs, the documentation you're looking for is here [1].
Post by Hetz Ben Hamo
1. Login through a script (I don't see any user/password, specially since
Unless you use the C/Python/Other APIs directly where you can actually specify
a callback that is called during the authentication phase, you're stuck with
the default callback which provides you with a prompt which reads from stdin.
Post by Hetz Ben Hamo
insteadd of vsphere.local if you connected it to your AD domain])
2. Get all the VMs running on the vCenter, not just specific hosts.
you're connecting via the ESX driver (using the type 'vpx' in the URI schema),
which from libvirt's point of view is client-side only which means that we use
the driver to talk to the vCenter. When querying the list of machines, I would
expect the vCenter/ESX server to return the list of all VMs on all vCenter
nodes, if not so, then either our driver needs to be updated to reflect the
changes or the backend API (the ESX server/vCenter) doesn't support this
feature and you'll need to query all the nodes manually.

I never tried using the esx driver, so that's just my understanding of how I
think things are supposed to work, i.e. it's fairly out of libvirt's reach,
since we just call the corresponding remote APIs the ESX provides, there's no
daemon we can control.

Erik
Erik Skultety
2018-01-08 15:18:08 UTC
Permalink
Post by Erik Skultety
Post by Hetz Ben Hamo
Hi,
I'm looking for a way to use virsh to connect to vCenter/VCSA and do some
simple management of the VM's in case of power loss (I'm planning to run
the script upon UPS/apcd event of power failure).
I'm not familiar with the VCSA solution topology, but virsh is just cli
frontend to libvirt APIs, the documentation you're looking for is here [1].
aand of course I forgot to link the URI itself:
[1] https://libvirt.org/drvesx.html

Erik
Post by Erik Skultety
Post by Hetz Ben Hamo
1. Login through a script (I don't see any user/password, specially since
Unless you use the C/Python/Other APIs directly where you can actually specify
a callback that is called during the authentication phase, you're stuck with
the default callback which provides you with a prompt which reads from stdin.
Post by Hetz Ben Hamo
insteadd of vsphere.local if you connected it to your AD domain])
2. Get all the VMs running on the vCenter, not just specific hosts.
you're connecting via the ESX driver (using the type 'vpx' in the URI schema),
which from libvirt's point of view is client-side only which means that we use
the driver to talk to the vCenter. When querying the list of machines, I would
expect the vCenter/ESX server to return the list of all VMs on all vCenter
nodes, if not so, then either our driver needs to be updated to reflect the
changes or the backend API (the ESX server/vCenter) doesn't support this
feature and you'll need to query all the nodes manually.
I never tried using the esx driver, so that's just my understanding of how I
think things are supposed to work, i.e. it's fairly out of libvirt's reach,
since we just call the corresponding remote APIs the ESX provides, there's no
daemon we can control.
Erik
_______________________________________________
libvirt-users mailing list
https://www.redhat.com/mailman/listinfo/libvirt-users
Loading...