Ejemplo n.º 1
0
def main():
	print "in aip"
	ip=commands.getstatusoutput("nmap -sP 192.168.0.0/24 | grep 192 | awk '{print $6}' | sed 's/(//' | sed 's/)//'")[1].split()
	print ip
	inst=[]
	for i in ip:
				print "in thread 1"
				t=threading.Thread(target=install,args=(i,))
				inst.append(t)
				t.start()
	for i in inst:
		print "joining thread 1"
		i.join()
	inst1=[]
	for i in ip:
				print "in thread 2"
				t=threading.Thread(target=aip,args=(i,))
				inst1.append(t)
				t.start()
	for i in inst1:
		print "joining thread 2"
		i.join()
	f.close()
	
	print "exiting from aip"
	out("clear")
Ejemplo n.º 2
0
Archivo: aip.py Proyecto: lwwale/Cloop
def main():
    print "in aip"
    ip = commands.getstatusoutput(
        "nmap -sP 192.168.0.0/24 | grep 192 | awk '{print $6}' | sed 's/(//' | sed 's/)//'"
    )[1].split()
    print ip
    inst = []
    for i in ip:
        print "in thread 1"
        t = threading.Thread(target=install, args=(i, ))
        inst.append(t)
        t.start()
    for i in inst:
        print "joining thread 1"
        i.join()
    inst1 = []
    for i in ip:
        print "in thread 2"
        t = threading.Thread(target=aip, args=(i, ))
        inst1.append(t)
        t.start()
    for i in inst1:
        print "joining thread 2"
        i.join()
    f.close()

    print "exiting from aip"
    out("clear")
Ejemplo n.º 3
0
 def task(self):
     self.lock.wait()
     instruction_iterator = iter(self.program.instructions)
     instruction = next(instruction_iterator)
     while True:
         if instruction == None:
             break
         elif instruction.command == 'CALCULATE':
             calculate(instruction.value, 0.01, self.lock, self.pid)
             instruction = advance(instruction_iterator)
         elif instruction.command == 'I/O':
             io(self, self.lock, self.pid, self.dispatcher,
                self.scheduler_lock, self.pcb)
             instruction = advance(instruction_iterator)
         elif instruction.command == 'YIELD':
             yield_from(self.lock, self.pid, self.scheduler_lock)
             instruction = advance(instruction_iterator)
         elif instruction.command == 'OUT':
             out(self, self.lock, self.pid)
             instruction = advance(instruction_iterator)
         elif instruction.command == 'CRITICAL BEGIN':
             cs = tables.critical_sections[instruction.value]
             if not cs.locked:
                 cs.lock()
                 cs.pid = self.pid
                 self.has_cs = True
                 self.is_waiting_for_cs = False
                 instruction = advance(instruction_iterator)
                 print(
                     f'---CRITICAL SECTION (id: {cs.id}, pid {self.pid}) BEGIN---'
                 )
                 self.lock.wait()
             elif cs.locked:
                 # print(f'Process {self.pid} waiting for lock {cs.id}')
                 self.has_cs = False
                 self.is_waiting_for_cs = True
                 self.pcb.state = 'WAIT'
                 continue_from(self.lock, self.pid, self.scheduler_lock)
         elif instruction.command == 'CRITICAL END':
             cs = tables.critical_sections[instruction.value]
             if cs.locked and cs.pid == self.pid:
                 cs.unlock()
                 cs.pid = -1
                 self.has_cs = False
                 self.is_waiting_for_cs = False
                 instruction = advance(instruction_iterator)
                 print(
                     f'----CRITICAL SECTION (id: {cs.id}, pid {self.pid})) END----'
                 )
                 self.lock.wait()
         else:
             print(f'Invalid command: {instruction.command}')
             instruction = advance(instruction_iterator)
             self.lock.wait()
     self.pcb.state = 'DONE'
     self.done = True
     print(f'---{self.pid}: DONE---')
