reguire gnupg1 on f>=31; sense the system to use gpg1 when installed
[nodemanager.git] / plugins / sfagids.py
index e7e2b1a..ac8be79 100644 (file)
@@ -1,9 +1,6 @@
-#!/usr/bin/python -tt
+#!/usr/bin/python3 -tt
 # vim:set ts=4 sw=4 expandtab:
 #
-# $Id$
-# $URL$
-#
 # NodeManager plugin for installing SFA GID's in slivers
 # 
 
@@ -15,7 +12,7 @@ import traceback
 import tempfile
 try:
     from sfa.util.namespace import *
-    from sfa.util.config import Config
+    from sfa.util.config import Config as SfaConfig
     import sfa.util.xmlrpcprotocol as xmlrpcprotocol
     from sfa.trust.certificate import Keypair, Certificate
     from sfa.trust.credential import Credential
@@ -30,9 +27,12 @@ def start():
     logger.log("sfagid: plugin starting up ...")
     if not sfa:
         return
-    keyfile, certfile = get_keypair(None)
-    api = ComponentAPI(key_file=keyfile, cert_file=certfile)
-    api.get_node_key()
+    try:
+        keyfile, certfile = get_keypair(None)
+        api = ComponentAPI(key_file=keyfile, cert_file=certfile)
+        api.get_node_key()
+    except:
+        return
 
 def GetSlivers(data, config=None, plc=None):
     if not sfa:
@@ -109,7 +109,7 @@ def install_trusted_certs(api):
         trusted_gid_names.append(relative_filename)
         gid_filename = trusted_certs_dir + os.sep + relative_filename
         if verbose:
-            print "Writing GID for %s as %s" % (gid.get_hrn(), gid_filename)
+            print("Writing GID for %s as %s" % (gid.get_hrn(), gid_filename))
         gid.save_to_file(gid_filename, save_parents=True)
 
     # remove old certs
@@ -117,7 +117,7 @@ def install_trusted_certs(api):
     for gid_name in all_gids_names:
         if gid_name not in trusted_gid_names:
             if verbose:
-                print "Removing old gid ", gid_name
+                print("Removing old gid ", gid_name)
             os.unlink(trusted_certs_dir + os.sep + gid_name)
     
 
@@ -125,7 +125,7 @@ def install_trusted_certs(api):
 
 def get_keypair(config = None):
     if not config:
-        config = Config()
+        config = SfaConfig()
     hierarchy = Hierarchy()
     key_dir= hierarchy.basedir
     data_dir = config.data_path