(plugin) apps::ipfabric - add snapshot id param (#3684)
* add snapshot id as parameter * help details about snapshot id param
This commit is contained in:
parent
d38b17ece7
commit
a370a53b27
|
@ -32,12 +32,13 @@ sub new {
|
|||
|
||||
if (!defined($options{noptions})) {
|
||||
$options{options}->add_options(arguments => {
|
||||
'hostname:s' => { name => 'hostname' },
|
||||
'url-path:s' => { name => 'url_path' },
|
||||
'port:s' => { name => 'port' },
|
||||
'proto:s' => { name => 'proto' },
|
||||
'api-key:s' => { name => 'api_key' },
|
||||
'timeout:s' => { name => 'timeout' }
|
||||
'hostname:s' => { name => 'hostname' },
|
||||
'url-path:s' => { name => 'url_path' },
|
||||
'port:s' => { name => 'port' },
|
||||
'proto:s' => { name => 'proto' },
|
||||
'api-key:s' => { name => 'api_key' },
|
||||
'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)
|
||||
|
|
|
@ -65,9 +65,8 @@ sub manage_selection {
|
|||
"limit" => undef,
|
||||
"start" => 0
|
||||
},
|
||||
"snapshot" => "\$last",
|
||||
"reports" => "/inventory/devices"
|
||||
};
|
||||
};
|
||||
|
||||
my $disco_api_results = $options{custom}->request_api(
|
||||
method => 'POST',
|
||||
|
@ -99,7 +98,6 @@ sub manage_selection {
|
|||
"limit" => undef,
|
||||
"start" => 0
|
||||
},
|
||||
"snapshot" => "\$last",
|
||||
"reports" => "/technology/management/snmp/communities"
|
||||
};
|
||||
|
||||
|
|
|
@ -156,7 +156,6 @@ sub manage_selection {
|
|||
"limit" => undef,
|
||||
"start" => 0
|
||||
},
|
||||
"snapshot" => "\$last",
|
||||
"reports" => "/technology/routing/path-verifications"
|
||||
};
|
||||
|
||||
|
@ -180,6 +179,11 @@ sub manage_selection {
|
|||
$self->{global}->{total_mismatch}++;
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue