commit 0aadbd778486183ba059d26253716cf1524d5b6f
Author: W. David Ashley <w.david.ashley(a)gmail.com>
Date: Sun Aug 2 18:30:52 2015 -0500
Storage chapter
- Added examples 6 and 7
- Added verbage to support example 6 and 7
en-US/Storage_Pools.xml | 20 ++++++++++++++++++--
en-US/extras/StoragePools-Example-2.py | 6 ++++++
en-US/extras/StoragePools-Example-6.py | 26 ++++++++++++++++++++++++++
en-US/extras/StoragePools-Example-7.py | 25 +++++++++++++++++++++++++
4 files changed, 75 insertions(+), 2 deletions(-)
---
diff --git a/en-US/Storage_Pools.xml b/en-US/Storage_Pools.xml
index 1a343ff..1a9b0f1 100644
--- a/en-US/Storage_Pools.xml
+++ b/en-US/Storage_Pools.xml
@@ -165,15 +165,31 @@
<section
id="libvirt_application_development_guide_using_python-Storage_Pools-Pool_Config">
<title>Pool configuration</title>
<para>
- TBD
+ There are a number of methods which can congigure aspects of a storage pool.
The main method
+ is the </para>literal>setAutostart</section> method.
</para>
+ <example>
+ <title>Demonstrate the setAutostart method</title>
+ <programlisting language="Python"><xi:include
href="extras/StoragePools-Example-6.py" parse="text"
xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
+ </example>
</section>
<section
id="libvirt_application_development_guide_using_python-Storage_Pools-Volume">
<title>Volume overview</title>
<para>
- TBD
+ Storage volumes are the basic unit of storage which house a guest
domain's storage requirements.
+ All the necessary partitions used to house a guest domain are encapsulated by
the storage volume.
+ Storage volumnes are in turn contained in storage pools. A storage pool can
conatain as many
+ storage pools as the underlying disk partition will hold.
</para>
+ <para>
+ The following example program demonstrates how to list all the storage
volumes contained by the
+ "default" storage pool.
+ </para>
+ <example>
+ <title>Demonstrate listing the storage volumes</title>
+ <programlisting language="Python"><xi:include
href="extras/StoragePools-Example-7.py" parse="text"
xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
+ </example>
</section>
<section
id="libvirt_application_development_guide_using_python-Storage_Pools-Listing">
diff --git a/en-US/extras/StoragePools-Example-2.py
b/en-US/extras/StoragePools-Example-2.py
index fd1fe58..58e16bc 100644
--- a/en-US/extras/StoragePools-Example-2.py
+++ b/en-US/extras/StoragePools-Example-2.py
@@ -13,12 +13,18 @@ if pool == None:
print('Failed to locate any StoragePool objects.', file=sys.stderr)
exit(1)
+info = pool.info()
+
print('Pool: '+pool.name())
print(' UUID: '+pool.UUIDString())
print(' Autostart: '+str(pool.autostart()))
print(' Is active: '+str(pool.isActive()))
print(' Is persistent: '+str(pool.isPersistent()))
print(' Num volumes: '+str(pool.numOfVolumes()))
+print(' Pool state: '+str(info[0]))
+print(' Capacity: '+str(info[1]))
+print(' Allocation: '+str(info[2]))
+print(' Available: '+str(info[3]))
conn.close()
exit(0)
diff --git a/en-US/extras/StoragePools-Example-6.py
b/en-US/extras/StoragePools-Example-6.py
new file mode 100644
index 0000000..8627d05
--- /dev/null
+++ b/en-US/extras/StoragePools-Example-6.py
@@ -0,0 +1,26 @@
+# Example-6.py
+from __future__ import print_function
+import sys
+import libvirt
+
+poolName = 'default'
+
+conn = libvirt.open('qemu:///system')
+if conn == None:
+ print('Failed to open connection to qemu:///system', 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)
diff --git a/en-US/extras/StoragePools-Example-7.py
b/en-US/extras/StoragePools-Example-7.py
new file mode 100644
index 0000000..952345b
--- /dev/null
+++ b/en-US/extras/StoragePools-Example-7.py
@@ -0,0 +1,25 @@
+# Example-7.py
+from __future__ import print_function
+import sys
+import libvirt
+from xml.dom import minidom
+
+poolName = 'default'
+
+conn = libvirt.open('qemu:///system')
+if conn == None:
+ print('Failed to open connection to qemu:///system', file=sys.stderr)
+ exit(1)
+
+sp = conn.storagePoolLookupByName(poolName)
+if sp == None:
+ print('Failed to find storage pool '+poolName, file=sys.stderr)
+ exit(1)
+
+stgvols = sp.listVolumes()
+print('Storage pool: '+poolName)
+for stgvol in stgvols :
+ print(' Storage vol: '+stgvol)
+
+conn.close()
+exit(0)