Subversion Repositories havirt

Rev

Rev 8 | Rev 10 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8 Rev 9
Line 42... Line 42...
42
our @ISA = qw( Exporter );
42
our @ISA = qw( Exporter );
43
our @EXPORT = qw( 
43
our @EXPORT = qw( 
44
                  &list
44
                  &list
45
                );
45
                );
46
 
46
 
-
 
47
sub help {
-
 
48
   my @return;
-
 
49
   push @return, "domain update [domainname|-t domainname]";
-
 
50
   push @return, "\tUpdates capabilities on one or more domains, default is all domains";
-
 
51
   push @return, "domain list [--format|-f screen|tsv]";
-
 
52
   push @return, "\tLists all domains with some statistics about them as screen or tsv (default screen)";
-
 
53
   return join( "\n", @return ) . "\n";
-
 
54
}
-
 
55
 
47
sub loadVirtDB {
56
sub loadVirtDB {
48
   return if $main::virtDB;
57
   return if $main::virtDB;
49
   $main::virtDB = &main::readDB( $main::domainDBName );
58
   $main::virtDB = &main::readDB( $main::domainDBName );
50
}
59
}
51
 
60
 
Line 84... Line 93...
84
   unless ( @_ ) {
93
   unless ( @_ ) {
85
      # they didn't pass in anything, so do everything
94
      # they didn't pass in anything, so do everything
86
      @_ = keys %{ $main::virtDB }
95
      @_ = keys %{ $main::virtDB }
87
   } # unless
96
   } # unless
88
   print "Preparing to update " . join( "\n", @_ ) . "\n" if $main::DEBUG > 1;
97
   print "Preparing to update " . join( "\n", @_ ) . "\n" if $main::DEBUG > 1;
89
   die;
-
 
90
   while ( my $virt = shift ) {
98
   while ( my $virt = shift ) {
91
      &parseDomain( $virt );
99
      &parseDomain( $virt );
92
   } # while
100
   } # while
93
   &writeDB( $main::domainDBName, $main::virtDB );
101
   &main::writeDB( $main::domainDBName, $main::virtDB );
-
 
102
   return "Updated\n";
94
}
103
}
95
 
104
 
96
sub getXMLValue {
105
sub getXMLValue {
97
   my ( $key, $string ) = @_;
106
   my ( $key, $string ) = @_;
-
 
107
   print "getXMLValue: looking for [$key] $string\n" if $main::DEBUG > 2;
98
   my $start = "<$key";
108
   my $start = "<$key";
99
   my $end = "</$key>";
109
   my $end = "</$key>";
100
   $string =~ m/$start([^>]*)>([^<]+)$end/;
110
   $string =~ m/$start([^>]*)>([^<]+)$end/;
101
   return ($1,$2);
111
   return ($1,$2);
102
}
112
}
Line 128... Line 138...
128
      open XML, "<$filename" or die "Could not read from $filename: $!\n";
138
      open XML, "<$filename" or die "Could not read from $filename: $!\n";
129
      $return = join( '', <XML> );
139
      $return = join( '', <XML> );
130
      close XML;
140
      close XML;
131
   } else {
141
   } else {
132
      &main::loadNodePopulations();
142
      &main::loadNodePopulations();
133
      #die Dumper( $nodePopulations );
-
 
134
      foreach my $node ( keys %$main::nodePopulations ) {
143
      foreach my $node ( keys %$main::nodePopulations ) {
135
         print "getVirtConfig Looking on $node for $virt\n";
144
         print "getVirtConfig Looking on $node for $virt\n" if $main::DEBUG > 1;;
136
         if ( exists( $main::nodePopulations->{$node}->{'running'}->{$virt} ) ) { # we found it
145
         if ( exists( $main::nodePopulations->{$node}->{'running'}->{$virt} ) ) { # we found it
137
            print "Found $virt on node $node\n";
146
            print "Found $virt on node $node\n" if $main::DEBUG;;
138
            $return = `ssh $node 'virsh dumpxml $virt'`;
147
            $return = `ssh $node 'virsh dumpxml $virt'`;
-
 
148
            print "Writing config for $virt from $node into $filename\n" if $main::DEBUG;
139
            open XML,">$filename" or die "Could not write to $filename: $!\n";
149
            open XML,">$filename" or die "Could not write to $filename: $!\n";
140
            print XML $return;
150
            print XML $return;
141
            close XML;
151
            close XML;
142
         } # if
152
         } # if
143
      } # foreach
153
      } # foreach