-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResourceProcessor.pm
39 lines (34 loc) · 930 Bytes
/
ResourceProcessor.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/perl
package ResourceProcessor;
use strict;
use warnings;
sub process_resources {
my ($resources) = @_;
my @vms;
my @containers;
foreach my $resource (@$resources) {
if ($resource->{type} eq 'qemu') {
push @vms, {
id => $resource->{vmid},
name => $resource->{name},
status => $resource->{status},
memory => $resource->{maxmem},
cpu => $resource->{maxcpu}
};
}
elsif ($resource->{type} eq 'lxc') {
push @containers, {
id => $resource->{vmid},
name => $resource->{name},
status => $resource->{status},
memory => $resource->{maxmem},
cpu => $resource->{maxcpu}
};
}
}
return {
vms => \@vms,
containers => \@containers
};
}
1;