Ejemplo n.º 4
0
def main():
	d=FeildStorage()
	aip.main()
	f=open("aip.txt")
	ip=f.read().split()
	f.close()
	nnip=d.getvalue('nn')
	jtip=d.getvalue('jt')
	count=0
	for i in ip:
		if i==nnip:
			swap(ip[count],ip[0])
		elif i==jtip:
			swap(ip[count],ip[1])
		else:
			pass
		count += 1	
	
	
	config.config(ip[0],ip[1])
	count=0	
	inst=[]
	for i in ip:
		
		t=threading.Thread(target=install,args=(i,))
		inst.append(t)
		t.start()
	for i in inst:
		i.join()
		
		
	
	abc=[]
	
	for i in ip:
		
	
		if count == 0:
			nn(i)
			
		elif count == 1:
			jt(i)
		else:
			t=threading.Thread(target=dntt,args=(i,))
			t.start()
			abc.append(t)
	
		count +=1
	for i in abc:
		i.join()
	
	print "\n\n\t\t\tSETUP COMPLETE"
	print("Namenode is "+ip[0])
	print("Jobtracker is "+ip[1])
	out("clear")
Ejemplo n.º 5
0
def aip(i):
	s=commands.getstatusoutput("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+i+" hadoop version")[0]
	if s==0:
		out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+i+" hadoop-daemon.sh stop jobtracker")
		out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+i+" hadoop-daemon.sh stop namenode")
		out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+i+" hadoop-daemon.sh stop datanode")
		out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+i+" hadoop-daemon.sh stop tasktracker")
		out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+i+" ln -s /usr/java/jdk1.7.0_51/bin/jps /bin/jps")
		#a.acquire()
		f.write(i)
		f.write("\n")
Ejemplo n.º 6
0
def command(timebook, config, at, sheet, **kwargs):
    # get the db
    cfg=parse_config(config)
    db=Database(timebook, cfg)

    timestamp=parse_date_time_or_now(at)

    sheet = sheet or db.get_current_sheet()

    if sheet not in db.get_sheet_names():
        parser.error('%s is not a known timesheet' % sheet)

    out(db, timestamp, sheet)
Ejemplo n.º 7
0
def pig(i):
	
	out("sshpass -p redhat scp pig.tar.gz pig.py root@"+i+":/tmp/")
	out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+i+" tar -xvzf /tmp/pig.tar.gz -C /etc/")
	out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+i+" python /tmp/pig.py")
	
	out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+i+" rm -ivf /pig.py /pig.tar.gz")
Ejemplo n.º 8
0
def nn(i):
		nn=open("nn_ip.txt",w+)
		nn.write(i)
		nn.close()
		out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+i+" rm -rvf /.hadoop")
		out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+i+" rm -rvf /tmp/hadoop-root/dfs/name")
		out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+i+" hadoop namenode -format")
		out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+i+" hadoop-daemon.sh start namenode")
Ejemplo n.º 9
0
def nn(i):
		nn=open("nn_ip.txt",'w+')
		nn.write(i)
		nn.close()
		out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+i+" rm -rvf /.hadoop")
		out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+i+" rm -rvf /tmp/hadoop-root/dfs/name")
		out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+i+" hadoop namenode -format")
		out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+i+" hadoop-daemon.sh start namenode")
Ejemplo n.º 10
0
def hive(i):
    out("sshpass -p redhat scp hive.tar.gz hive.py root@" + i + ":/tmp/")
    out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@" + i +
        " tar -xvzf /tmp/hive.tar.gz -C /etc/")
    out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@" + i +
        " python /tmp/hive.py")
    out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@" + i +
        " rm -ivf /tmp/hive.py /tmp/hive.tar.gz")
Ejemplo n.º 11
0
def pig(i):

    out("sshpass -p redhat scp pig.tar.gz pig.py root@" + i + ":/tmp/")
    out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@" + i +
        " tar -xvzf /tmp/pig.tar.gz -C /etc/")
    out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@" + i +
        " python /tmp/pig.py")

    out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@" + i +
        " rm -ivf /pig.py /pig.tar.gz")
Ejemplo n.º 12
0
def dntt(i):

    out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@" + i +
        " rm -rvf /.hadoop")
    out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@" + i +
        " rm -rvf /tmp/hadoop-root/dfs")
    out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@" + i +
        " hadoop-daemon.sh start datanode")
    out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@" + i +
        " hadoop-daemon.sh start tasktracker")
Ejemplo n.º 13
0
Archivo: aip.py Proyecto: lwwale/Cloop
def aip(i):
    s = commands.getstatusoutput(
        "sshpass -p redhat ssh -o StrictHostKeyChecking=no root@" + i +
        " hadoop version")[0]
    if s == 0:
        out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@" + i +
            " hadoop-daemon.sh stop jobtracker")
        out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@" + i +
            " hadoop-daemon.sh stop namenode")
        out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@" + i +
            " hadoop-daemon.sh stop datanode")
        out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@" + i +
            " hadoop-daemon.sh stop tasktracker")
        out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@" + i +
            " ln -s /usr/java/jdk1.7.0_51/bin/jps /bin/jps")
        #a.acquire()
        f.write(i)
        f.write("\n")
