Exemplo n.º 1
0
def Migrate(VMIPAddress,CPUMEMFlag):
 VMName = getVMName(VMIPAddress)
 VMHostIP=getVMHostIP(VMIPAddress)
 getDataCmd= "sh /home/node4_a1/DC/VMDominfo.sh " + VMName + " " + VMHostIP
 outputreceived=subprocess.check_output(getDataCmd,shell=True)
 out_text = outputreceived.decode('utf-8')
 print("data received" + str(out_text))
 data=str(out_text).split("|")
 targetHostIP =getTargetHost(float(data[1]),17,float(data[0]),CPUMEMFlag)
 print(targetHostIP) 

 if((targetHostIP!="") and (targetHostIP.strip() != VMHostIP.strip())) :
 	migrateCmd= "sh /home/node4_a1/migratevm.sh "+ VMName.strip() + " " + VMHostIP.strip() + " " + targetHostIP.strip()
 	statusreceived=subprocess.check_output(migrateCmd,shell=True)
 	out_text = statusreceived.decode('utf-8')
	print("output" + str(out_text).strip())
	if((str(out_text).strip())=="0"):
	    ReplaceVMInfoFile(VMIPAddress,targetHostIP.strip(),VMHostIP.strip())
            DeleteFromFile(VMIPAddress.strip(),"/home/node4_a1/MigrationExclusion.txt")
        else:
            DeleteFromFile(VMIPAddress.strip(),"/home/node4_a1/MigrationExclusion.txt")
 else:
  	DeleteFromFile(VMIPAddress.strip(),"/home/node4_a1/MigrationExclusion.txt")
Exemplo n.º 2
0
    vmID=sys.argv[6];
    numberofArguments= len(sys.argv);
    vmbaseImagePath="";
    if(numberofArguments > 7): 
      vmbaseImagePath=sys.argv[7];

    if str(vmbaseImagePath) !="":
      baseImagePath =vmbaseImagePath
    else:
      baseImagePath="/home/node4_a1/baseImg.qcow2"

    
    guestConfigurationPath="/home/node4_a1/Config_WithTokens.xml"

    targetHostIP=getTargetHost(userMemory,userIO,userCPU,"CPU")

    

    if str(targetHostIP) != "":

        createCmd = "sh /home/node4_a1/createvm.sh " + vmName + " " +  vmID + " " + userMemory + " " + userCPU + " " + baseImagePath + " " + guestConfigurationPath + " " + targetHostIP
        subprocess.check_call(createCmd,shell=True)

        time.sleep(80)

        IPaddr="ssh root@"+ str(targetHostIP) +" sh /home/node4_a1/RetrieveIP.sh " + vmName

        iprecieved=subprocess.check_output(IPaddr,shell=True)

        out_text = iprecieved.decode('utf-8')