Question about ovirt python sdk4,gluster volume rebalance return none

when in version 3 sdk ,i use: req_cluster = api.clusters.get(id=c_uid) req_volume = req_cluster.glustervolumes.get(id=volume_id) req_volume.rebalance().job.get_id() to get a rebalance job id to trace if the job is finished. Now I use ovirt python sdk4 for develop: cluster = clustersservice.cluster_service(clusterid) volume = cluster.gluster_volumes_service().volume_service(volumeid) response=volume.rebalance() the response is none,how can i get the rebalance job id?

Hi, Currently the job id cannot be fetched from the function volume.rebalance() .Although you can try to fetch the job id via a POST request with a blank action <action/> Eg :- POST /ovirt-engine/api/clusters/65dec1c0-9c85-11e8-be65-8c1645709524/glustervolumes/ee55f809-ff07-42f4-86f8-10a4eb8930f5/rebalance HTTP/1.1 Host: localhost:8080 Authorization: Basic YWRtaW5AaW50ZXJuYWw6cGFzc0AxMjM= Content-Type: application/xml Accept: application/xml Cache-Control: no-cache <action/> Equivalent python code : https://pastebin.com/aE65Pyiw Sample output : https://pastebin.com/mVVtLiJH On Wed, Aug 15, 2018 at 11:06 AM <chokko@126.com> wrote:
when in version 3 sdk ,i use: req_cluster = api.clusters.get(id=c_uid) req_volume = req_cluster.glustervolumes.get(id=volume_id) req_volume.rebalance().job.get_id() to get a rebalance job id to trace if the job is finished. Now I use ovirt python sdk4 for develop: cluster = clustersservice.cluster_service(clusterid) volume = cluster.gluster_volumes_service().volume_service(volumeid) response=volume.rebalance() the response is none,how can i get the rebalance job id? _______________________________________________ Devel mailing list -- devel@ovirt.org To unsubscribe send an email to devel-leave@ovirt.org Privacy Statement: https://www.ovirt.org/site/privacy-policy/ oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/ List Archives: https://lists.ovirt.org/archives/list/devel@ovirt.org/message/P2QN6VG2CRBF55...
Ondra is there an equivalent ovirt python sdk4 code for the above, if not we can open a bug for the same. -- KAUSTAV MAJUMDER ASSOCIATE SOFTWARE ENGINEER Red Hat India PVT LTD. <https://www.redhat.com/> kmajumder@redhat.com M: 08981884037 IM: IRC: kmajumder <https://red.ht/sig> TRIED. TESTED. TRUSTED. <https://redhat.com/trusted> @redhatway <https://twitter.com/redhatway> @redhatinc <https://instagram.com/redhatinc> @redhatsnaps <https://snapchat.com/add/redhatsnaps>

