Statistics
| Branch: | Tag: | Revision:

root / lib / rpc_defs.py @ 790d491c

History | View | Annotate | Download (25.3 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_SINGLE_DISK_DICT_DP,
74
 ED_NIC_DICT,
75
 ED_DEVICE_DICT) = range(1, 16)
76

    
77

    
78
def _Prepare(calls):
79
  """Converts list of calls to dictionary.
80

81
  """
82
  return utils.SequenceToDict(calls)
83

    
84

    
85
def _MigrationStatusPostProc(result):
86
  """Post-processor for L{rpc.RpcRunner.call_instance_get_migration_status}.
87

88
  """
89
  if not result.fail_msg and result.payload is not None:
90
    result.payload = objects.MigrationStatus.FromDict(result.payload)
91
  return result
92

    
93

    
94
def _BlockdevFindPostProc(result):
95
  """Post-processor for L{rpc.RpcRunner.call_blockdev_find}.
96

97
  """
98
  if not result.fail_msg and result.payload is not None:
99
    result.payload = objects.BlockDevStatus.FromDict(result.payload)
100
  return result
101

    
102

    
103
def _BlockdevGetMirrorStatusPostProc(result):
104
  """Post-processor for L{rpc.RpcRunner.call_blockdev_getmirrorstatus}.
105

106
  """
107
  if not result.fail_msg:
108
    result.payload = map(objects.BlockDevStatus.FromDict, result.payload)
109
  return result
110

    
111

    
112
def _BlockdevGetMirrorStatusMultiPreProc(node, args):
113
  """Prepares the appropriate node values for blockdev_getmirrorstatus_multi.
114

115
  """
116
  # there should be only one argument to this RPC, already holding a
117
  # node->disks dictionary, we just need to extract the value for the
118
  # current node
119
  assert len(args) == 1
120
  return [args[0][node]]
121

    
122

    
123
def _BlockdevGetMirrorStatusMultiPostProc(result):
124
  """Post-processor for L{rpc.RpcRunner.call_blockdev_getmirrorstatus_multi}.
125

126
  """
127
  if not result.fail_msg:
128
    for idx, (success, status) in enumerate(result.payload):
129
      if success:
130
        result.payload[idx] = (success, objects.BlockDevStatus.FromDict(status))
131

    
132
  return result
133

    
134

    
135
def _NodeInfoPreProc(node, args):
136
  """Prepare the exclusive_storage argument for node_info calls."""
137
  assert len(args) == 3
138
  # The third argument is either a dictionary with one value for each node, or
139
  # a fixed value to be used for all the nodes
140
  if type(args[2]) is dict:
141
    return [args[0], args[1], args[2][node]]
142
  else:
143
    return args
144

    
145

    
146
def _DrbdCallsPreProc(node, args):
147
  """Add the target node UUID as additional field for DRBD related calls."""
148
  return args + [node]
149

    
150

    
151
def _OsGetPostProc(result):
152
  """Post-processor for L{rpc.RpcRunner.call_os_get}.
153

154
  """
155
  if not result.fail_msg and isinstance(result.payload, dict):
156
    result.payload = objects.OS.FromDict(result.payload)
157
  return result
158

    
159

    
160
def _ImpExpStatusPostProc(result):
161
  """Post-processor for import/export status.
162

163
  @rtype: Payload containing list of L{objects.ImportExportStatus} instances
164
  @return: Returns a list of the state of each named import/export or None if
165
           a status couldn't be retrieved
166

167
  """
168
  if not result.fail_msg:
169
    decoded = []
170

    
171
    for i in result.payload:
172
      if i is None:
173
        decoded.append(None)
174
        continue
175
      decoded.append(objects.ImportExportStatus.FromDict(i))
176

    
177
    result.payload = decoded
178

    
179
  return result
180

    
181

    
182
def _TestDelayTimeout((duration, )):
183
  """Calculate timeout for "test_delay" RPC.
184

185
  """
186
  return int(duration + 5)
187

    
188

    
189
_FILE_STORAGE_CALLS = [
190
  ("file_storage_dir_create", SINGLE, None, constants.RPC_TMO_FAST, [
191
    ("file_storage_dir", None, "File storage directory"),
192
    ], None, None, "Create the given file storage directory"),
193
  ("file_storage_dir_remove", SINGLE, None, constants.RPC_TMO_FAST, [
194
    ("file_storage_dir", None, "File storage directory"),
195
    ], None, None, "Remove the given file storage directory"),
196
  ("file_storage_dir_rename", SINGLE, None, constants.RPC_TMO_FAST, [
197
    ("old_file_storage_dir", None, "Old name"),
198
    ("new_file_storage_dir", None, "New name"),
199
    ], None, None, "Rename file storage directory"),
200
  ]
