enhance vserver for netapp volumes

This commit is contained in:
garnier-quentin 2021-02-05 15:57:28 +01:00
parent 50db0dcea1
commit 69b2e5e0c1
2 changed files with 26 additions and 9 deletions

View File

@ -52,10 +52,12 @@ sub run {
my $volumes = $self->manage_selection(%options);
foreach (@{$volumes->{records}}) {
my $vserver_name = defined($_->{svm}) && $_->{svm}->{name} ne '' ? $_->{svm}->{name} : '-';
$self->{output}->output_add(long_msg => sprintf(
'[name = %s][state = %s]',
'[name = %s][state = %s][vserver = %s]',
$_->{name},
$_->{state}
$_->{state},
$vserver_name
));
}
@ -70,7 +72,7 @@ sub run {
sub disco_format {
my ($self, %options) = @_;
$self->{output}->add_disco_format(elements => ['name', 'state']);
$self->{output}->add_disco_format(elements => ['name', 'state', 'vserver_name']);
}
sub disco_show {
@ -78,9 +80,11 @@ sub disco_show {
my $volumes = $self->manage_selection(%options);
foreach (@{$volumes->{records}}) {
my $vserver_name = defined($_->{svm}) && $_->{svm}->{name} ne '' ? $_->{svm}->{name} : '-';
$self->{output}->add_disco_entry(
name => $_->{name},
state => $_->{state}
state => $_->{state},
vserver_name => $_->{svm}->{name}
);
}
}

View File

@ -153,7 +153,8 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
'filter-name:s' => { name => 'filter_name' }
'filter-name:s' => { name => 'filter_name' },
'filter-vserver-name:s' => { name => 'filter_vserver_name' }
});
return $self;
@ -166,14 +167,22 @@ sub manage_selection {
$self->{volumes} = {};
foreach (@{$volumes->{records}}) {
my $name = defined($_->{svm}) && $_->{svm}->{name} ne '' ?
$_->{svm}->{name} . ':' . $_->{name} :
$_->{name};
if (defined($self->{option_results}->{filter_vserver_name}) && $self->{option_results}->{filter_vserver_name} ne '' &&
defined($_->{svm}) && $_->{svm}->{name} ne '' && $_->{svm}->{name} !~ /$self->{option_results}->{filter_vserver_name}/) {
$self->{output}->output_add(long_msg => "skipping '" . $_->{svm}->{name} . "': no matching filter.", debug => 1);
next;
}
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$_->{name} !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "skipping volume '" . $_->{name} . "': no matching filter.", debug => 1);
$name !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "skipping volume '" . $name . "': no matching filter.", debug => 1);
next;
}
$self->{volumes}->{ $_->{name} } = {
display => $_->{name},
$self->{volumes}->{$name} = {
display => $name,
state => $_->{state},
total_space => $_->{space}->{size},
@ -216,6 +225,10 @@ Example: --filter-counters='^usage$'
Filter volume name (can be a regexp).
=item B<--filter-vserver-name>
Filter volumes by vserver name (can be a regexp).
=item B<--unknown-status>
Set unknown threshold for status.