Discussion:
[Libstoragemgmt-devel] [PATCH 3/5] smis.py: Exclude volumes reserved for system
Tony Asleson
2014-05-20 14:42:53 UTC
Permalink
Signed-off-by: Tony Asleson <***@redhat.com>
---
plugin/smispy/smis.py | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/plugin/smispy/smis.py b/plugin/smispy/smis.py
index c63d8cd..1846f93 100644
--- a/plugin/smispy/smis.py
+++ b/plugin/smispy/smis.py
@@ -1039,7 +1039,7 @@ class Smis(IStorageAreaNetwork):
cim_vol_pros.extend(
['OperationalStatus', 'ElementName', 'NameFormat',
'NameNamespace', 'BlockSize', 'NumberOfBlocks', 'Name',
- 'OtherIdentifyingInfo', 'IdentifyingDescriptions'])
+ 'OtherIdentifyingInfo', 'IdentifyingDescriptions', 'Usage'])
return cim_vol_pros

def _new_vol(self, cv, pool_id=None, sys_id=None):
@@ -1308,8 +1308,14 @@ class Smis(IStorageAreaNetwork):
ResultClass='CIM_StorageVolume',
PropertyList=cim_vol_pros)
for cim_vol in cim_vols:
- vol = self._new_vol(cim_vol, pool_id, sys_id)
- rc.extend([vol])
+ # Exclude those volumes which are reserved for system
+ if 'Usage' in cim_vol:
+ if cim_vol['Usage'] != 3:
+ vol = self._new_vol(cim_vol, pool_id, sys_id)
+ rc.extend([vol])
+ else:
+ vol = self._new_vol(cim_vol, pool_id, sys_id)
+ rc.extend([vol])
return rc

def _systems(self, system_name=None):
--
1.8.2.1
Tony Asleson
2014-05-20 14:42:54 UTC
Permalink
Also check to make sure we have > 0 pools, volumes
etc. during testing.

Signed-off-by: Tony Asleson <***@redhat.com>
---
test/plugin_test.py | 161 ++++++++++++++++++++++++++++------------------------
1 file changed, 86 insertions(+), 75 deletions(-)

diff --git a/test/plugin_test.py b/test/plugin_test.py
index 50c79a4..d5a65f6 100755
--- a/test/plugin_test.py
+++ b/test/plugin_test.py
@@ -268,6 +268,8 @@ class TestPlugin(unittest.TestCase):

def test_pools_list(self):
pools_list = self.c.pools()
+ self.assertTrue(len(pools_list) > 0, "We need at least 1 pool to test")
+

@staticmethod
def _vpd_correct(vpd):
@@ -285,8 +287,11 @@ class TestPlugin(unittest.TestCase):
"VPD is not as expected %s for volume id: %s" %
(v.vpd83, v.id))

+ self.assertTrue(len(volumes) > 0, "We need at least 1 volume to test")
+
def test_disks_list(self):
disks = self.c.disks()
+ self.assertTrue(len(disks) > 0, "We need at least 1 disk to test")

def test_pool_create(self):
pass
@@ -353,58 +358,61 @@ class TestPlugin(unittest.TestCase):
return False

def test_volume_create_delete(self):
- for s in self.systems:
- vol = None
- cap = self.c.capabilities(s)
- if supported(cap, [lsm.Capabilities.VOLUME_CREATE]):
- vol = self._volume_create(s.id)[0]
- self.assertTrue(vol is not None)
-
- if vol is not None and \
- supported(cap, [lsm.Capabilities.VOLUME_DELETE]):
- self._volume_delete(vol)
+ if self.pool_by_sys_id:
+ for s in self.systems:
+ vol = None
+ cap = self.c.capabilities(s)
+ if supported(cap, [lsm.Capabilities.VOLUME_CREATE]):
+ vol = self._volume_create(s.id)[0]
+ self.assertTrue(vol is not None)
+
+ if vol is not None and \
+ supported(cap, [lsm.Capabilities.VOLUME_DELETE]):
+ self._volume_delete(vol)

