Merge "Update compression license check"
This commit is contained in:
commit
65bed98079
@ -61,6 +61,7 @@ class StorwizeSVCManagementSimulator(object):
|
|||||||
'startfcmap': '',
|
'startfcmap': '',
|
||||||
'rmfcmap': '',
|
'rmfcmap': '',
|
||||||
'lslicense': '',
|
'lslicense': '',
|
||||||
|
'lsguicapabilities': '',
|
||||||
}
|
}
|
||||||
self._errors = {
|
self._errors = {
|
||||||
'CMMVC5701E': ('', 'CMMVC5701E No object ID was specified.'),
|
'CMMVC5701E': ('', 'CMMVC5701E No object ID was specified.'),
|
||||||
@ -351,6 +352,15 @@ class StorwizeSVCManagementSimulator(object):
|
|||||||
rows[2] = ['license_compression_enclosures', '1']
|
rows[2] = ['license_compression_enclosures', '1']
|
||||||
return self._print_info_cmd(rows=rows, **kwargs)
|
return self._print_info_cmd(rows=rows, **kwargs)
|
||||||
|
|
||||||
|
def _cmd_lsguicapabilities(self, **kwargs):
|
||||||
|
rows = [None]
|
||||||
|
if self._next_cmd_error['lsguicapabilities'] == 'no_compression':
|
||||||
|
self._next_cmd_error['lsguicapabilities'] = ''
|
||||||
|
rows[0] = ['license_scheme', '0']
|
||||||
|
else:
|
||||||
|
rows[0] = ['license_scheme', '9846']
|
||||||
|
return self._print_info_cmd(rows=rows, **kwargs)
|
||||||
|
|
||||||
# Print mostly made-up stuff in the correct syntax
|
# Print mostly made-up stuff in the correct syntax
|
||||||
def _cmd_lssystem(self, **kwargs):
|
def _cmd_lssystem(self, **kwargs):
|
||||||
rows = [None] * 3
|
rows = [None] * 3
|
||||||
@ -1861,6 +1871,7 @@ class StorwizeSVCDriverTestCase(test.TestCase):
|
|||||||
|
|
||||||
if self.USESIM:
|
if self.USESIM:
|
||||||
self.sim.error_injection('lslicense', 'no_compression')
|
self.sim.error_injection('lslicense', 'no_compression')
|
||||||
|
self.sim.error_injection('lsguicapabilities', 'no_compression')
|
||||||
self._set_flag('storwize_svc_vol_compression', True)
|
self._set_flag('storwize_svc_vol_compression', True)
|
||||||
self.driver.do_setup(None)
|
self.driver.do_setup(None)
|
||||||
self.assertRaises(exception.InvalidInput,
|
self.assertRaises(exception.InvalidInput,
|
||||||
@ -3698,21 +3709,32 @@ class StorwizeHelpersTestCase(test.TestCase):
|
|||||||
super(StorwizeHelpersTestCase, self).setUp()
|
super(StorwizeHelpersTestCase, self).setUp()
|
||||||
self.storwize_svc_common = storwize_svc_common.StorwizeHelpers(None)
|
self.storwize_svc_common = storwize_svc_common.StorwizeHelpers(None)
|
||||||
|
|
||||||
def test_compression_enabled(self):
|
@mock.patch.object(storwize_svc_common.StorwizeSSH, 'lslicense')
|
||||||
|
@mock.patch.object(storwize_svc_common.StorwizeSSH, 'lsguicapabilities')
|
||||||
|
def test_compression_enabled(self, lsguicapabilities, lslicense):
|
||||||
fake_license_without_keys = {}
|
fake_license_without_keys = {}
|
||||||
fake_license = {
|
fake_license = {
|
||||||
'license_compression_enclosures': '1',
|
'license_compression_enclosures': '1',
|
||||||
'license_compression_capacity': '1'
|
'license_compression_capacity': '1'
|
||||||
}
|
}
|
||||||
|
fake_license_scheme = {
|
||||||
|
'license_scheme': '9846'
|
||||||
|
}
|
||||||
|
fake_license_invalid_scheme = {
|
||||||
|
'license_scheme': '0000'
|
||||||
|
}
|
||||||
|
|
||||||
# Check when keys of return licenses do not contain
|
lslicense.side_effect = [fake_license_without_keys,
|
||||||
# 'license_compression_enclosures' and 'license_compression_capacity'
|
fake_license_without_keys,
|
||||||
with mock.patch.object(
|
fake_license,
|
||||||
storwize_svc_common.StorwizeSSH, 'lslicense') as lslicense:
|
fake_license_without_keys]
|
||||||
lslicense.return_value = fake_license_without_keys
|
lsguicapabilities.side_effect = [fake_license_without_keys,
|
||||||
self.assertFalse(self.storwize_svc_common.compression_enabled())
|
fake_license_invalid_scheme,
|
||||||
|
fake_license_scheme]
|
||||||
|
self.assertFalse(self.storwize_svc_common.compression_enabled())
|
||||||
|
|
||||||
with mock.patch.object(
|
self.assertFalse(self.storwize_svc_common.compression_enabled())
|
||||||
storwize_svc_common.StorwizeSSH, 'lslicense') as lslicense:
|
|
||||||
lslicense.return_value = fake_license
|
self.assertTrue(self.storwize_svc_common.compression_enabled())
|
||||||
self.assertTrue(self.storwize_svc_common.compression_enabled())
|
|
||||||
|
self.assertTrue(self.storwize_svc_common.compression_enabled())
|
||||||
|
@ -99,6 +99,10 @@ class StorwizeSSH(object):
|
|||||||
ssh_cmd = ['svcinfo', 'lslicense', '-delim', '!']
|
ssh_cmd = ['svcinfo', 'lslicense', '-delim', '!']
|
||||||
return self.run_ssh_info(ssh_cmd)[0]
|
return self.run_ssh_info(ssh_cmd)[0]
|
||||||
|
|
||||||
|
def lsguicapabilities(self):
|
||||||
|
ssh_cmd = ['svcinfo', 'lsguicapabilities', '-delim', '!']
|
||||||
|
return self.run_ssh_info(ssh_cmd)[0]
|
||||||
|
|
||||||
def lssystem(self):
|
def lssystem(self):
|
||||||
ssh_cmd = ['svcinfo', 'lssystem', '-delim', '!']
|
ssh_cmd = ['svcinfo', 'lssystem', '-delim', '!']
|
||||||
return self.run_ssh_info(ssh_cmd)[0]
|
return self.run_ssh_info(ssh_cmd)[0]
|
||||||
@ -411,6 +415,18 @@ class StorwizeHelpers(object):
|
|||||||
for key in keys:
|
for key in keys:
|
||||||
if resp.get(key, '0') != '0':
|
if resp.get(key, '0') != '0':
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
# lslicense is not used for V9000 compression check
|
||||||
|
# compression_enclosures and compression_capacity are
|
||||||
|
# always 0. V9000 uses license_scheme 9846 as an
|
||||||
|
# indicator and can always do compression
|
||||||
|
try:
|
||||||
|
resp = self.ssh.lsguicapabilities()
|
||||||
|
if resp.get('license_scheme', '0') == '9846':
|
||||||
|
return True
|
||||||
|
except exception.VolumeBackendAPIException as war:
|
||||||
|
LOG.warning(_LW("Failed to run lsguicapability. "
|
||||||
|
"Exception: %s."), war)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_system_info(self):
|
def get_system_info(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user