201

    
202
_STORAGE_CALLS = [
203
  ("storage_list", MULTI, None, constants.RPC_TMO_NORMAL, [
204
    ("su_name", None, None),
205
    ("su_args", None, None),
206
    ("name", None, None),
207
    ("fields", None, None),
208
    ], None, None, "Get list of storage units"),
209
  ("storage_modify", SINGLE, None, constants.RPC_TMO_NORMAL, [
210
    ("su_name", None, None),
211
    ("su_args", None, None),
212
    ("name", None, None),
213
    ("changes", None, None),
214
    ], None, None, "Modify a storage unit"),
215
  ("storage_execute", SINGLE, None, constants.RPC_TMO_NORMAL, [
216
    ("su_name", None, None),
217
    ("su_args", None, None),
218
    ("name", None, None),
219
    ("op", None, None),
220
    ], None, None, "Executes an operation on a storage unit"),
221
  ]
222

    
223
_INSTANCE_CALLS = [
224
  ("instance_info", SINGLE, None, constants.RPC_TMO_URGENT, [
225
    ("instance", None, "Instance name"),
226
    ("hname", None, "Hypervisor type"),
227
    ("hvparams", None, "Hypervisor parameters"),
228
    ], None, None, "Returns information about a single instance"),
229
  ("all_instances_info", MULTI, None, constants.RPC_TMO_URGENT, [
230
    ("hypervisor_list", None, "Hypervisors to query for instances"),
231
    ("all_hvparams", None, "Dictionary mapping hypervisor names to hvparams"),
232
    ], None, None,
233
   "Returns information about all instances on the given nodes"),
234
  ("instance_list", MULTI, None, constants.RPC_TMO_URGENT, [
235
    ("hypervisor_list", None, "Hypervisors to query for instances"),
236
    ("hvparams", None, "Hvparams of all hypervisors"),
237
    ], None, None, "Returns the list of running instances on the given nodes"),
238
  ("instance_reboot", SINGLE, None, constants.RPC_TMO_NORMAL, [
239
    ("inst", ED_INST_DICT, "Instance object"),
240
    ("reboot_type", None, None),
241
    ("shutdown_timeout", None, None),
242
    ("reason", None, "The reason for the reboot"),
243
    ], None, None, "Returns the list of running instances on the given nodes"),
244
  ("instance_shutdown", SINGLE, None, constants.RPC_TMO_NORMAL, [
245
    ("instance", ED_INST_DICT, "Instance object"),
246
    ("timeout", None, None),
247
    ("reason", None, "The reason for the shutdown"),
248
    ], None, None, "Stops an instance"),
249
  ("instance_balloon_memory", SINGLE, None, constants.RPC_TMO_NORMAL, [
250
    ("instance", ED_INST_DICT, "Instance object"),
251
    ("memory", None, None),
252
    ], None, None, "Modify the amount of an instance's runtime memory"),
253
  ("instance_run_rename", SINGLE, None, constants.RPC_TMO_SLOW, [
254
    ("instance", ED_INST_DICT, "Instance object"),
255
    ("old_name", None, None),
256
    ("debug", None, None),
257
    ], None, None, "Run the OS rename script for an instance"),
258
  ("instance_migratable", SINGLE, None, constants.RPC_TMO_NORMAL, [
259
    ("instance", ED_INST_DICT, "Instance object"),
260
    ], None, None, "Checks whether the given instance can be migrated"),
261
  ("migration_info", SINGLE, None, constants.RPC_TMO_NORMAL, [
262
    ("instance", ED_INST_DICT, "Instance object"),
263
    ], None, None,
264
    "Gather the information necessary to prepare an instance migration"),
265
  ("accept_instance", SINGLE, None, constants.RPC_TMO_NORMAL, [
266
    ("instance", ED_INST_DICT, "Instance object"),
267
    ("info", None, "Result for the call_migration_info call"),
268
    ("target", None, "Target hostname (usually an IP address)"),
269
    ], None, None, "Prepare a node to accept an instance"),
270
  ("instance_finalize_migration_dst", SINGLE, None, constants.RPC_TMO_NORMAL, [
271
    ("instance", ED_INST_DICT, "Instance object"),
272
    ("info", None, "Result for the call_migration_info call"),
273
    ("success", None, "Whether the migration was a success or failure"),
274
    ], None, None, "Finalize any target-node migration specific operation"),
275
  ("instance_migrate", SINGLE, None, constants.RPC_TMO_SLOW, [
276
    ("cluster_name", None, "Cluster name"),
277
    ("instance", ED_INST_DICT, "Instance object"),
278
    ("target", None, "Target node name"),
279
    ("live", None, "Whether the migration should be done live or not"),
280
    ], None, None, "Migrate an instance"),
281
  ("instance_finalize_migration_src", SINGLE, None, constants.RPC_TMO_SLOW, [
282
    ("instance", ED_INST_DICT, "Instance object"),
283
    ("success", None, "Whether the migration succeeded or not"),
284
    ("live", None, "Whether the user requested a live migration or not"),
285
    ], None, None, "Finalize the instance migration on the source node"),
286
  ("instance_get_migration_status", SINGLE, None, constants.RPC_TMO_SLOW, [
287
    ("instance", ED_INST_DICT, "Instance object"),
288
    ], None, _MigrationStatusPostProc, "Report migration status"),
289
  ("instance_start", SINGLE, None, constants.RPC_TMO_NORMAL, [
290
    ("instance_hvp_bep", ED_INST_DICT_HVP_BEP_DP, None),
291
    ("startup_paused", None, None),
292
    ("reason", None, "The reason for the startup"),
293
    ], None, None, "Starts an instance"),
294
  ("instance_os_add", SINGLE, None, constants.RPC_TMO_1DAY, [
295
    ("instance_osp", ED_INST_DICT_OSP_DP, None),
296
    ("reinstall", None, None),
297
    ("debug", None, None),
298
    ], None, None, "Starts an instance"),
299
  ("hotplug_device", SINGLE, None, constants.RPC_TMO_NORMAL, [
300
    ("instance", ED_INST_DICT, "Instance object"),
301
    ("action", None, "Hotplug Action"),
302
    ("dev_type", None, "Device type"),
303
    ("device", ED_DEVICE_DICT, "Device dict"),
304
    ("extra", None, "Extra info for device (dev_path for disk)"),
305
    ("seq", None, "Device seq"),
306
    ], None, None, "Hoplug a device to a running instance"),
307
  ]
