Commit e931e05b authored by fv3rdugo's avatar fv3rdugo
Browse files

List LXC templates

parent 19e21c31
......@@ -350,6 +350,37 @@ sub list_images_data {
}
sub list_images_lxc {
my $self = shift;
my @domains;
my $sth = $CONNECTOR->dbh->prepare(
"SELECT * FROM lx_templates ORDER BY name"
);
$sth->execute;
while (my $row = $sth->fetchrow_hashref) {
push @domains,($row);
}
$sth->finish;
return @domains;
}
=head2 list_images_data
List information about the images
=cut
sub list_images_data_lxc {
my $self = shift;
my @data;
for ($self->list_images_lxc ) {
push @data,{ id => $_->{id} , name => $_->{name} };
}
return \@data;
}
=head2 remove_volume
$ravada->remove_volume($file);
......
......@@ -96,10 +96,10 @@ sub _search_template {
my $self = shift;
my $id_template = shift or confess "Missing id_template";
my $sth = $$CONNECTOR->dbh->prepare("SELECT * FROM lxc_templates WHERE id = ?");
my $sth = $$CONNECTOR->dbh->prepare("SELECT * FROM lx_templates WHERE id = ?");
$sth->execute($id_template);
my $row = $sth->fetchrow_hashref;
die "Missing lxc_template id=$id_template" if !keys %$row;
die "Missing lx_template id=$id_template" if !keys %$row;
lock_hash(%$row);
return $row;
......
......@@ -24,6 +24,9 @@
$http.get('/list_vm_types.json').then(function(response) {
$scope.backends = response.data;
});
$http.get('/list_templates.json').then(function(response) {
$scope.templates_lxc = response.data;
});
};
......
......@@ -57,8 +57,8 @@
<label for="id_template">Template</label>
<select name ="id_template"
ng-model="id_template"
ng-options="item.name for item in templates_lxc track by item.id"
required="">
<option label="busybox" value="busybox">busybox</option>
</select>
</div><br/>
......@@ -120,4 +120,4 @@
</form>
</div>
</div>
\ No newline at end of file
</div>
......@@ -115,6 +115,12 @@ get '/list_machines.json' => sub {
$c->render(json => $RAVADA->list_domains_data);
};
get '/list_templates.json' => sub {
my $c = shift;
$c->render(json => $RAVADA->list_images_data_lxc);
};
# machine commands
get '/machine/manage/*html' => sub {
......
......@@ -53,7 +53,8 @@ sub test_remove_domain_by_name {
}
sub search_domain_db {
sub search_domain_db
{
my $name = shift;
my $sth = $test->dbh->prepare("SELECT * FROM domains WHERE name=? ");
$sth->execute($name);
......
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