Subversion Repositories havirt

Rev

Rev 29 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 29 Rev 38
Line 27... Line 27...
27
#
27
#
28
# v1.2.0 20240826 RWR
28
# v1.2.0 20240826 RWR
29
# Added some code to migrate domains if node placed in maintenance mode
29
# Added some code to migrate domains if node placed in maintenance mode
30
# Added a lot of 'verbose' print lines, and modified for new flag structure
30
# Added a lot of 'verbose' print lines, and modified for new flag structure
31
#
31
#
-
 
32
# v1.2.1 20240828 RWR
-
 
33
# removed forceScan from migrateAll and relying on calling scripts to do that.
32
 
34
 
33
package havirt;
35
package havirt;
34
 
36
 
35
use warnings;
37
use warnings;
36
use strict;  
38
use strict;  
Line 47... Line 49...
47
use Data::Dumper qw(Dumper); # Import the Dumper() subroutine
49
use Data::Dumper qw(Dumper); # Import the Dumper() subroutine
48
 
50
 
49
# define the version number
51
# define the version number
50
# see https://metacpan.org/pod/release/JPEACOCK/version-0.97/lib/version.pod
52
# see https://metacpan.org/pod/release/JPEACOCK/version-0.97/lib/version.pod
51
use version;
53
use version;
52
our $VERSION = version->declare("1.2.0");
54
our $VERSION = version->declare("1.2.1");
53
 
55
 
54
 
56
 
55
use Exporter;
57
use Exporter;
56
 
58
 
57
our @ISA = qw( Exporter );
59
our @ISA = qw( Exporter );
Line 251... Line 253...
251
   } else {
253
   } else {
252
      return "ssh $node '$command'";
254
      return "ssh $node '$command'";
253
   }
255
   }
254
}
256
}
255
 
257
 
256
# force a node scan, even if time has not expired
258
# force a node scan, of all domains, even if time has not expired
257
# do this by setting force to 1, calling scan, then resetting
259
# and/or target is set. do this by setting force to 1 and target to null
-
 
260
# then calling scan,
258
# it to old value
261
# after run, reset it to old value
259
sub forceScan {
262
sub forceScan {
260
   my $save = $main::config->{'flags'}->{'force'};
263
   my $force = $main::config->{'flags'}->{'force'};
-
 
264
   my $target = $main::config->{'flags'}->{'target'};
261
   $main::config->{'flags'}->{'force'} = 0;
265
   $main::config->{'flags'}->{'force'} = 1;
-
 
266
   $main::config->{'flags'}->{'target'} = '';
262
   &main::scan();
267
   &main::scan();
263
   $main::config->{'flags'}->{'force'} = $save;
268
   $main::config->{'flags'}->{'force'} = $force;
-
 
269
   $main::config->{'flags'}->{'target'} = $target;
264
}
270
}
265
 
271
 
266
 
272
 
267
# executes command $command, then repeatedly runs virsh list
273
# executes command $command, then repeatedly runs virsh list
268
# on $scanNode, grep'ing for $scanDomain
274
# on $scanNode, grep'ing for $scanDomain
Line 419... Line 425...
419
   die "$virt already on $target\n" if $target eq $node;
425
   die "$virt already on $target\n" if $target eq $node;
420
   my $command = &main::makeCommand( $node, "virsh migrate --live --persistent --verbose  $virt qemu+ssh://$target/system" );
426
   my $command = &main::makeCommand( $node, "virsh migrate --live --persistent --verbose  $virt qemu+ssh://$target/system" );
421
   if ( $main::config->{'flags'}->{'dryrun'} ) { # they want us to actually do it
427
   if ( $main::config->{'flags'}->{'dryrun'} ) { # they want us to actually do it
422
      $return = $command;
428
      $return = $command;
423
   } else {
429
   } else {
-
 
430
      print "Migrating $virt to $node\n" if $main::config->{'flags'}->{'verbose'};
424
      $return = ( &main::executeAndWait( $command, $node, $virt, 0 ) ? 'Success' : 'Time Out waiting for shutdown');
431
      $return = ( &main::executeAndWait( $command, $node, $virt, 0 ) ? 'Success' : 'Time Out waiting for shutdown');
425
      &main::forceScan();
432
      #&main::forceScan(); Removed since we're doing it at a higher level
426
   }
433
   }
427
   return "$return\n";
434
   return "$return\n";
428
}
435
}
429
 
436