The get() method is the key to looking up items in a configuration
file. It takes an array of designators as an argument. A designator
is simply something that identifies a portion of a configuration
file. For example (interface) is a designator for all the interfaces
and (ip route) is a designator for all the static routes.
When multiple designators are specified, they are used for nested configuration items. For example, (router bgp, neighbor) would be a designator for all the BGP neighbors. This assumes that there is only one router bgp defined.
In array context, get() will follow multiple paths to find configuration items that match the specification. For example (interface, ip address) would return a list of ip address items across multiple interfaces.
Designators must exactly match words in the configuration. You may not abbr anythng.
The set() method will generate Cisco configuration snippets
that will modify the configuration of an item. For example,
the following code:
If the configuration already matches the $newvalue then nothing would be printed.
The designator(s) say what will be modified. This should either be represent a line or an entire block. When multiple designators are needed, pass them as an anonymous array. The above example could also have been written as:
If no designators are needed, dont pass any. The following is nearly the same as the preceeding;
When providing code snippets to set(), indent blocks just like Ciscos do when they display their configuration. For example, the following:
Will print the following if the access list inst already set as listed:
When modifying a block, include the configruation line that starts the block in the replacement text. For example, when setting an entire interface, provide the entire block:
The all() method can be used to expand and select configuration
For example, to make sure that all loopback interfaces use a netmask of 255.255.255.255, use the following:
The $regex paramater is optional.
->single() Cisco::Reconfig objects may represent any word in a configruation file. For example the word address in the following is represented by an object that would be returned by the code that follows.
single() answers the question: does this Cisco::Reconfig object uniquely specify a single point in the configuration? In the example above, the object for word ip (above) does not but the object for the word address does.
single() returns an object (representing the last word on the line) or undef.
->zoom() zoom() is the same as to single() except that it will always return a valid Cisco::Reconfig object. ->endpt() Returns an Cisco::Reconfig object representing the last word on a configuration line that could follow from the current ZYZ object. When there are multiple possibilities the object picked is nearly random. ->next() next() returns an Cisco::Reconfig object representing the last word on the suceeding line of the current configuration block.
When used at the beginning of a block, it returns the last word of the first line in the block.
->context() Returns the configuration object that represents the surounding context.
context() always returns a configuration object.
->subs() For Cisco::Reconfig objects that represent a word in a line that introduces a block of configuration items (such as most interface lines), the subs() function returns an Cisco::Reconfig object that represents the contents of the block.
If the Cisco::Reconfig object in question does not represent the start of a configuration block, the undefined object is returned.
->kids() For Cisco::Reconfig objects that do not uniquely specify a single line (ie: ! -single()>), the ->kids() method will return an array of objects representing the possible following words.
If there is only one possibility, that one possibility is returned.
If the Cisco::Reconfig object represents the last word on a configuration line then that word is returned.
->text() Returns the text from the original configuration file (in original order) of all of the lines that could follow from the current Cisco::Reconfig object.
When the invoking Cisco::Reconfig object represents a single line text() returns that line. When the invoking Cisco::Reconfig object represents a block text() returns the entire block. When the Cisco::Reconfig object represents a word with multiple possible completions, text() returns all the completions.
->alltext() Returns the text from the original configuration file of all the lines that could follow from the current Cisco::Reconfig object and all lines that are introduced by the current object.
To get the text of all interface definitions in their entirety, use;
->setcontext() Returns an array of configuration lines that define the block surrounding the invoking object. ->unsetcontext() Returns an array of the word exit repeated as many times as nessasary to undo a setcontext(). ->block() Returns true if the object represents a whole configuration block.
Some cisco configurations have a minus one indent beginning with the class keyword. This exception is matched and handled. To change the regex for what is accepted for a minus-one indent, override $Cisco::Reconfig::allow_minus_one_indent to a new regex. Set to undef to disable this override.
Some cisco configurations have a plus one indent beginning with the service-index keyword. This exception is matched and handled. To change the regex for what is accepted for a plus-one indent, override $Cisco::Reconfig::allow_plus_one_indent to a new regex. Set to undef to disable this override.
If you encounter other broken indents, please let the maintiner know. If it can be handled with the above overrides, do so. If it cannot, you can change $Cisco::Reconfig::bad_indent_policy to WARN or IGNORE. The default behavior is to die.
Two operators are overloaded: boolean tests and stringification. Cisco::Reconfig objects booleanify as true if they are the special undefined objects. Cisco::Reconfig objects stringify as their text lines.
Since Cisco::Reconfig doesnt really understand Cisco configuration files it cant know things that you might think it should.
No attempt has been made to make this module particularly fast or efficient for the computer.
Cisco::Reconfig objects dont automatically garbage collect themselves because they are highly self-referrential.
Copyright (C) 2002-2010 David Muir Sharnoff <firstname.lastname@example.org> Copyright (C) 2011-2012 Google, Inc. This module may be licensed on the same terms as Perl itself.
|perl v5.20.3||CISCO::RECONFIG (3)||2013-09-27|