#!/usr/bin/python
import os
from os import getpid
import multiprocessing
build="613719"
file1=open('/auto/home/venkam11/python/install-script/build-ddr-file.txt', 'r')
def installation(model,ddr,build):
cli = "/auto/tools/qa/shared/qa-branch/util/install.pl -durham -restart -silentinstall -model %s -branch 6.2A %s %s" %(model, ddr, build)
print cli
os.popen2(cli)
print "installation has started on %s \n" %ddr
if name == 'main':
pid=getpid()
print("parent process id :{}".format(getpid()))
for ddr in file1:
print ddr.rstrip()
if 'dd4500' in ddr:
print "dd4500"
model = "dd4500"
elif ('apollo' or 'apolloplus') in ddr:
print "dd9500"
model = "dd9500"
elif 'dd2500' in ddr:
print "dd2500"
model = "dd2500"
elif 'dd7200' in ddr:
print "dd7200"
model = "dd7200"
elif 'jupiter' in ddr:
print "dd9800"
model = "dd9800"
ddr = ddr.rstrip()
ins=multiprocessing.Process(target=installation, args=(model,ddr,build))
ins.start()
Basically iam trying to read the file which has the machine names and using multiprocessing, I want to insatll the OS on the machines which I have read.
Above is my code, when I run, it starts installing on all the machines at once and the main program terminates.
But I want the main program not to terminate, it has to wait until the child process finish the job, also return the output saying the child process job is complete.
Install make take anytime 1 hr or 2 hrs, but I want the message saying that all the process jobs are completed.
Can anyone please help here.