Python libvirt domain api

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 20:28   1744   0
在libvirt中一个domain的含义相当于一个虚拟机,包含了很多关于虚拟机的操作。下面几行代码写出了获取一个虚拟机domain的步骤:
[python] view plain copy
import libvirt  
import pprint  
  
conn_004 = libvirt.open('qemu+tcp://username@server004/system')  
vm_domain = conn_004.lookupByName('instance_name')  
pprint.pprint(dir(vm_domain))  

下面是程序输出的结果,即vm_domain包含的接口或属性,要查看具体某个方法,可以使用pprint.pprint(help(vm_domain.method_name))打印。

['ID',
'OSType',
'UUID',
'UUIDString',
'XMLDesc',
'__class__',
'__del__',
'__delattr__',
'__dict__',
'__doc__',
'__format__',
'__getattribute__',
'__hash__',
'__init__',
'__module__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__setattr__',
'__sizeof__',
'__str__',
'__subclasshook__',
'__weakref__',
'_conn',
'_o',
'abortJob',
'attachDevice',
'attachDeviceFlags',
'autostart',
'blkioParameters',
'blockCommit',
'blockCopy',
'blockInfo',
'blockIoTune',
'blockJobAbort',
'blockJobInfo',
'blockJobSetSpeed',
'blockPeek',
'blockPull',
'blockRebase',
'blockResize',
'blockStats',
'blockStatsFlags',
'connect',
'controlInfo',
'coreDump',
'coreDumpWithFormat',
'create',
'createWithFiles',
'createWithFlags',
'destroy',
'destroyFlags',
'detachDevice',
'detachDeviceFlags',
'diskErrors',
'emulatorPinInfo',
'fSTrim',
'fsFreeze',
'fsThaw',
'getCPUStats',
'getTime',
'hasCurrentSnapshot',
'hasManagedSaveImage',
'hostname',
'info',
'injectNMI',
'interfaceParameters',
'interfaceStats',
'isActive',
'isPersistent',
'isUpdated',
'jobInfo',
'jobStats',
'listAllSnapshots',
'managedSave',
'managedSaveRemove',
'maxMemory',
'maxVcpus',
'memoryParameters',
'memoryPeek',
'memoryStats',
'metadata',
'migrate',
'migrate2',
'migrate3',
'migrateGetCompressionCache',
'migrateGetMaxSpeed',
'migrateSetCompressionCache',
'migrateSetMaxDowntime',
'migrateSetMaxSpeed',
'migrateToURI',
'migrateToURI2',
'migrateToURI3',
'name',
'numaParameters',
'openChannel',
'openConsole',
'openGraphics',
'openGraphicsFD',
'pMSuspendForDuration',
'pMWakeup',
'pinEmulator',
'pinVcpu',
'pinVcpuFlags',
'reboot',
'reset',
'resume',
'revertToSnapshot',
'save',
'saveFlags',
'schedulerParameters',
'schedulerParametersFlags',
'schedulerType',
'screenshot',
'securityLabel',
'securityLabelList',
'sendKey',
'sendProcessSignal',
'setAutostart',
'setBlkioParameters',
'setBlockIoTune',
'setInterfaceParameters',
'setMaxMemory',
'setMemory',
'setMemoryFlags',
'setMemoryParameters',
'setMemoryStatsPeriod',
'setMetadata',
'setNumaParameters',
'setSchedulerParameters',
'setSchedulerParametersFlags',
'setTime',
'setVcpus',
'setVcpusFlags',
'shutdown',
'shutdownFlags',
'snapshotCreateXML',
'snapshotCurrent',
'snapshotListNames',
'snapshotLookupByName',
'snapshotNum',
'state',
'suspend',
'undefine',
'undefineFlags',
'updateDeviceFlags',
'vcpuPinInfo',
'vcpus',
'vcpusFlags']

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP