Defining the parser service (cleanupparser) – H3C Technologies H3C Intelligent Management Center User Manual

Page 494

Advertising
background image

480

Note 5: TCL script.
Note 5: set_device_boot action.

Defining the parser service (CleanupParser)

CleanupParser consists of parser definition file xxxxxx_Cleanup_Parser.xml and parser script file

xxxxxx_Cleanup_Parser_Script.pl (xxxxxx refers to the drive name).

1.

xxxxxx_Cleanup_Parser.xml file format:

<?xml version="1.0"?>

<parser>

<!—note 1>

<perlfile>Cisco_Cleanup_Parser_Script.pl</perlfile>

<!—note 2>

<script name="cleanupConfiguration"> <!—note 3>

<callfunction name="cleanupConfiguration">

<!—note 4>

<parameterspec name="0" type="data_string"/>

<!—note 5>

<result type="single">configuration</result>

<!—note 6>

</callfunction>

</script>

<script

name="cleanupTFTPConfiguration">

<callfunction

name="cleanupTFTPConfiguration">

<parameterspec

name="0"

type="data_string"/>

<result

type="single">cleanedConfig</result>

</callfunction>

</script>

</parser>

Note 1: Parser label in fixed format.
Note 2: File that the parser script file belongs to. The label name is perlfile, which cannot be modified.
Note 3: Script name, which is used for calling.
Note 4: Called Perl function name. Perl functions are defined in the Perl file specified by the perlfile label.
Note 5: Enter the parameter name and type. Only the string type, data_string, is supported.
Note 6: Result variable. The parsing result assigns value to the variable, which is used by the caller. Array

is not supported, so the type is single.

2.

The parser script file xxxxxx_Cleanup_Parser_Script.pl consists of multiple Perl functions.

sub cleanupConfiguration

{

my($config) = @_;

my(@array) = ();

$start = index($config, "!");

if ($start == -1)

{

$start = 0;

}

… …

##

# ACNS remove CLI prompts

$config =~ s/\n\S+#\n/\n/g;

Advertising