def test_volume_resize(self):
- for s in self.systems:
- cap = self.c.capabilities(s)
-
- if supported(cap, [lsm.Capabilities.VOLUME_CREATE,
- lsm.Capabilities.VOLUME_DELETE,
- lsm.Capabilities.VOLUME_RESIZE]):
- vol = self._volume_create(s.id)[0]
- vol_resize = self.c.volume_resize(vol,
- vol.size_bytes * 1.10)[1]
- self.assertTrue(vol.size_bytes < vol_resize.size_bytes)
- self.assertTrue(vol.id == vol_resize.id,
- "Expecting re-sized volume to refer to "
- "same volume. Expected %s, got %s" %
- (vol.id, vol_resize.id))
- if vol.id == vol_resize.id:
- self._volume_delete(vol_resize)
- else:
- # Delete the original
- self._volume_delete(vol)
+ if self.pool_by_sys_id:
+ for s in self.systems:
+ cap = self.c.capabilities(s)
+
+ if supported(cap, [lsm.Capabilities.VOLUME_CREATE,
+ lsm.Capabilities.VOLUME_DELETE,
+ lsm.Capabilities.VOLUME_RESIZE]):
+ vol = self._volume_create(s.id)[0]
+ vol_resize = self.c.volume_resize(vol,
+ vol.size_bytes * 1.10)[1]
+ self.assertTrue(vol.size_bytes < vol_resize.size_bytes)
+ self.assertTrue(vol.id == vol_resize.id,
+ "Expecting re-sized volume to refer to "
+ "same volume. Expected %s, got %s" %
+ (vol.id, vol_resize.id))
+ if vol.id == vol_resize.id:
+ self._volume_delete(vol_resize)
+ else:
+ # Delete the original
+ self._volume_delete(vol)

def _replicate_test(self, capability, replication_type):
- for s in self.systems:
- cap = self.c.capabilities(s)
+ if self.pool_by_sys_id:
+ for s in self.systems:
+ cap = self.c.capabilities(s)

- if supported(cap, [lsm.Capabilities.VOLUME_CREATE,
- lsm.Capabilities.VOLUME_DELETE]):
- vol, pool = self._volume_create(s.id)
+ if supported(cap, [lsm.Capabilities.VOLUME_CREATE,
+ lsm.Capabilities.VOLUME_DELETE]):
+ vol, pool = self._volume_create(s.id)

- # For the moment lets allow the array to pick the pool
- # to supply the backing store for the replicate
- if supported(cap, [capability]):
- volume_clone = self.c.volume_replicate(
- None, replication_type, vol,
- rs('volume_clone'))[1]
+ # For the moment lets allow the array to pick the pool
+ # to supply the backing store for the replicate
+ if supported(cap, [capability]):
+ volume_clone = self.c.volume_replicate(
+ None, replication_type, vol,
+ rs('volume_clone'))[1]

- self.assertTrue(volume_clone is not None)
- self.assertTrue(self._volume_exists(volume_clone.id))
- self._volume_delete(volume_clone)
+ self.assertTrue(volume_clone is not None)
+ self.assertTrue(self._volume_exists(volume_clone.id))
+ self._volume_delete(volume_clone)

- self._volume_delete(vol)
+ self._volume_delete(vol)

def test_volume_replication(self):
self._replicate_test(lsm.Capabilities.VOLUME_REPLICATE_CLONE,
@@ -431,38 +439,41 @@ class TestPlugin(unittest.TestCase):
self.c.volume_replicate_range_block_size, s)

def test_replication_range(self):
- for s in self.systems:
- cap = self.c.capabilities(s)
-
- if supported(cap, [lsm.Capabilities.VOLUME_CREATE,
- lsm.Capabilities.VOLUME_DELETE,
- lsm.Capabilities.VOLUME_COPY_RANGE]):
-
- vol, pool = self._volume_create(s.id)
-
- br = lsm.BlockRange(0, 100, 10)
+ if self.pool_by_sys_id:
+ for s in self.systems:
+ cap = self.c.capabilities(s)
+
+ if supported(cap, [lsm.Capabilities.VOLUME_CREATE,
+ lsm.Capabilities.VOLUME_DELETE,
+ lsm.Capabilities.VOLUME_COPY_RANGE]):
+
+ vol, pool = self._volume_create(s.id)
+
+ br = lsm.BlockRange(0, 100, 10)
+
+ if supported(
+ cap, [lsm.Capabilities.VOLUME_COPY_RANGE_CLONE]):
+ self.c.volume_replicate_range(
+ lsm.Volume.REPLICATE_CLONE, vol, vol, [br])
+ else:
+ self.assertRaises(
+ lsm.LsmError,
+ self.c.volume_replicate_range,
+ lsm.Volume.REPLICATE_CLONE, vol, vol, [br])
+
+ br = lsm.BlockRange(200, 400, 50)
+
+ if supported(
+ cap, [lsm.Capabilities.VOLUME_COPY_RANGE_COPY]):
+ self.c.volume_replicate_range(
+ lsm.Volume.REPLICATE_COPY, vol, vol, [br])
+ else:
+ self.assertRaises(
+ lsm.LsmError,
+ self.c.volume_replicate_range,
+ lsm.Volume.REPLICATE_COPY, vol, vol, [br])

