Commit 1d3b92cb authored by Francesc Guasch's avatar Francesc Guasch
Browse files

[#518] store domain info

parent 766950f4
......@@ -748,6 +748,7 @@ sub _upgrade_tables {
$self->_upgrade_table('domains','status','varchar(32) DEFAULT "shutdown"');
$self->_upgrade_table('domains','display','varchar(128) DEFAULT NULL');
$self->_upgrade_table('domains','info','varchar(255) DEFAULT NULL');
$self->_upgrade_table('domains_network','allowed','int not null default 1');
......
......@@ -197,6 +197,8 @@ after '_select_domain_db' => \&_post_select_domain_db;
before 'migrate' => \&_pre_migrate;
after 'migrate' => \&_post_migrate;
around 'get_info' => \&_around_get_info;
##################################################
#
......@@ -581,6 +583,15 @@ sub _around_display($orig,$self,$user) {
$self->_data(display => $display);
return $display;
}
sub _around_get_info($orig, $self) {
my $info = $self->$orig();
if (ref($self) =~ /^Ravada::Domain/) {
$self->_data(info => encode_json($info));
}
return $info;
}
##################################################################################3
sub _init_connector {
......@@ -1402,6 +1413,7 @@ sub _post_start {
);
}
$self->get_info();
}
sub _update_id_vm($self) {
......
......@@ -10,6 +10,7 @@ Ravada::Front::Domain - Frontent domain information for Ravada
=cut
use Carp qw(cluck confess croak);
use JSON::XS;
use Moose;
no warnings "experimental::signatures";
......@@ -45,7 +46,12 @@ sub display($self, $user) {
}
sub force_shutdown { confess "TODO" }
sub get_info { confess "TODO" }
sub get_info($self) {
my $info = $self->_data('info');
return {} if !$info;
return decode_json($info);
}
sub hybernate { confess "TODO" }
sub is_active($self) {
......
......@@ -295,6 +295,11 @@ sub _around_create_domain {
$domain->run_timeout($base->run_timeout)
if defined $base->run_timeout();
}
my $user = Ravada::Auth::SQL->search_by_id($id_owner);
$domain->is_volatile(1) if $user->is_temporary();
$domain->get_info();
return $domain;
}
......
......@@ -17,6 +17,7 @@ CREATE TABLE `domains` (
`start_time` int not null default 0,
`status` varchar(32) default 'shutdown',
`display` varchar(128) default NULL,
`info` varchar(255) default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id_base` (`id_base`,`name`),
UNIQUE KEY `name` (`name`)
......
......@@ -17,6 +17,7 @@ CREATE TABLE `domains` (
, `start_time` integer not null default 0
, `status` varchar(32) default 'shutdown'
, `display` varchar(128) default NULL
, `info` varchar(255) default NULL
, UNIQUE (`id_base`,`name`)
, UNIQUE (`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