NA - Using Policy with Advanced Auto Remediation Script - machting block

Idea ID 2774276

NA - Using Policy with Advanced Auto Remediation Script - machting block

We have the request to use at a Advanced Auto Remediation Script (Perl) varriables from  policy machting block:

There is a limitation of the product. There is no logic to resolve variables from more than one condition which included blocktext/configtext to use in auto remediation scripts.

Existing logic  only checks and expects  one condition using blocktext.

See snapshot how it could lok like

3 Comments
Micro Focus Expert
Micro Focus Expert
Status changed to: Needs Clarification

Dear Submitter,

Can you please clarify as to how you like to use multiple conditions in a block text? An example would help.

Respected Contributor.. Respected Contributor..
Respected Contributor..

This is a fictional (simple) code of potential use cases (auto-remediation) which can't be work due of the requested feature enhancement.

Should be show the idea of teh EH.

Embedded -> new feature
matching block  code

Sample 1:

=====================================

#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
use Opsware::NAS::Connect;
use Data::Dumper;

my($host, $port, $user, $pass) = ('localhost','$tc_proxy_ssh_port$','$tc_user_username$','$tc_user_password$');
my $device = '#$tc_device_id$';
my @output;

my $con = Opsware::NAS::Connect->new( { -user => $user, -pass => $pass, -host => $host, -port => $port, -ssh => 1, -debug => 0, -timeout => 30 } );
$con->login();
my $prompt = qr/;1H([\x20-\x7e]*?#)/m;
$con->connect( $device, $prompt ) or die "Failed to connect.";

# ---> do some previous stuff -coding
print "pre stuff\n";

#===============================================================================================
# Embedded START -> new feature
# start maching blcok
@foreach $matching_block$ in $block_start$
// block variables that can be used:
// $matching_block$ or $matching_block.regex_group_0$
// $matching_block.regex_group_0$
// $matching_block.regex_group_1$
@foreach $matching_line$ in $condition_A_line_1$
// variables that can be used:
// $matching_line.regex_group_0$
no interface $matching_block.regex_group_1$ lacp
no cdp enable $matching_block.regex_group_1$
snmp-server enable traps link-change $matching_block.regex_group_1$
no spanning-tree $matching_block.regex_group_1$ auto-edge-port
interface $matching_block.regex_group_1$ bandwidth-min output 5 5 50 5 20 10 5 strict
@end
@end
# Embedded FINISHED -> new feature
# ===============================================================================================

# ---> do some post stuff - coding
# ex.
print "post stuff\n";

@output = $con->disconnect("logout\n");
#$con->logout();

undef $con;
exit(0);

Native PERL code using variables from policy "matching blocks"

Sample 2:

========================================================

#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
use Opsware::NAS::Connect;
use Data::Dumper;

my($host, $port, $user, $pass) = ('localhost','$tc_proxy_ssh_port$','$tc_user_username$','$tc_user_password$');
my $device = '#$tc_device_id$';
my @output;

my $con = Opsware::NAS::Connect->new( { -user => $user, -pass => $pass, -host => $host, -port => $port, -ssh => 1, -debug => 0, -timeout => 30 } );
$con->login();
my $prompt = qr/;1H([\x20-\x7e]*?#)/m;
$con->connect( $device, $prompt ) or die "Failed to connect.";

# ---> do some previous stuff -coding
print "pre stuff\n";

#===============================================================================================
# native PERL code using varibles from policy matching blocks
#START: -> new feature
# start maching blcok

if $block_start$ {
foreach ( $matching_block$ ) {
print "block";
foreach ( $matching_line$ eq $condition_A_line_1$ ) {
$cmd="no interface $matching_block.regex_group_1$ lacp";
@output = $connect->cmd($cmd);
}
}
}
# embended Finished -> new feature
# ===============================================================================================

# ---> do some post stuff - coding
# ex.
print "post stuff\n";

@output = $con->disconnect("logout\n");
#$con->logout();

undef $con;
exit(0);

 

 

 

Micro Focus Expert
Micro Focus Expert
Status changed to: Waiting for Votes

The idea has received an initial review to ensure adherence to our idea submission and community guidelines. More information may be needed at this stage, and we expect the community to help prioritize the idea with comments and community support (votes/kudos).

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.