(plugin) apps::ipfabric - add snapshot id param (#3684)

* add snapshot id as parameter

* help details about snapshot id param
This commit is contained in:
lchrdn 2022-05-24 22:22:55 +02:00 committed by GitHub
parent d38b17ece7
commit a370a53b27
3 changed files with 21 additions and 10 deletions

View File

@ -37,7 +37,8 @@ sub new {
'port:s' => { name => 'port' },
'proto:s' => { name => 'proto' },
'api-key:s' => { name => 'api_key' },
'timeout:s' => { name => 'timeout' }
'timeout:s' => { name => 'timeout' },
'snapshot-id:s' => { name => 'snapshot_id' }
});
}
$options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1);
@ -65,6 +66,7 @@ sub check_options {
$self->{url_path} = (defined($self->{option_results}->{url_path})) ? $self->{option_results}->{url_path} : '/api/v1/tables';
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10;
$self->{api_key} = (defined($self->{option_results}->{api_key})) ? $self->{option_results}->{api_key} : '';
$self->{snapshot_id} = (defined($self->{option_results}->{snapshot_id})) ? $self->{option_results}->{snapshot_id} : "\$last";
if (!defined($self->{hostname}) || $self->{hostname} eq '') {
$self->{output}->add_option_msg(short_msg => "Need to specify --hostname option.");
@ -102,6 +104,7 @@ sub request_api {
my $encoded_form_post;
if (defined($options{query_form_post})) {
$options{query_form_post}->{snapshot} = $self->{snapshot_id};
eval {
$encoded_form_post = JSON::XS->new->utf8->encode($options{query_form_post});
};
@ -159,6 +162,12 @@ IP Fabric API module.
Set hostname, it is mandatory.
=item B<--snapshot-id>
Specify snapshot id from which you want to base monitoring.
If no snapshot id is specified, the last one is set by default.
=item B<--port>
Port used (Default: 443)

View File

@ -65,7 +65,6 @@ sub manage_selection {
"limit" => undef,
"start" => 0
},
"snapshot" => "\$last",
"reports" => "/inventory/devices"
};
@ -99,7 +98,6 @@ sub manage_selection {
"limit" => undef,
"start" => 0
},
"snapshot" => "\$last",
"reports" => "/technology/management/snmp/communities"
};

View File

@ -156,7 +156,6 @@ sub manage_selection {
"limit" => undef,
"start" => 0
},
"snapshot" => "\$last",
"reports" => "/technology/routing/path-verifications"
};
@ -181,6 +180,11 @@ sub manage_selection {
}
}
if (scalar(keys %$path_state) <= 0) {
$self->{output}->add_option_msg(short_msg => "No path found.");
$self->{output}->option_exit();
}
foreach my $id (keys %$path_state) {
my $dest_port = (defined($path_state->{$id}->{dest_port})) ? $path_state->{$id}->{dest_port} : 'empty';