diff options
| author | Jerome Martin <jxm@risingtidesystems.com> | 2011-06-01 16:30:03 +0200 |
|---|---|---|
| committer | Jerome Martin <jxm@risingtidesystems.com> | 2011-06-01 17:23:23 +0200 |
| commit | c68f4265a2810906227bb7e5f37bee711fb5b813 (patch) | |
| tree | 52a250c2f4e0dd77c95c51bfe7080976d1098c39 /rtsadmin/ui_node.py | |
| parent | c436cb8031ef2883ac2e3b6677d4313dfb766d65 (diff) | |
| download | targetcli-c68f4265a2810906227bb7e5f37bee711fb5b813.tar.gz | |
Added auto_cd_after_create global.
* Automatically cd's to newly created object after a 'create' command if true.
* Added autosave (always) of last created node's path under @last bookmark.
Diffstat (limited to 'rtsadmin/ui_node.py')
| -rw-r--r-- | rtsadmin/ui_node.py | 50 |
1 files changed, 35 insertions, 15 deletions
diff --git a/rtsadmin/ui_node.py b/rtsadmin/ui_node.py index 7c45c5e..677d31c 100644 --- a/rtsadmin/ui_node.py +++ b/rtsadmin/ui_node.py @@ -39,6 +39,9 @@ class UINode(ConfigNode): [self.ui_type_bool, 'If true, use legacy HBA view, allowing to create more ' + 'than one storage object per HBA.'] + self._configuration_groups['global']['auto_cd_after_create'] = \ + [self.ui_type_bool, + 'If true, changes current path to newly created objects.'] def assert_root(self): ''' @@ -50,23 +53,21 @@ class UINode(ConfigNode): raise ExecutionError("This privileged command is disabled: " + "you are not root.") - def ui_command_refresh(self): + def new_node(self, new_node): ''' - Refreshes and updates the objects tree from the current path. - ''' - self.refresh() - - def ui_command_saveconfig(self): - ''' - Saves the whole configuration tree to disk so that it will be restored - on next boot. Unless you do that, changes are lost accross reboots. + Used to honor global 'auto_cd_after_create'. + Either returns None if the global is False, or the new_node if the + global is True. In both cases, set the @last bookmark to last_node. ''' - self.assert_root() - self.con.display("WARNING: Saving the current configuration to disk " - + "will overwrite your boot settings.") - self.con.display("The current target configuration will become the " - + "default boot config.") - system('PYTHONPATH="" python /usr/sbin/tcm_dump --o') + self.prefs['bookmarks']['last'] = new_node.path + self.prefs.save() + if self.prefs['auto_cd_after_create']: + self.log.info("Entering new node %s" % new_node.path) + # Piggy backs on cd instead of just returning new_node, + # so we update navigation history. + return self.ui_command_cd(new_node.path) + else: + return None def refresh(self): ''' @@ -97,6 +98,25 @@ class UINode(ConfigNode): self.log.debug("Command %s succeeded." % command) return result + + def ui_command_refresh(self): + ''' + Refreshes and updates the objects tree from the current path. + ''' + self.refresh() + + def ui_command_saveconfig(self): + ''' + Saves the whole configuration tree to disk so that it will be restored + on next boot. Unless you do that, changes are lost accross reboots. + ''' + self.assert_root() + self.con.display("WARNING: Saving the current configuration to disk " + + "will overwrite your boot settings.") + self.con.display("The current target configuration will become the " + + "default boot config.") + system('PYTHONPATH="" python /usr/sbin/tcm_dump --o') + def ui_command_status(self): ''' Displays the current node's status summary. |
