commit 8693f86ce9bc2b31d4cd0115858737d03de6ce36
Author: W. David Ashley <w.david.ashley(a)gmail.com>
Date: Fri Jul 31 13:42:17 2015 -0500
Storage chapter
- added example 5
- added storage pool sources verbage
en-US/Storage_Pools.xml | 12 +++++++--
en-US/extras/StoragePools-Example-5.py | 42 ++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 3 deletions(-)
---
diff --git a/en-US/Storage_Pools.xml b/en-US/Storage_Pools.xml
index 38466c1..2ad1305 100644
--- a/en-US/Storage_Pools.xml
+++ b/en-US/Storage_Pools.xml
@@ -52,11 +52,11 @@
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
+ The <literal>isActive</literal> method 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
+ The <literal>isPersistent</literal> method 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>
@@ -86,13 +86,19 @@
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.
+ </para>
</section>
<section
id="libvirt_application_development_guide_using_python-Storage_Pools-Discover_Sources">
<title>Discovering pool sources</title>
<para>
- TBD
+ The sources for a storage pool's sources can be discovered by examining
the pool's XML
+ description. An example program follows that prints out a pools source
description attributes.
</para>
+ <example>
+ <title>Discover a storage pool's sources</title>
+ <programlisting language="Python"><xi:include
href="extras/StoragePools-Example-5.py" parse="text"
xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
+ </example>
</section>
<section
id="libvirt_application_development_guide_using_python-Storage_Pools-Pool_Config">
diff --git a/en-US/extras/StoragePools-Example-5.py
b/en-US/extras/StoragePools-Example-5.py
new file mode 100644
index 0000000..8d453af
--- /dev/null
+++ b/en-US/extras/StoragePools-Example-5.py
@@ -0,0 +1,42 @@
+# Example-5.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)
+
+raw_xml = sp.XMLDesc(0)
+xml = minidom.parseString(raw_xml)
+name = xml.getElementsByTagName('name')
+print('pool name: '+poolName)
+spTypes = xml.getElementsByTagName('source')
+for spType in spTypes:
+ attr = spType.getAttribute('name')
+ if attr != None:
+ print(' name = '+attr)
+ attr = spType.getAttribute('path')
+ if attr != None:
+ print(' path = '+attr)
+ attr = spType.getAttribute('dir')
+ if attr != None:
+ print(' dir = '+attr)
+ attr = spType.getAttribute('type')
+ if attr != None:
+ print(' type = '+attr)
+ attr = spType.getAttribute('username')
+ if attr != None:
+ print(' username = '+attr)
+
+conn.close()
+exit(0)