Discussion:
[Libstoragemgmt-devel] [PATCH 1/3] lsmcli: new alias lt = lsmcli list --type target_ports
Gris Ge
2014-10-12 10:09:54 UTC
Permalink
* Create new alias 'lsmcli lt' for this command:
lsmcli list --type target_ports

Signed-off-by: Gris Ge <***@redhat.com>
---
doc/man/lsmcli.1.in | 2 ++
tools/lsmcli/cmdline.py | 1 +
2 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/doc/man/lsmcli.1.in b/doc/man/lsmcli.1.in
index 93b2b88..ec4e3eb 100644
--- a/doc/man/lsmcli.1.in
+++ b/doc/man/lsmcli.1.in
@@ -564,6 +564,8 @@ Alias of 'list --type disks'
Alias of 'list --type access_groups'
.SS lf
Alias of 'list --type fs'
+.SS lt
+Alias of 'list --type target_ports'
.SS c
Alias of 'capabilities'
.SS p
diff --git a/tools/lsmcli/cmdline.py b/tools/lsmcli/cmdline.py
index 0a4e656..66163b3 100644
--- a/tools/lsmcli/cmdline.py
+++ b/tools/lsmcli/cmdline.py
@@ -601,6 +601,7 @@ aliases = (
['ld', 'list --type disks'],
['la', 'list --type access_groups'],
['lf', 'list --type fs'],
+ ['lt', 'list --type target_ports'],
['c', 'capabilities'],
['p', 'plugin-info'],
['vc', 'volume-create'],
--
1.7.1
Gris Ge
2014-10-12 10:09:55 UTC
Permalink
* Before deleting replication source volume, we need to delete the
target volume first. In previous code, we just invoke volume_delete()
against target volume but not waiting its ASYNC job. In this patch,
we only delete source volume after target volume deletion done.

Signed-off-by: Gris Ge <***@redhat.com>
---
test/plugin_test.py | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/test/plugin_test.py b/test/plugin_test.py
index 77f4b29..b70420f 100755
--- a/test/plugin_test.py
+++ b/test/plugin_test.py
@@ -495,7 +495,9 @@ class TestPlugin(unittest.TestCase):
self.assertTrue(le.code ==
ErrorNumber.NAME_CONFLICT)

- self._volume_delete(volume_clone)
+ self.wait_for_it(
+ 'volume_create',
+ self._volume_delete(volume_clone), None)

self._volume_delete(vol)
--
1.7.1
Gris Ge
2014-10-12 10:09:56 UTC
Permalink
* Update plugin_test.py to read LSM_TEST_URI and LSM_TEST_PASSWORD
if command line arguments didn't provided URI and password.

* Update lsmenv to set LSM_TEST_URI and LSM_TEST_PASSWORD for given device
alias.

* Create a shortcut in lsmenv for plugin_test.py. Example:
lsmenv vnx plugin_test

* This patch just save my time of typing uri and password for plugin_test.

Signed-off-by: Gris Ge <***@redhat.com>
---
test/plugin_test.py | 10 +++++++++-
tools/lsmenv | 40 ++++++++++++++++++++++++++++++----------
2 files changed, 39 insertions(+), 11 deletions(-)

diff --git a/test/plugin_test.py b/test/plugin_test.py
index b70420f..73251a5 100755
--- a/test/plugin_test.py
+++ b/test/plugin_test.py
@@ -28,6 +28,7 @@ import atexit
import sys
import yaml
import re
+import os
from lsm import LsmError, ErrorNumber

results = {}
@@ -1041,13 +1042,20 @@ if __name__ == "__main__":

parser = argparse.ArgumentParser(add_help=False)
parser.add_argument('--password', default=None)
- parser.add_argument('--uri', default='sim://')
+ parser.add_argument('--uri')
options, other_args = parser.parse_known_args()

if options.uri:
TestPlugin.URI = options.uri
+ elif os.getenv('LSM_TEST_URI'):
+ TestPlugin.URI = os.getenv('LSM_TEST_URI')
+ else:
+ TestPlugin.URI = 'sim://'
+

if options.password:
TestPlugin.PASSWORD = options.password
+ elif os.getenv('LSM_TEST_PASSWORD'):
+ TestPlugin.PASSWORD = os.getenv('LSM_TEST_PASSWORD')

unittest.main(argv=sys.argv[:1] + other_args)
diff --git a/tools/lsmenv b/tools/lsmenv
index 0cedfa3..da14eed 100755
--- a/tools/lsmenv
+++ b/tools/lsmenv
@@ -105,6 +105,24 @@ sub lsm_env_setup() {
$ENV{LD_LIBRARY_PATH} .= ":$c_binding_dir";
}

+sub set_uri($) {
+ my $uri = shift;
+ $ENV{LSMCLI_URI} = $uri;
+ $ENV{LSM_TEST_URI} = $uri;
+}
+
+sub set_pass($) {
+ my $pass = shift;
+ if ( defined $pass ) {
+ $ENV{LSMCLI_PASSWORD} = $pass;
+ $ENV{LSM_TEST_PASSWORD} = $pass;
+ }
+ else {
+ delete $ENV{LSMCLI_PASSWORD};
+ delete $ENV{LSM_TEST_PASSWORD};
+ }
+}
+
sub call_out($) {

# take section name as $1 and global $cfg
@@ -116,26 +134,25 @@ sub call_out($) {
help();
}

+ my $uri;
+ my $pass = undef;
if ( is_in_array( [ keys( %{$REF_PRE_BUILD_URI} ) ], $dev_alias ) ) {
- $ENV{LSMCLI_URI} = $REF_PRE_BUILD_URI->{$dev_alias};
+ $uri = $REF_PRE_BUILD_URI->{$dev_alias};
}
else {
- my $uri = $URI_CFG->val( $dev_alias, 'uri' );
+ $uri = $URI_CFG->val( $dev_alias, 'uri' );
if ( $uri =~ /\n/m ) {
print "Duplicate settings for \"$dev_alias\"\n";
exit 1;
}
- $ENV{LSMCLI_URI} = $uri;
- unless ( $URI_CFG->val( $dev_alias, 'passwd' ) ) {
- delete $ENV{LSMCLI_PASSWORD};
- }
- else {
- $ENV{LSMCLI_PASSWORD} = $URI_CFG->val( $dev_alias, 'passwd' );
- }
+ $pass = $URI_CFG->val( $dev_alias, 'passwd' )
+ if $URI_CFG->val( $dev_alias, 'passwd' );
}

print "Device alias: $dev_alias\n";
- print "LSMCLI_URI: $ENV{LSMCLI_URI}\n";
+ print "URI: $uri\n";
+ set_uri($uri);
+ set_pass($pass);

my @cmd = @ARGV;
shift @cmd;
@@ -143,6 +160,9 @@ sub call_out($) {
if ( $cmd[0] eq "lsmcli" ) {
$cmd[0] = "$BASE_DIR/tools/lsmcli/lsmcli";
}
+ elsif ( $cmd[0] eq 'plugin_test' ) {
+ $cmd[0] = "$BASE_DIR/test/plugin_test.py";
+ }
system( "time", "-f", '\nTime: %E\n', @cmd );
my $rc = $? >> 8;
if ( $rc != 0 ) {
--
1.7.1
Tony Asleson
2014-10-13 16:56:09 UTC
Permalink
Post by Gris Ge
* Before deleting replication source volume, we need to delete the
target volume first. In previous code, we just invoke volume_delete()
against target volume but not waiting its ASYNC job. In this patch,
we only delete source volume after target volume deletion done.
---
test/plugin_test.py | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/test/plugin_test.py b/test/plugin_test.py
index 77f4b29..b70420f 100755
--- a/test/plugin_test.py
+++ b/test/plugin_test.py
self.assertTrue(le.code ==
ErrorNumber.NAME_CONFLICT)
- self._volume_delete(volume_clone)
+ self.wait_for_it(
+ 'volume_create',
+ self._volume_delete(volume_clone), None)
self._volume_delete(vol)
The plugin_test.py code uses a proxy object 'TestProxy'. If you look at
the implementation of method 'present' you will see that we (should)
handle this case in the proxy.

196 # If the job can do async, we will block looping on it.
197 if job_possible and rc is not None:
198 # Note: Some return a single unicode or None,
199 # others return a tuple (job, object)
200 if type(rc) != tuple and type(rc) != list:
201 rc = (rc, None)
202 rc = self.wait_for_it(_proxy_method_name, *rc)

If you are seeing different behavior where we haven't waited then we
have a bug in this function that needs to be addressed.

Thanks!

Regards,
Tony

Loading...