Skip to content

Commit

Permalink
wip(frontend): fetch bases and local info for node
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiejol committed Mar 8, 2024
1 parent 6c44b4a commit 43f5b78
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/Ravada/WebSocket.pm
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,31 @@ sub _get_node_info($rvd, $args) {
my $sth = $rvd->_dbh->prepare("SELECT * FROM vms WHERE id=?");
$sth->execute($id_node);
my $data = $sth->fetchrow_hashref;
$data->{is_local}=0;
$data->{is_local}=1 if $data->{hostname} eq 'localhost'
|| $data->{hostname} eq '127.0.0,1'
|| !$data->{hostname};

$data->{bases}=_list_bases_node($rvd, $data->{id});

return $data;
}

sub _list_bases_node($rvd, $id_node) {
my $sth = $rvd->_dbh->prepare(
"SELECT d.id FROM domains d,bases_vm bv"
." WHERE d.is_base=1"
." AND d.id = bv.id_domain "
." AND bv.id_vm=?"
." AND bv.enabled=1"
);
my @bases;
$sth->execute($id_node);
while ( my ($id_domain) = $sth->fetchrow ) {
push @bases,($id_domain);
}
$sth->finish;
return \@bases;
}

sub _list_recent_requests($rvd, $seconds) {
Expand Down

0 comments on commit 43f5b78

Please sign in to comment.