3 # NOTE: In development; not actually used yet.
5 #Collates the results of listvms from multiple VM servers. Part of the xvm
11 our @servers = qw/black-mesa.mit.edu sx-blade-2.mit.edu/;
15 sub openConnections() {
16 foreach (@servers) { openConnection($_); }
19 sub openConnection($) {
21 my $remctl = Net::Remctl->new;
22 $remctl->open($server)
23 or die "Cannot connect to $server: ", $remctl->error, "\n";
24 $connections{$server} = $remctl;
28 foreach my $remctl (values %connections) {
29 $remctl->command("remote", "web", "listvms", "--json");
32 foreach my $server (keys %connections) {
33 my $remctl = $connections{$server};
36 $output = $remctl->output;
37 if ($output->type eq 'output') {
38 if ($output->stream == 1) {
39 $jsonData .= $output->data;
40 } elsif ($output->stream == 2) {
41 print STDERR $output->data;
43 } elsif ($output->type eq 'error') {
44 warn $output->error, "\n";
45 } elsif ($output->type eq 'status') {
46 if ($output->status != 0) {
47 warn "Exit status was ".$output->status;
49 } elsif ($output->type eq 'done') {
52 die "Unknown output token from library: ", $output->type, "\n";
54 } while ($output->type ne 'done');
55 my $vmlist = jsonToObj($jsonData);
56 foreach my $key (keys %$vmlist) {
57 $vmstate{$key} = $vmlist->{$key};
58 $vmstate{$key}{"host"} = $server;
68 print Dumper({doListVMs()});
69 timethis(100, sub {doListVMs()});