{"id":2785,"date":"2015-10-28T14:04:11","date_gmt":"2015-10-28T06:04:11","guid":{"rendered":"https:\/\/drho.club\/?p=390"},"modified":"2015-10-28T14:04:11","modified_gmt":"2015-10-28T06:04:11","slug":"python-libvirt-listalldomains","status":"publish","type":"post","link":"https:\/\/104.es\/index.php\/2015\/10\/28\/python-libvirt-listalldomains\/","title":{"rendered":"Python-libvirt\u597d\u7528\u7684 listAllDomains"},"content":{"rendered":"<p style=\"font-family: \u5fae\u8edf\u6b63\u9ed1\u9ad4; font-size: 12pt; line-height: 200%; letter-spacing: 2pt;\">\u4f7f\u7528Python-libvirt\u51fd\u5f0f\u5eab\u4f86\u64cd\u4f5c\u865b\u64ec\u6a5f\uff0c\u4e3b\u8981\u7684\u6b65\u9a5f\u662f\u5148\u53d6\u5f97\u548cNode\u4e0a\u7684libvirtd\u9023\u7dda\uff0c\u7136\u5f8c\u518d\u900f\u904elistAllDomains\u627e\u51fa\u6240\u6709\u5728\u8a72Node\u4e0a\u6240\u6709\u7684Domain\u4e26\u5132\u653e\u5728\u4e32\u5217\u8b8a\u6578\u4e2d\uff0c\u9019\u6a23\u5b50\u5c31\u53ef\u4ee5\u81ea\u7531\u5730\u64cd\u4f5c\u4ee5\u53ca\u67e5\u8a62\u8a72Node\u4e0a\u7684Domain\u4e86\u3002\u4ee5\u4e0b\u662f\u7a0b\u5f0f\u7247\u6bb5\uff1a<\/p>\n<p>[code]<br \/>\n#!\/usr\/bin\/python<br \/>\nimport sys, libvirt<br \/>\nconn = libvirt.open(&quot;qemu:\/\/\/system&quot;)<br \/>\ndomains = conn.listAllDomains()<br \/>\n[\/code]<\/p>\n<p style=\"font-family: \u5fae\u8edf\u6b63\u9ed1\u9ad4; font-size: 12pt; line-height: 200%; letter-spacing: 2pt;\">\u4e0a\u8ff0\u7a0b\u5f0f\u78bc\u57f7\u884c\u4e4b\u5f8c\uff0c\u672c\u6a5f\u6240\u6709\u7684Domain\uff08\u865b\u64ec\u6a5f\uff09\u5c31\u90fd\u88ab\u653e\u5728domains\u4e2d\u4e86\uff0c\u5176\u4e2ddomains[0]\u662f\u7b2c\u4e00\u53f0\uff0cdomains[1] \u662f\u7b2c\u4e8c\u53f0\uff0c\u4f9d\u6b64\u985e\u63a8\u3002<\/p>\n<p style=\"font-family: \u5fae\u8edf\u6b63\u9ed1\u9ad4; font-size: 12pt; line-height: 200%; letter-spacing: 2pt;\">listAllDomains()\u9810\u8a2d\u662f\u627e\u51fa\u6240\u6709\u7684Domain\uff0c\u5982\u679c\u6211\u5011\u60f3\u8981\u6aa2\u67e5\u7684\u662f\u67d0\u4e9b\u7279\u5b9a\u985e\u578b\u4e5f\u6c92\u554f\u984c\uff0c\u53ea\u8981\u628a\u65d7\u6a19\u503c\u50b3\u9032\u53bb\u5c31\u53ef\u4ee5\u4e86\u3002\u6240\u6709\u53ef\u4ee5\u7528\u7684\u65d7\u6a19\u5982\u4e0b\uff1a<\/p>\n<table class=\"simplelist\" border=\"0\" summary=\"Simple list\">\n<tbody>\n<tr>\n<td>VIR_CONNECT_LIST_DOMAINS_ACTIVE<\/td>\n<\/tr>\n<tr>\n<td>VIR_CONNECT_LIST_DOMAINS_INACTIVE<\/td>\n<\/tr>\n<tr>\n<td>VIR_CONNECT_LIST_DOMAINS_PERSISTENT<\/td>\n<\/tr>\n<tr>\n<td>VIR_CONNECT_LIST_DOMAINS_TRANSIENT<\/td>\n<\/tr>\n<tr>\n<td>VIR_CONNECT_LIST_DOMAINS_RUNNING<\/td>\n<\/tr>\n<tr>\n<td>VIR_CONNECT_LIST_DOMAINS_PAUSED<\/td>\n<\/tr>\n<tr>\n<td>VIR_CONNECT_LIST_DOMAINS_SHUTOFF<\/td>\n<\/tr>\n<tr>\n<td>VIR_CONNECT_LIST_DOMAINS_OTHER<\/td>\n<\/tr>\n<tr>\n<td>VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE<\/td>\n<\/tr>\n<tr>\n<td>VIR_CONNECT_LIST_DOMAINS_NO_MANAGEDSAVE<\/td>\n<\/tr>\n<tr>\n<td>VIR_CONNECT_LIST_DOMAINS_AUTOSTART<\/td>\n<\/tr>\n<tr>\n<td>VIR_CONNECT_LIST_DOMAINS_NO_AUTOSTART<\/td>\n<\/tr>\n<tr>\n<td>VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT<\/td>\n<\/tr>\n<tr>\n<td>VIR_CONNECT_LIST_DOMAINS_NO_SNAPSHOT<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"font-family: \u5fae\u8edf\u6b63\u9ed1\u9ad4; font-size: 12pt; line-height: 200%; letter-spacing: 2pt;\">\u5728\u4f7f\u7528\u4e4b\u524d\uff0c\u8a18\u5f97\u8981\u52a0\u4e0alibvirt\uff0c\u4f8b\u5982\u4ee5\u4e0b\u7684\u7a0b\u5f0f\u7247\u6bb5\u662f\u8981\u627e\u51fa\u6240\u6709\u66ab\u505c\u4e2d\u7684Domain\uff1a<\/p>\n<p>[code]<br \/>\n#!\/usr\/bin\/python<br \/>\nimport sys, libvirt<br \/>\nconn = libvirt.open(&quot;qemu:\/\/\/system&quot;)<br \/>\npaused_domains = conn.listAllDomains(libvirt.VIR_CONNECT_LIST_DOMAINS_PAUSED)<br \/>\n[\/code]<\/p>\n<p style=\"font-family: \u5fae\u8edf\u6b63\u9ed1\u9ad4; font-size: 12pt; line-height: 200%; letter-spacing: 2pt;\">\n<p style=\"font-family: \u5fae\u8edf\u6b63\u9ed1\u9ad4; font-size: 12pt; line-height: 200%; letter-spacing: 2pt;\">\u6709\u4e86\u9019\u4e9b\u65d7\u6a19\u7684\u5354\u52a9\uff0c\u8981\u64cd\u4f5c\u67d0\u4e9b\u7279\u5b9a\u7684\u865b\u64ec\u6a5f\uff08\u4f8b\u5982\u628a\u6240\u6709\u66ab\u505c\u4e2d\u7684\u865b\u64ec\u6a5f\u5168\u90e8\u6062\u5fa9\u57f7\u884c\uff0c\u6216\u662f\u5217\u51fa\u6240\u6709\u9084\u6c92\u6709SNAPSHOT\u7684\u865b\u64ec\u6a5f\uff0c\u662f\u4e0d\u662f\u5c31\u66f4\u5bb9\u6613\u4e86\u5462\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528Python-libvirt\u51fd\u5f0f\u5eab\u4f86\u64cd\u4f5c\u865b\u64ec\u6a5f\uff0c\u4e3b\u8981\u7684\u6b65\u9a5f\u662f\u5148\u53d6\u5f97\u548cNode\u4e0a\u7684libvirtd\u9023\u7dda\uff0c\u7136\u5f8c\u518d\u900f\u904elistAllDomains\u627e\u51fa\u6240\u6709\u5728\u8a72Node\u4e0a\u6240\u6709\u7684Domain\u4e26\u5132\u653e\u5728\u4e32\u5217\u8b8a\u6578\u4e2d\uff0c\u9019\u6a23\u5b50\u5c31\u53ef\u4ee5\u81ea\u7531\u5730\u64cd\u4f5c\u4ee5\u53ca\u67e5\u8a62\u8a72Node\u4e0a\u7684Domain\u4e86\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[97,15],"tags":[144,166,167],"class_list":["post-2785","post","type-post","status-publish","format-standard","hentry","category-kvm-libvirt","category-python","tag-listalldomains","tag-python-libivrt-api","tag-python-libvirt"],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/2785","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/comments?post=2785"}],"version-history":[{"count":0,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/2785\/revisions"}],"wp:attachment":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/media?parent=2785"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/categories?post=2785"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/tags?post=2785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}