[Kimchi-devel] [PATCH 1/3] add a method to get iscsi storage pool auth information.

shaohef at linux.vnet.ibm.com shaohef at linux.vnet.ibm.com
Thu Mar 20 10:35:39 UTC 2014


From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>

when need the auth information when we create iscsi volume disk for guest.

Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
---
 src/kimchi/model/templates.py | 11 +++++++++++
 src/kimchi/vmtemplate.py      |  3 +++
 2 files changed, 14 insertions(+)

diff --git a/src/kimchi/model/templates.py b/src/kimchi/model/templates.py
index cf9e088..1a183fb 100644
--- a/src/kimchi/model/templates.py
+++ b/src/kimchi/model/templates.py
@@ -29,6 +29,7 @@ from kimchi.kvmusertests import UserTests
 from kimchi.utils import pool_name_from_uri
 from kimchi.utils import probe_file_permission_as_user
 from kimchi.vmtemplate import VMTemplate
+from lxml import objectify
 
 
 class TemplatesModel(object):
@@ -211,6 +212,16 @@ class LibvirtVMTemplate(VMTemplate):
         xml = pool.XMLDesc(0)
         return xmlutils.xpath_get_text(xml, "/pool/@type")[0]
 
+    def _get_storage_auth(self):
+        pool = self._storage_validate()
+        xml = pool.XMLDesc(0)
+        root = objectify.fromstring(xml)
+        auth = root.source.find("auth")
+        if auth is None:
+            return auth
+        au = auth.attrib
+        return au.update(auth.secret.attrib)
+
     def fork_vm_storage(self, vm_uuid):
         # Provision storage:
         # TODO: Rebase on the storage API once upstream
diff --git a/src/kimchi/vmtemplate.py b/src/kimchi/vmtemplate.py
index 003e524..bf43153 100644
--- a/src/kimchi/vmtemplate.py
+++ b/src/kimchi/vmtemplate.py
@@ -345,6 +345,9 @@ class VMTemplate(object):
     def _get_storage_type(self):
         return ''
 
+    def _get_storage_auth(self):
+        return None
+
     def _get_all_networks_name(self):
         return []
 
-- 
1.8.5.3




More information about the Kimchi-devel mailing list