Adding oar config file.
authorSandrine Avakian <sandrine.avakian@inria.fr>
Mon, 5 Nov 2012 14:43:02 +0000 (15:43 +0100)
committerSandrine Avakian <sandrine.avakian@inria.fr>
Mon, 5 Nov 2012 14:43:02 +0000 (15:43 +0100)
sfa/senslab/LDAPapi.py
sfa/senslab/OARrestapi.py
sfa/senslab/config/bash_nukem

index 26b8167..ef99daf 100644 (file)
@@ -4,7 +4,7 @@ from sfa.util.xrn import get_authority
 import ldap
 from sfa.util.config import Config
 from sfa.trust.hierarchy import Hierarchy
-#from sfa.trust.certificate import *
+
 import ldap.modlist as modlist
 from sfa.util.sfalogging import logger
 import os.path
@@ -14,6 +14,7 @@ import os.path
 
 class LdapConfig():
     def __init__(self, config_file =  '/etc/sfa/ldap_config.py'):
+        
         try:
             execfile(config_file, self.__dict__)
        
@@ -216,7 +217,7 @@ class LDAPapi :
         """
         #Keep consistency with Java Senslab's LDAP API 
         #RFC2307SSHAPasswordEncryptor so set the salt size to 8 bytres
-        return lssha.encrypt(password,salt_size = 8)
+        return lssha.encrypt(password, salt_size = 8)
     
 
 
@@ -344,7 +345,7 @@ class LDAPapi :
         #If the user wants to set his own password , he must go to the Senslab 
         #website.
         password = self.generate_password()
-        attrs['userPassword']= self.encrypt_password(password)
+        attrs['userPassword'] = self.encrypt_password(password)
         
         #Account automatically validated (no mail request to admins)
         #Set to 0 to disable the account, -1 to enable it,
index ee7f8b4..e530e1f 100644 (file)
@@ -3,7 +3,7 @@ from httplib import HTTPConnection, HTTPException
 import json
 #import datetime
 #from time import gmtime, strftime 
-
+import os.path
 #import urllib
 #import urllib2
 from sfa.util.config import Config
@@ -11,9 +11,9 @@ from sfa.util.config import Config
 
 from sfa.util.sfalogging import logger
 
-
 OARIP = '194.199.16.166'
 
+
 OAR_REQUEST_POST_URI_DICT = {'POST_job':{'uri': '/oarapi/jobs.json'},
                             'DELETE_jobs_id':{'uri':'/oarapi/jobs/id.json'},
                             }
@@ -28,14 +28,26 @@ POST_FORMAT = {'json' : {'content':"application/json", 'object':json},}
 
 
 class OARrestapi:
-    def __init__(self):
+    def __init__(self, config_file =  '/etc/sfa/oar_config.py'):
         self.oarserver = {}
-        self.oarserver['ip'] = OARIP
-        self.oarserver['port'] = 8800
+       
+        
         self.oarserver['uri'] = None
         self.oarserver['postformat'] = 'json'
+        
+        try:
+            execfile(config_file, self.__dict__)
+       
+            self.config_file = config_file
+            # path to configuration data
+            self.config_path = os.path.dirname(config_file)
+            
+        except IOError:
+            raise IOError, "Could not find or load the configuration file: %s" \
+                            % config_file
         #logger.setLevelDebug()
-
+        self.oarserver['ip'] = self.OAR_IP
+        self.oarserver['port'] = self.OAR_PORT
         self.jobstates  = ['Terminated', 'Hold', 'Waiting', 'toLaunch', \
                             'toError', 'toAckReservation', 'Launching', \
                             'Finishing', 'Running', 'Suspended', 'Resuming',\
index 2aaeec1..60c6c67 100755 (executable)
@@ -71,6 +71,7 @@ sudo cp $git_local_repo/sfa/senslab/config/$vm/default_config.xml /etc/sfa/defau
 # sudo cp $git_local_repo/sfa/senslab/config/$vm/site_config  /etc/sfa/configs/site_config
 # sudo ln -s ldap_config.py  /etc/sfa/ldap_config.py
 sudo cp $git_local_repo/sfa/senslab/config/ldap_config.py  /etc/sfa/ldap_config.py 
+sudo cp $git_local_repo/sfa/senslab/config/oar_config.py  /etc/sfa/oar_config.py 
 sudo service sfa restart
 
 # User stuff : clean your folder