Discussion:
[Libstoragemgmt-devel] [PATCH 4/9] plugin_test.py: Add test for iscsi_chap_auth call
Tony Asleson
2014-11-26 21:22:06 UTC
Permalink
Signed-off-by: Tony Asleson <***@redhat.com>
---
test/plugin_test.py | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)

diff --git a/test/plugin_test.py b/test/plugin_test.py
index 851475f..13febf2 100755
--- a/test/plugin_test.py
+++ b/test/plugin_test.py
@@ -834,6 +834,26 @@ class TestPlugin(unittest.TestCase):
self._test_ag_create_dup(ag, s)
self._delete_access_group(ag)

+ def test_iscsi_chap(self):
+ ag = None
+
+ for s in self.systems:
+ cap = self.c.capabilities(s)
+
+ if supported(cap, [Cap.ACCESS_GROUPS,
+ Cap.ACCESS_GROUP_CREATE_ISCSI_IQN,
+ Cap.VOLUME_ISCSI_CHAP_AUTHENTICATION]):
+ ag = self._create_access_group(
+ cap, rs('ag'), s, lsm.AccessGroup.INIT_TYPE_ISCSI_IQN)
+
+ self.c.iscsi_chap_auth(ag.init_ids[0], 'foo', rs(None, 12),
+ None, None)
+
+ if ag is not None and \
+ supported(cap, [Cap.ACCESS_GROUP_DELETE]):
+ self._test_ag_create_dup(ag, s)
+ self._delete_access_group(ag)
+
def test_access_group_create_delete(self):
for s in self.systems:
cap = self.c.capabilities(s)
--
1.8.2.1
Tony Asleson
2014-11-26 21:22:04 UTC
Permalink
Signed-off-by: Tony Asleson <***@redhat.com>
---
test/cmdtest.py | 22 ----------------------
1 file changed, 22 deletions(-)

diff --git a/test/cmdtest.py b/test/cmdtest.py
index 790fa39..80538d9 100755
--- a/test/cmdtest.py
+++ b/test/cmdtest.py
@@ -223,14 +223,6 @@ def volumes_accessible_by_access_group(ag_id):
call([cmd, 'list', '--type', 'volumes', '--ag', ag_id])


-def volume_accessible_by_initiator(iqn2):
- call([cmd, 'volumes-accessible-initiator', '--init', iqn2])
-
-
-def initiators_granted_to_volume(vol):
- call([cmd, 'initiators-granted-volume', '--vol', vol])
-
-
def access_groups_granted_to_volume(vol_id):
call([cmd, 'list', '--type', 'access_groups', '--vol', vol_id])

@@ -355,16 +347,6 @@ def get_systems():
return system_list


-def initiator_grant(initiator_id, vol_id):
-#initiator_grant(self, initiator_id, initiator_type, volume, access,
-# flags = 0):
- call([cmd,
- 'access-grant',
- '--init', initiator_id,
- '--vol', vol_id,
- '--access', 'RW'])
-
-
def initiator_chap(initiator):
call([cmd, 'iscsi-chap',
'--init', initiator])
@@ -378,10 +360,6 @@ def initiator_chap(initiator):
'--out-pass', "bar"])


-def initiator_revoke(initiator_id, vol_id):
- call([cmd, 'access-revoke', '--init', initiator_id, '--vol', vol_id])
-
-
def capabilities(system_id):
"""
Return a hash table of key:bool where key is supported operation
--
1.8.2.1
Tony Asleson
2014-11-26 21:22:07 UTC
Permalink
This appears to work, not sure why I disabled it before.

Signed-off-by: Tony Asleson <***@redhat.com>
---
plugin/nstor/nstor.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/plugin/nstor/nstor.py b/plugin/nstor/nstor.py
index bc0e339..3cffbba 100644
--- a/plugin/nstor/nstor.py
+++ b/plugin/nstor/nstor.py
@@ -299,8 +299,7 @@ class NexentaStor(INfs, IStorageAreaNetwork):
c.set(Capabilities.VOLUME_CHILD_DEPENDENCY)
c.set(Capabilities.VOLUME_CHILD_DEPENDENCY_RM)

- #tasleson, not working at the moment for me.
- #c.set(Capabilities.VOLUME_ISCSI_CHAP_AUTHENTICATION)
+ c.set(Capabilities.VOLUME_ISCSI_CHAP_AUTHENTICATION)

return c
--
1.8.2.1
Tony Asleson
2014-11-26 21:22:09 UTC
Permalink
Using nonexistant method on AccessGroup. Found when I added tests for
iSCSI authentication testing.

Signed-off-by: Tony Asleson <***@redhat.com>
---
python_binding/lsm/_client.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/python_binding/lsm/_client.py b/python_binding/lsm/_client.py
index 12b22f1..74c1e1a 100644
--- a/python_binding/lsm/_client.py
+++ b/python_binding/lsm/_client.py
@@ -335,8 +335,9 @@ class Client(INetworkAttachedStorage):
Register a user/password for the specified initiator for CHAP
authentication.
"""
- AccessGroup.init_id_validate(
- init_id, AccessGroup.INIT_TYPE_ISCSI_IQN, raise_error=True)
+ AccessGroup.initiator_id_verify(init_id,
+ AccessGroup.INIT_TYPE_ISCSI_IQN,
+ raise_exception=True)
return self._tp.rpc('iscsi_chap_auth', _del_self(locals()))

