Subversion Repositories havirt

Rev

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

Rev 15 Rev 16
Line 67... Line 67...
67
# find node a domain is on
67
# find node a domain is on
68
# first parameter is the domain name
68
# first parameter is the domain name
69
# rest of @_ is list of nodes to search
69
# rest of @_ is list of nodes to search
70
# if no nodes passed in, will search all known nodes
70
# if no nodes passed in, will search all known nodes
71
# returns first node found with the domain, or an empty string if not found
71
# returns first node found with the domain, or an empty string if not found
-
 
72
# possibly not being used??
72
sub findDomain {
73
sub findDomain {
73
   my $domainName = shift;
74
   my $domainName = shift;
74
   my @node = @_;
75
   my @node = @_;
75
   my $foundNode = '';
76
   my $foundNode = '';
76
   unless ( @node ) {
77
   unless ( @node ) {
Line 192... Line 193...
192
} # sub getVirtConfig
193
} # sub getVirtConfig
193
 
194
 
194
# start a domain
195
# start a domain
195
sub start {
196
sub start {
196
   my ( $virt, $node ) = @_;
197
   my ( $virt, $node ) = @_;
-
 
198
   my $return;
197
   $node = `hostname` unless $node;
199
   $node = `hostname` unless $node;
198
   chomp $node;
200
   chomp $node;
199
   &main::forceScan();
201
   &main::forceScan();
200
   #if ( my $alreadyRunning = &findDomain( $node ) ) {
-
 
201
   #   die "$virt already running on $alreadyRunning; not starting\n";
-
 
202
   #}
-
 
203
   &main::readDB();
202
   &main::readDB();
204
   for my $myNode ( keys %{$main::statusDB->{'nodePopulation'} } ) {
203
   for my $myNode ( keys %{$main::statusDB->{'nodePopulation'} } ) {
205
      die "$virt already running on $myNode, not starting\n" if ( $main::statusDB->{'nodePopulation'}->{$myNode}->{'running'}->{$virt} );
204
      die "$virt already running on $myNode, not starting\n" if ( $main::statusDB->{'nodePopulation'}->{$myNode}->{'running'}->{$virt} );
206
   }
205
   }
207
   die "I do not have a definition for $virt\n" unless exists( $main::statusDB->{'virt'}->{$virt} );
206
   die "I do not have a definition for $virt\n" unless exists( $main::statusDB->{'virt'}->{$virt} );
208
   print Dumper( $main::statusDB->{'nodePopulation'} ) if $main::DEBUG > 2;
207
   print Dumper( $main::statusDB->{'nodePopulation'} ) if $main::DEBUG > 2;
209
   my $filename = "$main::confDir/$virt.xml";
208
   my $filename = "$main::confDir/$virt.xml";
210
   return "ssh $node 'virsh create $filename'\n";
209
   my $command = &main::makeCommand( $node, "virsh create $filename" );
-
 
210
   if ( $main::force ) { # we'll actually do it
-
 
211
      $return = ( &main::executeAndWait( $command, $node, $virt, 1 ) ? 'Success' : 'Can not start');
-
 
212
      &main::forceScan();
-
 
213
   } else {
-
 
214
      $return =  $command;;
-
 
215
   }
-
 
216
   return "$return\n";
211
}
217
}
212
 
218
 
213
sub shutdown {
219
sub shutdown {
214
   my $virt = shift;
220
   my $virt = shift;
215
   my $node = '';
221
   my $node = '';