Ejemplo n.º 14
0
def main():
    aip.main()
    f = open("aip.txt")
    ip = f.read().split()
    f.close()
    config.config(ip[0], ip[1])
    count = 0
    inst = []
    for i in ip:

        t = threading.Thread(target=install, args=(i, ))
        inst.append(t)
        t.start()
    for i in inst:
        i.join()
    abc = []

    for i in ip:

        if count == 0:
            nn(i)

        elif count == 1:
            jt(i)
        else:
            t = threading.Thread(target=dntt, args=(i, ))
            t.start()
            abc.append(t)

        count += 1
    for i in abc:
        i.join()

    out("clear")
    print "\n\n\t\t\tSETUP COMPLETE"
    print("Namenode is " + ip[0])
    print("Jobtracker is " + ip[1])
    out("gnome-terminal -x sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"
        + ip[0])
    out("gnome-terminal -x sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"
        + ip[1])
Ejemplo n.º 15
0
def main():
	aip.main()
	f=open("aip.txt")
	ip=f.read().split()
	f.close()
	config.config(ip[0],ip[1])
	count=0	
	inst=[]
	for i in ip:
		
		t=threading.Thread(target=install,args=(i,))
		inst.append(t)
		t.start()
	for i in inst:
		i.join()	
	abc=[]
	
	for i in ip:
		
		
		if count == 0:
			nn(i)
			
		elif count == 1:
			jt(i)
		else:
			t=threading.Thread(target=dntt,args=(i,))
			t.start()
			abc.append(t)
	
		count +=1
	for i in abc:
		i.join()
	
	out("clear")	
	print "\n\n\t\t\tSETUP COMPLETE"
	print("Namenode is "+ip[0])
	print("Jobtracker is "+ip[1])
	out("gnome-terminal -x sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+ip[0])
	out("gnome-terminal -x sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+ip[1])
Ejemplo n.º 16
0
def jt(i):
		jt=open("jt_ip.txt",'w+')
		jt.write(i)
		jt.close()
		out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+i+" hadoop-daemon.sh start jobtracker")
Ejemplo n.º 17
0
def install(i):
		print i
		out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+i+" yum remove  hadoop -y")
		out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+i+" yum install jdk hadoop -y")
Ejemplo n.º 18
0
def dntt(i):
		
		out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+i+" rm -rvf /.hadoop")
		out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+i+" rm -rvf /tmp/hadoop-root/dfs")
		out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+i+" hadoop-daemon.sh start datanode")
		out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+i+" hadoop-daemon.sh start tasktracker")
Ejemplo n.º 19
0
def install(i):
		out("sshpass -p redhat scp core-site.xml root@"+i+":/etc/hadoop")
		out("sshpass -p redhat scp mapred-site.xml root@"+i+":/etc/hadoop")
		out("sshpass -p redhat scp hdfs-site.xml root@"+i+":/etc/hadoop")
Ejemplo n.º 20
0
def jt(i):
    jt = open("jt_ip.txt", 'w+')
    jt.write(i)
    jt.close()
    out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@" + i +
        " hadoop-daemon.sh start jobtracker")
Ejemplo n.º 21
0
def hive(i):
	out("sshpass -p redhat scp hive.tar.gz hive.py root@"+i+":/tmp/")
	out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+i+" tar -xvzf /tmp/hive.tar.gz -C /etc/")
	out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+i+" python /tmp/hive.py")
	out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@"+i+" rm -ivf /tmp/hive.py /tmp/hive.tar.gz")
Ejemplo n.º 22
0
def install(i):
    out("sshpass -p redhat scp core-site.xml root@" + i + ":/etc/hadoop")
    out("sshpass -p redhat scp mapred-site.xml root@" + i + ":/etc/hadoop")
    out("sshpass -p redhat scp hdfs-site.xml root@" + i + ":/etc/hadoop")
Ejemplo n.º 23
0
Archivo: aip.py Proyecto: lwwale/Cloop
def install(i):
    print i
    out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@" + i +
        " yum remove  hadoop -y")
    out("sshpass -p redhat ssh -o StrictHostKeyChecking=no root@" + i +
        " yum install jdk hadoop -y")