Overview | Index by: file name | procedure name | procedure call | annotation

sysconf.tcl Annotations

Created from source/sysconf.tcl
Procedures for handling MikroConf command specifications. This file encapsulates procedures and data structures for the following: * registering new commands/attributes/confmodes/authmodes * finding information about registered commands/attributes * internal representation of the command line hierarchy and confmodes/authmodes. * running system configuration data structure * retrieve running/startup configuration * save running config, load startup config @assume Dependency on the structure of the DOM tree.

Procedure Summary
authmode { sid op {mode {}} }
          Operations on Authmodes.
compute_fa { name NO node }
          Get a Finate Automaton (::grammar::fa) from embedded specifications.
confmode { sid op {mode {}} }
          Operations on Confmodes Supported: init, set, get, parent, list, exists, getstring, setstring, exit,
execute { sid cmdline }
          This command attempts to find if a given command is a mikroconf command and if so, it executes
inuse { name }
          Check if a module is in use by some session (user or background or remote), or
isArgFinal { NO node argList prefix count types values names startstate finalstates curstate prevFinal }
          When the cursor is placed on an argument, find whether the command line up and including the word where the cursor is placed, can be executed as it
isCmdFinal { NO node }
          When the cursor is placed on a path or command, find whether the command line up and including the word where the cursor is placed, can be executed as it
loadConf { {text {}} }
          Apply Startup Config, resulting in Running Config == Startup Config.
loadspecs { filepath }
          Load command specifications from an XML file into the internal data representation.
match { sid options cmdline wordIndex }
          It looks for MikroConf commands and arguments that can be placed in the word that the cursor is pointing at, and have as prefix the existing word part.
nextState { NO node curstate symbol }
          Returns the state of the automaton after consuming $symbol from
print { {arguments {}} {query {}} }
          Return the running configuration as XML, or a subparts of it, depetermined by a XPath
remove { name }
          Remove all command specifications associated with a module
runningConf { {parent root} }
          Generate the Running
saveConf { }
          Write Running Config to Startup Config
startupConf { }
          Retrieve Startup

Procedure Detail

authmode

proc authmode { sid op {mode {}} }
Operations on Authmodes. Supported: init, set, get, parent, list, exists, getstring, setstring, privilege, exit.
Parameters:
sid - Session Id.
op - Operation.
mode - The authentication mode name or string, depending on the operation. @error
Defined in:
sysconf.tcl, line 989

compute_fa

proc compute_fa { name NO node }
Get a Finate Automaton (::grammar::fa) from embedded specifications. Cache the generated fa by inserting it in the memory-resident DOM tree inside a tag, which is a sibling of .
Parameters:
name - Command name.
NO - Set if looking for the finate automaton that describes the negative form of the command.
node - The DOM node of the command.
Returns:
The command name of the finate automaton that corresponds to the found specification. @error
Defined in:
sysconf.tcl, line 1312

confmode

proc confmode { sid op {mode {}} }
Operations on Confmodes Supported: init, set, get, parent, list, exists, getstring, setstring, exit, store
Parameters:
sid - Session Id.
op - Operation.
mode - The configuration mode name or string, depending on the operation. @error
Defined in:
sysconf.tcl, line 1072

execute

proc execute { sid cmdline }
This command attempts to find if a given command is a mikroconf command and if so, it executes it.
Parameters:
command - The command name and arguments to execute.
Returns:
The result of the execution or a formatted error message. @error
Defined in:
sysconf.tcl, line 907

inuse

proc inuse { name }
Check if a module is in use by some session (user or background or remote), or not.
Returns:
'1' if in use, '0' otherwise.
Defined in:
sysconf.tcl, line 91

isArgFinal

proc isArgFinal { NO node argList prefix count types values names startstate finalstates curstate prevFinal }
When the cursor is placed on an argument, find whether the command line up and including the word where the cursor is placed, can be executed as it is.
Parameters:
NO - Boolean. Whether we have a negation command or not.
node - The node of the command the argument belongs to.
argList - List of arguments that match with the prefix: {type name values} ....
prefix - The prefix of the word the cursor is placed.
count - The number of matching arguments (or valid arguments).
types - The types of all valid arguments concatenated.
values - The matching values of all valid arguments concatenated.
names - The names of all valid arguments concatenated.
startstate - The name of the start state of the automaton.
finalstates - The names of final states of the automaton.
curstate - The name of the current state.
prevFinal - Whether the previous word was a command (-1), a final state (1) or else (0).
Returns:
'1' if argument is final, '0' otherwise.
Defined in:
sysconf.tcl, line 831

isCmdFinal

proc isCmdFinal { NO node }
When the cursor is placed on a path or command, find whether the command line up and including the word where the cursor is placed, can be executed as it is.
Parameters:
NO - Boolean. Whether we have a negation command or not.
node - The command node in the DOM tree.
Returns:
'1' if command is final, '0' otherwise.
Defined in:
sysconf.tcl, line 787

loadConf

proc loadConf { {text {}} }
Apply Startup Config, resulting in Running Config == Startup Config. Log but ignore any errors. @assume Existance of "priv" authmode and "global" conf mode.
Parameters:
text - Configuration text to apply. If not provided then the startup-config is applied. @error
Defined in:
sysconf.tcl, line 1236

loadspecs