308

    
309
_IMPEXP_CALLS = [
310
  ("import_start", SINGLE, None, constants.RPC_TMO_NORMAL, [
311
    ("opts", ED_OBJECT_DICT, None),
312
    ("instance", ED_INST_DICT, None),
313
    ("component", None, None),
314
    ("dest", ED_IMPEXP_IO, "Import destination"),
315
    ], None, None, "Starts an import daemon"),
316
  ("export_start", SINGLE, None, constants.RPC_TMO_NORMAL, [
317
    ("opts", ED_OBJECT_DICT, None),
318
    ("host", None, None),
319
    ("port", None, None),
320
    ("instance", ED_INST_DICT, None),
321
    ("component", None, None),
322
    ("source", ED_IMPEXP_IO, "Export source"),
323
    ], None, None, "Starts an export daemon"),
324
  ("impexp_status", SINGLE, None, constants.RPC_TMO_FAST, [
325
    ("names", None, "Import/export names"),
326
    ], None, _ImpExpStatusPostProc, "Gets the status of an import or export"),
327
  ("impexp_abort", SINGLE, None, constants.RPC_TMO_NORMAL, [
328
    ("name", None, "Import/export name"),
329
    ], None, None, "Aborts an import or export"),
330
  ("impexp_cleanup", SINGLE, None, constants.RPC_TMO_NORMAL, [
331
    ("name", None, "Import/export name"),
332
    ], None, None, "Cleans up after an import or export"),
333
  ("export_info", SINGLE, None, constants.RPC_TMO_FAST, [
334
    ("path", None, None),
335
    ], None, None, "Queries the export information in a given path"),
336
  ("finalize_export", SINGLE, None, constants.RPC_TMO_NORMAL, [
337
    ("instance", ED_INST_DICT, None),
338
    ("snap_disks", ED_FINALIZE_EXPORT_DISKS, None),
339
    ], None, None, "Request the completion of an export operation"),
340
  ("export_list", MULTI, None, constants.RPC_TMO_FAST, [], None, None,
341
   "Gets the stored exports list"),
342
  ("export_remove", SINGLE, None, constants.RPC_TMO_FAST, [
343
    ("export", None, None),
344
    ], None, None, "Requests removal of a given export"),
345
  ]
