Commit 968740ac authored by Francesc Guasch's avatar Francesc Guasch
Browse files

[#202] cache active VMs

parent 8e580696
......@@ -715,6 +715,7 @@ sub _upgrade_tables {
$self->_upgrade_table('vms','cached_active',"integer DEFAULT 0");
$self->_upgrade_table('vms','cached_active_time',"integer DEFAULT 0");
$self->_upgrade_table('vms','public_ip',"varchar(128) DEFAULT NULL");
$self->_upgrade_table('vms','is_active',"int DEFAULT 0");
$self->_upgrade_table('requests','at_time','int(11) DEFAULT NULL');
$self->_upgrade_table('requests','pid','int(11) DEFAULT NULL');
......
......@@ -298,7 +298,7 @@ Returns a list of Virtual Managers
sub list_vms($self, $type=undef) {
my $sql = "SELECT id,name,hostname,status FROM vms ";
my $sql = "SELECT id,name,hostname,is_active FROM vms ";
my @args = ();
if ($type) {
......@@ -312,8 +312,6 @@ sub list_vms($self, $type=undef) {
my @list;
while (my $row = $sth->fetchrow_hashref) {
$row->{is_active} = 0;
$row->{is_active} = 1 if $row->{status} eq 'active';
my $vm = $self->_vm_id($row->{id});
$self->_list_bases_vm($row);
lock_hash(%$row);
......
......@@ -5,6 +5,7 @@ create table vms (
`hostname` varchar(128) NOT NULL,
`default_storage` varchar(64) DEFAULT 'default',
`security` varchar(20) default null,
`is_active` int default 0,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
UNIQUE KEY `hostname_type` (`hostname`,`vm_type`)
......
......@@ -763,7 +763,7 @@ sub test_shutdown($node) {
diag("SKIPPED: I can't test shutdown of ".$node->type." nodes");
}
is($clone->is_active,0,"[".$clone->type."] Expecting clone ".$clone->name." inactive") or return;
is($clone->_data('is_active'),1,"[".$clone->type."] Expecting clone ".$clone->name." data active") or return;
is($clone->_data('status'),'active',"[".$clone->type."] Expecting clone ".$clone->name." data active") or return;
my $clone2 = Ravada::Domain->open($clone->id); #open will clean internal shutdown
......
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