Discussion:
[Libstoragemgmt-devel] [PATCH 1/3] nstor: Remove commented out non-existant constant
Tony Asleson
2014-07-21 22:47:56 UTC
Permalink
Signed-off-by: Tony Asleson <***@redhat.com>
---
plugin/nstor/nstor.py | 1 -
1 file changed, 1 deletion(-)

diff --git a/plugin/nstor/nstor.py b/plugin/nstor/nstor.py
index 8dd6eaf..7b02390 100644
--- a/plugin/nstor/nstor.py
+++ b/plugin/nstor/nstor.py
@@ -248,7 +248,6 @@ class NexentaStor(INfs, IStorageAreaNetwork):
# c.set(Capabilities.FILE_CLONE)
c.set(Capabilities.FS_SNAPSHOTS)
c.set(Capabilities.FS_SNAPSHOT_CREATE)
- # c.set(Capabilities.FS_SNAPSHOT_CREATE_SPECIFIC_FILES)
c.set(Capabilities.FS_SNAPSHOT_DELETE)
c.set(Capabilities.FS_SNAPSHOT_REVERT)
# c.set(Capabilities.FS_SNAPSHOT_REVERT_SPECIFIC_FILES)
--
1.8.2.1
Tony Asleson
2014-07-21 22:47:57 UTC
Permalink
If we return a reference to the one passed in, the user could
potentially run into issues as changes to one would show up in
the other which would be unexpected.

Signed-off-by: Tony Asleson <***@redhat.com>
---
plugin/nstor/nstor.py | 5 +++--
plugin/ontap/ontap.py | 5 +++--
2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/plugin/nstor/nstor.py b/plugin/nstor/nstor.py
index 7b02390..96f1e07 100644
--- a/plugin/nstor/nstor.py
+++ b/plugin/nstor/nstor.py
@@ -28,6 +28,7 @@ except ImportError:
import base64
import time
import traceback
+import copy

from lsm import (AccessGroup, Capabilities, ErrorNumber, FileSystem, INfs,
IStorageAreaNetwork, LsmError, NfsExport, Pool,
@@ -754,7 +755,7 @@ class NexentaStor(INfs, IStorageAreaNetwork):
[access_group.name])
if init_id in init_ids:
# Already in requested group.
- return access_group
+ return copy.deepcopy(access_group)

self._add_initiator(access_group.name, init_id)
init_ids = self._request("list_hostgroup_members", "stmf",
@@ -778,7 +779,7 @@ class NexentaStor(INfs, IStorageAreaNetwork):
[access_group.name])
if init_id not in init_ids:
# Already removed from requested group.
- return access_group
+ return copy.deepcopy(access_group)
self._add_initiator(access_group.name, init_id, True)
init_ids = self._request("list_hostgroup_members", "stmf",
[access_group.name])
diff --git a/plugin/ontap/ontap.py b/plugin/ontap/ontap.py
index 8fbf3b9..8696647 100644
--- a/plugin/ontap/ontap.py
+++ b/plugin/ontap/ontap.py
@@ -21,6 +21,7 @@ import os
import traceback
import urlparse
import sys
+import copy

import na
from lsm import (Volume, FileSystem, FsSnapshot, NfsExport,
@@ -742,7 +743,7 @@ class Ontap(IStorageAreaNetwork, INfs):
self.f.igroup_add_initiator(access_group.name, init_id)
except na.FilerError as oe:
if oe.errno == na.FilerError.IGROUP_ALREADY_HAS_INIT:
- return access_group
+ return copy.deepcopy(access_group)
elif oe.errno == na.FilerError.NO_SUCH_IGROUP:
raise LsmError(ErrorNumber.NOT_FOUND_ACCESS_GROUP,
"AccessGroup %s(%d) not found" %
@@ -764,7 +765,7 @@ class Ontap(IStorageAreaNetwork, INfs):
except na.FilerError as oe:
error_code, error_msg = error_map(oe)
if oe.errno == na.FilerError.IGROUP_NOT_CONTAIN_GIVEN_INIT:
- return access_group
+ return copy.deepcopy(access_group)
elif oe.errno == na.FilerError.NO_SUCH_IGROUP:
raise LsmError(ErrorNumber.NOT_FOUND_ACCESS_GROUP,
"AccessGroup %s(%d) not found" %
--
1.8.2.1
Tony Asleson
2014-07-21 22:47:58 UTC
Permalink
Signed-off-by: Tony Asleson <***@redhat.com>
---
plugin/nstor/nstor.py | 28 ++++++++++++----------------
1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/plugin/nstor/nstor.py b/plugin/nstor/nstor.py
index 96f1e07..7ce9d73 100644
--- a/plugin/nstor/nstor.py
+++ b/plugin/nstor/nstor.py
@@ -735,6 +735,16 @@ class NexentaStor(INfs, IStorageAreaNetwork):
self._request(command, "stmf", [group_name, initiator_id])
return

+ def _access_group_initiators(self, access_group):
+ hg_list = self._request("list_hostgroups", "stmf", [])
+ if access_group.name not in hg_list:
+ raise LsmError(ErrorNumber.NOT_FOUND_ACCESS_GROUP,
+ "AccessGroup %s(%s) not found" %
+ (access_group.name, access_group.id))
+
+ return self._request("list_hostgroup_members", "stmf",
+ [access_group.name])
+
@handle_nstor_errors
def access_group_initiator_add(self, access_group, init_id, init_type,
flags=0):
@@ -745,14 +755,7 @@ class NexentaStor(INfs, IStorageAreaNetwork):
raise LsmError(ErrorNumber.NO_SUPPORT,
"Nstor only support iSCSI Access Group")

- hg_list = self._request("list_hostgroups", "stmf", [])
- if access_group.name not in hg_list:
- raise LsmError(ErrorNumber.NOT_FOUND_ACCESS_GROUP,
- "AccessGroup %s(%s) not found" %
- (access_group.name, access_group.id))
-
- init_ids = self._request("list_hostgroup_members", "stmf",
- [access_group.name])
+ init_ids = self._access_group_initiators(access_group)
if init_id in init_ids:
# Already in requested group.
return copy.deepcopy(access_group)
@@ -769,14 +772,7 @@ class NexentaStor(INfs, IStorageAreaNetwork):
"""
Deletes an initiator from an access group
"""
- hg_list = self._request("list_hostgroups", "stmf", [])
- if access_group.name not in hg_list:
- raise LsmError(ErrorNumber.NOT_FOUND_ACCESS_GROUP,
- "AccessGroup %s(%s) not found" %
- (access_group.name, access_group.id))
-
- init_ids = self._request("list_hostgroup_members", "stmf",
- [access_group.name])
+ init_ids = self._access_group_initiators(access_group)
if init_id not in init_ids:
# Already removed from requested group.
return copy.deepcopy(access_group)
--
1.8.2.1
Loading...