Bug 1305781

Summary: [RFE] Add python method to get long name of OS directly from VM object
Product: [oVirt] ovirt-engine Reporter: Lukas Svaty <lsvaty>
Component: RestAPIAssignee: Michal Skrivanek <michal.skrivanek>
Status: CLOSED WONTFIX QA Contact: Pavel Stehlik <pstehlik>
Severity: low Docs Contact:
Priority: low    
Version: 3.6.2CC: bugs, michal.skrivanek, mtessun, oourfali
Target Milestone: ---Keywords: FutureFeature
Target Release: ---Flags: oourfali: ovirt-future?
rule-engine: planning_ack?
rule-engine: devel_ack?
rule-engine: testing_ack?
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-11-17 17:22:53 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Virt RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Lukas Svaty 2016-02-09 08:52:29 UTC
Description of problem:

Current way of getting Long OS name:

api.operatingsysteminfos.get(name=api.vms.get(name="test").get_os()).get_description()

Proposed way:
api.operatingsysteminfos.get(name=api.vms.get(name="test").get_os_description()

Version-Release number of selected component (if applicable):
rhevm-sdk-python-3.6.2.0-1.el6ev.noarch

Comment 1 Juan Hernández 2016-02-09 10:19:58 UTC
Note that the correct way to get the name of the operating system is the following:

  api.operatingsysteminfos.get(
    name=api.vms.get(name="myvm").get_os().get_type()
  ).get_description()

I guess that you are suggesting to allow something like this:

  api.vms.get(name="myvm").get_os().get_description()

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:

  <vm>
    ...
    <operating_system id="123" href="/operatingsystems/123"/>
    ...
  </vm>

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:

  https://github.com/oVirt/ovirt-engine-sdk-ruby/blob/master/sdk/examples/follow_vm_links.rb#L39

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()
  print(os.get_description())

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.

Comment 2 Juan Hernández 2016-05-04 10:15:18 UTC
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.

Comment 3 Martin Tessun 2017-11-17 11:12:22 UTC
Hi Michal,

can we easily do what is requested in comment #2
Also: Does it have any impact on Performance or other things?

Thanks!
Martin

Comment 4 Michal Skrivanek 2017-11-17 17:22:53 UTC
Doesn't seem to be worth the effort.
Feel free to reopen by submitting a patch