correction du bug 186 : Intégrer la configuration SGE des noeuds dans l'installeur
This commit is contained in:
parent
d97fca4143
commit
0a8b21dda3
|
@ -0,0 +1,95 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
#import sys
|
||||
#sys.path.insert(0, '/homes/raffy/SvnGRaffy/dev/Python')
|
||||
import re
|
||||
#import Lib.Util
|
||||
|
||||
class SgeConfig:
|
||||
def __init__( self ):
|
||||
self.m_attrs={}
|
||||
def getAttr( self, strAttrName ):
|
||||
return self.m_attrs[ strAttrName ]
|
||||
def setAttr( self, strAttrName, strAttrValue ):
|
||||
self.m_attrs[ strAttrName ] = strAttrValue
|
||||
def loadFromSgeFormat1String( self, strSgeConfigString ):
|
||||
"""
|
||||
loads attrs from a string such as :
|
||||
hostname simpatix11.univ-rennes1.fr
|
||||
load_scaling NONE
|
||||
complex_values has_molpro_2010=0
|
||||
load_values arch=darwin-x86,num_proc=4,mem_total=8192.000000M, \
|
||||
swap_total=0.000000M,virtual_total=8192.000000M, \
|
||||
load_avg=5.126465,load_short=5.186523, \
|
||||
load_medium=5.126465,load_long=5.087891, \
|
||||
mem_free=6654.054688M,swap_free=0.000000M, \
|
||||
virtual_free=6654.054688M,mem_used=1537.945312M, \
|
||||
swap_used=0.000000M,virtual_used=1537.945312M, \
|
||||
cpu=100.000000,m_topology=NONE,m_topology_inuse=NONE, \
|
||||
m_socket=0,m_core=0,np_load_avg=1.281616, \
|
||||
np_load_short=1.296631,np_load_medium=1.281616, \
|
||||
np_load_long=1.271973
|
||||
processors 4
|
||||
user_lists NONE
|
||||
xuser_lists NONE
|
||||
projects NONE
|
||||
xprojects NONE
|
||||
usage_scaling NONE
|
||||
report_variables NONE
|
||||
"""
|
||||
self.m_attrs={}
|
||||
# put multiline attributes on one line
|
||||
strSgeConfigString = re.sub(r"\\\n", "", strSgeConfigString)
|
||||
for strAttrDef in strSgeConfigString.split("\n"):
|
||||
#print strAttrDef
|
||||
if len(strAttrDef) != 0:
|
||||
matchObj = re.match( "^(?P<attrName>[^\s]+)[ ]+(?P<attrValue>[^\s].*)$", strAttrDef )
|
||||
#print( '%s = %s\n' % (matchObj.group("attrName"), matchObj.group("attrValue") ) )
|
||||
self.m_attrs[ matchObj.group("attrName") ] = matchObj.group("attrValue")
|
||||
|
||||
def loadFromSgeFormat2String( self, strSgeConfigString ):
|
||||
"""
|
||||
loads attrs from a string such as :
|
||||
arch=darwin-x86,num_proc=4,mem_total=8192.000000M, \
|
||||
swap_total=0.000000M,virtual_total=8192.000000M, \
|
||||
load_avg=5.126465,load_short=5.186523, \
|
||||
load_medium=5.126465,load_long=5.087891, \
|
||||
mem_free=6654.054688M,swap_free=0.000000M, \
|
||||
virtual_free=6654.054688M,mem_used=1537.945312M, \
|
||||
swap_used=0.000000M,virtual_used=1537.945312M, \
|
||||
cpu=100.000000,m_topology=NONE,m_topology_inuse=NONE, \
|
||||
m_socket=0,m_core=0,np_load_avg=1.281616, \
|
||||
np_load_short=1.296631,np_load_medium=1.281616, \
|
||||
np_load_long=1.271973
|
||||
"""
|
||||
self.m_attrs={}
|
||||
if strSgeConfigString != "NONE":
|
||||
for strAttrDef in strSgeConfigString.split(","):
|
||||
#print strAttrDef
|
||||
if len(strAttrDef) != 0:
|
||||
matchObj = re.match( "^(?P<attrName>[^=]+)=(?P<attrValue>.*)$", strAttrDef )
|
||||
#print matchObj.group("attrName")
|
||||
self.m_attrs[ matchObj.group("attrName") ] = matchObj.group("attrValue")
|
||||
def asFormat1String( self ):
|
||||
strResult = ""
|
||||
for (k,v) in self.m_attrs.iteritems():
|
||||
#print "%s %s" % (k,v)
|
||||
strResult += "%s %s\n" % (k,v)
|
||||
#print strSgeConfigString
|
||||
return strResult
|
||||
def asFormat2String( self ):
|
||||
strResult = ""
|
||||
iNumAttrs = len(self.m_attrs)
|
||||
if iNumAttrs == 0:
|
||||
return "NONE"
|
||||
iAttr = 0
|
||||
for (k,v) in self.m_attrs.iteritems():
|
||||
#print "%s %s" % (k,v)
|
||||
strResult += "%s=%s" % (k,v)
|
||||
if iAttr != (iNumAttrs - 1):
|
||||
strResult += ","
|
||||
iAttr+=1
|
||||
#print strSgeConfigString
|
||||
return strResult
|
||||
|
||||
|
|
@ -0,0 +1 @@
|
|||
# this file is here just so that the containing directory is treated as a python package
|
11
Util.py
11
Util.py
|
@ -20,6 +20,17 @@ def sendTextMail(strFrom, to, strSubject, text ):
|
|||
smtp.sendmail(strFrom, [to], mail.as_string())
|
||||
smtp.close()
|
||||
|
||||
class Error( Exception ):
|
||||
def __init__( self, strMessage ):
|
||||
self.m_strMessage = strMessage
|
||||
|
||||
def getHostName():
|
||||
(returnCode, stdout, stderr) = executeProgram(['hostname', '-s'])
|
||||
if returnCode != 0:
|
||||
raise Error(stderr)
|
||||
strHostName = re.sub(r"\n", "", stdout)
|
||||
return strHostName
|
||||
|
||||
def log( message ):
|
||||
print time.asctime(time.localtime())+' : '+ message
|
||||
|
||||
|
|
Loading…
Reference in New Issue