# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1252394005 25200
# Node ID fdc0d9aef3427500032bbd35caba0e5977be47f6
# Parent 30196cc506c07d81642c94a01fc65b34421c0714
[TEST] Modified pool.py to support RPCS CreateResourceInPool.
Added the following two functions which are used in RPCS/10*py and RPCS/11*py
1) get_stovol_rasd_from_sdc() to get the stovol rasd from sdc
2) get_stovol_default_settings() to get default sto vol settings
Also, modified common_util.py to remove the backed up exportfs file.
Added RAW_VOL_TYPE which is the FormatType supported by RPCS currently.
Once this patch gets accepted we can modify RPCS/10*py to refer to these functions.
Tested with KVM and current sources on SLES11.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r 30196cc506c0 -r fdc0d9aef342 suites/libvirt-cim/lib/XenKvmLib/common_util.py
--- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Wed Sep 02 05:11:16 2009 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Tue Sep 08 00:13:25 2009 -0700
@@ -531,7 +531,7 @@
# Remove the temp dir created .
clean_temp_files(server, src_dir, dst_dir)
-
+
# Restore the original exports file.
if os.path.exists(back_exports_file):
os.remove(exports_file)
@@ -551,6 +551,8 @@
try:
# Backup the original exports file.
if (os.path.exists(exports_file)):
+ if os.path.exists(back_exports_file):
+ os.remove(back_exports_file)
move_file(exports_file, back_exports_file)
fd = open(exports_file, "w")
line = "\n %s %s(rw)" %(src_dir_for_mnt, server)
diff -r 30196cc506c0 -r fdc0d9aef342 suites/libvirt-cim/lib/XenKvmLib/pool.py
--- a/suites/libvirt-cim/lib/XenKvmLib/pool.py Wed Sep 02 05:11:16 2009 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/pool.py Tue Sep 08 00:13:25 2009 -0700
@@ -34,6 +34,7 @@
from CimTest.CimExt import CIMClassMOF
from XenKvmLib.vxml import NetXML, PoolXML
from XenKvmLib.xm_virt_util import virsh_version
+from XenKvmLib.vsms import RASD_TYPE_STOREVOL
cim_errno = pywbem.CIM_ERR_NOT_SUPPORTED
cim_mname = "CreateChildResourcePool"
@@ -48,6 +49,9 @@
LOGICAL_POOL = 6L
SCSI_POOL = 7L
+#Volume types
+RAW_VOL_TYPE = 1
+
def pool_cn_to_rasd_cn(pool_cn, virt):
if pool_cn.find('ProcessorPool') >= 0:
return get_typed_class(virt, "ProcResourceAllocationSettingData")
@@ -297,3 +301,41 @@
status = PASS
return status
+
+def get_stovol_rasd_from_sdc(virt, server, dp_inst_id):
+ rasd = None
+ ac_cn = get_typed_class(virt, "AllocationCapabilities")
+ an_cn = get_typed_class(virt, "SettingsDefineCapabilities")
+ key_list = {"InstanceID" : dp_inst_id}
+
+ try:
+ inst = GetInstance(server, ac_cn, key_list)
+ rasd = Associators(server, an_cn, ac_cn, InstanceID=inst.InstanceID)
+ except Exception, detail:
+ logger.error("Exception: %s", detail)
+ return FAIL, None
+
+ return PASS, rasd
+
+def get_stovol_default_settings(virt, server, dp_cn,
+ pool_name, path, vol_name):
+
+ dp_inst_id = "%s/%s" % (dp_cn, pool_name)
+ status, dp_rasds = get_stovol_rasd_from_sdc(virt, server, dp_inst_id)
+ if status != PASS:
+ logger.error("Failed to get the StorageVol RASD's")
+ return None
+
+ for dpool_rasd in dp_rasds:
+ if dpool_rasd['ResourceType'] == RASD_TYPE_STOREVOL and \
+ 'Default' in dpool_rasd['InstanceID']:
+
+ dpool_rasd['PoolID'] = dp_inst_id
+ dpool_rasd['Path'] = path
+ dpool_rasd['VolumeName'] = vol_name
+ break
+
+ if not pool_name in dpool_rasd['PoolID']:
+ return None
+
+ return dpool_rasd