Commit b600c614 authored by Alain Takoudjou's avatar Alain Takoudjou Committed by Cédric de Saint Martin

BonjourGrid: Setup condor instance

parent 332ccd39
......@@ -147,8 +147,8 @@ class Client(GenericBaseRecipe):
condor_wrapper = self.createPythonScript(condor_script,
'%s.condor.runCondor' % __name__,
dict(ipv6=self.options['ipv6'].strip(),
condor_host=self.options['condor_host'].strip(),
collector_name=self.options['collector_name'].strip(),
condor_bin=self.options['condor_bin'].strip(),
condor_sbin=self.options['condor_sbin'].strip(),
condor_wrapper=self.options['condor_wrapper'].strip(),
condor_config=self.options['condor_config'].strip(),
condor_config_local=self.options['condor_config_local'].strip(),
......
......@@ -6,15 +6,44 @@ import re
import subprocess
import time
def startProcess(launch_args, env=None, cwd=None, stdout=subprocess.PIPE):
process = subprocess.Popen(launch_args, stdout=stdout,
stderr=subprocess.STDOUT, env=env,
cwd=cwd)
result = process.communicate()[0]
if process.returncode is None or process.returncode != 0:
raise NameError("Failed to execute executable.\nThe error was: %s" % result)
def writeFile(file, content):
f = open(file, 'w')
f.write(content)
f.close()
def updateCondorConfig(path, path_local, hostname, ipv6):
"""Replace Static information into condor_config and condor_config.local files"""
#replace condor host into condor_config
text = open(path, 'r').read()
text = re.sub(r'\[%s\]' % ipv6, hostname, text, flags=re.IGNORECASE)
writeFile(path, text)
#replace condor host into condor_config.local
text = open(path_local, 'r').read()
text = re.sub(r'\[%s\]' % ipv6, hostname, text, flags=re.IGNORECASE)
writeFile(path_local, text)
def updateCondorWrapper(folder, hostname, ipv6):
"""Replace slapos generated value by the true value"""
for file in os.listdir(folder):
path = os.path.join(folder, file)
if os.path.exists(path) and not os.path.isdir(path):
text = re.sub(r'\[%s\]' % ipv6, hostname, open(path, 'r').read(),
flags=re.IGNORECASE)
writeFile(path, text)
def runCondor(config):
if len(sys.argv) < 2:
print "Argument Error: uses %s hostname projectname" % sys.argv[0]
print "Argument Error: uses %s hostname" % sys.argv[0]
exit(1)
hostname = sys.argv[1]
updateCondorConfig(config['condor_config'], config['condor_config_local'],
hostname, config['ipv6'])
updateCondorWrapper(config['condor_bin'], hostname, config['ipv6'])
updateCondorWrapper(config['condor_sbin'], hostname, config['ipv6'])
#launch Boinc Client
condor = subprocess.Popen([config['condor_wrapper']],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
condor.wait()
......@@ -93,8 +93,8 @@ class Recipe(GenericBaseRecipe):
self.role = "manager,submit"
elif self.options['machine-role'].strip() == "worker":
self.role = "execute"
install_args += ['--central-manager='+self.condor_host,
'--type='+self.role]
install_args += ['--central-manager='+self.condor_host]
install_args += ['--type='+self.role]
configure = subprocess.Popen(install_args, env=self.environ,
stdout=subprocess.PIPE)
configure.communicate()[0]
......@@ -144,10 +144,11 @@ class Recipe(GenericBaseRecipe):
export CONDOR_LOCATION=%s
export CONDOR_IDS=%s
export HOME=%s
export HOSTNAME=%s
exec %s $*""" % (self.dash,
self.environ['LD_LIBRARY_PATH'], self.environ['PATH'],
condor_config, self.prefix, slapuser, self.environ['HOME'],
current_exe)
self.environ['HOSTNAME'], current_exe)
wrapper.write(content)
wrapper.close()
path_list.append(wrapper_location)
......@@ -165,10 +166,11 @@ class Recipe(GenericBaseRecipe):
export CONDOR_LOCATION=%s
export CONDOR_IDS=%s
export HOME=%s
export HOSTNAME=%s
exec %s $*""" % (self.dash,
self.environ['LD_LIBRARY_PATH'], self.environ['PATH'],
condor_config, self.prefix, slapuser, self.environ['HOME'],
current_exe)
self.environ['HOSTNAME'], current_exe)
wrapper.write(content)
wrapper.close()
path_list.append(wrapper_location)
......
......@@ -54,8 +54,8 @@ redis-port = $${slap-parameter:server-port}
#Boinc and Condor parameters
ipv6 = $${slap-network-information:global-ipv6}
email = $${slap-parameter:user-email}
condor_host = $${condor:condor_host}
collector_name = $${condor:collector_name}
condor_sbin = $${condor:sbin}
condor_bin = $${condor:bin}
boinc_wrapper = $${boinc-client:client-wrapper}
condor_wrapper = $${condor:wrapper-dir}/start_condor
boinc_cmd = $${boinc-client:cmd-bin}
......
......@@ -28,7 +28,7 @@ recipe = slapos.recipe.template
url = ${:_profile_base_location_}/bonjourgrid-instance.cfg
output = ${buildout:directory}/template-bonjourgrid.cfg
mode = 0644
md5sum = 3d470d742a690a2959d376f4d978d407
md5sum = 59b55246b2813bc162f528734132df02
[bonjourgrid]
recipe = hexagonit.recipe.download
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment