Commit bef1066f authored by Francesc Guasch's avatar Francesc Guasch
Browse files

Merge branch 'main' into feature/win11

parents e0610c58 b225727c
......@@ -3,7 +3,7 @@ package Ravada;
use warnings;
use strict;
our $VERSION = '1.3.1';
our $VERSION = '1.4.0';
use Carp qw(carp croak cluck);
use Data::Dumper;
......@@ -1966,7 +1966,7 @@ sub _sql_create_tables($self) {
volumes => {
id => 'integer PRIMARY KEY AUTO_INCREMENT',
id_domain => 'integer NOT NULL references `domains` (`id`) ON DELETE CASCADE',
name => 'char(200) NOT NULL',
name => 'char(255) NOT NULL',
file => 'varchar(255) NOT NULL',
n_order => 'integer NOT NULL',
info => 'TEXT',
......
......@@ -209,7 +209,13 @@ our %COMMAND = (
,important=> {
limit => 20
,priority => 1
,commands => ['clone','start','start_clones','shutdown_clones','create','open_iptables','list_network_interfaces','list_isos','ping_backend','refresh_machine','open_exposed_ports']
,commands => ['clone','start','start_clones','shutdown_clones','create','open_iptables','list_network_interfaces','list_isos','ping_backend','refresh_machine']
}
,iptables => {
limit => 1
,priority => 2
,commands => ['open_exposed_ports']
}
);
lock_hash %COMMAND;
......@@ -782,7 +788,7 @@ sub _validate_start_domain($self) {
next if !$req;
next if $req->at_time;
next if $command eq 'start' && !$req->after_request();
$self->after_request($req->id) if $req->id < $self->id;
$self->after_request($req->id) if $req && $req->id < $self->id;
}
}
......@@ -899,7 +905,8 @@ sub _search_request($self,$command,%fields) {
my $args = decode_json($args_json);
my $found=1;
for my $key (keys %fields) {
if ( $args->{$key} ne $fields{$key} ) {
if (!exists $args->{$key} || !defined $args->{$key}
|| $args->{$key} ne $fields{$key} ) {
$found = 0;
last;
}
......
......@@ -335,7 +335,7 @@ ravadaApp.directive("solShowMachine", swMach)
|| $scope.list_machines[i].date_changed != mach.date_changed
){
var show=false;
if (mach._level == 0 ) {
if (mach._level == 0 && !$scope.filter && !$scope.show_active) {
mach.show=true;
}
if ($scope.show_machine[mach.id]) {
......@@ -357,6 +357,7 @@ ravadaApp.directive("solShowMachine", swMach)
}
$scope.n_active=n_active_current;
if ( $scope.show_active ) { $scope.do_show_active() };
if ( $scope.filter) { $scope.show_filter() };
});
}
}
......@@ -591,6 +592,7 @@ ravadaApp.directive("solShowMachine", swMach)
$scope.show_filter = function() {
$scope.hide_clones = true;
$scope.show_active = false;
$scope.n_active_current = 0;
$scope.n_active_hidden = 0;
for (var [key, mach ] of Object.entries($scope.list_machines)) {
......
......@@ -263,7 +263,6 @@
ws.onmessage = function(event) {
var data = JSON.parse(event.data);
if (data === null || typeof(data) == undefined ) {
console.log("close");
ws.close();
window.location.href="/";
return;
......@@ -1001,7 +1000,6 @@
var already_subscribed_to_domain = false;
$scope.copy_password= function(driver) {
$scope.view_password=1;
console.log("copy-password "+driver);
var copyTextarea = document.querySelector('.js-copytextarea-'+driver);
if (copyTextarea) {
copyTextarea.select();
......@@ -1046,9 +1044,20 @@
already_subscribed_to_domain = true;
$scope.id_domain=data.id_domain;
$scope.subscribe_domain_info(url, data.id_domain);
$scope.open_ports(url, data.id_domain, id_request);
}
}
}
$scope.open_ports = function(url, id_domain, id_request) {
$http.post('/request/open_exposed_ports/'
,JSON.stringify(
{ 'id_domain': id_domain
,'after_request': id_request
})
).then(function(response) {
$scope.request_open_ports = true;
});
}
$scope.subscribe_domain_info= function(url, id_domain) {
already_subscribed_to_domain = true;
var ws = new WebSocket(url);
......@@ -1090,6 +1099,9 @@
redirected_display=true;
}
}
if ($scope.request_open_ports && $scope.domain.ip && $scope.domain.requests == 0) {
$scope.request_open_ports_done = true;
}
}
}
......
......@@ -14,8 +14,7 @@ use feature qw(signatures);
use lib 't/lib';
use Test::Ravada;
no warnings "experimental::signatures";
use feature qw(signatures);
my @MOCK_ISOS;
init();
#############################################################################
......@@ -66,7 +65,6 @@ sub test_frontend_refresh {
}
sub test_remove_disk($vm, %options) {
diag(Dumper(\%options));
my $make_base = delete $options{make_base};
my $clone = delete $options{clone};
my $remove_by_file = ( delete $options{remove_by_file} or 0);
......@@ -80,7 +78,6 @@ sub test_remove_disk($vm, %options) {
if keys %options;
for my $index ( 0 .. 3 ) {
diag("\tindex=$index");
my $name = new_domain_name();
my $req = Ravada::Request->create_domain(
name => $name
......@@ -220,6 +217,10 @@ sub test_add_cd($vm, $data) {
my $n_disks0 = scalar(@{$info0->{hardware}->{disk}});
my %targets0 = map { $_->{target} => 1 } @{$info0->{hardware}->{disk}};
if ($data->{device} eq 'cdrom' && exists $data->{file} && $data->{file} =~ /tmp/) {
open my $out, ">>",$data->{file} or die "$! $data->{file}";
close $out;
}
my $req = Ravada::Request->add_hardware(
id_domain => $domain->id
,name => 'disk'
......@@ -244,6 +245,10 @@ sub test_add_cd($vm, $data) {
is($new_dev->{driver_type}, 'raw');
is($new_dev->{driver}, 'ide');
is($new_dev->{file},$data->{file});
if ($data->{device} eq 'cdrom' && exists $data->{file} && $data->{file} =~ /tmp/) {
unlink $data->{file} or die "$! $data->{file}";
}
}
sub test_add_disk {
......@@ -380,7 +385,7 @@ sub test_add_cd_kvm($vm) {
test_add_cd($vm
, { 'device' => 'cdrom'
,'driver' => 'ide'
,'file' => "/tmp/a.iso"
,'file' => "/tmp/".new_domain_name()."a.iso"
});
}
......@@ -404,8 +409,6 @@ sub _list_id_isos($vm) {
next if $iso->{name} =~ /Empty/;
next if $iso->{name} =~ /Android/i;
die Dumper($iso) if !defined $iso->{id};
$sth->execute($device, $iso->{id});
push @list, ( $iso->{id} );
}
......@@ -485,15 +488,36 @@ sub _req_remove_cd($domain) {
wait_request( debug => 0);
}
sub _create_mock_iso($vm) {
my $file = $vm->dir_img()."/".new_domain_name()."a.iso";
open my $out, ">>",$file or die "$! $file";
print $out "test\n";
close $out;
push @MOCK_ISOS,($file);
return $file;
}
sub remove_mock_isos() {
for my $file (@MOCK_ISOS) {
next if $file !~ m{/tst_};
unlink $file if -e $file;
}
}
sub _req_add_cd($domain) {
my $info = $domain->info(user_admin);
my $disks = $info->{hardware}->{disk};
my $file = _create_mock_iso($domain->_vm);
my $req = Ravada::Request->add_hardware(
uid => Ravada::Utils::user_daemon->id
,id_domain => $domain->id
,name => 'disk'
,data => { type => 'cdrom'
,file => "/var/tmp/a.iso"
,file => $file
}
);
wait_request(debug => 0);
......@@ -557,6 +581,7 @@ sub test_cdrom($vm) {
_req_add_cd($domain);
remove_domain($domain);
remove_mock_isos();
}
}
......@@ -588,10 +613,9 @@ for my $vm_name (vm_names() ) {
test_add_cd_kvm($vm) if $vm_name eq 'KVM';
for my $id_iso ( _list_id_isos($vm) ) {
diag("Testing id iso = ".($id_iso or '<UNDEF>'));
for my $by_file ( 1, 0 ) {
for my $by_index ( 0, 1 ) {
diag("by_file=$by_file, by_index=$by_index");
diag("Testing id_iso: $id_iso , by_file:$by_file, by_index:$by_index");
test_remove_disk($vm
,clone => 1
,id_iso => $id_iso
......
......@@ -13,7 +13,6 @@
<div class="jumbotron" ng-cloak="">
<h2><%=l 'Running' %> {{domain.name}}</h2>
<div class="alert alert-warning">
<%=l 'A viewer is required to run the virtual machines.' %>
<a href="/requirements"><%=l 'Read more.' %></a>
......@@ -43,8 +42,14 @@
<li><b><%=l 'Memory' %>:</b> {{domain.memory}}</li>
<li><b>CPUs:</b> {{domain.nrVirtCpu}}</li>
</ul>
<h3 ng-show="domain.ports.length">Open ports</h3>
<div class="container pl-5">
<h3 ng-show="domain.ports.length">Open ports
<i ng-hide="request_open_ports && request_open_ports_done"
class="fas fa-sync-alt fa-spin"></i>
</h3>
<div class="container pl-5"
ng-show="request_open_ports && request_open_ports_done">
<table border="0">
<tr ng-repeat="port in domain.ports">
<td align="right">
......
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