@@ -55,21 +55,27 @@ def handleArguments(argv):
5555 ignoreHosts = ''
5656 global threads
5757 threads = 5
58+ global halt_hypervisor
59+ halt_hypervisor = False
5860
5961 # Usage message
6062 help = "Usage: ./" + os .path .basename (__file__ ) + ' [options]' + \
61- '\n --config-profile -c <profilename>\t \t Specify the CloudMonkey profile name to get the credentials from (or specify in ./config file)' + \
63+ '\n --config-profile -c <profilename>\t \t Specify the CloudMonkey profile name to ' \
64+ 'get the credentials from (or specify in ./config file)' + \
6265 '\n --clustername -n <clustername> \t \t Name of the cluster to work with' + \
63- '\n --ignore-hosts <list>\t \t \t \t Skip work on the specified hosts (for example if you need to resume): Example: --ignore-hosts="host1, host2" ' + \
66+ '\n --ignore-hosts <list>\t \t \t \t Skip work on the specified hosts (for example if you need to resume): ' \
67+ 'Example: --ignore-hosts="host1, host2" ' + \
6468 '\n --threads <nr>\t \t \t \t Use this number or concurrent migration threads" ' + \
69+ '\n --halt\t \t \t \t \t Instead of the default reboot, halt the hypervisor (useful in case of hardware ' \
70+ 'upgrades)" ' + \
6571 '\n --debug\t \t \t \t \t Enable debug mode' + \
6672 '\n --exec\t \t \t \t \t Execute for real' + \
6773 '\n --prepare\t \t \t \t \t Execute some prepare commands'
6874
6975 try :
7076 opts , args = getopt .getopt (
7177 argv , "hc:n:t:p" , [
72- "credentials-file=" , "clustername=" , "ignore-hosts=" , "threads=" , "debug" , "exec" , "prepare" ])
78+ "credentials-file=" , "clustername=" , "ignore-hosts=" , "threads=" , "halt" , " debug" , "exec" , "prepare" ])
7379 except getopt .GetoptError as e :
7480 print "Error: " + str (e )
7581 print help
@@ -87,6 +93,8 @@ def handleArguments(argv):
8793 threads = arg
8894 elif opt in ("--ignore-hosts" ):
8995 ignoreHostList = arg
96+ elif opt in ("--halt" ):
97+ halt_hypervisor = True
9098 elif opt in ("--debug" ):
9199 DEBUG = 1
92100 elif opt in ("--exec" ):
@@ -179,6 +187,10 @@ def handleArguments(argv):
179187checkBonds = True
180188c .printHypervisors (clusterID , poolmaster .name , checkBonds )
181189
190+ if halt_hypervisor :
191+ print "Warning: Instead of reboot, we will halt the hypervisor. You need to start it yourself for the script to" \
192+ " continue moving to the next hypervisor."
193+
182194if DRYRUN == 1 :
183195 print
184196 print "Warning: We are running in DRYRUN mode."
@@ -189,7 +201,7 @@ def handleArguments(argv):
189201 print " - For any hypervisor it will do this (poolmaster " + poolmaster .name + " first):"
190202 print " - put it to Disabled aka Maintenance in XenServer"
191203 print " - live migrate all VMs off of it using XenServer evacuate command"
192- print " - when empty, it will reboot the hypervisor"
204+ print " - when empty, it will reboot the hypervisor (halting is " + str ( halt_hypervisor ) + ") "
193205 print " - will wait for it to come back online (checks SSH connection)"
194206 print " - set the hypervisor to Enabled in XenServer"
195207 print " - continues to the next hypervisor"
@@ -239,7 +251,7 @@ def handleArguments(argv):
239251 vm_count = x .host_get_vms (poolmaster )
240252 if vm_count :
241253 print "Note: " + poolmaster .name + " (poolmaster) has " + vm_count + " VMs running."
242- reboot_result = x .host_reboot (poolmaster )
254+ reboot_result = x .host_reboot (poolmaster , halt_hypervisor )
243255 if reboot_result is False :
244256 print "Error: Stopping sequence, as a reboot failed. Please investigate."
245257 x .roll_back (poolmaster )
@@ -268,7 +280,7 @@ def handleArguments(argv):
268280 vm_count = x .host_get_vms (h )
269281 if vm_count :
270282 print "Note: " + h .name + " has " + vm_count + " VMs running."
271- reboot_result = x .host_reboot (h )
283+ reboot_result = x .host_reboot (h , halt_hypervisor )
272284 if reboot_result is False :
273285 print "Error: Stopping sequence, as a reboot failed. Please investigate."
274286 x .roll_back (h )
0 commit comments