[virt-tools-list] [PATCH 04/11] Created the storage pool configuration class.
Darryl L. Pierce
dpierce at redhat.com
Thu Apr 14 18:22:04 UTC 2011
---
src/virtlib/config.py | 59 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 59 insertions(+), 0 deletions(-)
diff --git a/src/virtlib/config.py b/src/virtlib/config.py
index 5f35c71..f3cd1b4 100644
--- a/src/virtlib/config.py
+++ b/src/virtlib/config.py
@@ -92,3 +92,62 @@ class NetworkConfig:
self.public_ipv4_network = (self.ipv4_address_raw.iptype() == "PUBLIC")
+from virtinst import Storage
+
+ROOT_TARGET_PATH='/var/lib/libvirt/images/%s'
+
+class StoragePoolConfig:
+ '''
+ Describes a storage pool.
+ '''
+
+ def __init__(self, name, type):
+ self.name = name
+ self.type = type
+ self.needs_target_path = False
+ self.needs_format = False
+ self.needs_target_path = False
+ self.needs_format = False
+ self.needs_hostname = False
+ self.needs_source_path = False
+ self.needs_build_pool = False
+ if type is not None:
+ if type is Storage.StoragePool.TYPE_DIR:
+ self.needs_target_path = True
+ self.target_path = ROOT_TARGET_PATH % self.name
+ self.build_pool = True
+ elif type is Storage.StoragePool.TYPE_DISK:
+ self.needs_target_path = True
+ self.needs_format = True
+ self.needs_source_path = True
+ self.needs_build_pool = True
+ elif type is Storage.StoragePool.TYPE_FS:
+ self.needs_target_path = True
+ self.needs_format = True
+ self.needs_source_path = True
+ self.build_pool = True
+ elif type is Storage.StoragePool.TYPE_ISCSI:
+ self.needs_target_path = True
+ self.needs_hostname = True
+ self.needs_source_path = True
+ self.build_pool = False
+ elif type is Storage.StoragePool.TYPE_LOGICAL:
+ self.needs_target_path = True
+ self.needs_source_path = True
+ self.needs_build_pool = True
+ elif type is Storage.StoragePool.TYPE_NETFS:
+ self.needs_target_path = True
+ self.needs_format = True
+ self.needs_hostname = True
+ self.needs_source_path = True
+ self.build_pool = True
+ self.pool_class = Storage.StoragePool.get_pool_class(self.type)
+ else:
+ self.type = Storage.StoragePool.get_pool_types()[0]
+
+ def create(self, conn):
+ # create pool
+ self.pool = self.pool_class(name = self.name,
+ conn = conn)
+ if self.needs_format:
+ self.format = self.pool.formats[0]
--
1.7.4.2
More information about the virt-tools-list
mailing list