[ovirt-users] changing vm's product serial

Nathanaël Blanchet blanchet at abes.fr
Wed Mar 9 16:05:49 UTC 2016


thank you, it's ok for the python script!
another simple way I found is with ovirt-shell:
ovirt-shell -E "update vm name --serial_number-value $(uuidgen)"

anyway we need not to simply reboot, but stop and start the vm so as to 
this change take effect

Le 09/03/2016 12:35, Juan Hernández a écrit :
> 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 at 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---
>

-- 
Nathanaël Blanchet

Supervision réseau
Pôle Infrastrutures Informatiques
227 avenue Professeur-Jean-Louis-Viala
34193 MONTPELLIER CEDEX 5 	
Tél. 33 (0)4 67 54 84 55
Fax  33 (0)4 67 54 84 14
blanchet at abes.fr




More information about the Users mailing list