Change in vdsm[master]: tests: vdsProxy remove need to duplicate api

asegurap at redhat.com asegurap at redhat.com
Thu Aug 22 13:36:18 UTC 2013


Antoni Segura Puimedon has posted comments on this change.

Change subject: tests: vdsProxy remove need to duplicate api
......................................................................


Patch Set 1:

(5 comments)

....................................................
File tests/functional/utils.py
Line 132:             netinfo.NetInfo(self.vdscli.getVdsCapabilities()['info'])
Line 133: 
Line 134:     def __getattr__(self, func):
Line 135:         """
Line 136:         trying to access api call that is not defined here results
I propose:

"""When the attribute is missing we look it up at self.vdscli and return the proxy usual tuple (result['status']['code'], result['status']['message'])"""
Line 137:         in using standard template of
Line 138:             result = vdsproxy.call(params)
Line 139:             return result['status']['code'], result['status']['message']
Line 140:         """


Line 137:         in using standard template of
Line 138:             result = vdsproxy.call(params)
Line 139:             return result['status']['code'], result['status']['message']
Line 140:         """
Line 141:         if hasattr(self.vdscli, func):
func = getattr(self.vdscli, func)
@wraps(func)
and then in the wrapper just result=func(*args, **kwargs)
Line 142:             def wrapper(*args, **kw):
Line 143:                 result = getattr(self.vdscli, func)(*args, **kw)
Line 144:                 return result['status']['code'], result['status']['message']
Line 145:             return wrapper


Line 138:             result = vdsproxy.call(params)
Line 139:             return result['status']['code'], result['status']['message']
Line 140:         """
Line 141:         if hasattr(self.vdscli, func):
Line 142:             def wrapper(*args, **kw):
s/kw/kwargs/
Line 143:                 result = getattr(self.vdscli, func)(*args, **kw)
Line 144:                 return result['status']['code'], result['status']['message']
Line 145:             return wrapper
Line 146:         raise AttributeError(func)


Line 139:             return result['status']['code'], result['status']['message']
Line 140:         """
Line 141:         if hasattr(self.vdscli, func):
Line 142:             def wrapper(*args, **kw):
Line 143:                 result = getattr(self.vdscli, func)(*args, **kw)
We could allow an extra keyword argument to be passed to these methods called proxyKeys that would be an iterator (preferably a tuple) that would allow to specify extra keys from "result" to be returned.
    if 'proxyKeys' in kwargs:
        keys = kwargs['proxyKeys']
        del kwargs['proxyKeys']

With this, one could do:

code, message, info = self.getVdsCapabilities(proxyKeys=('info'))
Line 144:                 return result['status']['code'], result['status']['message']
Line 145:             return wrapper
Line 146:         raise AttributeError(func)
Line 147: 


Line 140:         """
Line 141:         if hasattr(self.vdscli, func):
Line 142:             def wrapper(*args, **kw):
Line 143:                 result = getattr(self.vdscli, func)(*args, **kw)
Line 144:                 return result['status']['code'], result['status']['message']
part of the proxyKeys proposal:
    proxyValues = tuple(result[value] for value in proxyKeys)
    return (result['status']['code'], result['status']['message']) + values
Line 145:             return wrapper
Line 146:         raise AttributeError(func)
Line 147: 
Line 148:     def netinfo_altering(func):


-- 
To view, visit http://gerrit.ovirt.org/18417
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I84d1e696a5280402725223ecc87646a75ba60061
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpoledni at redhat.com>
Gerrit-Reviewer: Antoni Segura Puimedon <asegurap at redhat.com>
Gerrit-Reviewer: Giuseppe Vallarelli <gvallare at redhat.com>
Gerrit-Reviewer: Mei Liu <liumbj at linux.vnet.ibm.com>
Gerrit-Reviewer: Michal Skrivanek <michal.skrivanek at redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes


More information about the vdsm-patches mailing list