diff options
author | Andy Grover <agrover@redhat.com> | 2014-12-17 16:13:27 -0800 |
---|---|---|
committer | Andy Grover <agrover@redhat.com> | 2014-12-17 16:13:27 -0800 |
commit | 3947c435cb32f8f8347b8f51f8dde967ac0d47c6 (patch) | |
tree | 17b513973866646aa1f88979f956557d36ec0392 | |
parent | 4e3f06f529d776f6ce70be16d3f62db6b6211c44 (diff) | |
download | targetcli-3947c435cb32f8f8347b8f51f8dde967ac0d47c6.tar.gz |
Add a global pref for adding default portal
Expand info messages to mention this pref as well
Fixes #46
Signed-off-by: Andy Grover <agrover@redhat.com>
-rwxr-xr-x | scripts/targetcli | 1 | ||||
-rw-r--r-- | targetcli/ui_node.py | 3 | ||||
-rw-r--r-- | targetcli/ui_target.py | 13 |
3 files changed, 13 insertions, 4 deletions
diff --git a/scripts/targetcli b/scripts/targetcli index b95e842..5404fcd 100755 --- a/scripts/targetcli +++ b/scripts/targetcli @@ -49,6 +49,7 @@ class TargetCLI(ConfigShell): 'auto_add_mapped_luns': True, 'auto_cd_after_create': False, 'auto_save_on_exit': True, + 'auto_add_default_portal': True, } def usage(): diff --git a/targetcli/ui_node.py b/targetcli/ui_node.py index 53c095f..5abfd7f 100644 --- a/targetcli/ui_node.py +++ b/targetcli/ui_node.py @@ -43,6 +43,9 @@ class UINode(ConfigNode): self.define_config_group_param( 'global', 'auto_save_on_exit', 'bool', 'If true, saves configuration on exit.') + self.define_config_group_param( + 'global', 'auto_add_default_portal', 'bool', + 'If true, adds a portal listening on all IPs to new targets.') def assert_root(self): ''' diff --git a/targetcli/ui_target.py b/targetcli/ui_target.py index a28925c..7fcaab0 100644 --- a/targetcli/ui_target.py +++ b/targetcli/ui_target.py @@ -335,10 +335,15 @@ class UIMultiTPGTarget(UIRTSLibNode): self.shell.log.info("Created TPG %s." % tpg.tag) - if tpg.has_feature("nps"): - NetworkPortal(tpg, "0.0.0.0") - self.shell.log.info("Created default portal listening on all IPs" - " (0.0.0.0), port 3260.") + if tpg.has_feature("nps") and self.shell.prefs['auto_add_default_portal']: + try: + NetworkPortal(tpg, "0.0.0.0") + self.shell.log.info("Global pref auto_add_default_portal=true") + self.shell.log.info("Created default portal listening on all IPs" + " (0.0.0.0), port 3260.") + except RTSLibError: + self.shell.log.info("Default portal not created, TPGs within a " + + "target cannot share ip:port.") ui_tpg = UITPG(tpg, self) return self.new_node(ui_tpg) |