346

    
347
_X509_CALLS = [
348
  ("x509_cert_create", SINGLE, None, constants.RPC_TMO_NORMAL, [
349
    ("validity", None, "Validity in seconds"),
350
    ], None, None, "Creates a new X509 certificate for SSL/TLS"),
351
  ("x509_cert_remove", SINGLE, None, constants.RPC_TMO_NORMAL, [
352
    ("name", None, "Certificate name"),
353
    ], None, None, "Removes a X509 certificate"),
354
  ]
355

    
356
_BLOCKDEV_CALLS = [
357
  ("bdev_sizes", MULTI, None, constants.RPC_TMO_URGENT, [
358
    ("devices", None, None),
359
    ], None, None,
360
   "Gets the sizes of requested block devices present on a node"),
361
  ("blockdev_create", SINGLE, None, constants.RPC_TMO_NORMAL, [
362
    ("bdev", ED_OBJECT_DICT, None),
363
    ("size", None, None),
364
    ("owner", None, None),
365
    ("on_primary", None, None),
366
    ("info", None, None),
367
    ("exclusive_storage", None, None),
368
    ], None, None, "Request creation of a given block device"),
369
  ("blockdev_wipe", SINGLE, None, constants.RPC_TMO_SLOW, [
370
    ("bdev", ED_SINGLE_DISK_DICT_DP, None),
371
    ("offset", None, None),
372
    ("size", None, None),
373
    ], None, None,
374
    "Request wipe at given offset with given size of a block device"),
375
  ("blockdev_remove", SINGLE, None, constants.RPC_TMO_NORMAL, [
376
    ("bdev", ED_OBJECT_DICT, None),
377
    ], None, None, "Request removal of a given block device"),
378
  ("blockdev_pause_resume_sync", SINGLE, None, constants.RPC_TMO_NORMAL, [
379
    ("disks", ED_DISKS_DICT_DP, None),
380
    ("pause", None, None),
381
    ], None, None, "Request a pause/resume of given block device"),
382
  ("blockdev_assemble", SINGLE, None, constants.RPC_TMO_NORMAL, [
383
    ("disk", ED_SINGLE_DISK_DICT_DP, None),
384
    ("owner", None, None),
385
    ("on_primary", None, None),
386
    ("idx", None, None),
387
    ], None, None, "Request assembling of a given block device"),
388
  ("blockdev_shutdown", SINGLE, None, constants.RPC_TMO_NORMAL, [
389
    ("disk", ED_SINGLE_DISK_DICT_DP, None),
390
    ], None, None, "Request shutdown of a given block device"),
391
  ("blockdev_addchildren", SINGLE, None, constants.RPC_TMO_NORMAL, [
392
    ("bdev", ED_SINGLE_DISK_DICT_DP, None),
393
    ("ndevs", ED_OBJECT_DICT_LIST, None),
394
    ], None, None,
395
   "Request adding a list of children to a (mirroring) device"),
396
  ("blockdev_removechildren", SINGLE, None, constants.RPC_TMO_NORMAL, [
397
    ("bdev", ED_OBJECT_DICT, None),
398
    ("ndevs", ED_OBJECT_DICT_LIST, None),
399
    ], None, None,
400
   "Request removing a list of children from a (mirroring) device"),
401
  ("blockdev_close", SINGLE, None, constants.RPC_TMO_NORMAL, [
402
    ("instance_name", None, None),
403
    ("disks", ED_OBJECT_DICT_LIST, None),
404
    ], None, None, "Closes the given block devices"),
405
  ("blockdev_getdimensions", SINGLE, None, constants.RPC_TMO_NORMAL, [
406
    ("disks", ED_OBJECT_DICT_LIST, None),
407
    ], None, None, "Returns size and spindles of the given disks"),
408
  ("drbd_disconnect_net", MULTI, None, constants.RPC_TMO_NORMAL, [
409
    ("nodes_ip", None, None),
410
    ("disks", ED_OBJECT_DICT_LIST, None),
411
    ], _DrbdCallsPreProc, None,
412
   "Disconnects the network of the given drbd devices"),
413
  ("drbd_attach_net", MULTI, None, constants.RPC_TMO_NORMAL, [
414
    ("nodes_ip", None, None),
415
    ("disks", ED_DISKS_DICT_DP, None),
416
    ("instance_name", None, None),
417
    ("multimaster", None, None),
418
    ], _DrbdCallsPreProc, None, "Connects the given DRBD devices"),
419
  ("drbd_wait_sync", MULTI, None, constants.RPC_TMO_SLOW, [
420
    ("nodes_ip", None, None),
421
    ("disks", ED_DISKS_DICT_DP, None),
422
    ], _DrbdCallsPreProc, None,
423
   "Waits for the synchronization of drbd devices is complete"),
424
  ("blockdev_grow", SINGLE, None, constants.RPC_TMO_NORMAL, [
425
    ("cf_bdev", ED_SINGLE_DISK_DICT_DP, None),
426
    ("amount", None, None),
427
    ("dryrun", None, None),
428
    ("backingstore", None, None),
429
    ("es_flag", None, None),
430
    ], None, None, "Request growing of the given block device by a"
431
   " given amount"),
432
  ("blockdev_export", SINGLE, None, constants.RPC_TMO_1DAY, [
433
    ("cf_bdev", ED_SINGLE_DISK_DICT_DP, None),
434
    ("dest_node", None, None),
435
    ("dest_path", None, None),
436
    ("cluster_name", None, None),
437
    ], None, None, "Export a given disk to another node"),
438
  ("blockdev_snapshot", SINGLE, None, constants.RPC_TMO_NORMAL, [
439
    ("cf_bdev", ED_SINGLE_DISK_DICT_DP, None),
440
    ], None, None, "Export a given disk to another node"),
441
  ("blockdev_rename", SINGLE, None, constants.RPC_TMO_NORMAL, [
442
    ("devlist", ED_BLOCKDEV_RENAME, None),
443
    ], None, None, "Request rename of the given block devices"),
444
  ("blockdev_find", SINGLE, None, constants.RPC_TMO_NORMAL, [
445
    ("disk", ED_OBJECT_DICT, None),
446
    ], None, _BlockdevFindPostProc,
447
    "Request identification of a given block device"),
448
  ("blockdev_getmirrorstatus", SINGLE, None, constants.RPC_TMO_NORMAL, [
449
    ("disks", ED_DISKS_DICT_DP, None),
450
    ], None, _BlockdevGetMirrorStatusPostProc,
451
    "Request status of a (mirroring) device"),
452
  ("blockdev_getmirrorstatus_multi", MULTI, None, constants.RPC_TMO_NORMAL, [
453
    ("node_disks", ED_NODE_TO_DISK_DICT, None),
454
    ], _BlockdevGetMirrorStatusMultiPreProc,
455
   _BlockdevGetMirrorStatusMultiPostProc,
456
    "Request status of (mirroring) devices from multiple nodes"),
457
  ("blockdev_setinfo", SINGLE, None, constants.RPC_TMO_NORMAL, [
458
    ("disk", ED_OBJECT_DICT, None),
459
    ("info", None, None),
460
    ], None, None, "Sets metadata information on a given block device"),
461
  ]
