def detachVolume(vm_id, vol_id): ''' Author : LHearen E-mail : [email protected] Time : 2016-01-07 16:27 Description : Detach a disk specified by mounted target from a VM; ''' vol = VBDHelper.retrieveVolume({"_id": vol_id}) target = vol["target"] try: vm = conn.lookupByUUIDString(vm_id) except Exception, e: logNotFound("VM", vm_id, e) return None
def attachVolume(vm_id, vol_id, target, driver='qemu', driverType='qcow2'): ''' Author : LHearen E-mail : [email protected] Time : 2016-01-07 10:54 Description : Attaching a volume to a VM; ''' vol = VBDHelper.retrieveVolume({"_id": vol_id}) volName = vol["volName"] poolName = vol["poolName"] try: pool = conn.storagePoolLookupByName(poolName) except Exception, e: logNotFound("Pool", poolName, e) return None
def deleteVolume(_id): ''' Author : LHearen E-mail : [email protected] Time : 2015-12-30 10 : 31 Description : Used to delete a volume in a specified pool; ''' vol = VBDHelper.retrieveVolume({"_id": _id}) poolName = vol["poolName"] volName = vol["volName"] try: pool = conn.storagePoolLookupByName(poolName) except libvirtError, e: logNotFound("Pool", poolName, e) return None