def importVm(): req = ImportVmTempReq() req.name = "impor" req.location = "urn:sites:4D9D0815:clusters:79" opt = OsOption() opt.osType = "Linux" opt.osVersion = 99 req.osOptions = dict(opt) config = VmConfig() cpu = CPU() cpu.quantity = 1 cpu.coresPerSocket = 1 config.cpu = dict(cpu) mem = Memory() mem.quantityMB = 128 config.memory = dict(mem) di = Disk() di.quantityGB = 1 di.sequenceNum = 1 di.datastoreUrn = "urn:sites:4D9D0815:datastores:1" di.isDataCopy = True di.volType = 0 config.disks = [dict(di)] req.vmConfig = dict(config) req.url = "//1.1.1.1/z/x.ova" req.protocol = "cifs" req.autoBoot = False bbb = resorce.importVm("/service/sites/4D9D0815", dict(req)) return bbb
def exportVm(): req = ExportVmTempReq() req.name = "zxc" req.format = "ovf" req.username = "******" req.password = "******" req.isOverwrite = True req.url = "//172.24.0.232/Share/zxc" req.protocol = "cifs" config = VmConfig() cpu = CPU() cpu.quantity = 1 cpu.coresPerSocket = 1 cpu.cpuHotPlug = 0 cpu.limit = 0 cpu.weight = 1000; config.cpu = dict(cpu) mem = Memory() mem.quantityMB = 128 mem.reservation = 0 mem.weight = 1280 config.memory = dict(mem) pp = Property(); pp.isAutoUpgrade = True; pp.isEnableMemVol = True; pp.isEnableHa = False; pp.vmFaultProcess = "notprocess"; pp.attachType = False; pp.clockMode = "freeClock"; config.properties = dict(pp) di = Disk() di.quantityGB = 1 di.sequenceNum = 1 di.datastoreUrn = "urn:sites:4D9D0815:datastores:1" di.isDataCopy = True di.volType = 0 config.disks = [dict(di)] nic = Nic(); nic.sequenceNum = 1; nic.portGroupUrn = "urn:sites:4D9D0815:dvswitchs:1:portgroups:1"; nic.virtIo = 0; config.nics = [dict(nic)] gpu = GPU() gpu.gpuUrn = "SDGSDGSDG" config.gpu = [dict(gpu)] usb = Usb(); usbDevice = UsbDevice(); usbDevice .usbUrn = [dict(usb)] config.usb = [dict(usb)] req.vmConfig = dict(config) bbb = resorce.exportVm("/service/sites/4D9D0815/vms/i-00000278", dict(req)) return bbb
def createVm(): req = CreateVmReq() req.name = "createTest" req.location = "urn:sites:4D9D0815:clusters:79" req.group = "FC_test" opt = OsOption() opt.osType = "Linux" opt.osVersion = 99 req.osOptions = dict(opt) config = VmConfig() cpu = CPU() cpu.quantity = 1 cpu.coresPerSocket = 1 config.cpu = dict(cpu) mem = Memory() mem.quantityMB = 128 config.memory = dict(mem) disk1 = Disk() disk1.datastoreUrn = "urn:sites:4D9D0815:datastores:1" disk1.sequenceNum = 2 disk1.quantityGB = 1 disk1.type = "share" disk2 = Disk() disk2.datastoreUrn = "urn:sites:4D9D0815:datastores:1" disk2.sequenceNum = 3 disk2.quantityGB = 1 disk2.type = "share" config.disks = [dict(disk1), dict(disk2)] req.vmConfig = dict(config) bbb = resorce.createVm("/service/sites/4D9D0815", dict(req)) return bbb