Commit 4ff5fb5f authored by Francesc Guasch's avatar Francesc Guasch
Browse files

refactor(backend): fast search already started

issue #1265
parent d3e5fed0
......@@ -316,7 +316,8 @@ sub _start_preconditions{
}
#_check_used_memory(@_);
return if $self->_search_already_started();
return if $self->_search_already_started('fast');
$self->status('starting');
# if it is a clone ( it is not a base )
if ($self->id_base) {
# $self->_set_last_vm(1)
......@@ -349,10 +350,10 @@ sub _start_preconditions{
#$self->_check_cpu_usage($request);
}
sub _search_already_started($self) {
my $sth = $$CONNECTOR->dbh->prepare(
"SELECT id FROM vms where vm_type=?"
);
sub _search_already_started($self, $fast = 0) {
my $sql = "SELECT id FROM vms where vm_type=?";
$sql .= " AND is_active=1" if $fast;
my $sth = $$CONNECTOR->dbh->prepare($sql);
$sth->execute($self->_vm->type);
my %started;
while (my ($id) = $sth->fetchrow) {
......@@ -876,7 +877,7 @@ sub _around_display_info($orig,$self,$user ) {
if (!$self->readonly) {
$self->_set_display_ip($display);
$self->_data(display => encode_json($display));
$self->_data(display => encode_json($display)) if $self->is_active;
}
return $display;
}
......@@ -3367,7 +3368,7 @@ sub set_driver_id {
$sth->finish;
}
sub _listen_ip($self, $remote_ip) {
sub _listen_ip($self, $remote_ip=undef) {
return $self->_vm->listen_ip($remote_ip);
}
......
......@@ -636,6 +636,8 @@ sub _interface_ip($self, $remote_ip=undef) {
my ($network, $ip) = ($1, $2);
$route{$network} = $ip;
return $ip if $remote_ip && $remote_ip eq $ip;
my $netaddr = NetAddr::IP->new($network);
return $ip if $remote_ip_addr->within($netaddr);
......
Markdown is supported
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