Last active
September 30, 2015 08:39
-
-
Save avirambh/daf3f0f9e19cd8263924 to your computer and use it in GitHub Desktop.
print protocol type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From 73e8cb03ad7d14ae517bd2e847e1eae07e9117a7 Mon Sep 17 00:00:00 2001 | |
| From: Aviram Bar-Haim <aviramb@mellanox.com> | |
| Date: Tue, 10 Feb 2015 17:36:51 +0200 | |
| Subject: [PATCH] Added protocol type print for cinder-rtstool | |
| --- | |
| cinder/cmd/rtstool.py | 19 +++++++++++++++---- | |
| 1 file changed, 15 insertions(+), 4 deletions(-) | |
| diff --git a/cinder/cmd/rtstool.py b/cinder/cmd/rtstool.py | |
| index 4ec404a..f50b6f3 100644 | |
| --- a/cinder/cmd/rtstool.py | |
| +++ b/cinder/cmd/rtstool.py | |
| @@ -153,10 +153,17 @@ def delete_initiator(target_iqn, initiator_iqn): | |
| % {'target': target_iqn, 'acl': initiator_iqn}) | |
| -def get_targets(): | |
| +def get_targets(show_protocol = False): | |
| rtsroot = rtslib_fb.root.RTSRoot() | |
| for x in rtsroot.targets: | |
| - print(x.wwn) | |
| + if show_protocol: | |
| + tpg = x.tpgs.next() # get the first one | |
| + portals = tpg.network_portals | |
| + protocol = \ | |
| + ['tcp', 'iser'][True in [p._get_iser() for p in portals]] | |
| + print("%s: %s" % (protocol, x.wwn)) | |
| + else: | |
| + print(x.wwn) | |
| def delete(iqn): | |
| @@ -169,7 +176,7 @@ def usage(): | |
| " add-initiator [target_iqn] [userid] [password] [initiator_iqn]") | |
| print(sys.argv[0] + | |
| " delete-initiator [target_iqn] [initiator_iqn]") | |
| - print(sys.argv[0] + " get-targets") | |
| + print(sys.argv[0] + " get-targets <show_protocol>") | |
| print(sys.argv[0] + " delete [iqn]") | |
| print(sys.argv[0] + " verify") | |
| sys.exit(1) | |
| @@ -223,7 +230,11 @@ def main(argv=None): | |
| delete_initiator(target_iqn, initiator_iqn) | |
| elif argv[1] == 'get-targets': | |
| - get_targets() | |
| + if len(argv) < 3: | |
| + show_protocol = False | |
| + else: | |
| + show_protocol = argv[2].lower() == 'true' | |
| + get_targets(show_protocol) | |
| elif argv[1] == 'delete': | |
| if len(argv) < 3: | |
| -- | |
| 1.9.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment