I am running ovirt-system-tests (basic-suite-master) to write storage domain reattachment tests. When trying to import an "unregistered" VM from a reattached storage domain, I found out that the correct REST command to do so is not "import" (this gives me 404 because the VM is not registered) but "register", if I also want to "Reassign Bad MACs". I followed documentation (REST API Guide accessible from the https://engine/ovirt-engine/ main page) and the generated v4 API, and both of them wrongly suggest that "import" accepts this parameter (reassign_bad_macs) and "register" doesn't. First, I verified that the Engine accepted the parameter with the "register" action manually with cURL and then I fixed /usr/lib/python2.7/site-packages/ovirtsdk4/services.py and copied handling of the parameter to the "register" method. Now my tests work, the VM is imported and its MACs are reassigned in the MAC pool. May I ask that the code (from which REST API bindings are generated) is fixed and the parameter moved to the correct function? Thanks :-)
A fix has been merged and backported.
Before considering this MODIFIED a new release of the API specification has to be published, containing the fix, and then the Python SDK needs to be updated to use that version. I am moving the bug back to NEW and reassigning it.
Hi Ondra, could you please explain me how to verify this bug?
As explained in the description the 'register' action missed the option to specify following attributes: - vnic_profile_mappings - reassign_bad_macs during the register operation. So in order to test it try to pass that parameters to the register action: --- import logging import ovirtsdk4 as sdk import ovirtsdk4.types as types logging.basicConfig(level=logging.DEBUG, filename='example.log') # This example will connect to the server and start a virtual machine. # Create the connection to the server: connection = sdk.Connection( url='https://engine/ovirt-engine/api', username='admin@internal', password='123', ca_file='ca.pem', debug=True, log=logging.getLogger(), ) # Get the reference to the "storage_domains" service: storage_domains_service = connection.system_service().storage_domains_service() # Find the storage domain with unregistered VM: sd = storage_domains_service.list(search='name=mysd')[0] # Locate the service that manages the storage domain, as that is where # the action methods are defined: storage_domain_service = storage_domains_service.storage_domain_service(sd.id) # Locate the service that manages the VMs in storage domain: vms_service = storage_domain_service.vms_service() # Find the the unregistered VM we want to register: vms = vms_service.list(unregistered=True) vm = next( (v for v in vms if v.name == 'myvm'), None ) # Locate the service that manages the storage domain, as that is where # the action methods are defined: vm_service = vms_service.vm_service(vm.id) # Register the VM into the system: vm = vm_service.register( cluster=types.Cluster( name='mycluster', ), vm=types.Vm( name='exported_myvm', ), vnic_profile_mappings=[ types.VnicProfileMapping( source_network_name='mynetwork', source_network_profile_name='mynetwork', target_vnic_profile=types.VnicProfile( name='mynetwork', ), ), ], reassign_bad_macs=True, ) # Close the connection to the server: connection.close() ---
Verified on python-ovirt-engine-sdk4-4.1.3-1.el7ev.x86_64