Red Hat Bugzilla – Bug 1305781
[RFE] Add python method to get long name of OS directly from VM object
Last modified: 2016-05-04 06:15:49 EDT
Description of problem:
Current way of getting Long OS name:
Version-Release number of selected component (if applicable):
Note that the correct way to get the name of the operating system is the following:
I guess that you are suggesting to allow something like this:
This can't be done within the SDK, as the "Vm" class and the "OperatingSystem" class (returned by the Vm.get_os method) are generated from the XML schema of the API by the generateDS.py tool, and we don't have any mechanism to add additional methods.
If we really want this then we would need to modify the specification of the API so that the "OperatingSystem" type includes a "Description" property. The server implementation will then need to populate this property, which will probably require an additional query per VM (afecting performance when retrieving multiple virtual machines).
If this is really needed then I'd suggest the following approach:
1. Add a new "operatingSystem" property to the "Vm" type. This property should be of type "OperatingSystemInfo", not "OperatingSystem". The reason is that the "OperatingSystemInfo" type can be used as a link:
<operating_system id="123" href="/operatingsystems/123"/>
2. Modify the server so that it populates this link. This shouldn't be too expensive because it only needs the id, not the description.
3. Add to the Python SDK the capability to follow links, similar to what the new Ruby SDK already provides. For example:
With these three changes the user could find the description of the operating system in like this:
vm = ...
os = vm.get_operating_system().follow_link()
None of these changes is trivial, and specially the changes required to the Python SDK aren't feasible unless we do a complete overhaul of it. It isn't clear at the moment if we will be able to do this overhaul for oVirt 4.
The "follow_link" method has already been added to version 4 of the SDK, so in order to complete this RFE what is needed is to modify add the "operating_system" property to the "Vm" type. I'm moving the bug to the RestAPI component and to the Virt team.