import traceback
import string
import xmlrpclib
+
+import sfa.util.sfalogging
+import sfa.util.xmlrpcprotocol as xmlrpcprotocol
from sfa.trust.auth import Auth
from sfa.util.config import *
from sfa.util.faults import *
from sfa.util.namespace import *
from sfa.util.api import *
from sfa.util.nodemanager import NodeManager
-from sfa.util.sfalogging import *
try:
from collections import defaultdict
except:
self.hrn = self.config.SFA_INTERFACE_HRN
self.time_format = "%Y-%m-%d %H:%M:%S"
- self.logger=get_sfa_logger()
+ self.logger=sfa.util.sfalogging.logger
def getPLCShell(self):
self.plauth = {'Username': self.config.SFA_PLC_USER,
return shell
def getCredential(self):
+ """
+ Retrun a valid credential for this interface.
+ """
if self.interface in ['registry']:
return self.getCredentialFromLocalRegistry()
else:
return self.getCredentialFromRegistry()
-
+
+ def getDelegatedCredential(self, creds):
+ """
+ Attempt to find a credential delegated to us in
+ the specified list of creds.
+ """
+ if creds and not isinstance(creds, list):
+ creds = [creds]
+ delegated_creds = filter_creds_by_caller(creds,self.hrn)
+ if not delegated_creds:
+ return None
+ return delegated_creds[0]
+
def getCredentialFromRegistry(self):
"""
Get our credential from a remote registry
"""
path = self.config.SFA_DATA_DIR
config_dir = self.config.config_path
- credfile = path + os.sep + 'node.cred'
+ cred_filename = path + os.sep + 'node.cred'
try:
credential = Credential(filename = cred_filename)
return credential.save_to_string(save_parents=True)
except IOError:
node_pkey_file = config_dir + os.sep + "node.key"
node_gid_file = config_dir + os.sep + "node.gid"
+ cert_filename = path + os.sep + 'server.cert'
if not os.path.exists(node_pkey_file) or \
not os.path.exists(node_gid_file):
self.get_node_key()
gid = GID(filename=node_gid_file)
hrn = gid.get_hrn()
# get credential from registry
+ cert_str = Certificate(filename=cert_filename).save_to_string(save_parents=True)
registry = self.get_registry()
cred = registry.get_self_credential(cert_str, 'node', hrn)
Credential(string=cred).save_to_file(credfile, save_parents=True)