Subversion Repositories havirt

Rev

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

Rev 9 Rev 10
Line 67... Line 67...
67
   push @return, "\tUpdates list of domains on one or more existing nodes, default is all nodes";
67
   push @return, "\tUpdates list of domains on one or more existing nodes, default is all nodes";
68
   return join( "\n", @return ) . "\n";
68
   return join( "\n", @return ) . "\n";
69
}
69
}
70
 
70
 
71
 
71
 
72
# read the node database into memory, if it was not already loaded
-
 
73
sub loadNodeDB {
-
 
74
   print "In loadNodeDB, reading $main::nodeDBName\n" if $main::DEBUG > 1;
-
 
75
   return if $main::nodeDB;
-
 
76
   $main::nodeDB = &main::readDB( $main::nodeDBName );
-
 
77
   print "Success\n" if $main::DEBUG > 1;
-
 
78
}
-
 
79
 
-
 
80
# scans a node to determine which domains are running on it
72
# scans a node to determine which domains are running on it
81
sub getDomainsOnNode {
73
sub getDomainsOnNode {
82
   my $node = shift;
74
   my $node = shift;
83
   my @nodeList = grep { /^\s*\d/ } `ssh $node 'virsh list'`;
75
   my @nodeList = grep { /^\s*\d/ } `ssh $node 'virsh list'`;
84
   for ( my $i = 0; $i < @nodeList; $i++ ) {
76
   for ( my $i = 0; $i < @nodeList; $i++ ) {
Line 93... Line 85...
93
# lists hardware capabilities of all nodes (virsh nodeinfo)
85
# lists hardware capabilities of all nodes (virsh nodeinfo)
94
sub list {
86
sub list {
95
   my @header;
87
   my @header;
96
   my @data;
88
   my @data;
97
   my $return;
89
   my $return;
98
   &loadNodeDB();
90
   &main::loadNodeDB();
99
   foreach my $node ( sort keys %$main::nodeDB ) {
91
   foreach my $node ( sort keys %$main::nodeDB ) {
100
      unless ( @header ) {
92
      unless ( @header ) {
101
         # just grab the keys for headers
93
         # just grab the keys for headers
102
         @header = sort keys %{ $main::nodeDB->{$node} };
94
         @header = sort keys %{ $main::nodeDB->{$node} };
103
         # put Node at the beginning
95
         # put Node at the beginning
Line 116... Line 108...
116
# Get information about a node. Really only needs to be done when a node is
108
# Get information about a node. Really only needs to be done when a node is
117
# first defined, or if there is a hardware upgrade
109
# first defined, or if there is a hardware upgrade
118
# reads information off of the stack (@_), but will add to that if --target
110
# reads information off of the stack (@_), but will add to that if --target
119
# was defined
111
# was defined
120
sub update {
112
sub update {
121
   &loadNodeDB();
113
   &main::loadNodeDB();
122
   my $return;
114
   my $return;
123
   my @targets;
115
   my @targets;
124
   if ( $main::targetNode ) {
116
   if ( $main::targetNode ) {
125
      push @_, $main::targetNode;
117
      push @_, $main::targetNode;
126
   }
118
   }
Line 147... Line 139...
147
 
139
 
148
# check one or more nodes and determine which domains are running on them.
140
# check one or more nodes and determine which domains are running on them.
149
# defaults to everything in the node database, but the -t can have it run on only one
141
# defaults to everything in the node database, but the -t can have it run on only one
150
# this is the function that should be run every few minutes on one of the servers
142
# this is the function that should be run every few minutes on one of the servers
151
sub scan {
143
sub scan {
152
   &loadNodeDB();
144
   &main::loadNodeDB();
153
   &main::loadNodePopulations();
145
   &main::loadNodePopulations();
154
   print Dumper( $main::nodePopulations ) if $main::DEBUG > 2;
146
   print Dumper( $main::nodePopulations ) if $main::DEBUG > 2;
155
   my @targets;
147
   my @targets;
156
   if ( $main::targetNode ) {
148
   if ( $main::targetNode ) {
157
      push @targets, $main::targetNode;
149
      push @targets, $main::targetNode;
Line 169... Line 161...
169
}
161
}
170
 
162
 
171
 
163
 
172
# add a new node. This is the same as doing an update on a node that doesn't exist.
164
# add a new node. This is the same as doing an update on a node that doesn't exist.
173
sub add {
165
sub add {
174
#   &loadNodeDB();
166
#   &main::loadNodeDB();
175
#   print "Adding $main::targetNode as new node\n" if $main::DEBUG;
167
#   print "Adding $main::targetNode as new node\n" if $main::DEBUG;
176
#   $main::nodeDB->{$main::targetNode} = '';
168
#   $main::nodeDB->{$main::targetNode} = '';
177
#   print "Calling update for new node\n" if $main::DEBUG;
169
#   print "Calling update for new node\n" if $main::DEBUG;
178
   &update();
170
   &update();
179
}
171
}