don't know how to fix fix this one - just reverted as my attempt was incorrect
[sfa.git] / sfa / plc / api.py
index ddca04d..6da1188 100644 (file)
@@ -10,18 +10,18 @@ import os
 import traceback
 import string
 import xmlrpclib
+
+from sfa.util.sfalogging import sfa_logger
 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.debug import *
 from sfa.trust.rights import *
 from sfa.trust.credential import *
 from sfa.trust.certificate 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:
@@ -106,7 +106,7 @@ class SfaAPI(BaseAPI):
 
         self.hrn = self.config.SFA_INTERFACE_HRN
         self.time_format = "%Y-%m-%d %H:%M:%S"
-        self.logger=get_sfa_logger()
+        self.logger=sfa_logger
 
     def getPLCShell(self):
         self.plauth = {'Username': self.config.SFA_PLC_USER,
@@ -126,7 +126,7 @@ class SfaAPI(BaseAPI):
 
     def getCredential(self):
         """
-        Retrun a valid credential for this interface. 
+        Return a valid credential for this interface. 
         """
         if self.interface in ['registry']:
             return self.getCredentialFromLocalRegistry()
@@ -643,6 +643,7 @@ class ComponentAPI(BaseAPI):
         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()
@@ -651,6 +652,7 @@ class ComponentAPI(BaseAPI):
             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)