Setting tag nodemanager-2.0-27
[nodemanager.git] / plugins / sliverauth.py
index 6e3d25f..9e872c5 100644 (file)
@@ -24,7 +24,7 @@ import socket
 import logger
 import tools
 
-def start(options, conf):
+def start():
     logger.log("sliverauth: (dummy) plugin starting up...")
 
 def GetSlivers(data, config, plc):
@@ -46,8 +46,11 @@ def GetSlivers(data, config, plc):
                 logger.log("sliverauth: plc-instantiated slice %s does not yet exist. IGNORING!" % sliver['name'])
             continue
 
-        manage_hmac (plc, sliver)
-        manage_sshkey (plc, sliver)
+        for chunk in sliver['attributes']:
+            if chunk['tagname']=='enable_hmac':
+                manage_hmac (plc, sliver)
+            elif chunk['tagname']=='omf_control':
+                manage_sshkey (plc, sliver)
 
 
 def SetSliverTag(plc, slice, tagname, value):
@@ -92,7 +95,11 @@ def manage_hmac (plc, sliver):
 
 # create the key if needed and returns the key contents
 def generate_sshkey (sliver): 
-    keyfile="/vservers/%s/home/%s/.ssh/id_rsa"%(sliver['name'],sliver['name'])
+# initial version was storing stuff in the sliver directly
+#    keyfile="/vservers/%s/home/%s/.ssh/id_rsa"%(sliver['name'],sliver['name'])
+# we're now storing this in the same place as the authorized_keys, which in turn
+# gets mounted to the user's home directory in the sliver
+    keyfile="/home/%s/.ssh/id_rsa"%(sliver['name'])
     pubfile="%s.pub"%keyfile
     dotssh=os.path.dirname(keyfile)
     # create dir if needed
@@ -104,7 +111,7 @@ def generate_sshkey (sliver):
         logger.log_call( [ 'ssh-keygen', '-t', 'rsa', '-N', '', '-f', keyfile , '-C', comment] )
         os.chmod (keyfile, 0400)
         logger.log_call ( [ 'chown', "%s:slices"%(sliver['name']), keyfile, pubfile ] )
-    return file(pubfile).read()
+    return file(pubfile).read().strip()
 
 # a sliver can get created, deleted and re-created
 # the slice having the tag is not sufficient to skip key geneneration