Commit 6e86716f authored by Francesc Guasch's avatar Francesc Guasch
Browse files

Merge branch 'main' into develop

parents 14cce1da ac5cb097
......@@ -4,7 +4,19 @@
- Machine schedule reservation [\#1337]
- Manage nodes and networks settings [\#1305]
- User management part in ravada [\#1500]
- Manage LDAP groups
- Limit to start virtual machines [\#1490]
- Add access filter to a machine with LDAP groups [\#1488]
- Debian 11 (Bullesye) ISO support [\#1580]
**Refactor**
- Confusing button placement in ports form [\#1469]
- Clones number sequence coherency [\#1454]
- Responsive grants form
**Bugfixes**
- Linux Mint ISO Download fails [\#1576]
- Machine in a node returns to KVMlocalhost when a machine option is modified [\#1440]
......@@ -688,25 +688,6 @@ sub _update_isos {
}
sub _update_table_isos_url($self, $data) {
my $sth = $CONNECTOR->dbh->prepare("SELECT * FROM iso_images WHERE name=?");
for my $release (sort keys %$data) {
my $entry = $data->{$release};
$sth->execute($entry->{name});
my $row = $sth->fetchrow_hashref();
for my $field (keys %$entry) {
next if defined $row->{$field} && $row->{$field} eq $entry->{$field};
my $sth_update = $CONNECTOR->dbh->prepare(
"UPDATE iso_images SET $field=?"
." WHERE id=?"
);
$sth_update->execute($entry->{$field}, $row->{id});
warn("INFO: updating $release $field '$row->{$field}' -> '$entry->{$field}'\n")
if !$FIRST_TIME_RUN && $0 !~ /\.t$/;
}
}
}
sub _update_table_isos_url($self, $data) {
my $sth = $CONNECTOR->dbh->prepare("SELECT * FROM iso_images WHERE name=?");
for my $release (sort keys %$data) {
......@@ -3177,14 +3158,17 @@ sub process_requests {
next if $request_type ne 'all' && $req->type ne $request_type;
next if $duplicated{$id_request}++;
next if $duplicated{"id_req.$id_request"}++;
next if $req->command !~ /shutdown/i
&& $self->_domain_working($id_domain, $id_request);
my $domain = '';
$domain = $id_domain if $id_domain;
$domain .= ($req->defined_arg('name') or '');
next if $duplicated{$domain}++;
next if $domain && $duplicated{$domain};
my $id_base = $req->defined_arg('id_base');
next if $id_base && $duplicated{$id_base};
$duplicated{"domain.$domain"}++;
push @reqs,($req);
}
$sth->finish;
......@@ -3347,6 +3331,7 @@ sub _kill_stale_process($self) {
." WHERE start_time<? "
." AND ( command = 'refresh_vms' or command = 'screenshot' or command = 'set_time' "
." OR command = 'open_exposed_ports' OR command='remove' "
." OR command = 'refresh_machine_ports'"
.") "
." AND status <> 'done' "
." AND start_time IS NOT NULL "
......@@ -4510,7 +4495,7 @@ sub _cmd_refresh_machine($self, $request) {
$domain->client_status(1) if $is_active;
Ravada::Request->refresh_machine_ports(id_domain => $domain->id, uid => $user->id
,retry => 20)
,timeout => 60, retry => 20)
if $is_active && $domain->ip;
}
......
......@@ -878,10 +878,12 @@ sub grant($self,$user,$permission,$value=1) {
.Dumper(\@perms);
}
if ( $value eq 'false' || !$value ) {
$value = 0;
} else {
$value = 1;
if ( $self->grant_type($permission) eq 'boolean' ) {
if ($value eq 'false' || !$value ) {
$value = 0;
} else {
$value = 1;
}
}
return 0 if !$value && !$user->can_do($permission);
......@@ -955,6 +957,7 @@ sub list_all_permissions($self) {
}
sub grant_type($self, $permission) {
return 'boolean' if !exists $self->{_grant_type}->{$permission};
return $self->{_grant_type}->{$permission};
}
......
......@@ -42,7 +42,8 @@ sub test_remove_domain {
my $vm = shift;
my $name = shift;
my $domain = $name if ref($name);
my $domain;
$domain = $name if ref($name);
$domain = $vm->search_domain($name,1);
if ($domain) {
......
......@@ -168,7 +168,6 @@ SKIP: {
};
}
remove_old_domains();
remove_old_disks();
end();
done_testing();
......@@ -860,7 +860,8 @@ sub _remove_old_disks_void_remote($node) {
return if !$node->ping(undef,0);
my $cmd = "rm -rfv ".$node->dir_img."/".base_domain_name().'_*';
$node->run_command($cmd);
eval { $node->run_command($cmd); };
die $@ if $@ && $@ !~ /Error connecting/i;
}
sub _remove_old_disks_void_local {
......@@ -1369,16 +1370,22 @@ sub remove_old_user_ldap {
sub _remove_old_groups_ldap() {
my $ldap;
eval { $ldap = Ravada::Auth::LDAP::_init_ldap_admin() if !$ldap };
eval { $ldap = Ravada::Auth::LDAP::_init_ldap_admin() };
return if $@ && $@ =~ /Missing ldap section/;
warn $@ if $@;
return if !$ldap;
my $name = base_domain_name();
for my $group ( Ravada::Auth::LDAP::search_group( name => "group_$name".'*')
,Ravada::Auth::LDAP::search_group( name => $name.'*')
) {
my @groups;
eval {
push @groups,(Ravada::Auth::LDAP::search_group( name => "group_$name".'*', ldap => $ldap));
push @groups,( Ravada::Auth::LDAP::search_group( name => $name.'*', ldap => $ldap) );
};
return if $@ && $@ =~ /Error.*can't connect/i;
die $@ if $@;
for my $group ( @groups ) {
next if !$group;
warn $group->dn;
for my $n ( 1 .. 3 ) {
my $mesg = $ldap->delete($group);
last if !$mesg->code;
......
......@@ -191,7 +191,7 @@ sub test_login_fail {
like($t->tx->res->dom->at("button#submit")->text,qr'Login') or exit;
$t->get_ok("/admin/users")->status_is(401);
is($t->tx->res->dom->at("button#submit")->text,'Login') or exit;
like($t->tx->res->dom->at("button#submit")->text,qr'Login') or exit;
}
sub test_copy_without_prepare($clone) {
......
......@@ -250,15 +250,21 @@ sub test_limit_change($vm, $limit) {
is(scalar @list,1) or warn Dumper([map { $_->name } @list]);
user_admin->grant($user, 'start_limit', 2);
is($user->can_start_limit,2) or exit;
$clone1->start(user_admin);
$clone2->start(user_admin);
$clone3->start(user_admin);
delete_request('set_time');
@list = rvd_back->list_domains(user => $user, active => 1);
is(scalar @list,3) or warn Dumper([map { $_->name } @list]);
wait_request( debug => 1);
@list = rvd_back->list_domains(user => $user, active => 1);
$req = Ravada::Request->enforce_limits(timeout => 1, _force => 1);
wait_request( debug => 0);
delete_request('set_time');
wait_request( debug => 1);
is($req->status,'done');
is($req->error,'');
......
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