Product SiteDocumentation Site

5.6. Pool configuration

There are a number of methods which can configure aspects of a storage pool. The main method is the setAutostart method.

Example 5.6. Demonstrate the setAutostart method

# Example-6.py
#!/usr/bin/env python3
import sys
import libvirt

poolName = 'default'

conn = None
try:
    conn = libvirt.open("qemu:///system")
except libvirt.libvirtError as e:
    print(repr(e), file=sys.stderr)
    exit(1)

sp = conn.storagePoolLookupByName(poolName)
if sp == None:
    print('Failed to find storage pool '+poolName, file=sys.stderr)
    exit(1)

print('Current autostart seting: '+str(sp.autostart()))
if sp.autostart() == True:
    sp.setAutostart(0)
else:
    sp.setAutostart(1)
print('Current autostart seting: '+str(sp.autostart()))

conn.close()
exit(0)