Commit 90348489 authored by robertperez-upc's avatar robertperez-upc Committed by frankiejol
Browse files

#1527: add option to start all clones sequentially (#1529)

parent 755951f0
...@@ -1162,12 +1162,28 @@ post '/request/(:name)/' => sub { ...@@ -1162,12 +1162,28 @@ post '/request/(:name)/' => sub {
confess "Error: $_ should not be provided".Dumper($args) confess "Error: $_ should not be provided".Dumper($args)
if exists $args->{$_}; if exists $args->{$_};
} }
if ($name eq 'start_clones') { if (($name eq 'start_clones') || ($name eq 'start_clones_sequentially')) {
$args->{remote_ip} = _remote_ip($c); $args->{remote_ip} = _remote_ip($c);
} }
app->log->info($USER->name." requesting $name ".encode_json($args)) if $CONFIG_FRONT->{log}->{log}; app->log->info($USER->name." requesting $name ".encode_json($args)) if $CONFIG_FRONT->{log}->{log};
my $req; my $req;
if ($name eq 'start_clones_sequentially') {
my $domain = $RAVADA->search_domain_by_id($args->{'id_domain'}) or do {
$c->stash( error => "This machine doesn't exist. Probably it has been deleted recently.");
return;
};
delete($args->{'id_domain'});
foreach my $clone ($domain->clones()) {
$req = Ravada::Request->start_domain(uid => $USER->id
,name => $clone->{'name'}
,%$args
);
$args->{'after_request'} = $req->id;
}
} else {
eval { eval {
$req = Ravada::Request->new_request( $req = Ravada::Request->new_request(
$name $name
...@@ -1175,6 +1191,7 @@ post '/request/(:name)/' => sub { ...@@ -1175,6 +1191,7 @@ post '/request/(:name)/' => sub {
,%$args ,%$args
); );
}; };
}
return $c->render(json => { ok => 0, error => $@ }) if !$req; return $c->render(json => { ok => 0, error => $@ }) if !$req;
return $c->render(json => { ok => 1, request => $req->id }); return $c->render(json => { ok => 1, request => $req->id });
}; };
......
...@@ -3,6 +3,11 @@ ...@@ -3,6 +3,11 @@
<label><%=l 'These actions affect all the clones on the machine' %></label> <label><%=l 'These actions affect all the clones on the machine' %></label>
</div> </div>
<div class="row"> <div class="row">
<button class="btn btn-primary mr-2" id="start-clones" name="start-clones"
ng-click="request('start_clones_sequentially',{ 'id_domain': showmachine.id })"
>
<%=l 'Start all clones sequentially' %>
</button>
<button class="btn btn-primary mr-2" id="start-clones" name="start-clones" <button class="btn btn-primary mr-2" id="start-clones" name="start-clones"
ng-click="request('start_clones',{ 'id_domain': showmachine.id })" ng-click="request('start_clones',{ 'id_domain': showmachine.id })"
> >
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment