Tagging module BootManager - BootManager-3.2-20
[bootmanager.git] / source / BootAPI.py
index 9565128..b2fddbe 100644 (file)
@@ -32,24 +32,33 @@ def create_auth_structure( vars, call_params ):
     auth['AuthMethod']= 'hmac'
 
     try:
-        network= vars['NETWORK_SETTINGS']
-        
-        auth['node_id']= vars['NODE_ID']
-        auth['node_ip']= network['ip']
-        node_key= vars['NODE_KEY']
+        auth['node_id'] = vars['NODE_ID']
+        auth['node_ip'] = vars['NETWORK_SETTINGS']['ip']
     except KeyError, e:
         return None
 
-    params= serialize_params(call_params)
-    params.sort()
-    msg= "[" + "".join(params) + "]"
-    node_hmac= hmac.new(node_key,msg.encode('utf-8'),sha).hexdigest()
+    #params= serialize_params(call_params)
+    #params.sort()
+    #msg= "[" + "".join(params) + "]"
+    #node_hmac= hmac.new(vars['NODE_KEY'], msg.encode('utf-8'), sha).hexdigest()
+    node_hmac= hmac.new(vars['NODE_KEY'], "[]".encode('utf-8'), sha).hexdigest()
     auth['value']= node_hmac
-
+    try:
+        auth_session = {}
+        if not vars.has_key('NODE_SESSION'):
+            session = vars['API_SERVER_INST'].GetSession(auth)
+            auth_session['session'] = session
+            vars['NODE_SESSION'] = session
+        else:
+            auth_session['session'] = vars['NODE_SESSION']
+        auth_session['AuthMethod'] = 'session'
+        auth = auth_session
+    except Exception, e:
+        print e
+        pass
     return auth
 
 
-
 def serialize_params( call_params ):
     """
     convert a list of parameters into a format that will be used in the