The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

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 identify different types of commands and their outputs from a buffer given as parameter to the module. For each 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.

Logging of this class can be enabled by using Siebel::Srvrmgr logging feature.

Features

Currently, this class can parse the output of the following Siebel Server Manager commands:

  • load preferences

  • list comp

  • list compdef

  • list comp type

  • list params

  • list server

  • list session

  • list task

Also the initial text after connecting to Server Manager can be parsed.

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.

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.

enterprise

A reference to a Siebel::Srvrmgr::ListParser::Output::Greetings. It is defined during initial parsing (can be available or not).

This object has some details about the enterprise connected. Check the related Pod for more information.

fsa

clear_raw

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).

BUILD

Automatically defines the state machine object based on Siebel::Srvrmgr::ListParser::FSA.

set_buffer

Sets the buffer attribute, inserting new Siebel::Srvrmgr::ListParser::Buffer objects into the array reference as necessary.

Expects an instance of a FSA::State class as parameter (obligatory parameter).

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.

Can use an optional parameter as Siebel::Srvrmgr::ListParser::Buffer instance, othewise it will use the returned value from get_buffer method.

It uses Siebel::Srvrmgr::ListParser::OutputFactory to create the proper Siebel::Srvrmgr::ListParser::Output object based on the Siebel::Srvrmgr::ListParser::Buffer type.

If the item received as parameter is a Siebel::Srvrmgr::ListParser::Output::Greetings instance, it will be assigned to the enterprise attribute instead of being added to the parsed_tree attribute.

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. The array references indexes values should be rid off any EOL character.

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.

DEMOLISH

Due issues with memory leak and garbage collection, DEMOLISH was implemented to call additional methods from the API to clean buffer and parsed tree data.

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.

SEE ALSO

AUTHOR

Alceu Rodrigues de Freitas Junior, <arfreitas@cpan.org<>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 of Alceu Rodrigues de Freitas Junior, <arfreitas@cpan.org>

This file is part of Siebel Monitoring Tools.

Siebel Monitoring Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Siebel Monitoring Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Siebel Monitoring Tools. If not, see <http://www.gnu.org/licenses/>.