If you know the name of the VM then you can find it, including its id,
doing a search:
https://engine.example.com/ovirt-engine/api/vms?search=name%3Dmyvm
If you prefer to use a script, which is probably the right thing, then
you can do something like this, using the Python SDK:
---8<---
#!/usr/bin/python
from ovirtsdk.api import API
from ovirtsdk.xml import params
# Connect to the server:
api = API(
url="https://engine.example.com/ovirt-engine/api",
username="admin@internal",
password="******",
ca_file="/etc/pki/ovirt-engine/ca.pem",
debug=False
)
# Find the VM:
vm = api.vms.get(name="myvm")
# Print the id:
print(vm.get_id())
# Disconnect:
api.disconnect()
--->8---
Once you have the VM you can create a snapshot like this:
---8<---
vm.snapshots.add(
params.Snapshot(description="My snapshot")
)
--->8---
engine/ca.pem",
debug=False
)
# Find the VM:
vm = api.vms.get(name="myvm")
# Print the id:
print(vm.get_id())
# Disconnect:
api.disconnect()
You can also use the Java SDK, if you prefer Java.
--
Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta
3ºD, 28016 Madrid, Spain
Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.