Script cfgshell :: Class ConfigShell
[hide private]
[frames] | no frames]

Class ConfigShell


Command tool for editing the config file.

Note that although we don't do saves after remove, the current ConfigWriter code does that; so we can't prevent someone from actually breaking the config with this tool. It's the users' responsibility to know what they're doing.

Instance Methods [hide private]
 
__init__(self, cfg_file=None)
Constructor for the ConfigShell object.
 
emptyline(self)
Empty line handling.
 
precmd(self, line)
Precmd hook to prevent commands in invalid states.
 
postcmd(self, stop, line)
Postcmd hook to update the prompt.
 
do_load(self, line)
Load function.
 
do_ls(self, line)
List the current entry.
 
complete_cd(self, text, line, begidx, endidx)
Completion function for the cd command.
 
do_cd(self, line)
Changes the current path.
 
do_pwd(self, line)
Shows the current path.
 
complete_cat(self, text, line, begidx, endidx)
Completion for the cat command.
 
do_cat(self, line)
Shows the contents of the given file.
 
do_verify(self, line)
Verify the configuration.
 
do_save(self, line)
Saves the configuration data.
 
do_rm(self, line)
Removes an instance or a node.

Inherited from cmd.Cmd: cmdloop, columnize, complete, complete_help, completedefault, completenames, default, do_help, get_names, onecmd, parseline, postloop, preloop, print_topics

Static Methods [hide private]
 
_get_entries(obj)
Computes the list of subdirs and files in the given object.
 
do_EOF(line)
Exit the application.
 
do_quit(line)
Exit the application.
Class Variables [hide private]
  prompt = "(/) "

Inherited from cmd.Cmd: doc_header, doc_leader, identchars, intro, lastcmd, misc_header, nohelp, ruler, undoc_header, use_rawinput

Method Details [hide private]

__init__(self, cfg_file=None)
(Constructor)

 

Constructor for the ConfigShell object.

The optional cfg_file argument will be used to load a config file at startup.

Overrides: cmd.Cmd.__init__

emptyline(self)

 

Empty line handling.

Note that the default will re-run the last command. We don't want that, and just ignore the empty line.

Overrides: cmd.Cmd.emptyline

_get_entries(obj)
Static Method

 

Computes the list of subdirs and files in the given object.

This, depending on the passed object entry, look at each logical child of the object and decides if it's a container or a simple object. Based on this, it computes the list of subdir and files.

precmd(self, line)

 

Precmd hook to prevent commands in invalid states.

This will prevent everything except load and quit when no configuration is loaded.

Overrides: cmd.Cmd.precmd

postcmd(self, stop, line)

 

Postcmd hook to update the prompt.

We show the current location in the prompt and this function is used to update it; this is only needed after cd and load, but we update it anyway.

Overrides: cmd.Cmd.postcmd

do_load(self, line)

 

Load function.

Syntax: load [/path/to/config/file]

This will load a new configuration, discarding any existing data (if any). If no argument has been passed, it will use the default config file location.

do_ls(self, line)

 

List the current entry.

This will show directories with a slash appended and files normally.

do_cd(self, line)

 

Changes the current path.

Valid arguments: either .., /, "" (no argument) or a child of the current object.

do_pwd(self, line)

 

Shows the current path.

This duplicates the prompt functionality, but it's reasonable to have.

do_cat(self, line)

 

Shows the contents of the given file.

This will display the contents of the given file, which must be a child of the current path (as shows by `ls`).

do_verify(self, line)

 

Verify the configuration.

This verifies the contents of the configuration file (and not the in-memory data, as every modify operation automatically saves the file).

do_save(self, line)

 

Saves the configuration data.

Note that is redundant (all modify operations automatically save the data), but it is good to use it as in the future that could change.

do_rm(self, line)

 

Removes an instance or a node.

This function works only on instances or nodes. You must be in either `/nodes` or `/instances` and give a valid argument.