Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1309 from teharrison/develop
repo cleanup, bug fixes, function lookup
- Loading branch information
Showing
9 changed files
with
263 additions
and
533 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/env perl | ||
|
||
###### cleanup tool ###### | ||
# given AWE ID | ||
# 1. delete job from AWE | ||
# 2. delete all output files in shock | ||
|
||
use lib "/MG-RAST/conf"; | ||
|
||
use strict; | ||
use warnings; | ||
no warnings('once'); | ||
|
||
use Conf; | ||
use JSON; | ||
use LWP::UserAgent; | ||
use HTTP::Request::Common; | ||
|
||
my $shock_url = $Conf::shock_url; | ||
my $awe_url = $Conf::awe_url; | ||
my $auth_token = $Conf::pipeline_token; | ||
|
||
my $aweid = shift @ARGV; | ||
|
||
unless ($aweid) { | ||
print STDERR "Usage: \tdelete_job_and_files.pl <awe_id> \n"; | ||
exit 1; | ||
} | ||
|
||
# set handels | ||
my $agent = LWP::UserAgent->new(); | ||
$agent->timeout(3600); | ||
my $json = JSON->new; | ||
$json = $json->utf8(); | ||
$json->max_size(0); | ||
$json->allow_nonref; | ||
|
||
# get job document | ||
my $response = undef; | ||
my $job_doc = undef; | ||
eval { | ||
my $get = $self->agent->get($awe_url.'/job/'.$aweid, 'Authorization', $auth_token); | ||
$response = $self->json->decode( $get->content ); | ||
}; | ||
if ($@ || (! ref($response))) { | ||
print STDERR "ERROR: unable to connect to AWE server\n"; | ||
} elsif (exists($response->{error}) && $response->{error}) { | ||
print STDERR "ERROR: ".$response->{error}[0]."\n"; | ||
} else { | ||
$job_doc = $response->{data}; | ||
} | ||
|
||
# delete job | ||
system("curl -X DELETE -H 'Authorization: $auth_token' '$awe_url/job/$aweid?full=1'; echo"); | ||
|
||
# delete nodes | ||
foreach my $task (@{$job_doc->{tasks}}) { | ||
foreach my $out (@{$task->{outputs}}) { | ||
if ($out->{node} && ($out->{node} ne '-')) { | ||
system("curl -X DELETE -H 'Authorization: $auth_token' '$shock_url/node/".$out->{node}."'; echo"); | ||
} | ||
} | ||
} | ||
|
||
exit 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.