Skip to content

Commit

Permalink
reduce ShowDevice calls
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnychou committed Nov 18, 2016
1 parent f1c28ad commit e803005
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/raidcmd_cli/common_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ def __init__(self, protocol, configuration=None):
self.fc_lookup_service = fczm_utils.create_lookup_service()

self._volume_stats = None
self.system_id = None
self._model_type = 'R'
self._replica_timeout = self.cli_timeout

Expand Down Expand Up @@ -691,12 +692,12 @@ def _get_target_pool_id(self, volume):
return pool_id

def _get_system_id(self, system_ip):
rc, device_info = self._execute('ShowDevice')

for entry in device_info:
if system_ip == entry['Connected-IP']:
return str(int(entry['ID'], 16))
return
if not self.system_id:
rc, device_info = self._execute('ShowDevice')
for entry in device_info:
if system_ip == entry['Connected-IP']:
self.system_id = str(int(entry['ID'], 16))
return self.system_id

@log_func
def _get_lun_id(self, ch_id, controller='slot_a'):
Expand Down Expand Up @@ -1043,9 +1044,10 @@ def get_volume_stats(self, refresh=False):
'Successfully update volume stats. '
'backend: %(volume_backend_name)s, '
'vendor: %(vendor_name)s, '
'driver version: %(driver_version)s, '
'model type: %(model_type)s, '
'storage protocol: %(storage_protocol)s.'), self._volume_stats)
'model_type: %(model_type)s, '
'system_id: %(system_id)s, '
'driver_version: %(driver_version)s, '
'storage_protocol: %(storage_protocol)s.'), self._volume_stats)

return self._volume_stats

Expand All @@ -1059,6 +1061,7 @@ def _update_volume_stats(self):
'driver_version': self.VERSION,
'storage_protocol': self.protocol,
'model_type': self._model_type,
'system_id': self._get_system_id(self.ip),
'pools': self._update_pools_stats(),
}
self._volume_stats = data
Expand Down Expand Up @@ -1365,7 +1368,12 @@ def _do_fc_connection(self, volume, connector):
else:
create_new_maps = True

LOG.info(_LI('Map_lun_list:[%(list)s] '), {'list': map_lun_list})
LOG.info(_LI('volume: [%(volume)s], '
'mapped_lun_list: %(list)s, '
'create_new_maps: [%(flag)s]'), {
'volume': volume['id'],
'list': map_lun_list,
'flag': create_new_maps})

if create_new_maps:
for initiator_wwpn in sorted(initiator_target_map):
Expand Down
1 change: 1 addition & 0 deletions test/test_infortrend_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ class InfortrendCLITestData(object):
'driver_version': '99.99',
'storage_protocol': 'iSCSI',
'model_type': 'R',
'system_id': fake_system_id[0],
'pools': test_pools,
}

Expand Down
1 change: 1 addition & 0 deletions test/test_infortrend_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,7 @@ def test_get_volume_stats(self):
}
self._driver_setup(mock_commands)
self.driver.VERSION = '99.99'
self.driver.system_id = self.cli_data.fake_system_id[0]

volume_states = self.driver.get_volume_stats(True)

Expand Down

0 comments on commit e803005

Please sign in to comment.