Revision b87948f5
b/qa/rapi-workload.py | ||
---|---|---|
122 | 122 |
return MockMethod |
123 | 123 |
|
124 | 124 |
|
125 |
def Finish(client, fn, *args, **kwargs): |
|
126 |
""" When invoked with a job-starting RAPI client method, it passes along any |
|
127 |
additional arguments and waits until its completion. |
|
128 |
|
|
129 |
@type client C{GanetiRapiClientWrapper} |
|
130 |
@param client The client wrapper. |
|
131 |
@type fn function |
|
132 |
@param fn A client method returning a job id. |
|
133 |
|
|
134 |
""" |
|
135 |
possible_job_id = fn(*args, **kwargs) |
|
136 |
try: |
|
137 |
# The job ids are returned as both ints and ints represented by strings. |
|
138 |
# This is a pythonic check to see if the content is an int. |
|
139 |
int(possible_job_id) |
|
140 |
except (ValueError, TypeError): |
|
141 |
# As a rule of thumb, failures will return None, and other methods are |
|
142 |
# expected to return at least something |
|
143 |
if possible_job_id is not None: |
|
144 |
print ("Finish called with a method not producing a job id, " |
|
145 |
"returning %s" % possible_job_id) |
|
146 |
return possible_job_id |
|
147 |
|
|
148 |
success = client.WaitForJobCompletion(possible_job_id) |
|
149 |
|
|
150 |
result = client.GetJobStatus(possible_job_id)["opresult"][0] |
|
151 |
if success: |
|
152 |
return result |
|
153 |
else: |
|
154 |
print "Error encountered while performing operation: " |
|
155 |
print result |
|
156 |
return None |
|
157 |
|
|
158 |
|
|
125 | 159 |
def Workload(client): |
126 | 160 |
""" The actual RAPI workload used for tests. |
127 | 161 |
|
... | ... | |
147 | 181 |
client.GetGroups() |
148 | 182 |
client.GetGroups(bulk=True) |
149 | 183 |
|
150 |
job_id = client.RedistributeConfig() |
|
151 |
client.WaitForJobCompletion(job_id) |
|
184 |
Finish(client, client.RedistributeConfig) |
|
152 | 185 |
|
153 | 186 |
|
154 | 187 |
def Usage(): |
Also available in: Unified diff