From: Sandrine Avakian Date: Mon, 5 Nov 2012 14:43:02 +0000 (+0100) Subject: Adding oar config file. X-Git-Tag: sfa-2.1-24~3^2~39 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=1b4573f0bc061b966b483955ac219c291986dbac;p=sfa.git Adding oar config file. --- diff --git a/sfa/senslab/LDAPapi.py b/sfa/senslab/LDAPapi.py index 26b81671..ef99daf0 100644 --- a/sfa/senslab/LDAPapi.py +++ b/sfa/senslab/LDAPapi.py @@ -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, diff --git a/sfa/senslab/OARrestapi.py b/sfa/senslab/OARrestapi.py index ee7f8b4f..e530e1fe 100644 --- a/sfa/senslab/OARrestapi.py +++ b/sfa/senslab/OARrestapi.py @@ -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',\ diff --git a/sfa/senslab/config/bash_nukem b/sfa/senslab/config/bash_nukem index 2aaeec18..60c6c67c 100755 --- a/sfa/senslab/config/bash_nukem +++ b/sfa/senslab/config/bash_nukem @@ -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