diff --git a/cgi-bin/set_power b/cgi-bin/set_power index 75656cd5..fe0e130a 100755 --- a/cgi-bin/set_power +++ b/cgi-bin/set_power @@ -18,6 +18,8 @@ if (($running_directory =~ /^\./) && ($ENV{PWD})) $running_directory =~ s/^\./$ENV{PWD}/; } +my $anvil = Anvil::Tools->new(); + sub set_anvil_power { # Expects the first element of @_ (argument array) to be a hash. @@ -28,7 +30,7 @@ sub set_anvil_power $anvil->Log->variables({ source => $THIS_FILE, line => __LINE__, - level => $debug, + level => 2, list => { anvil_uuid => $anvil_uuid, on => $on @@ -47,7 +49,7 @@ sub set_host_power $anvil->Log->variables({ source => $THIS_FILE, line => __LINE__, - level => $debug, + level => 2, list => { host_uuid => $host_uuid, on => $on @@ -55,10 +57,13 @@ sub set_host_power }); } -my $anvil = Anvil::Tools->new(); - $anvil->Get->switches; +# Temporary; for debugging +$anvil->Log->level({ + set => 2 +}); + $anvil->Database->connect; $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132"}); if (not $anvil->data->{sys}{database}{connections}) @@ -79,13 +84,27 @@ print $anvil->Template->get({file => "shared.html", name => "json_headers", show my $hash = {}; my $anvil_uuid = exists $anvil->data->{cgi}{anvil_uuid}{value} ? $anvil->data->{cgi}{anvil_uuid}{value} : ""; my $host_uuid = exists $anvil->data->{cgi}{host_uuid}{value} ? $anvil->data->{cgi}{host_uuid}{value} : ""; + +$anvil->Log->variables({ + source => $THIS_FILE, + line => __LINE__, + level => 2, + list => { + anvil_uuid => $anvil_uuid, + host_uuid => $host_uuid, + # Requests made with the PUT method won't have query params + CGI => Dumper($anvil->data->{cgi}), + PUTDATA => Dumper($anvil->data->{cgi}{PUTDATA}) + } +}); + if ($anvil_uuid) { if (exists $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}) { set_anvil_power({ anvil_uuid => $anvil_uuid, - on => $anvil->{cgi}{PUTDATA}{value} + on => $anvil->data->{cgi}{PUTDATA}{value} }); } else @@ -99,7 +118,7 @@ elsif ($host_uuid) { set_host_power({ host_uuid => $host_uuid, - on => $anvil->{cgi}{PUTDATA}{value} + on => $anvil->data->{cgi}{PUTDATA}{value} }); } else