From 2f5cde4aba027772d6d0d758523df3056cd294f4 Mon Sep 17 00:00:00 2001 From: Paul Cuzner Date: Tue, 8 Aug 2017 11:44:16 +1200 Subject: [PATCH] iscsi.py: updates to address code review comments --- collectors/iscsi.py | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/collectors/iscsi.py b/collectors/iscsi.py index 5ad45ce..284ffb6 100644 --- a/collectors/iscsi.py +++ b/collectors/iscsi.py @@ -105,8 +105,8 @@ class ISCSIGateway(BaseCollector): def refresh(self): """ populate the instance by exploring rtslib - :return: """ + self.iops = 0 self.read_bytes_per_sec = 0 self.write_bytes_per_sec = 0 @@ -150,9 +150,9 @@ class ISCSIGateway(BaseCollector): def prune(self): """ drop child objects held by the instance, that are no longer in the - iSCSI config i.e. don't report on old tut! - :return: + iSCSI config i.e. don't report on old information """ + for client_name in self.clients: client = self.clients[client_name] @@ -189,44 +189,39 @@ class ISCSIGateway(BaseCollector): } + def _get_so(self): return [so for so in self._root.storage_objects] def _get_node_acls(self): return [node for node in self._root.node_acls] - def _get_tpg_count(self): + @property + def tpg_count(self): return len([tpg for tpg in self._root.tpgs]) - def _get_lun_count(self): + @property + def lun_count(self): return len(self._get_so()) - def _get_session_count(self): + @property + def sessions(self): return len([session for session in self._root.sessions]) - def _get_gateway_name(self): + @property + def gateway_name(self): # Only the 1st gateway is considered/supported gw_iqn = [gw.wwn for gw in self._root.targets][0] return gw_iqn.replace('.', '-') - def _get_client_count(self): + @property + def client_count(self): return len(self._get_node_acls()) - def _get_capacity(self): + @property + def capacity(self): return sum([so.size for so in self._get_so()]) - lun_count = property(_get_lun_count) - - tpg_count = property(_get_tpg_count) - - sessions = property(_get_session_count) - - client_count = property(_get_client_count) - - gateway_name = property(_get_gateway_name) - - capacity = property(_get_capacity) - def get_stats(self): start = time.time() -- 2.47.3