Adding Ondra On Thu, Aug 16, 2018 at 1:28 PM, Kaustav Majumder <kmajumde@redhat.com> wrote:
Hi, Currently the job id cannot be fetched from the function volume.rebalance() .Although you can try to fetch the job id via a POST request with a blank action <action/> Eg :- POST /ovirt-engine/api/clusters/65dec1c0-9c85-11e8-be65- 8c1645709524/glustervolumes/ee55f809-ff07-42f4-86f8-10a4eb8930f5/rebalance HTTP/1.1 Host: localhost:8080 Authorization: Basic YWRtaW5AaW50ZXJuYWw6cGFzc0AxMjM= Content-Type: application/xml Accept: application/xml Cache-Control: no-cache
<action/> Equivalent python code : https://pastebin.com/aE65Pyiw Sample output : https://pastebin.com/mVVtLiJH On Wed, Aug 15, 2018 at 11:06 AM <chokko@126.com> wrote:
when in version 3 sdk ,i use: req_cluster = api.clusters.get(id=c_uid) req_volume = req_cluster.glustervolumes.get(id=volume_id) req_volume.rebalance().job.get_id() to get a rebalance job id to trace if the job is finished. Now I use ovirt python sdk4 for develop: cluster = clustersservice.cluster_service(clusterid) volume = cluster.gluster_volumes_service().volume_service(volumeid) response=volume.rebalance() the response is none,how can i get the rebalance job id? _______________________________________________ Devel mailing list -- devel@ovirt.org To unsubscribe send an email to devel-leave@ovirt.org Privacy Statement: https://www.ovirt.org/site/privacy-policy/ oVirt Code of Conduct: https://www.ovirt.org/community/about/community- guidelines/ List Archives: https://lists.ovirt.org/archives/list/devel@ovirt.org/ message/P2QN6VG2CRBF55U4FRA65PX3W5SBLPWG/
Ondra is there an equivalent ovirt python sdk4 code for the above, if not we can open a bug for the same. --
KAUSTAV MAJUMDER
ASSOCIATE SOFTWARE ENGINEER
Red Hat India PVT LTD. <https://www.redhat.com/>
kmajumder@redhat.com M: 08981884037 IM: IRC: kmajumder <https://red.ht/sig> TRIED. TESTED. TRUSTED. <https://redhat.com/trusted> @redhatway <https://twitter.com/redhatway> @redhatinc <https://instagram.com/redhatinc> @redhatsnaps <https://snapchat.com/add/redhatsnaps>
_______________________________________________ Devel mailing list -- devel@ovirt.org To unsubscribe send an email to devel-leave@ovirt.org Privacy Statement: https://www.ovirt.org/site/privacy-policy/ oVirt Code of Conduct: https://www.ovirt.org/community/about/community- guidelines/ List Archives: https://lists.ovirt.org/archives/list/devel@ovirt.org/ message/CQZHPBPR6RQEX5EXN2Y2LADBMOTCN7VT/
-- Martin Perina Associate Manager, Software Engineering Red Hat Czech s.r.o.

Hi, I looked through the current Python sdk4 and found that an blank `action` has already been sent when calling `volume.reblance()`, as well as Job ID is contained in the returned response. IMHO, the root cause is that missing a return clause at https://github.com/oVirt/ovirt-engine-sdk/blob/master/sdk/lib/ovirtsdk4/serv..., the following codes may could elaborate the reason. ```python def _internal_action(self, action, path, member=None, headers=None, query=None, wait=None): """ Executes an action method. """ # Populate the headers: headers = headers or {} # Send the request and wait for the response: request = http.Request( method='POST', path='%s/%s' % (self._path, path), query=query, headers=headers, ) request.body = writer.Writer.write(action, indent=True) context = self._connection.send(request) def callback(response): if response.code in [200, 201, 202]: result = self._check_action(response) if member: return getattr(result, member) // +++++++++++ If the `member` parameter is None, the `result` who carries a `types.Action` should also be returned. return result // +++++++++++ else: self._check_fault(response) future = Future(self._connection, context, callback) return future.wait() if wait else future ``` After adding it, we could successfully fetch the job ID via `volume.rebalance().job.id()`. BTW: 1. This issue also affect the oVirt Java sdk4, current sdk generator implementation (https://github.com/oVirt/ovirt-engine-sdk-java/blob/2744d4b59e952d1cd1d81f1d...) is going to drop the returned `Action` object if there has no `@Out` parameters defined. IMHO, an additional property with type of `Action` could be added in the action `Response` in this situation, or an `@Out Action` parameter could added in API model. 2. My Go sdk4 also has the same issue. It's just my point of view, please correct me if I'm wrong. Thanks.

Hi, From my perspective, adding an out Action parameter in API model may significantly affect current implementations. I commit a patch [1], that return the full action object when member is None, into ovirt-engine-sdk project. If possible, could anybody tell me the way to trigger the CI in gerrit, great thanks. :) [1]: https://gerrit.ovirt.org/#/c/93798/

On Sun, Aug 19, 2018 at 4:15 PM, iterjpnic <majunjiev@gmail.com> wrote:
Hi,
From my perspective, adding an out Action parameter in API model may significantly affect current implementations. I commit a patch [1], that return the full action object when member is None, into ovirt-engine-sdk project.
Ondro, could you please review the patch?
If possible, could anybody tell me the way to trigger the CI in gerrit, great thanks. :)
Please take a look at below thread: https://lists.ovirt.org/pipermail/devel/2017-February/029630.html
[1]: https://gerrit.ovirt.org/#/c/93798/ _______________________________________________ Devel mailing list -- devel@ovirt.org To unsubscribe send an email to devel-leave@ovirt.org Privacy Statement: https://www.ovirt.org/site/privacy-policy/ oVirt Code of Conduct: https://www.ovirt.org/communit y/about/community-guidelines/ List Archives: https://lists.ovirt.org/archiv es/list/devel@ovirt.org/message/KPRC3VY5EER3U72EA35JX23RSMBXWXEX/
-- Martin Perina Associate Manager, Software Engineering Red Hat Czech s.r.o.

