Bug 1305781 - [RFE] Add python method to get long name of OS directly from VM object
Summary: [RFE] Add python method to get long name of OS directly from VM object
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: ovirt-engine
Classification: oVirt
Component: RestAPI
Version: 3.6.2
Hardware: All
OS: Linux
low
low
Target Milestone: ---
: ---
Assignee: Michal Skrivanek
QA Contact: Pavel Stehlik
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-02-09 08:52 UTC by Lukas Svaty
Modified: 2017-11-17 17:22 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-11-17 17:22:53 UTC
oVirt Team: Virt
Embargoed:
oourfali: ovirt-future?
rule-engine: planning_ack?
rule-engine: devel_ack?
rule-engine: testing_ack?


Attachments (Terms of Use)

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


Note You need to log in before you can comment on or make changes to this bug.