462

    
463
_OS_CALLS = [
464
  ("os_diagnose", MULTI, None, constants.RPC_TMO_FAST, [], None, None,
465
   "Request a diagnose of OS definitions"),
466
  ("os_validate", MULTI, None, constants.RPC_TMO_FAST, [
467
    ("required", None, None),
468
    ("name", None, None),
469
    ("checks", None, None),
470
    ("params", None, None),
471
    ], None, None, "Run a validation routine for a given OS"),
472
  ("os_get", SINGLE, None, constants.RPC_TMO_FAST, [
473
    ("name", None, None),
474
    ], None, _OsGetPostProc, "Returns an OS definition"),
475
  ]
476

    
477
_EXTSTORAGE_CALLS = [
478
  ("extstorage_diagnose", MULTI, None, constants.RPC_TMO_FAST, [], None, None,
479
   "Request a diagnose of ExtStorage Providers"),
480
  ]
481

    
482
_NODE_CALLS = [
483
  ("node_has_ip_address", SINGLE, None, constants.RPC_TMO_FAST, [
484
    ("address", None, "IP address"),
485
    ], None, None, "Checks if a node has the given IP address"),
486
  ("node_info", MULTI, None, constants.RPC_TMO_URGENT, [
487
    ("storage_units", None,
488
     "List of tuples '<storage_type>,<key>' to ask for disk space"
489
     " information"),
490
    ("hv_specs", None,
491
     "List of hypervisor specification (name, hvparams) to ask for node "
492
     "information"),
493
    ("exclusive_storage", None,
494
     "Whether exclusive storage is enabled"),
495
    ], _NodeInfoPreProc, None, "Return node information"),
496
  ("node_verify", MULTI, None, constants.RPC_TMO_NORMAL, [
497
    ("checkdict", None, "What to verify"),
498
    ("cluster_name", None, "Cluster name"),
499
    ("all_hvparams", None, "Dictionary mapping hypervisor names to hvparams"),
500
    ], None, None, "Request verification of given parameters"),
501
  ("node_volumes", MULTI, None, constants.RPC_TMO_FAST, [], None, None,
502
   "Gets all volumes on node(s)"),
503
  ("node_demote_from_mc", SINGLE, None, constants.RPC_TMO_FAST, [], None, None,
504
   "Demote a node from the master candidate role"),
505
  ("node_powercycle", SINGLE, ACCEPT_OFFLINE_NODE, constants.RPC_TMO_NORMAL, [
506
    ("hypervisor", None, "Hypervisor type"),
507
    ("hvparams", None, "Hypervisor parameters"),
508
    ], None, None, "Tries to powercycle a node"),
509
  ]
