commit 44915f0d3d61122212fa9505769ac59f481a2f8c
Author: W. David Ashley <w.david.ashley(a)gmail.com>
Date: Thu Jul 30 19:50:44 2015 -0500
Storage chapter
- added example 4
- added support verbage for the new example in the Lifecycle section
- updated some of the verbage in the Pool Usage section
en-US/Storage_Pools.xml | 31 ++++++++++++++++++++-
en-US/extras/StoragePools-Example-4.py | 48 ++++++++++++++++++++++++++++++++
2 files changed, 78 insertions(+), 1 deletions(-)
---
diff --git a/en-US/Storage_Pools.xml b/en-US/Storage_Pools.xml
index 0153ef2..38466c1 100644
--- a/en-US/Storage_Pools.xml
+++ b/en-US/Storage_Pools.xml
@@ -44,6 +44,23 @@
<programlisting language="Python"><xi:include
href="extras/StoragePools-Example-2.py" parse="text"
xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
</example>
<para>
+ Many of the methods shown in the previous example provide information
concerning storage pools
+ that are on remote file systems, disk systems, or types other that local file
systems.
+ For instance. if the <literal>autostart</literal> flag is set
then when the user connects to
+ the storage pool libvirt will automatically make the storage pool available
if it is not
+ on a local file system e.g. an NFS mount. Storage pools on local file systems
also need to be
+ started if the <literal>autostart</literal> is not set.
+ </para>
+ <para>
+ The <literal>isActive</literal> indicates whether or not the user
must activate the storage
+ pool in some way. The <literal>create</literal> method can
activate a storage pool.
+ </para>
+ <para>
+ The <literal>isPersistent</literal> indicates whether or not a
storage pool needs to be activated
+ using <literal>create</literal> method. A value of 1 indicates
that the storage pool is persistent
+ and will remain on the file system after it is realeased.
+ </para>
+ <para>
The following example shows how to get the XML description of a storage
pool.
</para>
<example>
@@ -55,8 +72,20 @@
<section
id="libvirt_application_development_guide_using_python-Storage_Pools-Lifecycle">
<title>Lifecycle control</title>
<para>
- TBD
+ The following example shows how to create and destroy both a persistent and a
+ non-persistent storage pool. Note that a storage pool can not be destroyed
if
+ it is in a active state. By default storage pools are created in a inactive
state.
</para>
+ <example>
+ <title>Create and destroy storage pools</title>
+ <programlisting language="Python"><xi:include
href="extras/StoragePools-Example-4.py" parse="text"
xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
+ </example>
+ <para>
+ Note that the storage volumes defined in a storage pool will remain on the
file system
+ unless the <literal>delete</literal> method is called. But be
careful about leaving storage
+ volumes in place because if they exist on a remote file system or disk then
that file system
+ may become unavailable to the guest domain since there will be no mechanism
to reactivate the
+ remote file system or disk by the libvirt storage system at a future time.
</section>
<section
id="libvirt_application_development_guide_using_python-Storage_Pools-Discover_Sources">
diff --git a/en-US/extras/StoragePools-Example-4.py
b/en-US/extras/StoragePools-Example-4.py
new file mode 100644
index 0000000..85f7e21
--- /dev/null
+++ b/en-US/extras/StoragePools-Example-4.py
@@ -0,0 +1,48 @@
+# Example-4.py
+from __future__ import print_function
+import sys
+import libvirt
+xmlDesc = """
+<pool type='dir'>
+ <name>mypool</name>
+ <uuid>8c79f996-cb2a-d24d-9822-ac7547ab2d01</uuid>
+ <capacity unit='bytes'>4306780815</capacity>
+ <allocation unit='bytes'>237457858</allocation>
+ <available unit='bytes'>4069322956</available>
+ <source>
+ </source>
+ <target>
+ <path>/home/dashley/images</path>
+ <permissions>
+ <mode>0755</mode>
+ <owner>-1</owner>
+ <group>-1</group>
+ </permissions>
+ </target>
+</pool>"""
+
+conn = libvirt.open('qemu:///system')
+if conn == None:
+ print('Failed to open connection to qemu:///system', file=sys.stderr)
+ exit(1)
+
+# create a new persistent storage pool
+pool = conn.storagePoolDefineXML(xmlDesc, 0)
+if pool == None:
+ print('Failed to create StoragePool object.', file=sys.stderr)
+ exit(1)
+
+# destroy the storage pool
+pool.undefine()
+
+# create a new non-persistent storage pool
+pool = conn.storagePoolCreateXML(xmlDesc, 0)
+if pool == None:
+ print('Failed to create StoragePool object.', file=sys.stderr)
+ exit(1)
+
+# destroy the storage pool
+pool.undefine()
+
+conn.close()
+exit(0)