Commit caf695c1 authored by frankiejol's avatar frankiejol Committed by Francesc Guasch
Browse files

[#315] filter domain list

parent 53571330
...@@ -1013,13 +1013,36 @@ List all created domains ...@@ -1013,13 +1013,36 @@ List all created domains
my @list = $ravada->list_domains(); my @list = $ravada->list_domains();
This list can be filtered:
my @active = $ravada->list_domains(active => 1);
my @inactive = $ravada->list_domains(active => 0);
my @user_domains = $ravada->list_domains(user => $id_user);
my @user_active = $ravada->list_domains(user => $id_user, active => 1);
=cut =cut
sub list_domains { sub list_domains {
my $self = shift; my $self = shift;
my %args = @_;
my $active = delete $args{active};
my $user = delete $args{user};
die "ERROR: Unknown arguments ".join(",",sort keys %args)
if keys %args;
my @domains; my @domains;
for my $vm ($self->list_vms) { for my $vm ($self->list_vms) {
for my $domain ($vm->list_domains) { for my $domain ($vm->list_domains) {
next if defined $active &&
( $domain->is_active && !$active
|| !$domain->is_active && $active );
next if $user && $domain->id_owner != $user->id;
push @domains,($domain); push @domains,($domain);
} }
} }
......
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