510

    
511
_MISC_CALLS = [
512
  ("lv_list", MULTI, None, constants.RPC_TMO_URGENT, [
513
    ("vg_name", None, None),
514
    ], None, None, "Gets the logical volumes present in a given volume group"),
515
  ("vg_list", MULTI, None, constants.RPC_TMO_URGENT, [], None, None,
516
   "Gets the volume group list"),
517
  ("bridges_exist", SINGLE, None, constants.RPC_TMO_URGENT, [
518
    ("bridges_list", None, "Bridges which must be present on remote node"),
519
    ], None, None, "Checks if a node has all the bridges given"),
520
  ("etc_hosts_modify", SINGLE, None, constants.RPC_TMO_NORMAL, [
521
    ("mode", None,
522
     "Mode to operate; currently L{constants.ETC_HOSTS_ADD} or"
523
     " L{constants.ETC_HOSTS_REMOVE}"),
524
    ("name", None, "Hostname to be modified"),
525
    ("ip", None, "IP address (L{constants.ETC_HOSTS_ADD} only)"),
526
    ], None, None, "Modify hosts file with name"),
527
  ("drbd_helper", MULTI, None, constants.RPC_TMO_URGENT, [],
528
   None, None, "Gets DRBD helper"),
529
  ("restricted_command", MULTI, None, constants.RPC_TMO_SLOW, [
530
    ("cmd", None, "Command name"),
531
    ], None, None, "Runs restricted command"),
532
  ("run_oob", SINGLE, None, constants.RPC_TMO_NORMAL, [
533
    ("oob_program", None, None),
534
    ("command", None, None),
535
    ("remote_node", None, None),
536
    ("timeout", None, None),
537
    ], None, None, "Runs out-of-band command"),
538
  ("hooks_runner", MULTI, None, constants.RPC_TMO_NORMAL, [
539
    ("hpath", None, None),
540
    ("phase", None, None),
541
    ("env", None, None),
542
    ], None, None, "Call the hooks runner"),
543
  ("iallocator_runner", SINGLE, None, constants.RPC_TMO_NORMAL, [
544
    ("name", None, "Iallocator name"),
545
    ("idata", None, "JSON-encoded input string"),
546
    ], None, None, "Call an iallocator on a remote node"),
547
  ("test_delay", MULTI, None, _TestDelayTimeout, [
548
    ("duration", None, None),
549
    ], None, None, "Sleep for a fixed time on given node(s)"),
550
  ("hypervisor_validate_params", MULTI, None, constants.RPC_TMO_NORMAL, [
551
    ("hvname", None, "Hypervisor name"),
552
    ("hvfull", None, "Parameters to be validated"),
553
    ], None, None, "Validate hypervisor params"),
554
  ("get_watcher_pause", SINGLE, None, constants.RPC_TMO_URGENT, [],
555
    None, None, "Get watcher pause end"),
556
  ("set_watcher_pause", MULTI, None, constants.RPC_TMO_URGENT, [
557
    ("until", None, None),
558
    ], None, None, "Set watcher pause end"),
559
  ]