- if supported(cap, [lsm.Capabilities.VOLUME_COPY_RANGE_CLONE]):
- self.c.volume_replicate_range(lsm.Volume.REPLICATE_CLONE,
- vol, vol, [br])
- else:
- self.assertRaises(
- lsm.LsmError,
- self.c.volume_replicate_range,
- lsm.Volume.REPLICATE_CLONE, vol, vol, [br])
-
- br = lsm.BlockRange(200, 400, 50)
-
- if supported(cap, [lsm.Capabilities.VOLUME_COPY_RANGE_COPY]):
- self.c.volume_replicate_range(lsm.Volume.REPLICATE_COPY,
- vol, vol, [br])
- else:
- self.assertRaises(
- lsm.LsmError,
- self.c.volume_replicate_range,
- lsm.Volume.REPLICATE_COPY, vol, vol, [br])
-
- self._volume_delete(vol)
+ self._volume_delete(vol)

def test_fs_creation_deletion(self):
for s in self.systems:
--
1.8.2.1
Tony Asleson
2014-05-20 14:42:55 UTC
Permalink
Make sure they are present before trying to use.

Signed-off-by: Tony Asleson <***@redhat.com>
---
plugin/smispy/smis.py | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/plugin/smispy/smis.py b/plugin/smispy/smis.py
index 1846f93..77fbc2b 100644
--- a/plugin/smispy/smis.py
+++ b/plugin/smispy/smis.py
@@ -1709,20 +1709,21 @@ class Smis(IStorageAreaNetwork):
# This code needs to be re-investigated to work with a wide
# range of array vendors.

- if s[
- 'SyncState'] == Smis.Synchronized.SyncState.SYNCHRONIZED \
- and (s['CopyType'] != Smis.CopyTypes.UNSYNCASSOC):
- if 'SyncedElement' in s:
- item = s['SyncedElement']
+ if 'SyncState' in s and 'CopyType' in s:
+ if s['SyncState'] == \
+ Smis.Synchronized.SyncState.SYNCHRONIZED and \
+ (s['CopyType'] != Smis.CopyTypes.UNSYNCASSOC):
+ if 'SyncedElement' in s:
+ item = s['SyncedElement']

- if Smis._cim_name_match(item, lun_path):
- self._detach(vol, s)
+ if Smis._cim_name_match(item, lun_path):
+ self._detach(vol, s)

- if 'SystemElement' in s:
- item = s['SystemElement']
+ if 'SystemElement' in s:
+ item = s['SystemElement']

- if Smis._cim_name_match(item, lun_path):
- self._detach(vol, s)
+ if Smis._cim_name_match(item, lun_path):
+ self._detach(vol, s)

@handle_cim_errors
def volume_delete(self, volume, flags=0):
--
1.8.2.1
Tony Asleson
2014-05-20 14:42:52 UTC
Permalink
Signed-off-by: Tony Asleson <***@redhat.com>
---
test/webtest/test_automated.py | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/test/webtest/test_automated.py b/test/webtest/test_automated.py
index 7334fdc..53e99af 100755
--- a/test/webtest/test_automated.py
+++ b/test/webtest/test_automated.py
@@ -26,6 +26,7 @@ import sys
from subprocess import Popen, PIPE
from multiprocessing import Process
import yaml
+import time


def call(command):
@@ -84,12 +85,33 @@ if __name__ == '__main__':

p = Process(target=run_test, args=(sys.argv[2], sys.argv[3],
system_id, uri, password))
+ p.name = system_id
p.start()
process_list.append(p)

+ start = time.time()
+ print 'Test run started at: %s' % time.strftime("%c")
+ sys.stdout.flush()
+
while len(process_list) > 0:
for p in process_list:
p.join(1)
if not p.is_alive():
+ print '%s exited with %s' % (p.name, str(p.exitcode))
+ sys.stdout.flush()
process_list.remove(p)
- break
\ No newline at end of file
+ break
+
+ current = time.time()
+ if current - start > 3600:
+ print 'Test taking too long...'
+ sys.stdout.flush()
+ for p in process_list:
+ print 'Terminating process %s, name %s' % \
+ (str(p.pid), p.name)
+ sys.stdout.flush()
+ p.terminate()
+ break
+
+ print 'Test run exiting at: %s' % time.strftime("%c")
+ sys.stdout.flush()
--
1.8.2.1
Loading...