Commit 5c76fa33 authored by Priscila Manhaes's avatar Priscila Manhaes

Updated acording to master

parent 2272651b
...@@ -46,18 +46,12 @@ class SlapOSControler(object): ...@@ -46,18 +46,12 @@ class SlapOSControler(object):
'reference': config['computer_id'], 'reference': config['computer_id'],
'software_root': config['software_root']})) 'software_root': config['software_root']}))
def runSoftwareRelease(self, config, environment, process_group_pid_set=None): def runSoftwareRelease(self, config, environment, process_group_pid_set=None,
stdout=None, stderr=None):
print "SlapOSControler.runSoftwareRelease" print "SlapOSControler.runSoftwareRelease"
while True:
cpu_count = os.sysconf("SC_NPROCESSORS_ONLN") cpu_count = os.sysconf("SC_NPROCESSORS_ONLN")
os.putenv('MAKEFLAGS', '-j%s' % cpu_count) os.putenv('MAKEFLAGS', '-j%s' % cpu_count)
os.environ['PATH'] = environment['PATH'] os.environ['PATH'] = environment['PATH']
stdout = open(os.path.join(
config['instance_root'],'.runSoftwareRelease_out'),
'w+')
stderr = open(os.path.join(
config['instance_root'],'.runSoftwareRelease_err'),
'w+')
slapgrid = subprocess.Popen([config['slapgrid_software_binary'], '-v', '-c', slapgrid = subprocess.Popen([config['slapgrid_software_binary'], '-v', '-c',
#'--buildout-parameter',"'-U -N' -o", #'--buildout-parameter',"'-U -N' -o",
config['slapos_config']], config['slapos_config']],
...@@ -75,19 +69,26 @@ class SlapOSControler(object): ...@@ -75,19 +69,26 @@ class SlapOSControler(object):
stderr.close() stderr.close()
return status_dict return status_dict
def runComputerPartition(self, config, process_group_pid_set=None): def runComputerPartition(self, config, environment,
process_group_pid_set=None,
stdout=None, stderr=None):
print "SlapOSControler.runInstanceRelease" print "SlapOSControler.runInstanceRelease"
slap = slapos.slap.slap() slap = slapos.slap.slap()
slap.registerOpenOrder().request(self.software_profile, slap.registerOpenOrder().request(self.software_profile,
partition_reference='testing partition', partition_reference='testing partition',
partition_parameter_kw=config['instance_dict']) partition_parameter_kw=config['instance_dict'])
slapgrid = subprocess.Popen([config['slapgrid_partition_binary'], slapgrid = subprocess.Popen([config['slapgrid_partition_binary'],
config['slapos_config'], '-c', '-v'], close_fds=True, preexec_fn=os.setsid, config['slapos_config'], '-c', '-v'],
stdout=-1, stderr=-1) stdout=stdout, stderr=stderr,
ss, se = slapgrid.communicate() close_fds=True, preexec_fn=os.setsid)
print " \n %s \n \n %s \n" % (ss, se)
process_group_pid_set.add(slapgrid.pid) process_group_pid_set.add(slapgrid.pid)
slapgrid.wait() slapgrid.wait()
stdout.seek(0)
stderr.seek(0)
process_group_pid_set.remove(slapgrid.pid) process_group_pid_set.remove(slapgrid.pid)
if slapgrid.returncode != 0: status_dict = {'status_code':slapgrid.returncode,
raise ValueError('Slapgrid instance failed') 'stdout':stdout.read(),
'stderr':stderr.read()}
stdout.close()
stderr.close()
return status_dict
...@@ -55,6 +55,16 @@ def safeRpcCall(function, *args): ...@@ -55,6 +55,16 @@ def safeRpcCall(function, *args):
time.sleep(retry) time.sleep(retry)
retry += retry >> 1 retry += retry >> 1
def getInputOutputFileList(config, command_name):
stdout = open(os.path.join(
config['instance_root'],'.%s_out' % command_name),
'w+')
stdout.write("%s\n" % command_name)
stderr = open(os.path.join(
config['instance_root'],'.%s_err' % command_name),
'w+')
return (stdout, stderr)
slapos_controler = None slapos_controler = None
def run(args): def run(args):
...@@ -168,22 +178,25 @@ branch = %(branch)s ...@@ -168,22 +178,25 @@ branch = %(branch)s
updater = Updater(repository_path, git_binary=config['git_binary'], updater = Updater(repository_path, git_binary=config['git_binary'],
revision=repository_revision.split('-')[1]) revision=repository_revision.split('-')[1])
updater.checkout() updater.checkout()
# Now prepare the installation of SlapOS # Now prepare the installation of SlapOS
slapos_controler = SlapOSControler(config, slapos_controler = SlapOSControler(config,
process_group_pid_set=process_group_pid_set) process_group_pid_set=process_group_pid_set)
# this should be always true later, but it is too slow for now for method_name in ("runSoftwareRelease", "runComputerPartition"):
status_dict = slapos_controler.runSoftwareRelease(config, stdout, stderr = getInputOutputFileList(config, method_name)
config['environment'], slapos_method = getattr(slapos_controler, method_name)
process_group_pid_set, status_dict = slapos_method(config,
environment=config['environment'],
process_group_pid_set=process_group_pid_set,
stdout=stdout, stderr=stderr
) )
if status_dict['status_code'] != 0:
break
if status_dict['status_code'] != 0: if status_dict['status_code'] != 0:
safeRpcCall(master.reportTaskFailure, safeRpcCall(master.reportTaskFailure,
test_result_path, status_dict, config['test_node_title']) test_result_path, status_dict, config['test_node_title'])
retry_software = True retry_software = True
continue continue
# create instances, it should take some seconds only
slapos_controler.runComputerPartition(config,
process_group_pid_set=process_group_pid_set)
partition_path = os.path.join(config['instance_root'], partition_path = os.path.join(config['instance_root'],
config['partition_reference']) config['partition_reference'])
......
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