X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Futil%2Fapi.py;h=514364abafc1e66e34786d7949693ffe2d412093;hb=3d7237fa0b5f2b4a60cb97c7fb3b6aecfd94558a;hp=3158851412ab52f7bb528a288d64f0218a525360;hpb=87e111946f03261daab0705bbacf8cdfbb6e1321;p=sfa.git diff --git a/sfa/util/api.py b/sfa/util/api.py index 31588514..514364ab 100644 --- a/sfa/util/api.py +++ b/sfa/util/api.py @@ -1,8 +1,8 @@ # -# Geniwrapper XML-RPC and SOAP interfaces +# SFA XML-RPC and SOAP interfaces # -### $Id: api.py 15596 2009-10-31 21:42:05Z anil $ -### $URL: https://svn.planet-lab.org/svn/sfa/trunk/sfa/plc/api.py $ +### $Id$ +### $URL$ # import sys @@ -17,7 +17,7 @@ from sfa.util.faults import * from sfa.util.debug import * from sfa.trust.credential import * from sfa.trust.certificate import * -from sfa.util.misc import * +from sfa.util.namespace import * from sfa.util.sfalogging import * # See "2.2 Characters" in the XML specification: @@ -103,8 +103,9 @@ class BaseAPI: self.encoding = encoding # flat list of method names - methods_module = __import__(methods) - self.methods = methods_module.methods.all + + self.methods_module = methods_module = __import__(methods, fromlist=[methods]) + self.methods = methods_module.all # Better just be documenting the API if config is None: @@ -120,13 +121,6 @@ class BaseAPI: self.cert = Certificate(filename=self.cert_file) self.credential = None - # Initialize the PLC shell only if SFA wraps a myPLC - rspec_type = self.config.get_aggregate_rspec_type() - if (rspec_type == 'pl' or rspec_type == 'vini'): - self.plshell = self.getPLCShell() - self.plshell_version = self.getPLCShellVersion() - - self.hrn = self.config.SFA_INTERFACE_HRN self.time_format = "%Y-%m-%d %H:%M:%S" self.logger=get_sfa_logger() @@ -137,16 +131,16 @@ class BaseAPI: """ # Look up method if method not in self.methods: - raise GeniInvalidAPIMethod, method + raise SfaInvalidAPIMethod, method # Get new instance of method try: classname = method.split(".")[-1] - module = __import__("sfa.methods." + method, globals(), locals(), [classname]) + module = __import__(self.methods_module.__name__ + "." + method, globals(), locals(), [classname]) callablemethod = getattr(module, classname)(self) return getattr(module, classname)(self) except ImportError, AttributeError: - raise GeniInvalidAPIMethod, method + raise SfaInvalidAPIMethod, method def call(self, source, method, *args): """ @@ -192,7 +186,7 @@ class BaseAPI: # Return result if interface == xmlrpclib: - if not isinstance(result, GeniFault): + if not isinstance(result, SfaFault): result = (result,) data = xmlrpclib.dumps(result, methodresponse = True, encoding = self.encoding, allow_none = 1)