| 88 | |
| 89 | |
| 90 | def virshlist(states): |
| 91 | libvirt_states={ 'running': libvirt.VIR_DOMAIN_RUNNING, |
| 92 | 'shutoff': libvirt.VIR_DOMAIN_SHUTOFF, |
| 93 | 'shutdown': libvirt.VIR_DOMAIN_SHUTDOWN, |
| 94 | 'paused': libvirt.VIR_DOMAIN_PAUSED, |
| 95 | 'nostate': libvirt.VIR_DOMAIN_NOSTATE, |
| 96 | 'blocked': libvirt.VIR_DOMAIN_BLOCKED, |
| 97 | 'crashed': libvirt.VIR_DOMAIN_CRASHED, |
| 98 | } |
| 99 | |
| 100 | searchstates = list(libvirt_states[state] for state in states) |
| 101 | |
| 102 | conn = get_libvirt_connection() |
| 103 | |
| 104 | alldomains = [domain for domain in map(conn.lookupByID, conn.listDomainsID())] |
| 105 | alldomains += [domain for domain in map(conn.lookupByName, conn.listDefinedDomains())] |
| 106 | |
| 107 | domains = [] |
| 108 | for domain in alldomains: |
| 109 | if domain.info()[0] in searchstates: |
| 110 | domains.append(domain.name()) |
| 111 | |
| 112 | conn.close() |
| 113 | |
| 114 | return domains |
| 115 | |
| 116 | |
| 117 | def virshdumpxml(domain): |