Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
billsung committed Aug 2, 2018
2 parents 5f87b4c + da42729 commit 444b699
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions infortrend/raidcmd_cli/cli_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,14 @@ def __init__(self, *args, **kwargs):
self.command = "lock"


class InitCache(CLIBaseCommand):
"""Refresh cacahe data for update volume status."""

def __init__(self, *args, **kwargs):
super(InitCache, self).__init__(*args, **kwargs)
self.command = "utility init-cache"


class CreateLD(CLIBaseCommand):

"""The Create LD Command."""
Expand Down
7 changes: 7 additions & 0 deletions infortrend/raidcmd_cli/common_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@
'ShowHost': {'error': _('Failed to get host info.')},
'SetIOTimeout': {'error': _('Failed to set IO timeout.')},
'ConnectRaid': {'error': _('Failed to connect to raid.')},
'InitCache': {
'warning': {9: 'Device not connected.'},
'error': _('Failed to init cache.')},
'ExecuteCommand': {'error': _('Failed to execute common command.')},
'ShellCommand': {'error': _('Failed to execute shell command.')},
}
Expand Down Expand Up @@ -1429,6 +1432,10 @@ def get_volume_stats(self, refresh=False):
return self._volume_stats

def _update_volume_stats(self):
# Refresh cache
rc, out = self._execute('InitCache')
if rc != 0:
LOG.Warning('[InitCache Failed]')

self.backend_name = self.configuration.safe_get('volume_backend_name')
system_id = self._get_system_id(self.ip)
Expand Down
4 changes: 4 additions & 0 deletions test/infortrend/test_infortrend_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,7 @@ def test_get_volume_stats_full(self):
test_volume_states = self.cli_data.test_volume_states_full

mock_commands = {
'InitCache': SUCCEED,
'ShowLicense': self.cli_data.get_test_show_license_full(),
'ShowLV': [self.cli_data.get_test_show_lv_tier(),
self.cli_data.get_test_show_lv()],
Expand All @@ -1115,6 +1116,7 @@ def test_get_volume_stats_full(self):

volume_states = self.driver.get_volume_stats(True)

self.assertDictEqual.__self__.maxDiff = None
self.assertDictEqual(test_volume_states, volume_states)

@mock.patch.object(common_cli.LOG, 'info', mock.Mock())
Expand All @@ -1123,6 +1125,7 @@ def test_get_volume_stats_thin(self):
test_volume_states = self.cli_data.test_volume_states_thin

mock_commands = {
'InitCache': SUCCEED,
'ShowLicense': self.cli_data.get_test_show_license_thin(),
'ShowLV': [self.cli_data.get_test_show_lv_tier(),
self.cli_data.get_test_show_lv()],
Expand All @@ -1142,6 +1145,7 @@ def test_get_volume_stats_thin(self):
def test_get_volume_stats_fail(self):

mock_commands = {
'InitCache': SUCCEED,
'ShowLicense': self.cli_data.get_test_show_license_thin(),
'ShowLV': FAKE_ERROR_RETURN,
}
Expand Down

0 comments on commit 444b699

Please sign in to comment.