560

    
561
CALLS = {
562
  "RpcClientDefault":
563
    _Prepare(_IMPEXP_CALLS + _X509_CALLS + _OS_CALLS + _NODE_CALLS +
564
             _FILE_STORAGE_CALLS + _MISC_CALLS + _INSTANCE_CALLS +
565
             _BLOCKDEV_CALLS + _STORAGE_CALLS + _EXTSTORAGE_CALLS),
566
  "RpcClientJobQueue": _Prepare([
567
    ("jobqueue_update", MULTI, None, constants.RPC_TMO_URGENT, [
568
      ("file_name", None, None),
569
      ("content", ED_COMPRESS, None),
570
      ], None, None, "Update job queue file"),
571
    ("jobqueue_purge", SINGLE, None, constants.RPC_TMO_NORMAL, [], None, None,
572
     "Purge job queue"),
573
    ("jobqueue_rename", MULTI, None, constants.RPC_TMO_URGENT, [
574
      ("rename", None, None),
575
      ], None, None, "Rename job queue file"),
576
    ("jobqueue_set_drain_flag", MULTI, None, constants.RPC_TMO_URGENT, [
577
      ("flag", None, None),
578
      ], None, None, "Set job queue drain flag"),
579
    ]),
580
  "RpcClientBootstrap": _Prepare([
581
    ("node_start_master_daemons", SINGLE, None, constants.RPC_TMO_FAST, [
582
      ("no_voting", None, None),
583
      ], None, None, "Starts master daemons on a node"),
584
    ("node_activate_master_ip", SINGLE, None, constants.RPC_TMO_FAST, [
585
      ("master_params", ED_OBJECT_DICT, "Network parameters of the master"),
586
      ("use_external_mip_script", None,
587
       "Whether to use the user-provided master IP address setup script"),
588
      ], None, None,
589
      "Activates master IP on a node"),
590
    ("node_stop_master", SINGLE, None, constants.RPC_TMO_FAST, [], None, None,
591
     "Deactivates master IP and stops master daemons on a node"),
592
    ("node_deactivate_master_ip", SINGLE, None, constants.RPC_TMO_FAST, [
593
      ("master_params", ED_OBJECT_DICT, "Network parameters of the master"),
594
      ("use_external_mip_script", None,
595
       "Whether to use the user-provided master IP address setup script"),
596
      ], None, None,
597
     "Deactivates master IP on a node"),
598
    ("node_change_master_netmask", SINGLE, None, constants.RPC_TMO_FAST, [
599
      ("old_netmask", None, "The old value of the netmask"),
600
      ("netmask", None, "The new value of the netmask"),
601
      ("master_ip", None, "The master IP"),
602
      ("master_netdev", None, "The master network device"),
603
      ], None, None, "Change master IP netmask"),
604
    ("node_leave_cluster", SINGLE, None, constants.RPC_TMO_NORMAL, [
605
      ("modify_ssh_setup", None, None),
606
      ], None, None,
607
     "Requests a node to clean the cluster information it has"),
608
    ("master_info", MULTI, None, constants.RPC_TMO_URGENT, [], None, None,
609
     "Query master info"),
610
    ]),
611
  "RpcClientDnsOnly": _Prepare([
612
    ("version", MULTI, ACCEPT_OFFLINE_NODE, constants.RPC_TMO_URGENT, [], None,
613
     None, "Query node version"),
614
    ("node_verify_light", MULTI, None, constants.RPC_TMO_NORMAL, [
615
      ("checkdict", None, "What to verify"),
616
      ("cluster_name", None, "Cluster name"),
617
      ("hvparams", None, "Dictionary mapping hypervisor names to hvparams"),
618
      ], None, None, "Request verification of given parameters"),
619
    ]),
620
  "RpcClientConfig": _Prepare([
621
    ("upload_file", MULTI, None, constants.RPC_TMO_NORMAL, [
622
      ("file_name", ED_FILE_DETAILS, None),
623
      ], None, None, "Upload a file"),
624
    ("write_ssconf_files", MULTI, None, constants.RPC_TMO_NORMAL, [
625
      ("values", None, None),
626
      ], None, None, "Write ssconf files"),
627
    ]),
628
  }