
On 03/08/2016 04:57 PM, Nathanaël Blanchet wrote:
Hi all,
We've been using templates for months before we realized that "ocs report" used Serial Number given into "demidecode -t system" to identify a VM as unique. This Serial Number is located into /sys/devices/virtual/dmi/id/product_serial, and we'd really want each vm to have its own Serial Number instead of the template's one. We tried to generate a new id with uuidgen, but it can't be written into the product_serial file. Is there a simple way to do such a thing? Thank you.
You can change the serial number of the VM via the GUI: Vms -> Edit -> System -> Provide custom serial number There you can specify that the VM should have as serial number the id of the host, the id of the VM, or a custom serial number. You can do the same with the API. For example, to set a custom serial number for a specific VM using the Python SDK you can do something like this: ---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") # Set a custom serial number: vm.set_serial_number( params.SerialNumber( policy="custom", value="yourserial", ) ) vm.update() # Disconnect: api.disconnect() --->8--- -- 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.