On Mon, Aug 20, 2018 at 3:06 PM Martin Perina <mperina@redhat.com> wrote:
On Sun, Aug 19, 2018 at 4:15 PM, iterjpnic <majunjiev@gmail.com> wrote:
Hi,
From my perspective, adding an out Action parameter in API model may significantly affect current implementations. I commit a patch [1], that return the full action object when member is None, into ovirt-engine-sdk project.
Ondro, could you please review the patch?
If possible, could anybody tell me the way to trigger the CI in gerrit, great thanks. :)
Please take a look at below thread:
https://lists.ovirt.org/pipermail/devel/2017-February/029630.html
Hi Martin, great thanks for your guidance.
[1]: https://gerrit.ovirt.org/#/c/93798/ _______________________________________________ Devel mailing list -- devel@ovirt.org To unsubscribe send an email to devel-leave@ovirt.org Privacy Statement: https://www.ovirt.org/site/privacy-policy/ oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/ List Archives: https://lists.ovirt.org/archives/list/devel@ovirt.org/message/KPRC3VY5EER3U7...
-- Martin Perina Associate Manager, Software Engineering Red Hat Czech s.r.o.

Hi, Martin and Ondra, I just tried but found that after adding the missing out parameter of `job` for gluster volume rebalance method in API model, the sdk generators always failed to run `mvn package` and had an error like "duplicated definitions for the job attribute". After diving into the API model/metamodel, probably the cause is: * The `Action` is a built-in model defined in [1] in API metamodel, instead of API model traditionally. * The `job` attribute has been explicitly added in `Action`. * All the input/output parameters of all the action methods are also added as the attributes of `Action`. So after I added a extra out job parameters, there would have two job attributes in the generated `types.Action`, as well as the reader/writer generated for `Action`. Basically, I think the sdks themselves are responsible to handle this, maybe it's reasonable to return a full action object here. If I'am wrong or miss something, please let me know, thanks so much. [1]: https://github.com/oVirt/ovirt-engine-api-metamodel/blob/master/tool/src/mai... On Mon, Aug 20, 2018 at 3:06 PM Martin Perina <mperina@redhat.com> wrote:
On Sun, Aug 19, 2018 at 4:15 PM, iterjpnic <majunjiev@gmail.com> wrote:
Hi,
From my perspective, adding an out Action parameter in API model may significantly affect current implementations. I commit a patch [1], that return the full action object when member is None, into ovirt-engine-sdk project.
Ondro, could you please review the patch?
If possible, could anybody tell me the way to trigger the CI in gerrit, great thanks. :)
Please take a look at below thread:
https://lists.ovirt.org/pipermail/devel/2017-February/029630.html
[1]: https://gerrit.ovirt.org/#/c/93798/ _______________________________________________ Devel mailing list -- devel@ovirt.org To unsubscribe send an email to devel-leave@ovirt.org Privacy Statement: https://www.ovirt.org/site/privacy-policy/ oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/ List Archives: https://lists.ovirt.org/archives/list/devel@ovirt.org/message/KPRC3VY5EER3U7...
-- Martin Perina Associate Manager, Software Engineering Red Hat Czech s.r.o.

the problem is _internal_action(self, action, path, member=None, headers=None, query=None, wait=None) function,the code: ``` def callback(response): if response.code in [200, 201, 202]: result = self._check_action(response) if member: return getattr(result, member) else: self._check_fault(response) ``` should change to: ``` def callback(response): if response.code in [200, 201, 202]: result = self._check_action(response) if member: return getattr(result, member) return result else: self._check_fault(response) ``` it should retrun an action type like sdk3.
participants (5)
-
chokko@126.com
-
iterjpnic
-
Joey Ma
-
Kaustav Majumder
-
Martin Perina