git://git.onelab.eu
/
sfa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'nocomponent' into geni-v3
[sfa.git]
/
sfa
/
methods
/
Resolve.py
diff --git
a/sfa/methods/Resolve.py
b/sfa/methods/Resolve.py
index
f3a6e67
..
39618a7
100644
(file)
--- a/
sfa/methods/Resolve.py
+++ b/
sfa/methods/Resolve.py
@@
-1,23
+1,23
@@
-import types
-
from sfa.util.xrn import Xrn, urn_to_hrn
from sfa.util.method import Method
from sfa.util.xrn import Xrn, urn_to_hrn
from sfa.util.method import Method
+from sfa.util.sfalogging import logger
from sfa.trust.credential import Credential
from sfa.storage.parameter import Parameter, Mixed
from sfa.trust.credential import Credential
from sfa.storage.parameter import Parameter, Mixed
+
class Resolve(Method):
"""
Resolve a record.
@param cred credential string authorizing the caller
class Resolve(Method):
"""
Resolve a record.
@param cred credential string authorizing the caller
- @param hrn human readable name to resolve (hrn or urn)
- @return a list of record dictionaries or empty list
+ @param hrn human readable name to resolve (hrn or urn)
+ @return a list of record dictionaries or empty list
"""
interfaces = ['registry']
"""
interfaces = ['registry']
-
+
# should we not accept an optional 'details' argument ?
accepts = [
Mixed(Parameter(str, "Human readable name (hrn or urn)"),
# should we not accept an optional 'details' argument ?
accepts = [
Mixed(Parameter(str, "Human readable name (hrn or urn)"),
@@
-25,28
+25,33
@@
class Resolve(Method):
Mixed(Parameter(str, "Credential string"),
Parameter(list, "List of credentials)")),
Parameter(dict, "options"),
Mixed(Parameter(str, "Credential string"),
Parameter(list, "List of credentials)")),
Parameter(dict, "options"),
-
]
+ ]
# xxx used to be [SfaRecord]
returns = [Parameter(dict, "registry record")]
# xxx used to be [SfaRecord]
returns = [Parameter(dict, "registry record")]
-
- def call(self, xrns, creds, options={}):
- # use details=False by default, only when explicitly specified do we want
+
+ def call(self, xrns, creds, options=None):
+ if options is None:
+ options = {}
+ # use details=False by default, only when explicitly specified do we want
# to mess with the testbed details
# to mess with the testbed details
- if 'details' in options: details=options['details']
- else: details=False
+ if 'details' in options:
+ details = options['details']
+ else:
+ details = False
type = None
type = None
- if not isinstance(xrns,
types.ListType
):
+ if not isinstance(xrns,
list
):
type = Xrn(xrns).get_type()
type = Xrn(xrns).get_type()
- xrns
=
[xrns]
+ xrns
=
[xrns]
hrns = [urn_to_hrn(xrn)[0] for xrn in xrns]
hrns = [urn_to_hrn(xrn)[0] for xrn in xrns]
- #find valid credentials
+ #
find valid credentials
valid_creds = self.api.auth.checkCredentials(creds, 'resolve')
valid_creds = self.api.auth.checkCredentials(creds, 'resolve')
- #log the call
- origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
- self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrns, self.name))
-
+ # log the call
+ origin_hrn = Credential(
+ string=valid_creds[0]).get_gid_caller().get_hrn()
+ logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s" %
+ (self.api.interface, origin_hrn, hrns, self.name))
+
# send the call to the right manager
return self.api.manager.Resolve(self.api, xrns, type, details=details)
# send the call to the right manager
return self.api.manager.Resolve(self.api, xrns, type, details=details)
-