change if statements to elsif

This commit is contained in:
mischa 2021-05-09 16:28:05 +02:00
parent b7df6b75de
commit 047151d10e
1 changed files with 4 additions and 13 deletions

View File

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