Discussion:
[Libstoragemgmt-devel] [PATCH 0/2] simarray.py updates
Tony Asleson
2015-02-23 22:17:24 UTC
Permalink
Hi Gris,

These were a couple of things I found during my review. As
they are minor I added a couple updates for you to review. Please
review and commit if you find them correct.

Thanks,
Tony

Tony Asleson (2):
simarray.py: Simplify _data_add
simarray.py: Add missing @_handle_errors

plugin/sim/simarray.py | 28 ++++++++++------------------
1 files changed, 10 insertions(+), 18 deletions(-)
Tony Asleson
2015-02-23 22:17:26 UTC
Permalink
Signed-off-by: Tony Asleson <***@redhat.com>
---
plugin/sim/simarray.py | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/plugin/sim/simarray.py b/plugin/sim/simarray.py
index 4599ea1..73f4492 100644
--- a/plugin/sim/simarray.py
+++ b/plugin/sim/simarray.py
@@ -2183,6 +2183,7 @@ class SimArray(object):
self.bs_obj.trans_commit()
return None

+ @_handle_errors
def volume_unmask(self, ag_id, vol_id, flags=0):
self.bs_obj.trans_begin()
self.bs_obj.sim_vol_unmask(
@@ -2191,6 +2192,7 @@ class SimArray(object):
self.bs_obj.trans_commit()
return None

+ @_handle_errors
def volumes_accessible_by_access_group(self, ag_id, flags=0):
self.bs_obj.trans_begin()

@@ -2200,6 +2202,7 @@ class SimArray(object):
self.bs_obj.trans_rollback()
return [SimArray._sim_vol_2_lsm(v) for v in sim_vols]

+ @_handle_errors
def access_groups_granted_to_volume(self, vol_id, flags=0):
self.bs_obj.trans_begin()
sim_ags = self.bs_obj.sim_ags(
@@ -2207,6 +2210,7 @@ class SimArray(object):
self.bs_obj.trans_rollback()
return [SimArray._sim_ag_2_lsm(a) for a in sim_ags]

+ @_handle_errors
def iscsi_chap_auth(self, init_id, in_user, in_pass, out_user, out_pass,
flags=0):
self.bs_obj.trans_begin()
@@ -2224,5 +2228,6 @@ class SimArray(object):
sim_tgt['physical_name'],
BackStore.SYS_ID)

+ @_handle_errors
def target_ports(self):
return list(SimArray._sim_tgt_2_lsm(t) for t in self.bs_obj.sim_tgts())
--
1.7.1
Tony Asleson
2015-02-23 22:17:25 UTC
Permalink
This seems a little more straight forward and pythonic.

Signed-off-by: Tony Asleson <***@redhat.com>
---
plugin/sim/simarray.py | 23 +++++------------------
1 files changed, 5 insertions(+), 18 deletions(-)

diff --git a/plugin/sim/simarray.py b/plugin/sim/simarray.py
index a240d29..4599ea1 100644
--- a/plugin/sim/simarray.py
+++ b/plugin/sim/simarray.py
@@ -841,25 +841,12 @@ class BackStore(object):

def _data_add(self, table_name, data_dict):
keys = data_dict.keys()
- values = data_dict.values()
+ values = ['' if v is None else str(v) for v in data_dict.values()]

- sql_cmd = "INSERT INTO %s (" % table_name
- for key in keys:
- sql_cmd += "'%s', " % key
-
- # Remove tailing ', '
- sql_cmd = sql_cmd[:-2]
-
- sql_cmd += ") VALUES ( "
- for value in values:
- if value is None:
- value = ''
- sql_cmd += "'%s', " % value
-
- # Remove tailing ', '
- sql_cmd = sql_cmd[:-2]
-
- sql_cmd += ");"
+ sql_cmd = "INSERT INTO %s (%s) VALUES (%s);" % \
+ (table_name,
+ "'%s'" % ("', '".join(keys)),
+ "'%s'" % ("', '".join(values)))
self._sql_exec(sql_cmd)

def _data_find(self, table, condition, key_list, flag_unique=False):
--
1.7.1
Tony Asleson
2015-02-24 16:30:20 UTC
Permalink
Post by Tony Asleson
Hi Gris,
These were a couple of things I found during my review. As
they are minor I added a couple updates for you to review. Please
review and commit if you find them correct.
Oh part of my paragraph was lost during editing...

"These were a couple of things I found during my review. As
they are minor I committed your patch series and added a couple
updates for you to review. Please review and commit if you find them
correct."

Thanks!
-Tony
Gris Ge
2015-02-26 03:35:35 UTC
Permalink
Post by Tony Asleson
Post by Tony Asleson
Hi Gris,
These were a couple of things I found during my review. As
they are minor I added a couple updates for you to review. Please
review and commit if you find them correct.
Oh part of my paragraph was lost during editing...
"These were a couple of things I found during my review. As
they are minor I committed your patch series and added a couple
updates for you to review. Please review and commit if you find them
correct."
Thanks!
-Tony
Hi Tony,

Thanks for the patches!
It looks good and passed the 'make rpm' on OBS and RHEL6/7.

Patch committed.

Best regards.
--
Gris Ge
Loading...