Skip to content

Commit 842c7dc

Browse files
committed
implement --prepare switch
1 parent f6f3b2d commit 842c7dc

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

cloudstackops/xenserver.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def host_disable(self, host):
131131

132132
# Live migrate all VMS off of a hypervisor
133133
def host_evacuate(self, host):
134-
print "Note: Evacuating host " + host.name
134+
print "Note: Evacuating host " + host.name + " @ " + time.strftime("%Y-%m-%d %H:%M")
135135
print "Note: Migration progress will appear here.."
136136
try:
137137
with settings(host_string=self.ssh_user + "@" + host.ipaddress):
@@ -145,6 +145,7 @@ def host_evacuate(self, host):
145145
if int(numer_of_vms) == 0:
146146
break
147147
time.sleep(5)
148+
print "Note: Done evacuating host " + host.name + " @ " + time.strftime("%Y-%m-%d %H:%M")
148149
return True
149150
except:
150151
return False

xenserver_rolling_reboot.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ def handleArguments(argv):
4343
DEBUG = 0
4444
global DRYRUN
4545
DRYRUN = 1
46+
global PREPARE
47+
PREPARE = 0
4648
global clustername
4749
clustername = ''
4850
global configProfileName
4951
configProfileName = ''
50-
global force
51-
force = 0
5252
global ignoreHostList
5353
ignoreHostList = ""
5454
global ignoreHosts
@@ -63,12 +63,13 @@ def handleArguments(argv):
6363
'\n --ignore-hosts <list>\t\t\t\tSkip work on the specified hosts (for example if you need to resume): Example: --ignore-hosts="host1, host2" ' + \
6464
'\n --threads <nr>\t\t\t\tUse this number or concurrent migration threads" ' + \
6565
'\n --debug\t\t\t\t\tEnable debug mode' + \
66-
'\n --exec\t\t\t\t\tExecute for real'
66+
'\n --exec\t\t\t\t\tExecute for real' + \
67+
'\n --prepare\t\t\t\t\tExecute some prepare commands'
6768

6869
try:
6970
opts, args = getopt.getopt(
70-
argv, "hc:n:t:", [
71-
"credentials-file=", "clustername=", "ignore-hosts=", "threads=", "debug", "exec", "force"])
71+
argv, "hc:n:t:p", [
72+
"credentials-file=", "clustername=", "ignore-hosts=", "threads=", "debug", "exec", "prepare"])
7273
except getopt.GetoptError as e:
7374
print "Error: " + str(e)
7475
print help
@@ -90,8 +91,8 @@ def handleArguments(argv):
9091
DEBUG = 1
9192
elif opt in ("--exec"):
9293
DRYRUN = 0
93-
elif opt in ("--force"):
94-
force = 1
94+
elif opt in ("--prepare"):
95+
PREPARE = 1
9596

9697
# Default to cloudmonkey default config file
9798
if len(configProfileName) == 0:
@@ -179,13 +180,13 @@ def handleArguments(argv):
179180
# Put the scripts we need
180181
for h in cluster_hosts:
181182
x.put_scripts(h)
182-
if DRYRUN == 0:
183+
if DRYRUN == 0 or PREPARE == 1:
183184
x.fake_pv_tools(h)
184185
if h.name == poolmaster_name:
185186
poolmaster = h
186187

187188
# Eject CDs
188-
if DRYRUN == 0:
189+
if DRYRUN == 0 or PREPARE == 1:
189190
eject_result = x.eject_cds(poolmaster)
190191
if eject_result == False:
191192
print "Warning: Ejecting CDs failed. Continuing anyway."

0 commit comments

Comments
 (0)