Subversion Repositories havirt

Rev

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

Rev 16 Rev 17
Line 58... Line 58...
58
   push @return, "\tmigrates domain from current node to target. If target node not specified";
58
   push @return, "\tmigrates domain from current node to target. If target node not specified";
59
   push @return, "\twill be automatically selected";
59
   push @return, "\twill be automatically selected";
60
   push @return, "domain new [domainname]";
60
   push @return, "domain new [domainname]";
61
   push @return, "\tgenerates a virt-install command that will fill in several blanks";
61
   push @return, "\tgenerates a virt-install command that will fill in several blanks";
62
   push @return, "\tNOTE: MAC address not guaranteed to be unique";
62
   push @return, "\tNOTE: MAC address not guaranteed to be unique";
-
 
63
   push @return, "domain [--yes] migrate domainname targetnode";
-
 
64
   push @return, "\tMigates a domain from its current location to targetnode";
-
 
65
   push @return, "domain maintenance domainname [on|off]";
-
 
66
   push @return, "\tSet/Unset/display maintenance flag on domain";
-
 
67
   push @return, "\tIf maintenance flag is set, no havirt will refuse any actions";
63
   return join( "\n", @return ) . "\n";
68
   return join( "\n", @return ) . "\n";
64
}
69
}
65
 
70
 
66
 
71
 
67
# find node a domain is on
72
# find node a domain is on
Line 240... Line 245...
240
   return "$return\n";
245
   return "$return\n";
241
}
246
}
242
 
247
 
243
sub migrate {
248
sub migrate {
244
   my ( $virt, $target ) = @_;
249
   my ( $virt, $target ) = @_;
-
 
250
   my $return;
-
 
251
   my $node;
-
 
252
   &main::forceScan();
-
 
253
   &main::readDB();
-
 
254
   for my $myNode ( keys %{$main::statusDB->{'nodePopulation'} } ) {
-
 
255
      if ( $main::statusDB->{'nodePopulation'}->{$myNode}->{'running'}->{$virt} ) {
-
 
256
         $node = $myNode;
-
 
257
         last;
-
 
258
      }
-
 
259
   }
-
 
260
   print Dumper( $main::statusDB->{'nodePopulation'} ) if $main::DEBUG > 2;
245
   return "I don't know how to migrate yet\n";
261
   die "I can not find $virt on any node\n" unless $node;
-
 
262
   my $command = &main::makeCommand( $node, "virsh migrate --live --persistent --verbose  $virt qemu+ssh://$target/system" );
-
 
263
   if ( $main::force ) { # they want us to actually do it
-
 
264
      $return = ( &main::executeAndWait( $command, $node, $virt, 0 ) ? 'Success' : 'Time Out waiting for shutdown');
-
 
265
      &main::forceScan();
-
 
266
   } else {
-
 
267
      $return = $command;
-
 
268
   }
-
 
269
   return "$return\n";
246
}
270
}
247
 
271
 
248
# find an unused VNC port
272
# find an unused VNC port
249
sub findVNCPort {
273
sub findVNCPort {
250
   my $currentPorts = shift;
274
   my $currentPorts = shift;
Line 309... Line 333...
309
         $return .= "$key: $config{$key}\n";
333
         $return .= "$key: $config{$key}\n";
310
      }
334
      }
311
   }
335
   }
312
   return $return;
336
   return $return;
313
}
337
}
-
 
338
 
-
 
339
sub maintenance {
-
 
340
   my ( $domain, $action ) = @_;
-
 
341
   &main::readDB(1);
-
 
342
   if ( $action ) {
-
 
343
      $main::statusDB->{'virt'}->{$domain}->{'maintenance'} = ( lc( $action ) eq 'on' ) ? 1 : 0;
-
 
344
   }
-
 
345
   &main::writeDB();
-
 
346
   return "Maintenance set to " . ( $main::statusDB->{'virt'}->{$domain}->{'maintenance'} ? 'On' : 'Off' ) . "\n";
-
 
347
}
-
 
348