コード例 #1
0
ファイル: virtauto.py プロジェクト: zhiqian1027/kvm_vm_setup
def vm_ct():
    """ split vm info and assign to vm object;
    and create vm inst """
    global vmarray, vminfo
    global vminicouter
    global vg
    global vmurl
    j = 0
    vminfo = range(vminicouter)
    print "vm config info is:"
    while j < vminicouter:
        #print vmarray[j],j
        #vminfo[j]=vmarray[j].split
        a = vmarray[j]
        vminfo = string.split(a, ",")
        colpt.ptred("vm " + str(j) + " info")
        colpt.ptyellow(str(vminfo))
        vmtmp = classvm.vm()
        ifvg = vminfo[0]
        if (ifvg.find("Lvm") > 0):
            vmtmp.vgname = "vg"
        elif (ifvg.find("CpOnly") > 0):
            vmtmp.vgname = "cp"
        else:
            vmtmp.vgname = "none"
        vmtmp.temp = vminfo[1]
        c = syncTemp.checkTempFile(vmtmp.temp, vmurl1, vmurl2)
        print str(c) + " is check vm iamges error status"
        if (c != 0):
            colpt.ptred(" vm images errors Please check!!!")
            sys.exit(5)
        colpt.ptgreen(" vm images check is ok!")
        vmtmp.name = vminfo[2]
        vmtmp.define_vda_vdb()
        vmtmp.disk1_size = vminfo[3]
        vmtmp.disk2_size = vminfo[4]
        vmtmp.mem = vminfo[5]
        vmtmp.cpu = vminfo[6]
        vmtmp.out_type = vminfo[7]
        vmtmp.out_bridge = vminfo[8]
        vmtmp.in_bridge = vminfo[9]
        vmtmp.vnc_port = vminfo[10]
        vmtmp.outip = vminfo[11]
        vmtmp.outmask = vminfo[12]
        vmtmp.outgw = vminfo[13]
        vmtmp.in_type = vminfo[7]
        vmtmp.inip = vminfo[14]
        vmtmp.inmask = vminfo[15]
        vmtmp.ingw = vminfo[16]
        if vmtmp.vm_xmlfile_exist() == "1":
            colpt.ptred("xml or vda vdb file exist skip vm create!")
        elif vmtmp.vm_host_exist() == "1":
            colpt.ptred("vm allready exist skip vm create!")
        else:
            vmtmp.vm_os_check()
            if (vmtmp.vgname == "none"):
                vmtmp.vm_resize_disk1()
                vmtmp.vm_resize_disk2()
            elif (vmtmp.vgname == "cp"):
                vmtmp.vm_cp_disk1()
                vmtmp.vm_resize_disk2()
            elif (vmtmp.vgname == "vg"):
                vmtmp.vm_lvm_disk1()
                vmtmp.vm_lvm_disk2()
            vmtmp.vm_xmlfile_create2()
            vmtmp.vm_nicinfo_create()
            vmtmp.vm_nicinfo_copy_in()
            if vmtmp.vm_define() == "1":
                colpt.ptred("define failed skip vm create!")
            else:
                vmtmp.vm_run()
                vmtmp.vm_autostart()
        j = j + 1
コード例 #2
0
ファイル: v1.py プロジェクト: longxintaiye/kvm_vm_setup
import os
import sys
import string

mycwd = os.getcwd()
modcwd = mycwd + "/virtmod"
sys.path.append(modcwd)
modcwd = mycwd + "/virtclass"
sys.path.append(modcwd)
import colpt
import classvm
import syncTemp

global vmarray, vminfo
global vminicouter

syncTemp.checkTempFile("win2008ent64chs")
コード例 #3
0
ファイル: virtauto.py プロジェクト: cathywife/kvm_vm_setup
def vm_ct():
    """ split vm info and assign to vm object;
    and create vm inst """
    global vmarray, vminfo
    global vminicouter
    global vg
    global vmurl
    j=0
    vminfo=range(vminicouter)
    print "vm config info is:"
    while j < vminicouter:
         #print vmarray[j],j
         #vminfo[j]=vmarray[j].split
         a=vmarray[j]
         vminfo=string.split(a,",")
         colpt.ptred("vm "+str(j)+" info")
         colpt.ptyellow(str(vminfo))
         vmtmp=classvm.vm()
         ifvg=vminfo[0]
         if (ifvg.find("Lvm")>0):
             vmtmp.vgname="vg"
         elif (ifvg.find("CpOnly")>0):
             vmtmp.vgname="cp"
         else:
             vmtmp.vgname="none"
         vmtmp.temp=vminfo[1]
         c=syncTemp.checkTempFile(vmtmp.temp,vmurl1,vmurl2)
         print str(c)+" is check vm iamges error status"
         if (c != 0 ):
             colpt.ptred(" vm images errors Please check!!!")
             sys.exit(5)
         colpt.ptgreen(" vm images check is ok!")
         vmtmp.name=vminfo[2]
         vmtmp.define_vda_vdb()
         vmtmp.disk1_size=vminfo[3]
         vmtmp.disk2_size=vminfo[4]
         vmtmp.mem=vminfo[5]
         vmtmp.cpu=vminfo[6]
         vmtmp.out_type=vminfo[7]
         vmtmp.out_bridge=vminfo[8]
         vmtmp.in_bridge=vminfo[9]
         vmtmp.vnc_port=vminfo[10]
         vmtmp.outip=vminfo[11]
         vmtmp.outmask=vminfo[12]
         vmtmp.outgw=vminfo[13]
         vmtmp.in_type=vminfo[7]
         vmtmp.inip=vminfo[14]
         vmtmp.inmask=vminfo[15]
         vmtmp.ingw=vminfo[16]
         if vmtmp.vm_xmlfile_exist()=="1":
            colpt.ptred("xml or vda vdb file exist skip vm create!")
         elif vmtmp.vm_host_exist()=="1":
            colpt.ptred("vm allready exist skip vm create!")
         else:
            vmtmp.vm_os_check()
            if (vmtmp.vgname=="none"):
                vmtmp.vm_resize_disk1()
                vmtmp.vm_resize_disk2()
            elif (vmtmp.vgname=="cp"):
                vmtmp.vm_cp_disk1()
                vmtmp.vm_resize_disk2()
            elif (vmtmp.vgname=="vg"):
                vmtmp.vm_lvm_disk1()
                vmtmp.vm_lvm_disk2()
            vmtmp.vm_xmlfile_create2()
            vmtmp.vm_nicinfo_create()
            vmtmp.vm_nicinfo_copy_in()
            if vmtmp.vm_define()=="1":
                colpt.ptred("define failed skip vm create!")
            else:
                vmtmp.vm_run()
                vmtmp.vm_autostart()
         j=j+1
コード例 #4
0
ファイル: v1.py プロジェクト: zhiqian1027/kvm_vm_setup
import os
import sys
import string
mycwd=os.getcwd()
modcwd=mycwd+'/virtmod'
sys.path.append(modcwd)
modcwd=mycwd+'/virtclass'
sys.path.append(modcwd)
import colpt
import classvm
import syncTemp

global vmarray, vminfo
global vminicouter

syncTemp.checkTempFile("win2008ent64chs")