proc loadspecs { filepath }
Load command specifications from an XML file into the internal data representation. In case of parse or other error, we catch them in here, and log it.
Parameters:
filepath - The source file itself. @error
Defined in:
sysconf.tcl, line 54

match

proc match { sid options cmdline wordIndex }
It looks for MikroConf commands and arguments that can be placed in the word that the cursor is pointing at, and have as prefix the existing word part. Matching of commands is based solely on their names. An argument can be of type: 1. exact : One possible value is permitted, and this is the name of the argument as found in the name=".." parameter of the argument tag. This argument type can be abbreviated. 2. list : A fixed finite list of alternatives that is defined in the XML specifications for the command. This argument type can be abbreviated. 3. dlist : A dynamic finite list of alternatives that is automatically generated on runtime. This argument type can be abbreviated. 4. any : Any value fits in this category. The validity is determined by the command handler on execution. This argument type cannot be abbreviated. It can coexist with the previous types, in which case if there is no exact match with any of the exact/list/dlist alternatives, it is caught by this one, however if there is an exact match, it takes precedence. It is not considered by TAB expansion, which only considers types 1-3. In-line help (?) on the other hand always lists it, along with any matching types of 1-3. 5. fixed : The value of this element must hold a serialized Tcl array mapping names to help messages. Command expansion (TAB) will consider the names as valid alternatives, whereas in-line help (with ?) will display the names as alternatives along with the corresponding help messages. The "fixed" type is useful for brevity purposes, and performance. Instead of having a complex automaton with multiple "exact" element types, you only have one element and only one state in the automaton. All words except the last one are expected to be unambiguous, meaning that (after aplying proper precedence rules) match to exactly one possible entity (argument or command). To resolve collisions between literals coming from "list" "dlist" "fixed" or "exact" types with the "any" type that accepts any string, we give precedence to the former types, if and only if there is an exact match. For example "running-config" will match the "exact" type with name "running-config", but "running" will match the "any" type if it is supported in the argument position being processed. For the last argument the procedure returns information based on a list of provided flags. Supported flags: -no : Indicates whether the command is a negation (starts with no) or not. -type : For commands it returns the string "command" and for arguments the string "argument". -pos : The position in the command list when the last word that is interpreted as command resides. After this point, all remaining words are arguments. -nodes : For commands it returns the matching nodes, INCLUDING structural paths. For arguments, it returns the single command node the arguments belongs to. -count : For commands it returns the number of matching commands, EXCLUDING structural paths. For arguments, it returns the number of matching arguments, of all types; it does not consider type precedence (e.g. "exact" has higher precedence then "any" type). -names : Returns matching names (command & argument names). For commands structural nodes are not considered. -values : Returns matching values (command names & argument values). This is used by Tab completion. -types : The types of the arguments that are valid for the specified argument position. -help : Return a list of tuples for each matching argument/command of the form: {Name Description}. For commands structural nodes are not considered. This is used by question mark help. -final : 1 indicates that the command can be executed as it is. 0 that it is not specific enough or complete yet. -vector : Return a list of tuples of the form: , one for each argument in cmdlist. is the unique name of the argument and is the value provided in the cmdlist by the user. Note: "no" is counted in -count, -help, -values, -names, but not in -vector. The command supports returning information for multiple flags with a single call. This is for performance reasons. It is more efficient to run the algorithm once and retrieve as much information as possible, than running it multiple times for different types of info. When multiple flags are specified then the result is a list of lists. One sub-list for each flag in the order they are provided (from left to right). Note: Any backslashes in the input command string are substituted (removed) first before processing it.
Parameters:
sid - Session Id.
options - A combination of: "-count", "-names", "-values", "-help", "-final"
cmdline - The command line string to operate on.
wordIndex - The word index the cursor is pointing at in the cmdline list.
Returns:
Returns the matched names/values for each provided flag in order. @error
Defined in:
sysconf.tcl, line 230

nextState

proc nextState { NO node curstate symbol }
Returns the state of the automaton after consuming $symbol from $curstate.
Parameters:
NO - Boolean. Whether we have a negation command or not.
node - The node of the command the argument belongs to.
curstate - The name of the current state.
symbol - The symbol to consume.
Returns:
The state of the automaton after consuming $symbol from $curstate.
Defined in:
sysconf.tcl, line 889

print

proc print { {arguments {}} {query {}} }
Return the running configuration as XML, or a subparts of it, depetermined by a XPath query.
Parameters:
arguments - The arguments accepted by the 'asXML' sub-command of domDoc/domNode.
query - XPath query to determine the nodes whose subtrees will be concatanated and printed.
Returns:
An XML string.
Defined in:
sysconf.tcl, line 131

remove

proc remove { name }
Remove all command specifications associated with a module name.
Parameters:
name - The module name.
Defined in:
sysconf.tcl, line 114

runningConf

proc runningConf { {parent root} }
Generate the Running Configuration.
Parameters:
parent - The mainconf section to generate the running configuration for.
Returns:
The Running Configuration for $parent. @error
Defined in:
sysconf.tcl, line 1153

saveConf

proc saveConf {  }
Write Running Config to Startup Config @error
Defined in:
sysconf.tcl, line 1274

startupConf

proc startupConf {  }
Retrieve Startup Configuration
Returns:
Startup Configuration @error
Defined in:
sysconf.tcl, line 1213

Overview | Index by: file name | procedure name | procedure call | annotation
File generated 2010-03-13 at 22:28.