root / lib / rpc_defs.py @ b262a5c6
History | View | Annotate | Download (25.5 kB)
1 |
#
|
---|---|
2 |
#
|
3 |
|
4 |
# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Google Inc.
|
5 |
#
|
6 |
# This program is free software; you can redistribute it and/or modify
|
7 |
# it under the terms of the GNU General Public License as published by
|
8 |
# the Free Software Foundation; either version 2 of the License, or
|
9 |
# (at your option) any later version.
|
10 |
#
|
11 |
# This program is distributed in the hope that it will be useful, but
|
12 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
# General Public License for more details.
|
15 |
#
|
16 |
# You should have received a copy of the GNU General Public License
|
17 |
# along with this program; if not, write to the Free Software
|
18 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
19 |
# 02110-1301, USA.
|
20 |
|
21 |
"""RPC definitions for communication between master and node daemons.
|
22 |
|
23 |
RPC definition fields:
|
24 |
|
25 |
- Name as string
|
26 |
- L{SINGLE} for single-node calls, L{MULTI} for multi-node
|
27 |
- Name resolver option(s), can be callable receiving all arguments in a tuple
|
28 |
- Timeout (e.g. L{constants.RPC_TMO_NORMAL}), or callback receiving all
|
29 |
arguments in a tuple to calculate timeout
|
30 |
- List of arguments as tuples
|
31 |
|
32 |
- Name as string
|
33 |
- Argument kind used for encoding/decoding
|
34 |
- Description for docstring (can be C{None})
|
35 |
|
36 |
- Custom body encoder (e.g. for preparing per-node bodies)
|
37 |
- Return value wrapper (e.g. for deserializing into L{objects}-based objects)
|
38 |
- Short call description for docstring
|
39 |
|
40 |
"""
|
41 |
|
42 |
from ganeti import constants |
43 |
from ganeti import utils |
44 |
from ganeti import objects |
45 |
|
46 |
|
47 |
# Guidelines for choosing timeouts:
|
48 |
# - call used during watcher: timeout of 1min, constants.RPC_TMO_URGENT
|
49 |
# - trivial (but be sure it is trivial)
|
50 |
# (e.g. reading a file): 5min, constants.RPC_TMO_FAST
|
51 |
# - other calls: 15 min, constants.RPC_TMO_NORMAL
|
52 |
# - special calls (instance add, etc.):
|
53 |
# either constants.RPC_TMO_SLOW (1h) or huge timeouts
|
54 |
|
55 |
SINGLE = "single-node"
|
56 |
MULTI = "multi-node"
|
57 |
|
58 |
ACCEPT_OFFLINE_NODE = object()
|
59 |
|
60 |
# Constants for encoding/decoding
|
61 |
(ED_OBJECT_DICT, |
62 |
ED_OBJECT_DICT_LIST, |
63 |
ED_INST_DICT, |
64 |
ED_INST_DICT_HVP_BEP_DP, |
65 |
ED_NODE_TO_DISK_DICT, |
66 |
ED_INST_DICT_OSP_DP, |
67 |
ED_IMPEXP_IO, |
68 |
ED_FILE_DETAILS, |
69 |
ED_FINALIZE_EXPORT_DISKS, |
70 |
ED_COMPRESS, |
71 |
ED_BLOCKDEV_RENAME, |
72 |
ED_DISKS_DICT_DP, |
73 |
ED_MULTI_DISKS_DICT_DP, |
74 |
ED_SINGLE_DISK_DICT_DP, |
75 |
ED_NIC_DICT, |
76 |
ED_DEVICE_DICT) = range(1, 17) |
77 |
|
78 |
|
79 |
def _Prepare(calls): |
80 |
"""Converts list of calls to dictionary.
|
81 |
|
82 |
"""
|
83 |
return utils.SequenceToDict(calls)
|
84 |
|
85 |
|
86 |
def _MigrationStatusPostProc(result): |
87 |
"""Post-processor for L{rpc.RpcRunner.call_instance_get_migration_status}.
|
88 |
|
89 |
"""
|
90 |
if not result.fail_msg and result.payload is not None: |
91 |
result.payload = objects.MigrationStatus.FromDict(result.payload) |
92 |
return result
|
93 |
|
94 |
|
95 |
def _BlockdevFindPostProc(result): |
96 |
"""Post-processor for L{rpc.RpcRunner.call_blockdev_find}.
|
97 |
|
98 |
"""
|
99 |
if not result.fail_msg and result.payload is not None: |
100 |
result.payload = objects.BlockDevStatus.FromDict(result.payload) |
101 |
return result
|
102 |
|
103 |
|
104 |
def _BlockdevGetMirrorStatusPostProc(result): |
105 |
"""Post-processor for L{rpc.RpcRunner.call_blockdev_getmirrorstatus}.
|
106 |
|
107 |
"""
|
108 |
if not result.fail_msg: |
109 |
result.payload = map(objects.BlockDevStatus.FromDict, result.payload)
|
110 |
return result
|
111 |
|
112 |
|
113 |
def _BlockdevGetMirrorStatusMultiPreProc(node, args): |
114 |
"""Prepares the appropriate node values for blockdev_getmirrorstatus_multi.
|
115 |
|
116 |
"""
|
117 |
# there should be only one argument to this RPC, already holding a
|
118 |
# node->disks dictionary, we just need to extract the value for the
|
119 |
# current node
|
120 |
assert len(args) == 1 |
121 |
return [args[0][node]] |
122 |
|
123 |
|
124 |
def _BlockdevGetMirrorStatusMultiPostProc(result): |
125 |
"""Post-processor for L{rpc.RpcRunner.call_blockdev_getmirrorstatus_multi}.
|
126 |
|
127 |
"""
|
128 |
if not result.fail_msg: |
129 |
for idx, (success, status) in enumerate(result.payload): |
130 |
if success:
|
131 |
result.payload[idx] = (success, objects.BlockDevStatus.FromDict(status)) |
132 |
|
133 |
return result
|
134 |
|
135 |
|
136 |
def _NodeInfoPreProc(node, args): |
137 |
"""Prepare the storage_units argument for node_info calls."""
|
138 |
assert len(args) == 2 |
139 |
# The storage_units argument is either a dictionary with one value for each
|
140 |
# node, or a fixed value to be used for all the nodes
|
141 |
if type(args[0]) is dict: |
142 |
return [args[0][node], args[1]] |
143 |
else:
|
144 |
return args
|
145 |
|
146 |
|
147 |
def _DrbdCallsPreProc(node, args): |
148 |
"""Add the target node UUID as additional field for DRBD related calls."""
|
149 |
return args + [node]
|
150 |
|
151 |
|
152 |
def _OsGetPostProc(result): |
153 |
"""Post-processor for L{rpc.RpcRunner.call_os_get}.
|
154 |
|
155 |
"""
|
156 |
if not result.fail_msg and isinstance(result.payload, dict): |
157 |
result.payload = objects.OS.FromDict(result.payload) |
158 |
return result
|
159 |
|
160 |
|
161 |
def _ImpExpStatusPostProc(result): |
162 |
"""Post-processor for import/export status.
|
163 |
|
164 |
@rtype: Payload containing list of L{objects.ImportExportStatus} instances
|
165 |
@return: Returns a list of the state of each named import/export or None if
|
166 |
a status couldn't be retrieved
|
167 |
|
168 |
"""
|
169 |
if not result.fail_msg: |
170 |
decoded = [] |
171 |
|
172 |
for i in result.payload: |
173 |
if i is None: |
174 |
decoded.append(None)
|
175 |
continue
|
176 |
decoded.append(objects.ImportExportStatus.FromDict(i)) |
177 |
|
178 |
result.payload = decoded |
179 |
|
180 |
return result
|
181 |
|
182 |
|
183 |
def _TestDelayTimeout((duration, )): |
184 |
"""Calculate timeout for "test_delay" RPC.
|
185 |
|
186 |
"""
|
187 |
return int(duration + 5) |
188 |
|
189 |
|
190 |
_FILE_STORAGE_CALLS = [ |
191 |
("file_storage_dir_create", SINGLE, None, constants.RPC_TMO_FAST, [ |
192 |
("file_storage_dir", None, "File storage directory"), |
193 |
], None, None, "Create the given file storage directory"), |
194 |
("file_storage_dir_remove", SINGLE, None, constants.RPC_TMO_FAST, [ |
195 |
("file_storage_dir", None, "File storage directory"), |
196 |
], None, None, "Remove the given file storage directory"), |
197 |
("file_storage_dir_rename", SINGLE, None, constants.RPC_TMO_FAST, [ |
198 |
("old_file_storage_dir", None, "Old name"), |
199 |
("new_file_storage_dir", None, "New name"), |
200 |
], None, None, "Rename file storage directory"), |
201 |
] |
202 |
|
203 |
_STORAGE_CALLS = [ |
204 |
("storage_list", MULTI, None, constants.RPC_TMO_NORMAL, [ |
205 |
("su_name", None, None), |
206 |
("su_args", None, None), |
207 |
("name", None, None), |
208 |
("fields", None, None), |
209 |
], None, None, "Get list of storage units"), |
210 |
("storage_modify", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
211 |
("su_name", None, None), |
212 |
("su_args", None, None), |
213 |
("name", None, None), |
214 |
("changes", None, None), |
215 |
], None, None, "Modify a storage unit"), |
216 |
("storage_execute", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
217 |
("su_name", None, None), |
218 |
("su_args", None, None), |
219 |
("name", None, None), |
220 |
("op", None, None), |
221 |
], None, None, "Executes an operation on a storage unit"), |
222 |
] |
223 |
|
224 |
_INSTANCE_CALLS = [ |
225 |
("instance_info", SINGLE, None, constants.RPC_TMO_URGENT, [ |
226 |
("instance", None, "Instance name"), |
227 |
("hname", None, "Hypervisor type"), |
228 |
("hvparams", None, "Hypervisor parameters"), |
229 |
], None, None, "Returns information about a single instance"), |
230 |
("all_instances_info", MULTI, None, constants.RPC_TMO_URGENT, [ |
231 |
("hypervisor_list", None, "Hypervisors to query for instances"), |
232 |
("all_hvparams", None, "Dictionary mapping hypervisor names to hvparams"), |
233 |
], None, None, |
234 |
"Returns information about all instances on the given nodes"),
|
235 |
("instance_list", MULTI, None, constants.RPC_TMO_URGENT, [ |
236 |
("hypervisor_list", None, "Hypervisors to query for instances"), |
237 |
("hvparams", None, "Hvparams of all hypervisors"), |
238 |
], None, None, "Returns the list of running instances on the given nodes"), |
239 |
("instance_reboot", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
240 |
("inst", ED_INST_DICT, "Instance object"), |
241 |
("reboot_type", None, None), |
242 |
("shutdown_timeout", None, None), |
243 |
("reason", None, "The reason for the reboot"), |
244 |
], None, None, "Returns the list of running instances on the given nodes"), |
245 |
("instance_shutdown", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
246 |
("instance", ED_INST_DICT, "Instance object"), |
247 |
("timeout", None, None), |
248 |
("reason", None, "The reason for the shutdown"), |
249 |
], None, None, "Stops an instance"), |
250 |
("instance_balloon_memory", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
251 |
("instance", ED_INST_DICT, "Instance object"), |
252 |
("memory", None, None), |
253 |
], None, None, "Modify the amount of an instance's runtime memory"), |
254 |
("instance_run_rename", SINGLE, None, constants.RPC_TMO_SLOW, [ |
255 |
("instance", ED_INST_DICT, "Instance object"), |
256 |
("old_name", None, None), |
257 |
("debug", None, None), |
258 |
], None, None, "Run the OS rename script for an instance"), |
259 |
("instance_migratable", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
260 |
("instance", ED_INST_DICT, "Instance object"), |
261 |
], None, None, "Checks whether the given instance can be migrated"), |
262 |
("migration_info", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
263 |
("instance", ED_INST_DICT, "Instance object"), |
264 |
], None, None, |
265 |
"Gather the information necessary to prepare an instance migration"),
|
266 |
("accept_instance", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
267 |
("instance", ED_INST_DICT, "Instance object"), |
268 |
("info", None, "Result for the call_migration_info call"), |
269 |
("target", None, "Target hostname (usually an IP address)"), |
270 |
], None, None, "Prepare a node to accept an instance"), |
271 |
("instance_finalize_migration_dst", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
272 |
("instance", ED_INST_DICT, "Instance object"), |
273 |
("info", None, "Result for the call_migration_info call"), |
274 |
("success", None, "Whether the migration was a success or failure"), |
275 |
], None, None, "Finalize any target-node migration specific operation"), |
276 |
("instance_migrate", SINGLE, None, constants.RPC_TMO_SLOW, [ |
277 |
("cluster_name", None, "Cluster name"), |
278 |
("instance", ED_INST_DICT, "Instance object"), |
279 |
("target", None, "Target node name"), |
280 |
("live", None, "Whether the migration should be done live or not"), |
281 |
], None, None, "Migrate an instance"), |
282 |
("instance_finalize_migration_src", SINGLE, None, constants.RPC_TMO_SLOW, [ |
283 |
("instance", ED_INST_DICT, "Instance object"), |
284 |
("success", None, "Whether the migration succeeded or not"), |
285 |
("live", None, "Whether the user requested a live migration or not"), |
286 |
], None, None, "Finalize the instance migration on the source node"), |
287 |
("instance_get_migration_status", SINGLE, None, constants.RPC_TMO_SLOW, [ |
288 |
("instance", ED_INST_DICT, "Instance object"), |
289 |
], None, _MigrationStatusPostProc, "Report migration status"), |
290 |
("instance_start", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
291 |
("instance_hvp_bep", ED_INST_DICT_HVP_BEP_DP, None), |
292 |
("startup_paused", None, None), |
293 |
("reason", None, "The reason for the startup"), |
294 |
], None, None, "Starts an instance"), |
295 |
("instance_os_add", SINGLE, None, constants.RPC_TMO_1DAY, [ |
296 |
("instance_osp", ED_INST_DICT_OSP_DP, None), |
297 |
("reinstall", None, None), |
298 |
("debug", None, None), |
299 |
], None, None, "Starts an instance"), |
300 |
("hotplug_device", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
301 |
("instance", ED_INST_DICT, "Instance object"), |
302 |
("action", None, "Hotplug Action"), |
303 |
("dev_type", None, "Device type"), |
304 |
("device", ED_DEVICE_DICT, "Device dict"), |
305 |
("extra", None, "Extra info for device (dev_path for disk)"), |
306 |
("seq", None, "Device seq"), |
307 |
], None, None, "Hoplug a device to a running instance"), |
308 |
] |
309 |
|
310 |
_IMPEXP_CALLS = [ |
311 |
("import_start", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
312 |
("opts", ED_OBJECT_DICT, None), |
313 |
("instance", ED_INST_DICT, None), |
314 |
("component", None, None), |
315 |
("dest", ED_IMPEXP_IO, "Import destination"), |
316 |
], None, None, "Starts an import daemon"), |
317 |
("export_start", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
318 |
("opts", ED_OBJECT_DICT, None), |
319 |
("host", None, None), |
320 |
("port", None, None), |
321 |
("instance", ED_INST_DICT, None), |
322 |
("component", None, None), |
323 |
("source", ED_IMPEXP_IO, "Export source"), |
324 |
], None, None, "Starts an export daemon"), |
325 |
("impexp_status", SINGLE, None, constants.RPC_TMO_FAST, [ |
326 |
("names", None, "Import/export names"), |
327 |
], None, _ImpExpStatusPostProc, "Gets the status of an import or export"), |
328 |
("impexp_abort", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
329 |
("name", None, "Import/export name"), |
330 |
], None, None, "Aborts an import or export"), |
331 |
("impexp_cleanup", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
332 |
("name", None, "Import/export name"), |
333 |
], None, None, "Cleans up after an import or export"), |
334 |
("export_info", SINGLE, None, constants.RPC_TMO_FAST, [ |
335 |
("path", None, None), |
336 |
], None, None, "Queries the export information in a given path"), |
337 |
("finalize_export", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
338 |
("instance", ED_INST_DICT, None), |
339 |
("snap_disks", ED_FINALIZE_EXPORT_DISKS, None), |
340 |
], None, None, "Request the completion of an export operation"), |
341 |
("export_list", MULTI, None, constants.RPC_TMO_FAST, [], None, None, |
342 |
"Gets the stored exports list"),
|
343 |
("export_remove", SINGLE, None, constants.RPC_TMO_FAST, [ |
344 |
("export", None, None), |
345 |
], None, None, "Requests removal of a given export"), |
346 |
] |
347 |
|
348 |
_X509_CALLS = [ |
349 |
("x509_cert_create", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
350 |
("validity", None, "Validity in seconds"), |
351 |
], None, None, "Creates a new X509 certificate for SSL/TLS"), |
352 |
("x509_cert_remove", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
353 |
("name", None, "Certificate name"), |
354 |
], None, None, "Removes a X509 certificate"), |
355 |
] |
356 |
|
357 |
_BLOCKDEV_CALLS = [ |
358 |
("bdev_sizes", MULTI, None, constants.RPC_TMO_URGENT, [ |
359 |
("devices", None, None), |
360 |
], None, None, |
361 |
"Gets the sizes of requested block devices present on a node"),
|
362 |
("blockdev_create", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
363 |
("bdev", ED_OBJECT_DICT, None), |
364 |
("size", None, None), |
365 |
("owner", None, None), |
366 |
("on_primary", None, None), |
367 |
("info", None, None), |
368 |
("exclusive_storage", None, None), |
369 |
], None, None, "Request creation of a given block device"), |
370 |
("blockdev_wipe", SINGLE, None, constants.RPC_TMO_SLOW, [ |
371 |
("bdev", ED_SINGLE_DISK_DICT_DP, None), |
372 |
("offset", None, None), |
373 |
("size", None, None), |
374 |
], None, None, |
375 |
"Request wipe at given offset with given size of a block device"),
|
376 |
("blockdev_remove", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
377 |
("bdev", ED_OBJECT_DICT, None), |
378 |
], None, None, "Request removal of a given block device"), |
379 |
("blockdev_pause_resume_sync", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
380 |
("disks", ED_DISKS_DICT_DP, None), |
381 |
("pause", None, None), |
382 |
], None, None, "Request a pause/resume of given block device"), |
383 |
("blockdev_assemble", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
384 |
("disk", ED_SINGLE_DISK_DICT_DP, None), |
385 |
("owner", None, None), |
386 |
("on_primary", None, None), |
387 |
("idx", None, None), |
388 |
], None, None, "Request assembling of a given block device"), |
389 |
("blockdev_shutdown", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
390 |
("disk", ED_SINGLE_DISK_DICT_DP, None), |
391 |
], None, None, "Request shutdown of a given block device"), |
392 |
("blockdev_addchildren", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
393 |
("bdev", ED_SINGLE_DISK_DICT_DP, None), |
394 |
("ndevs", ED_OBJECT_DICT_LIST, None), |
395 |
], None, None, |
396 |
"Request adding a list of children to a (mirroring) device"),
|
397 |
("blockdev_removechildren", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
398 |
("bdev", ED_OBJECT_DICT, None), |
399 |
("ndevs", ED_OBJECT_DICT_LIST, None), |
400 |
], None, None, |
401 |
"Request removing a list of children from a (mirroring) device"),
|
402 |
("blockdev_close", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
403 |
("instance_name", None, None), |
404 |
("disks", ED_OBJECT_DICT_LIST, None), |
405 |
], None, None, "Closes the given block devices"), |
406 |
("blockdev_getdimensions", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
407 |
("disks", ED_OBJECT_DICT_LIST, None), |
408 |
], None, None, "Returns size and spindles of the given disks"), |
409 |
("drbd_disconnect_net", MULTI, None, constants.RPC_TMO_NORMAL, [ |
410 |
("nodes_ip", None, None), |
411 |
("disks", ED_OBJECT_DICT_LIST, None), |
412 |
], _DrbdCallsPreProc, None,
|
413 |
"Disconnects the network of the given drbd devices"),
|
414 |
("drbd_attach_net", MULTI, None, constants.RPC_TMO_NORMAL, [ |
415 |
("nodes_ip", None, None), |
416 |
("disks", ED_DISKS_DICT_DP, None), |
417 |
("instance_name", None, None), |
418 |
("multimaster", None, None), |
419 |
], _DrbdCallsPreProc, None, "Connects the given DRBD devices"), |
420 |
("drbd_wait_sync", MULTI, None, constants.RPC_TMO_SLOW, [ |
421 |
("nodes_ip", None, None), |
422 |
("disks", ED_DISKS_DICT_DP, None), |
423 |
], _DrbdCallsPreProc, None,
|
424 |
"Waits for the synchronization of drbd devices is complete"),
|
425 |
("drbd_needs_activation", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
426 |
("nodes_ip", None, None), |
427 |
("disks", ED_MULTI_DISKS_DICT_DP, None), |
428 |
], _DrbdCallsPreProc, None,
|
429 |
"Returns the drbd disks which need activation"),
|
430 |
("blockdev_grow", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
431 |
("cf_bdev", ED_SINGLE_DISK_DICT_DP, None), |
432 |
("amount", None, None), |
433 |
("dryrun", None, None), |
434 |
("backingstore", None, None), |
435 |
("es_flag", None, None), |
436 |
], None, None, "Request growing of the given block device by a" |
437 |
" given amount"),
|
438 |
("blockdev_export", SINGLE, None, constants.RPC_TMO_1DAY, [ |
439 |
("cf_bdev", ED_SINGLE_DISK_DICT_DP, None), |
440 |
("dest_node", None, None), |
441 |
("dest_path", None, None), |
442 |
("cluster_name", None, None), |
443 |
], None, None, "Export a given disk to another node"), |
444 |
("blockdev_snapshot", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
445 |
("cf_bdev", ED_SINGLE_DISK_DICT_DP, None), |
446 |
], None, None, "Export a given disk to another node"), |
447 |
("blockdev_rename", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
448 |
("devlist", ED_BLOCKDEV_RENAME, None), |
449 |
], None, None, "Request rename of the given block devices"), |
450 |
("blockdev_find", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
451 |
("disk", ED_OBJECT_DICT, None), |
452 |
], None, _BlockdevFindPostProc,
|
453 |
"Request identification of a given block device"),
|
454 |
("blockdev_getmirrorstatus", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
455 |
("disks", ED_DISKS_DICT_DP, None), |
456 |
], None, _BlockdevGetMirrorStatusPostProc,
|
457 |
"Request status of a (mirroring) device"),
|
458 |
("blockdev_getmirrorstatus_multi", MULTI, None, constants.RPC_TMO_NORMAL, [ |
459 |
("node_disks", ED_NODE_TO_DISK_DICT, None), |
460 |
], _BlockdevGetMirrorStatusMultiPreProc, |
461 |
_BlockdevGetMirrorStatusMultiPostProc, |
462 |
"Request status of (mirroring) devices from multiple nodes"),
|
463 |
("blockdev_setinfo", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
464 |
("disk", ED_OBJECT_DICT, None), |
465 |
("info", None, None), |
466 |
], None, None, "Sets metadata information on a given block device"), |
467 |
] |
468 |
|
469 |
_OS_CALLS = [ |
470 |
("os_diagnose", MULTI, None, constants.RPC_TMO_FAST, [], None, None, |
471 |
"Request a diagnose of OS definitions"),
|
472 |
("os_validate", MULTI, None, constants.RPC_TMO_FAST, [ |
473 |
("required", None, None), |
474 |
("name", None, None), |
475 |
("checks", None, None), |
476 |
("params", None, None), |
477 |
], None, None, "Run a validation routine for a given OS"), |
478 |
("os_get", SINGLE, None, constants.RPC_TMO_FAST, [ |
479 |
("name", None, None), |
480 |
], None, _OsGetPostProc, "Returns an OS definition"), |
481 |
] |
482 |
|
483 |
_EXTSTORAGE_CALLS = [ |
484 |
("extstorage_diagnose", MULTI, None, constants.RPC_TMO_FAST, [], None, None, |
485 |
"Request a diagnose of ExtStorage Providers"),
|
486 |
] |
487 |
|
488 |
_NODE_CALLS = [ |
489 |
("node_has_ip_address", SINGLE, None, constants.RPC_TMO_FAST, [ |
490 |
("address", None, "IP address"), |
491 |
], None, None, "Checks if a node has the given IP address"), |
492 |
("node_info", MULTI, None, constants.RPC_TMO_URGENT, [ |
493 |
("storage_units", None, |
494 |
"List of tuples '<storage_type>,<key>,[<param>]' to ask for disk space"
|
495 |
" information; the parameter list varies depending on the storage_type"),
|
496 |
("hv_specs", None, |
497 |
"List of hypervisor specification (name, hvparams) to ask for node "
|
498 |
"information"),
|
499 |
], _NodeInfoPreProc, None, "Return node information"), |
500 |
("node_verify", MULTI, None, constants.RPC_TMO_NORMAL, [ |
501 |
("checkdict", None, "What to verify"), |
502 |
("cluster_name", None, "Cluster name"), |
503 |
("all_hvparams", None, "Dictionary mapping hypervisor names to hvparams"), |
504 |
], None, None, "Request verification of given parameters"), |
505 |
("node_volumes", MULTI, None, constants.RPC_TMO_FAST, [], None, None, |
506 |
"Gets all volumes on node(s)"),
|
507 |
("node_demote_from_mc", SINGLE, None, constants.RPC_TMO_FAST, [], None, None, |
508 |
"Demote a node from the master candidate role"),
|
509 |
("node_powercycle", SINGLE, ACCEPT_OFFLINE_NODE, constants.RPC_TMO_NORMAL, [
|
510 |
("hypervisor", None, "Hypervisor type"), |
511 |
("hvparams", None, "Hypervisor parameters"), |
512 |
], None, None, "Tries to powercycle a node"), |
513 |
] |
514 |
|
515 |
_MISC_CALLS = [ |
516 |
("lv_list", MULTI, None, constants.RPC_TMO_URGENT, [ |
517 |
("vg_name", None, None), |
518 |
], None, None, "Gets the logical volumes present in a given volume group"), |
519 |
("vg_list", MULTI, None, constants.RPC_TMO_URGENT, [], None, None, |
520 |
"Gets the volume group list"),
|
521 |
("bridges_exist", SINGLE, None, constants.RPC_TMO_URGENT, [ |
522 |
("bridges_list", None, "Bridges which must be present on remote node"), |
523 |
], None, None, "Checks if a node has all the bridges given"), |
524 |
("etc_hosts_modify", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
525 |
("mode", None, |
526 |
"Mode to operate; currently L{constants.ETC_HOSTS_ADD} or"
|
527 |
" L{constants.ETC_HOSTS_REMOVE}"),
|
528 |
("name", None, "Hostname to be modified"), |
529 |
("ip", None, "IP address (L{constants.ETC_HOSTS_ADD} only)"), |
530 |
], None, None, "Modify hosts file with name"), |
531 |
("drbd_helper", MULTI, None, constants.RPC_TMO_URGENT, [], |
532 |
None, None, "Gets DRBD helper"), |
533 |
("restricted_command", MULTI, None, constants.RPC_TMO_SLOW, [ |
534 |
("cmd", None, "Command name"), |
535 |
], None, None, "Runs restricted command"), |
536 |
("run_oob", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
537 |
("oob_program", None, None), |
538 |
("command", None, None), |
539 |
("remote_node", None, None), |
540 |
("timeout", None, None), |
541 |
], None, None, "Runs out-of-band command"), |
542 |
("hooks_runner", MULTI, None, constants.RPC_TMO_NORMAL, [ |
543 |
("hpath", None, None), |
544 |
("phase", None, None), |
545 |
("env", None, None), |
546 |
], None, None, "Call the hooks runner"), |
547 |
("iallocator_runner", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
548 |
("name", None, "Iallocator name"), |
549 |
("idata", None, "JSON-encoded input string"), |
550 |
], None, None, "Call an iallocator on a remote node"), |
551 |
("test_delay", MULTI, None, _TestDelayTimeout, [ |
552 |
("duration", None, None), |
553 |
], None, None, "Sleep for a fixed time on given node(s)"), |
554 |
("hypervisor_validate_params", MULTI, None, constants.RPC_TMO_NORMAL, [ |
555 |
("hvname", None, "Hypervisor name"), |
556 |
("hvfull", None, "Parameters to be validated"), |
557 |
], None, None, "Validate hypervisor params"), |
558 |
("get_watcher_pause", SINGLE, None, constants.RPC_TMO_URGENT, [], |
559 |
None, None, "Get watcher pause end"), |
560 |
("set_watcher_pause", MULTI, None, constants.RPC_TMO_URGENT, [ |
561 |
("until", None, None), |
562 |
], None, None, "Set watcher pause end"), |
563 |
] |
564 |
|
565 |
CALLS = { |
566 |
"RpcClientDefault":
|
567 |
_Prepare(_IMPEXP_CALLS + _X509_CALLS + _OS_CALLS + _NODE_CALLS + |
568 |
_FILE_STORAGE_CALLS + _MISC_CALLS + _INSTANCE_CALLS + |
569 |
_BLOCKDEV_CALLS + _STORAGE_CALLS + _EXTSTORAGE_CALLS), |
570 |
"RpcClientJobQueue": _Prepare([
|
571 |
("jobqueue_update", MULTI, None, constants.RPC_TMO_URGENT, [ |
572 |
("file_name", None, None), |
573 |
("content", ED_COMPRESS, None), |
574 |
], None, None, "Update job queue file"), |
575 |
("jobqueue_purge", SINGLE, None, constants.RPC_TMO_NORMAL, [], None, None, |
576 |
"Purge job queue"),
|
577 |
("jobqueue_rename", MULTI, None, constants.RPC_TMO_URGENT, [ |
578 |
("rename", None, None), |
579 |
], None, None, "Rename job queue file"), |
580 |
("jobqueue_set_drain_flag", MULTI, None, constants.RPC_TMO_URGENT, [ |
581 |
("flag", None, None), |
582 |
], None, None, "Set job queue drain flag"), |
583 |
]), |
584 |
"RpcClientBootstrap": _Prepare([
|
585 |
("node_start_master_daemons", SINGLE, None, constants.RPC_TMO_FAST, [ |
586 |
("no_voting", None, None), |
587 |
], None, None, "Starts master daemons on a node"), |
588 |
("node_activate_master_ip", SINGLE, None, constants.RPC_TMO_FAST, [ |
589 |
("master_params", ED_OBJECT_DICT, "Network parameters of the master"), |
590 |
("use_external_mip_script", None, |
591 |
"Whether to use the user-provided master IP address setup script"),
|
592 |
], None, None, |
593 |
"Activates master IP on a node"),
|
594 |
("node_stop_master", SINGLE, None, constants.RPC_TMO_FAST, [], None, None, |
595 |
"Deactivates master IP and stops master daemons on a node"),
|
596 |
("node_deactivate_master_ip", SINGLE, None, constants.RPC_TMO_FAST, [ |
597 |
("master_params", ED_OBJECT_DICT, "Network parameters of the master"), |
598 |
("use_external_mip_script", None, |
599 |
"Whether to use the user-provided master IP address setup script"),
|
600 |
], None, None, |
601 |
"Deactivates master IP on a node"),
|
602 |
("node_change_master_netmask", SINGLE, None, constants.RPC_TMO_FAST, [ |
603 |
("old_netmask", None, "The old value of the netmask"), |
604 |
("netmask", None, "The new value of the netmask"), |
605 |
("master_ip", None, "The master IP"), |
606 |
("master_netdev", None, "The master network device"), |
607 |
], None, None, "Change master IP netmask"), |
608 |
("node_leave_cluster", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
609 |
("modify_ssh_setup", None, None), |
610 |
], None, None, |
611 |
"Requests a node to clean the cluster information it has"),
|
612 |
("master_info", MULTI, None, constants.RPC_TMO_URGENT, [], None, None, |
613 |
"Query master info"),
|
614 |
]), |
615 |
"RpcClientDnsOnly": _Prepare([
|
616 |
("version", MULTI, ACCEPT_OFFLINE_NODE, constants.RPC_TMO_URGENT, [], None, |
617 |
None, "Query node version"), |
618 |
("node_verify_light", MULTI, None, constants.RPC_TMO_NORMAL, [ |
619 |
("checkdict", None, "What to verify"), |
620 |
("cluster_name", None, "Cluster name"), |
621 |
("hvparams", None, "Dictionary mapping hypervisor names to hvparams"), |
622 |
], None, None, "Request verification of given parameters"), |
623 |
]), |
624 |
"RpcClientConfig": _Prepare([
|
625 |
("upload_file", MULTI, None, constants.RPC_TMO_NORMAL, [ |
626 |
("file_name", ED_FILE_DETAILS, None), |
627 |
], None, None, "Upload a file"), |
628 |
("write_ssconf_files", MULTI, None, constants.RPC_TMO_NORMAL, [ |
629 |
("values", None, None), |
630 |
], None, None, "Write ssconf files"), |
631 |
]), |
632 |
} |