diff options
author | Andy Grover <agrover@redhat.com> | 2014-12-17 16:07:20 -0800 |
---|---|---|
committer | Andy Grover <agrover@redhat.com> | 2014-12-17 16:07:20 -0800 |
commit | 4e3f06f529d776f6ce70be16d3f62db6b6211c44 (patch) | |
tree | c6764073ac76853f45b44dc7911e3b0eb5cd2797 | |
parent | d220bc0e9770aaa4a8d0a4cb215c4aff4b5ab2e9 (diff) | |
download | targetcli-4e3f06f529d776f6ce70be16d3f62db6b6211c44.tar.gz |
Catch exception if an invalid tag is given when creating a tpg
Also, allow e.g "tpg6" as well as "6" for the tpg tag. This matches what
we do for lun creation.
Fixes #47
Signed-off-by: Andy Grover <agrover@redhat.com>
-rw-r--r-- | targetcli/ui_target.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/targetcli/ui_target.py b/targetcli/ui_target.py index 5c8e2f4..a28925c 100644 --- a/targetcli/ui_target.py +++ b/targetcli/ui_target.py @@ -306,9 +306,10 @@ class UIMultiTPGTarget(UIRTSLibNode): def ui_command_create(self, tag=None): ''' - Creates a new Target Portal Group within the target. The I{tag} must be - a strictly positive integer value. If omitted, the next available - Target Portal Group Tag (TPGT) will be used. + Creates a new Target Portal Group within the target. The + I{tag} must be a positive integer value, optionally prefaced + by 'tpg'. If omitted, the next available Target Portal Group + Tag (TPGT) will be used. SEE ALSO ======== @@ -316,6 +317,15 @@ class UIMultiTPGTarget(UIRTSLibNode): ''' self.assert_root() + if tag: + if tag.startswith("tpg"): + tag = tag[3:] + + try: + tag = int(tag) + except ValueError: + raise ExecutionError("Tag argument must be a number.") + tpg = TPG(self.rtsnode, tag, mode='create') if self.shell.prefs['auto_enable_tpgt']: tpg.enable = True |