summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormischa <mischa@rx.high5.nl>2021-05-09 16:28:05 +0200
committermischa <mischa@rx.high5.nl>2021-05-09 16:28:05 +0200
commit047151d10e6faeee9836946c20aed24f5385c7d2 (patch)
tree9d84d35eb429464941b59b177de48480bd18316c
parentb7df6b75de6e6ac98d9a1d95a2b238420369ce9c (diff)
change if statements to elsif
-rwxr-xr-xnotify.pl17
1 files changed, 4 insertions, 13 deletions
diff --git a/notify.pl b/notify.pl
index 849b03a..f97174e 100755
--- a/notify.pl
+++ b/notify.pl
@@ -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";
}