NAME
Siebel::Srvrmgr::ListParser - state model parser to idenfity which output type was read
SYNOPSIS
use Siebel::Srvrmgr::ListParser;
my $parser = Siebel::Srvrmgr::ListParser->new({ prompt_regex => $some_prompt });
DESCRIPTION
Siebel::Srvrmgr::ListParser is a state machine parser created to parse output of "list" commands executed through srvrmgr
program.
The parser can idenfity different types of commands and their outputs from a buffer given as parameter to the module. Foreach type of output identified an Siebel::Srvrmgr::ListParser::Buffer object will be created, identifying which type of command was executed and the raw information from it.
At the end of information read from the buffer, this class will call Siebel::Srvrmgr::ListParser::OutputFactory to create specific Siebel::Srvrmgr::ListParser::Output objects based on the identified type of Buffer object. Each of this objects will parse the raw output and populate attributes based on this information. After this is easier to obtain the information from those subclasses of Siebel::Srvrmgr::ListParser::Output.
Siebel::Srvrmgr::ListParser expects to receive output from srvrmgr
program in an specific format and is able to idenfity a limited number of commands and their outputs, raising an exception when those types cannot be identified. See subclasses of Siebel::Srvrmgr::ListParser::Output to see which classes/types are available.
ATTRIBUTES
parsed_tree
An array reference of parsed data. Each index should be a reference to another data extructure, most probably an hash reference, with parsed data related from one line read from output of srvrmgr
program.
This is an read-only attribute.
has_tree
A boolean value that identifies if the ListParser object has a parsed tree or not.
prompt_regex
A regular expression reference of how the srvrmgr
prompt looks like.
hello_regex
A regular expression reference of how the first line of text received right after the login in one server (or enterprise).
last_command
A string with the last command identified by the parser. It is used for several things, including changes in the state model machine.
This is a read-only attribute.
is_cmd_changed
A boolean value that identified when the last_command attribute has been changed (i.e another command was identified by the parser).
buffer
An array reference with each one of the indexes being a Siebel::Srvrmgr::ListParser::Buffer
object.
is_warn_enabled
A boolean value that is used for debugging purpouses during the parsing time. If enabled some debug messages may be printed during this phase.
METHODS
is_cmd_changed
Sets the boolean attribute with the same name. If no parameter is given, returns the value stored in the is_cmd_changed
attribute. If a parameter is given, expects to received true (1) or false (0), otherwise it will return an exception.
get_parsed_tree
Returns the parsed_tree attribute.
get_prompt_regex
Returns the regular expression reference from the prompt_regex attribute.
set_prompt_regex
Sets the prompt_regex attribute. Expects an regular expression reference as parameter.
get_hello_regex
Returns the regular expression reference from the hello_regex attribute.
set_hello_regex
Sets the hello_regex attribute. Expects an regular expression reference as parameter.
get_last_command
Returns an string of the last command read by the parser.
has_tree
Returns a boolean value (1 for true, 0 for false) if the parser has or not a parsed tree.
set_last_command
Set the last command found in the parser received data. It also triggers that the command has changed (see method is_cmd_changed).
set_buffer
Sets the buffer attribute, inserting new Siebel::Srvrmgr::ListParser::Buffer
objects into the array reference as necessary.
clear_buffer
Removes the array reference from the buffer attribute and associates a new one with an empty array. This should be used for cleanup purpouses or attemp to free memory.
count_parsed
Returns an integer with the total number of objects available in the parsed_tree attribute.
clear_parsed_tree
Removes the reference on parsed_tree attribute. Also, sets has_tree attribute to false.
set_parsed_tree
Sets the parsed_tree attribute, adding references as necessary. Also sets the has_tree attribute to true.
This method should not be called directly unless you know what you're doing. See append_output
method.
append_output
Appends an object to an existing parsed tree. Expects as a parameter an Siebel::Srvrmgr::ListParser::Buffer
object as a parameter.
It uses Siebel::Srvrmgr::ListParser::OutputFactory
to create the proper Siebel::Srvrmgr::ListParser::Output
object based on the Siebel::Srvrmgr::ListParser::Buffer
type.
parse
Parses one or more commands output executed through srvrmgr
program.
Expects as parameter an array reference with the output of srvrmgr, including the command executed.
It will create an FSA::Rules
object to parse the given array reference, calling append_output
method for each Siebel::Srvrmgr::ListParser::Buffer
object found.
This method will raise an exception if a given output cannot be identified by the parser.
CAVEATS
Checkout the POD for the Siebel::Srvrmgr::ListParser::Output
objects to see details about which kind of output is expected if you're getting errors from the parser. There are details regarding how the settings of srvrmgr are expect for output of list commands.