## Returns an array of volume objects
--
1.8.2.1
Tony Asleson
2014-11-26 21:22:10 UTC
Permalink
Targetd is the only plug-in that doesn't support access groups. We
tried to make this work by faking each initiator to look as a standalone
access group, however this has a number of issues and didn't work as
advertised. As this feature never worked, it cannot have been used
by anyone. We are choosing to remove it and add support for access groups
to targetd and the targetd plugin.

Notes:
* Access group id is now required, not optional
* The underlying API needs no changes
* The man page didn't document this (thus no update)
* Masking is indeed broken and continutes to be broken for targetd
with patches in the works

Signed-off-by: Tony Asleson <***@redhat.com>
---
tools/lsmcli/cmdline.py | 19 +------------------
1 file changed, 1 insertion(+), 18 deletions(-)

diff --git a/tools/lsmcli/cmdline.py b/tools/lsmcli/cmdline.py
index 66163b3..29f75d1 100644
--- a/tools/lsmcli/cmdline.py
+++ b/tools/lsmcli/cmdline.py
@@ -324,12 +324,7 @@ cmds = (
'like LUN Masking',
args=[
dict(vol_id_opt),
- ],
- optional=[
dict(ag_id_opt),
- dict(name='--init', metavar='<INIT_ID>', action='append',
- help='Initiator ID, only used when access-group-create is '
- 'not supported'),
],
),

@@ -1239,20 +1234,8 @@ class CmdLine:
out(self.c.volume_replicate_range_block_size(s))

def volume_mask(self, args):
- if not args.ag and not args.init:
- raise ArgError('Neither --ag nor --init is defined. '
- 'Please specify at lease one')
- if args.ag and args.init:
- raise ArgError('In volume-mask command, --init is '
- 'conflicting with --ag')
vol = _get_item(self.c.volumes(), args.vol, 'Volume ID')
- ag = None
- if args.ag:
- ag = _get_item(self.c.access_groups(), args.ag, 'Access Group ID')
-
- if args.init:
- (init_id, init_type) = parse_convert_init(args.init)
- ag = AccessGroup(0, '', [init_id], init_type, vol.system_id)
+ ag = _get_item(self.c.access_groups(), args.ag, 'Access Group ID')
self.c.volume_mask(ag, vol)

def volume_unmask(self, args):
--
1.8.2.1
Tony Asleson
2014-11-26 21:22:08 UTC
Permalink
This was supported, it just wasn't added to the capabilities.

Signed-off-by: Tony Asleson <***@redhat.com>
---
plugin/simc/simc_lsmplugin.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/plugin/simc/simc_lsmplugin.c b/plugin/simc/simc_lsmplugin.c
index 289f5e7..7c4d287 100644
--- a/plugin/simc/simc_lsmplugin.c
+++ b/plugin/simc/simc_lsmplugin.c
@@ -364,6 +364,7 @@ static int cap(lsm_plugin_ptr c, lsm_system *system,
LSM_CAP_VOLUME_UNMASK,
LSM_CAP_ACCESS_GROUPS,
LSM_CAP_ACCESS_GROUP_CREATE_ISCSI_IQN,
+ LSM_CAP_VOLUME_ISCSI_CHAP_AUTHENTICATION,
LSM_CAP_ACCESS_GROUP_CREATE_WWPN,
LSM_CAP_ACCESS_GROUP_INITIATOR_ADD_WWPN,
LSM_CAP_ACCESS_GROUP_INITIATOR_DELETE,
--
1.8.2.1
Tony Asleson
2014-11-26 21:22:11 UTC
Permalink
Signed-off-by: Tony Asleson <***@redhat.com>
---
plugin/nstor/nstor.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/plugin/nstor/nstor.py b/plugin/nstor/nstor.py
index 3cffbba..9e854fc 100644
--- a/plugin/nstor/nstor.py
+++ b/plugin/nstor/nstor.py
@@ -143,8 +143,8 @@ class NexentaStor(INfs, IStorageAreaNetwork):
[str(pool), ""])

pools.append(Pool(pool_info['name'], pool_info['name'],
- Pool.ELEMENT_TYPE_VOLUME | \
- Pool.ELEMENT_TYPE_VOLUME_THIN | \
+ Pool.ELEMENT_TYPE_VOLUME |
+ Pool.ELEMENT_TYPE_VOLUME_THIN |
Pool.ELEMENT_TYPE_FS,
0,
NexentaStor._to_bytes(pool_info['size']),
@@ -163,7 +163,7 @@ class NexentaStor(INfs, IStorageAreaNetwork):
pool_name = NexentaStor._get_pool_id(fs)
if pool_name == 'syspool':
continue
- if not pool_name in pools:
+ if pool_name not in pools:
pool_info = self._request("get_child_props", "volume",
[str(fs), ""])
pools[pool_name] = pool_info
--
1.8.2.1
Tony Asleson
2014-11-26 21:22:05 UTC
Permalink
Signed-off-by: Tony Asleson <***@redhat.com>
---
test/cmdtest.py | 3 +++
1 file changed, 3 insertions(+)

diff --git a/test/cmdtest.py b/test/cmdtest.py
index 80538d9..551e7af 100755
--- a/test/cmdtest.py
+++ b/test/cmdtest.py
@@ -567,6 +567,9 @@ def test_mapping(cap, system_id):
if cap['ACCESS_GROUP_CREATE_ISCSI_IQN']:
ag_id = access_group_create(iqn1, system_id)

+ if cap['VOLUME_ISCSI_CHAP_AUTHENTICATION']:
+ initiator_chap(iqn1)
+
if cap['ACCESS_GROUP_INITIATOR_ADD_ISCSI_IQN']:
access_group_initiator_add(ag_id, iqn2)
--
1.8.2.1
Loading...