change if statements to elsif
This commit is contained in:
parent
b7df6b75de
commit
047151d10e
17
notify.pl
17
notify.pl
|
@ -161,14 +161,10 @@ my @files = glob "$conf{'conf'}{'VMS'}/*.txt";
|
||||||
|
|
||||||
if ($function =~ /notify/) {
|
if ($function =~ /notify/) {
|
||||||
mailout(\%conf, \%vms);
|
mailout(\%conf, \%vms);
|
||||||
}
|
} elsif ($function =~ /(msg|deployed)/ and $function_variable !~ /empty/) {
|
||||||
|
|
||||||
if ($function =~ /(msg|deployed)/ and $function_variable !~ /empty/) {
|
|
||||||
my %slice = %vms{$function_variable};
|
my %slice = %vms{$function_variable};
|
||||||
mailout(\%conf, \%slice);
|
mailout(\%conf, \%slice);
|
||||||
}
|
} elsif ($function =~ /(renewal|subscription|deprovision)/) {
|
||||||
|
|
||||||
if ($function =~ /(renewal|subscription|deprovision)/) {
|
|
||||||
my $year = strftime("%Y", localtime);
|
my $year = strftime("%Y", localtime);
|
||||||
my $month = strftime("%m", localtime);
|
my $month = strftime("%m", localtime);
|
||||||
for my $vm_name (sort keys %vms) {
|
for my $vm_name (sort keys %vms) {
|
||||||
|
@ -181,19 +177,14 @@ if ($function =~ /(renewal|subscription|deprovision)/) {
|
||||||
if ($function =~ /subscription/) {
|
if ($function =~ /subscription/) {
|
||||||
if (defined $vms{$vm_name}{'subscription'} and $vms{$vm_name}{'subscription'} eq "") { delete $vms{$vm_name}; next; }
|
if (defined $vms{$vm_name}{'subscription'} and $vms{$vm_name}{'subscription'} eq "") { delete $vms{$vm_name}; next; }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
mailout(\%conf, \%vms);
|
mailout(\%conf, \%vms);
|
||||||
}
|
} elsif ($function =~ /stopped/) {
|
||||||
|
|
||||||
if ($function =~ /stopped/) {
|
|
||||||
my @stopped_vms = qx(vmctl show | grep stopped | awk '{print \$9}');
|
my @stopped_vms = qx(vmctl show | grep stopped | awk '{print \$9}');
|
||||||
for my $vm_name (sort keys %vms) {
|
for my $vm_name (sort keys %vms) {
|
||||||
if (!grep(/$vm_name/, @stopped_vms)) { delete $vms{$vm_name}; next; }
|
if (!grep(/$vm_name/, @stopped_vms)) { delete $vms{$vm_name}; next; }
|
||||||
}
|
}
|
||||||
mailout(\%conf, \%vms);
|
mailout(\%conf, \%vms);
|
||||||
}
|
} else {
|
||||||
|
|
||||||
if ($function =~ /empty/) {
|
|
||||||
print "Specify function: deployed <vmid>, stopped, renewal, notify, deprovision, msg <vmid>\n";
|
print "Specify function: deployed <vmid>, stopped, renewal, notify, deprovision, msg <vmid>\n";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue