Martin Polednik has uploaded a new change for review. Change subject: tests: vdsProxy remove need to duplicate api ......................................................................
tests: vdsProxy remove need to duplicate api Currently, every API call to be made has to be appended to utils.py in order to be accessible by vdsProxy instance, this patch removes this need for calls where only status and msg return values are relevant and therefore reducing code (and api) duplication Change-Id: I84d1e696a5280402725223ecc87646a75ba60061 Signed-off-by: Martin Polednik <mpole...@redhat.com> --- M tests/functional/utils.py 1 file changed, 14 insertions(+), 8 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/17/18417/1 diff --git a/tests/functional/utils.py b/tests/functional/utils.py index f3751fa..5ce602f 100644 --- a/tests/functional/utils.py +++ b/tests/functional/utils.py @@ -131,6 +131,20 @@ self.netinfo = \ netinfo.NetInfo(self.vdscli.getVdsCapabilities()['info']) + def __getattr__(self, func): + """ + trying to access api call that is not defined here results + in using standard template of + result = vdsproxy.call(params) + return result['status']['code'], result['status']['message'] + """ + if hasattr(self.vdscli, func): + def wrapper(*args, **kw): + result = getattr(self.vdscli, func)(*args, **kw) + return result['status']['code'], result['status']['message'] + return wrapper + raise AttributeError(func) + def netinfo_altering(func): """Updates the cached information that might have been altered by an api call that has side-effects on the server.""" @@ -230,14 +244,6 @@ def networkQos(self, networkName): network = self.netinfo.networks[networkName] return network['qosInbound'], network['qosOutbound'] - - def setMOMPolicy(self, policyStr): - result = self.vdscli.setMOMPolicy(policyStr) - return result['status']['code'], result['status']['message'] - - def setBalloonTarget(self, vmId, target): - result = self.vdscli.setBalloonTarget(vmId, target) - return result['status']['code'], result['status']['message'] def getVdsStats(self): result = self.vdscli.getVdsStats() -- To view, visit http://gerrit.ovirt.org/18417 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I84d1e696a5280402725223ecc87646a75ba60061 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Martin Polednik <mpole...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches