通过python-libvirt管理KVM虚拟机源码版本:0.9.13
libvirt库可真是⼤,先看看该版本⾥⾯都有哪些类和⽅法,验证过的⽅法我会⽤O开头,|开头的标⽰还没亲⾃验证过。[python]
1. <span >CLASSES
2. virConnect
3. virDomain
4. virDomainSnapshot
5. virInterface
6. virNWFilter
7. virNetwork
8. virNodeDevice
9. virSecret
10. virStoragePool
11. virStorageVol
12. virStream
13.
14.
15. class virConnect
16. | __del__(self)
17. | __init__(self, _obj=None)
18. | baselineCPU(self, xmlCPUs, flags)
19. | changeBegin(self, flags)
20. | changeCommit(self, flags)
21. | changeRollback(self, flags)
22. | close(self)
23. | compareCPU(self, xmlDesc, flags)
24. | createLinux(self, xmlDesc, flags)
25. | createXML(self, xmlDesc, flags)
26. | defineXML(self, xml)
27. | dispatchDomainEventBlockPullCallback(self, dom, path, type, status, cbData)
28. | domainEventDeregister(self, cb)
29. | domainEventDeregisterAny(self, callbackID)
30. | domainEventRegister(self, cb, opaque)
31. | domainEventRegisterAny(self, dom, eventID, cb, opaque)
32. | domainXMLFromNative(self, nativeFormat, nativeConfig, flags)
33. | domainXMLToNative(self, nativeFormat, domainXml, flags)
34. | findStoragePoolSources(self, type, srcSpec, flags)
35. | getCPUStats(self, cpuNum, flags)
36. o getCapabilities(self)
37. | getCellsFreeMemory(self, startCell, maxCells)
38. o getFreeMemory(self) 6663041024 bytes
39. o getHostname(self) client
40. o getInfo(self) ['x86_64', 7846, 4, 2394, 1, 1, 4, 1]
41. o getLibVersion(self) 9013 ------0.9.13-0ubuntu12.2
42. | getMaxVcpus(self, type) 160----type是xml配置⽂件中domain参数的值
43. | getMemoryStats(self, cellNum, flags)
44. o getSysinfo(self, flags)
45. o getType(self) QEMU
46. o getURI(self) qemu:///system
47. o getVersion(self) 1002000
48. | interfaceDefineXML(self, xml, flags)
49. | interfaceLookupByMACString(self, macstr)
50. | interfaceLookupByName(self, name)
51. o isAlive(self) 1
52. o isEncrypted(self) 0
53. o isSecure(self) 1
54. o listAllDomains(self, flags)
55. o listDefinedDomains(self) ['kvm-t1'] 列出offline的domains
56. o listDefinedInterfaces(self) []
57. o listDefinedNetworks(self) ['default']
58. o listDefinedStoragePools(self) []
59. | listDevices(self, cap, flags)
60. o listDomainsID(self) [2, 3]
61. o listInterfaces(self) ['br0', 'lo']
62. o listNWFilters(self)
63. o listNetworks(self)
64. o listSecrets(self)
65. o listStoragePools(self)
66. o lookupByID(self, id)
67. o lookupByName(self, name)
68. | lookupByUUID(self, uuid)
69. o lookupByUUIDString(self, uuidstr)
70. | migrate(self, domain, flags, dname, uri, bandwidth)
71. | migrate2(self, domain, dxml, flags, dname, uri, bandwidth)
72. | networkCreateXML(self, xmlDesc)
73. | networkDefineXML(self, xml)
74. | networkLookupByName(self, name)
75. | networkLookupByUUID(self, uuid)
76. | networkLookupByUUIDString(self, uuidstr)
77. | newStream(self, flags)
78. | nodeDeviceCreateXML(self, xmlDesc, flags)
79. | nodeDeviceLookupByName(self, name)
80. | numOfDefinedDomains(self)
81. | numOfDefinedInterfaces(self)
82. | numOfDefinedNetworks(self)
83. | numOfDefinedStoragePools(self)
84. | numOfDevices(self, cap, flags)
85. | numOfDomains(self)
86. | numOfInterfaces(self)
87. | numOfNWFilters(self)
88. | numOfNetworks(self)
89. | numOfSecrets(self)
90. | numOfStoragePools(self)
91. | nwfilterDefineXML(self, xmlDesc)
92. | nwfilterLookupByName(self, name)
93. | nwfilterLookupByUUID(self, uuid)
94. | nwfilterLookupByUUIDString(self, uuidstr)
95. | restore(self, frm)
96. | restoreFlags(self, frm, dxml, flags)
97. | saveImageDefineXML(self, file, dxml, flags)
98. | saveImageGetXMLDesc(self, file, flags)
99. | secretDefineXML(self, xml, flags)
100. | secretLookupByUUID(self, uuid)
101. | secretLookupByUUIDString(self, uuidstr)
102. | secretLookupByUsage(self, usageType, usageID)
103. | setKeepAlive(self, interval, count)
104. | storagePoolCreateXML(self, xmlDesc, flags)
105. | storagePoolDefineXML(self, xml, flags)
106. | storagePoolLookupByName(self, name)
107. | storagePoolLookupByUUID(self, uuid)
108. | storagePoolLookupByUUIDString(self, uuidstr)
109. | storageVolLookupByKey(self, key)
110. | storageVolLookupByPath(self, path)
111. | suspendForDuration(self, target, duration, flags)
112. | virConnGetLastError(self)
113. | virConnResetLastError(self)
114.
115. class virDomain
116. o ID(self)
117. 获取domainID
118. o OSType(self)
119. 获取domain的type
120. o UUID(self)
121. 获取domain的UUID
122. o UUIDString(self)
123. 以字符串的形式获取domian的UUID
124. o XMLDesc(self, flags)
125. 提供⼀个描述domian的xml⽂件,该⽂件会在后⾯⽤来relanuch domain
126. | __del__(self)
127. | __init__(self, conn, _obj=None)
128. | abortJob(self)
129. 快速的终⽌在后台运⾏的任务,
130. | attachDevice(self, xml)
131. 创建⼀个虚拟设备,挂载到后端,类似于热插拔技术,只被允许在活跃的domian上⾯132. | attachDeviceFlags(self, xml, flags)
133. 挂载⼀个虚拟设备到domian上⾯,flags标志控制挂载的⽅式。
134. o autostart(self)
135. 获取domian的⾃启动标志
136. | blkioParameters(self, flags)
137. 获取blkio参数
138. | blockInfo(self, path, flags)
139. 获取domian的块设备⼤⼩的信息
140. | blockIoTune(self, disk, flags)
141. | blockJobAbort(self, disk, flags)
142. 取消⼀个活跃的块设备....
143. | blockJobInfo(self, path, flags)
144. 针对⼀个块任务获取process信息
145. | blockJobSetSpeed(self, disk, bandwidth, flags)
146. | blockPeek(self, disk, offset, size, flags)
147. 读取domian的disk设备的内容
148. | blockPull(self, disk, bandwidth, flags)
149. | blockRebase(self, disk, base, bandwidth, flags)
150. | blockResize(self, disk, size, flags)
151. resize⼀个domian的块设备⼤⼩,在domian运⾏时。
152. | blockStats(self, path)
153. 获取⼀个domain的块设备的统计信息
154. | blockStatsFlags(self, path, flags)
155. 在domain运⾏时获取块设备的统计参数
156. o controlInfo(self, flags)
157. 获取⼀个domain控制接⼝的详细信息
158. | coreDump(self, to, flags)
159. o create(self)
160. 创建⼀个domian,如果成功,则会把domian移动到运⾏domian池中。
161. o createWithFlags(self, flags)
162. o destroy(self)
163. o destroyFlags(self, flags)
164. | detachDevice(self, xml)
165. | detachDeviceFlags(self, xml, flags)
166. | diskErrors(self, flags)
167. 获取disk设备的错误信息
168. | getCPUStats(self, total, flags)
169. 获取运⾏domian的cpu的统计信息
170. | hasCurrentSnapshot(self, flags)
171. 决定domian是否做⼀个snapshot
172. | hasManagedSaveImage(self, flags)
173. o info(self) [1, 2097152L, 2097152L, 1, 459250000000L]
174. 获取⼀个domian的信息
175. | injectNMI(self, flags)
176. | interfaceParameters(self, device, flags)
177. 获取接⼝设备的带宽
178. o interfaceStats(self, path) (119092654L, 1179917L, 0L, 0L, 723682L, 9669L, 0L, 0L)---interfaceStats('vnet0') vnet0通过XMLDesc获取
179. 获取⼀个domian的接⼝设备的统计信息
180. o isActive(self)
181. 判断⼀个domian是否在运⾏
182. o isPersistent(self)
183. 判断⼀个domian是否和配置⽂件是强联系的,也就是在shutdown之后他仍旧存在
184. o isUpdated(self)
185. o jobInfo(self) [0, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L]
186. o listAllSnapshots(self, flags)
187. 列出所有的快照
188. | managedSave(self, flags)
189. 该函数会suspend⼀个domian并且保存他在内存中的东西到磁盘上。
190. | managedSaveRemove(self, flags)
191. o maxMemory(self)
192. 检索分配给该domian的最⼤物理内存
193. o maxVcpus(self)
194. 给guest vm提供的最⼤vcpu数⽬
195. o memoryParameters(self, flags) {'swap_hard_limit': 9007199254740991L, 'hard_limit': 9007199254740991L, 'soft_limit': 9007199254740991L} 196. 获取内存参数
197. | memoryPeek(self, start, size, flags)
198. 读取domain的内存中的数据
199. o memoryStats(self) {'actual': 2097152L, 'rss': 375248L}
200. 获取⼀个domain的内存统计信息
201. | metadata(self, type, uri, flags)
202. | migrate(self, dconn, flags, dname, uri, bandwidth)
203. 迁移⼀个domian从⼀台host到另⼀台host
204. | migrate2(self, dconn, dxml, flags, dname, uri, bandwidth)
205. | migrateGetMaxSpeed(self, flags)
206. 获取⼀个domian当前配置的最⼤迁移速度
207. | migrateSetMaxDowntime(self, downtime, flags)
208. | migrateSetMaxSpeed(self, bandwidth, flags)
209. | migrateToURI(self, duri, flags, dname, bandwidth)
210. | migrateToURI2(self, dconnuri, miguri, dxml, flags, dname, bandwidth)
211. o name(self)
212. 获取⼀个domian的公共名称
213. | numaParameters(self, flags)
214. 获取NUMA参数
215. | openConsole(self, dev_name, st, flags)
216. | openGraphics(self, idx, fd, flags)
217. | pMSuspendForDuration(self, target, duration, flags)
218. | pMWakeup(self, flags)
219. | pinVcpu(self, vcpu, cpumap)
220. | pinVcpuFlags(self, vcpu, cpumap, flags)
221. o reboot(self, flags)
222. reboot⼀个domian
223. o reset(self, flags)
224. ⽴即reset⼀个domian
225. o resume(self)
226. | revertToSnapshot(self, snap, flags)
227. o save(self, to)
228. | saveFlags(self, to, dxml, flags)
229. o schedulerParameters(self) {'vcpu_quota': -1L, 'vcpu_period': 100000L, 'cpu_shares': 1024L} 230. 获取调度参数
231. o schedulerParametersFlags(self, flags)
232. o schedulerType(self)
233. 获取调度类型
234. | screenshot(self, stream, screen, flags)
235. | sendKey(self, codeset, holdtime, keycodes, nkeycodes, flags)
236. o setAutostart(self, autostart)
237. 配置domian是否在宿主机启动后⾃启动
238. | setBlkioParameters(self, params, flags)
239. | setBlockIoTune(self, disk, params, flags)
240. | setInterfaceParameters(self, device, params, flags)
241. | setMaxMemory(self, memory)
242. 动态改变⼀个domian的最⼤物理内存
243. o setMemory(self, memory)
244. 动态改变分配给⼀个domian的物理内存
245. o setMemoryFlags(self, memory, flags)
246. | setMemoryParameters(self, params, flags)
247. | setMetadata(self, type, metadata, key, uri, flags)
248. | setNumaParameters(self, params, flags)
249. | setSchedulerParameters(self, params)
250. | setSchedulerParametersFlags(self, params, flags)
251. | setVcpus(self, nvcpus)
252. 动态改变⼀个domian的vcpus
253. | setVcpusFlags(self, nvcpus, flags)
254. o shutdown(self)
255. 关闭⼀个domian
256. o shutdownFlags(self, flags)
257. | snapshotCreateXML(self, xmlDesc, flags)
258. | snapshotCurrent(self, flags)
259. | snapshotListNames(self, flags)
260. | snapshotLookupByName(self, name, flags)
261. | snapshotNum(self, flags)
262. o state(self, flags)
263. 检查⼀个domian的状态
264. o suspend(self)
265. suspends⼀个活跃的domian
266. o undefine(self)
267. undefine⼀个domian
268. o undefineFlags(self, flags)
269. | updateDeviceFlags(self, xml, flags)
270. o vcpuPinInfo(self, flags)
271. 获取cpu到vcpu的亲和性
272. o vcpus(self)
273. 获取vcpus的信息
274. | vcpusFlags(self, flags)
275. 查询⼀个domian使⽤了多少个vcpus
276.
277. class virDomainSnapshot
278. | __del__(self)
279. | __init__(self, dom, _obj=None)
280. | delete(self, flags)
281. 删除⼀个快照
282. | domain(self)
283. | getConnect(self)
284. | getDomain(self)
285. | getName(self)
286. | getParent(self, flags)
287. | getXMLDesc(self, flags)
288. 提供⼀个描述domian snapshot的xml⽂件
289. | hasMetadata(self, flags)
290. | isCurrent(self, flags)
291. | listAllChildren(self, flags)
292. | listChildrenNames(self, flags)
293. | numChildren(self, flags)
294. | ref(self)
295.
296.
297. class virInterface
298. | MACString(self)
299. | XMLDesc(self, flags)
300. | __del__(self)
301. | __init__(self, conn, _obj=None)
302. | connect(self)
303. | create(self, flags)
304. | destroy(self, flags)
305. | isActive(self)
306. | name(self)
307. | undefine(self)
308.
309.
310. class virNWFilter
311. | UUID(self)
312. | UUIDString(self)
313. | XMLDesc(self, flags)
314. | __del__(self)
315. | __init__(self, conn, _obj=None)
316. | connect(self)
317. | name(self)
318. | undefine(self)
319. class virNetwork
320. | UUID(self)
321. | UUIDString(self)
322. | XMLDesc(self, flags)
323. | __del__(self)
324. | __init__(self, conn, _obj=None)
325. | autostart(self)
326. | bridgeName(self)
327. | connect(self)
328. | create(self)
329. | destroy(self)
330. | isActive(self)
331. | isPersistent(self)
332. | name(self)
333. | setAutostart(self, autostart)
334. | undefine(self)python处理xml文件
335. class virNodeDevice
336. | XMLDesc(self, flags)
337. 获取描述device各个⽅⾯信息的xml⽂件
338. | __del__(self)
339. | __init__(self, conn, _obj=None)
340. | connect(self)
341. | destroy(self)
342. 破坏device对象,虚拟device会在host的系统中被移除343. | dettach(self)
344. | listCaps(self)
345. 列出node设备的能⼒
346. | name(self)
347. 返回device的名称
348. | numOfCaps(self)
349. | parent(self)
350. | reAttach(self)
351. | reset(self)
352. class virSecret
353. | UUID(self)
354. 获取⼀个secret的UUID
355. | UUIDString(self)
356. 以字符串的形式获取⼀个secret的UUID
357. | XMLDesc(self, flags)
358. 获取⼀个描述secret的xml⽂件
359. | __del__(self)
360. | __init__(self, conn, _obj=None)
361. | connect(self)
362. | setValue(self, value, flags)
363. 使⽤secret联合⼀个值
364. | undefine(self)
365. 删除⼀个特定的secret
366. | usageID(self)
367. | usageType(self)
368. | value(self, flags)
369. 使⽤secret获取联合的值
370. class virStoragePool
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论