Statistics
| Branch: | Tag: | Revision:

root / lib / rpc_defs.py @ 030ab01a

History | View | Annotate | Download (24.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_SINGLE_DISK_DICT_DP,
74
 ED_NIC_DICT) = range(1, 15)
75

    
76

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

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

    
83

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

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

    
92

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

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

    
101

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

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

    
110

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

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

    
121

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

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

    
131
  return result
132

    
133

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

    
144

    
145
def _OsGetPostProc(result):
146
  """Post-processor for L{rpc.RpcRunner.call_os_get}.
147

148
  """
149
  if not result.fail_msg and isinstance(result.payload, dict):
150
    result.payload = objects.OS.FromDict(result.payload)
151
  return result
152

    
153

    
154
def _ImpExpStatusPostProc(result):
155
  """Post-processor for import/export status.
156

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

161
  """
162
  if not result.fail_msg:
163
    decoded = []
164

    
165
    for i in result.payload:
166
      if i is None:
167
        decoded.append(None)
168
        continue
169
      decoded.append(objects.ImportExportStatus.FromDict(i))
170

    
171
    result.payload = decoded
172

    
173
  return result
174

    
175

    
176
def _TestDelayTimeout((duration, )):
177
  """Calculate timeout for "test_delay" RPC.
178

179
  """
180
  return int(duration + 5)
181

    
182

    
183
_FILE_STORAGE_CALLS = [
184
  ("file_storage_dir_create", SINGLE, None, constants.RPC_TMO_FAST, [
185
    ("file_storage_dir", None, "File storage directory"),
186
    ], None, None, "Create the given file storage directory"),
187
  ("file_storage_dir_remove", SINGLE, None, constants.RPC_TMO_FAST, [
188
    ("file_storage_dir", None, "File storage directory"),
189
    ], None, None, "Remove the given file storage directory"),
190
  ("file_storage_dir_rename", SINGLE, None, constants.RPC_TMO_FAST, [
191
    ("old_file_storage_dir", None, "Old name"),
192
    ("new_file_storage_dir", None, "New name"),
193
    ], None, None, "Rename file storage directory"),
194
  ]
195

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

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

    
292
_IMPEXP_CALLS = [
293
  ("import_start", SINGLE, None, constants.RPC_TMO_NORMAL, [
294
    ("opts", ED_OBJECT_DICT, None),
295
    ("instance", ED_INST_DICT, None),
296
    ("component", None, None),
297
    ("dest", ED_IMPEXP_IO, "Import destination"),
298
    ], None, None, "Starts an import daemon"),
299
  ("export_start", SINGLE, None, constants.RPC_TMO_NORMAL, [
300
    ("opts", ED_OBJECT_DICT, None),
301
    ("host", None, None),
302
    ("port", None, None),
303
    ("instance", ED_INST_DICT, None),
304
    ("component", None, None),
305
    ("source", ED_IMPEXP_IO, "Export source"),
306
    ], None, None, "Starts an export daemon"),
307
  ("impexp_status", SINGLE, None, constants.RPC_TMO_FAST, [
308
    ("names", None, "Import/export names"),
309
    ], None, _ImpExpStatusPostProc, "Gets the status of an import or export"),
310
  ("impexp_abort", SINGLE, None, constants.RPC_TMO_NORMAL, [
311
    ("name", None, "Import/export name"),
312
    ], None, None, "Aborts an import or export"),
313
  ("impexp_cleanup", SINGLE, None, constants.RPC_TMO_NORMAL, [
314
    ("name", None, "Import/export name"),
315
    ], None, None, "Cleans up after an import or export"),
316
  ("export_info", SINGLE, None, constants.RPC_TMO_FAST, [
317
    ("path", None, None),
318
    ], None, None, "Queries the export information in a given path"),
319
  ("finalize_export", SINGLE, None, constants.RPC_TMO_NORMAL, [
320
    ("instance", ED_INST_DICT, None),
321
    ("snap_disks", ED_FINALIZE_EXPORT_DISKS, None),
322
    ], None, None, "Request the completion of an export operation"),
323
  ("export_list", MULTI, None, constants.RPC_TMO_FAST, [], None, None,
324
   "Gets the stored exports list"),
325
  ("export_remove", SINGLE, None, constants.RPC_TMO_FAST, [
326
    ("export", None, None),
327
    ], None, None, "Requests removal of a given export"),
328
  ]
329

    
330
_X509_CALLS = [
331
  ("x509_cert_create", SINGLE, None, constants.RPC_TMO_NORMAL, [
332
    ("validity", None, "Validity in seconds"),
333
    ], None, None, "Creates a new X509 certificate for SSL/TLS"),
334
  ("x509_cert_remove", SINGLE, None, constants.RPC_TMO_NORMAL, [
335
    ("name", None, "Certificate name"),
336
    ], None, None, "Removes a X509 certificate"),
337
  ]
338

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

    
444
_OS_CALLS = [
445
  ("os_diagnose", MULTI, None, constants.RPC_TMO_FAST, [], None, None,
446
   "Request a diagnose of OS definitions"),
447
  ("os_validate", MULTI, None, constants.RPC_TMO_FAST, [
448
    ("required", None, None),
449
    ("name", None, None),
450
    ("checks", None, None),
451
    ("params", None, None),
452
    ], None, None, "Run a validation routine for a given OS"),
453
  ("os_get", SINGLE, None, constants.RPC_TMO_FAST, [
454
    ("name", None, None),
455
    ], None, _OsGetPostProc, "Returns an OS definition"),
456
  ]
457

    
458
_EXTSTORAGE_CALLS = [
459
  ("extstorage_diagnose", MULTI, None, constants.RPC_TMO_FAST, [], None, None,
460
   "Request a diagnose of ExtStorage Providers"),
461
  ]
462

    
463
_NODE_CALLS = [
464
  ("node_has_ip_address", SINGLE, None, constants.RPC_TMO_FAST, [
465
    ("address", None, "IP address"),
466
    ], None, None, "Checks if a node has the given IP address"),
467
  ("node_info", MULTI, None, constants.RPC_TMO_URGENT, [
468
    ("storage_units", None,
469
     "List of tuples '<storage_type>,<key>' to ask for disk space"
470
     " information"),
471
    ("hv_specs", None,
472
     "List of hypervisor specification (name, hvparams) to ask for node "
473
     "information"),
474
    ("exclusive_storage", None,
475
     "Whether exclusive storage is enabled"),
476
    ], _NodeInfoPreProc, None, "Return node information"),
477
  ("node_verify", MULTI, None, constants.RPC_TMO_NORMAL, [
478
    ("checkdict", None, "What to verify"),
479
    ("cluster_name", None, "Cluster name"),
480
    ("all_hvparams", None, "Dictionary mapping hypervisor names to hvparams"),
481
    ], None, None, "Request verification of given parameters"),
482
  ("node_volumes", MULTI, None, constants.RPC_TMO_FAST, [], None, None,
483
   "Gets all volumes on node(s)"),
484
  ("node_demote_from_mc", SINGLE, None, constants.RPC_TMO_FAST, [], None, None,
485
   "Demote a node from the master candidate role"),
486
  ("node_powercycle", SINGLE, ACCEPT_OFFLINE_NODE, constants.RPC_TMO_NORMAL, [
487
    ("hypervisor", None, "Hypervisor type"),
488
    ], None, None, "Tries to powercycle a node"),
489
  ]
490

    
491
_MISC_CALLS = [
492
  ("lv_list", MULTI, None, constants.RPC_TMO_URGENT, [
493
    ("vg_name", None, None),
494
    ], None, None, "Gets the logical volumes present in a given volume group"),
495
  ("vg_list", MULTI, None, constants.RPC_TMO_URGENT, [], None, None,
496
   "Gets the volume group list"),
497
  ("bridges_exist", SINGLE, None, constants.RPC_TMO_URGENT, [
498
    ("bridges_list", None, "Bridges which must be present on remote node"),
499
    ], None, None, "Checks if a node has all the bridges given"),
500
  ("etc_hosts_modify", SINGLE, None, constants.RPC_TMO_NORMAL, [
501
    ("mode", None,
502
     "Mode to operate; currently L{constants.ETC_HOSTS_ADD} or"
503
     " L{constants.ETC_HOSTS_REMOVE}"),
504
    ("name", None, "Hostname to be modified"),
505
    ("ip", None, "IP address (L{constants.ETC_HOSTS_ADD} only)"),
506
    ], None, None, "Modify hosts file with name"),
507
  ("drbd_helper", MULTI, None, constants.RPC_TMO_URGENT, [],
508
   None, None, "Gets DRBD helper"),
509
  ("restricted_command", MULTI, None, constants.RPC_TMO_SLOW, [
510
    ("cmd", None, "Command name"),
511
    ], None, None, "Runs restricted command"),
512
  ("run_oob", SINGLE, None, constants.RPC_TMO_NORMAL, [
513
    ("oob_program", None, None),
514
    ("command", None, None),
515
    ("remote_node", None, None),
516
    ("timeout", None, None),
517
    ], None, None, "Runs out-of-band command"),
518
  ("hooks_runner", MULTI, None, constants.RPC_TMO_NORMAL, [
519
    ("hpath", None, None),
520
    ("phase", None, None),
521
    ("env", None, None),
522
    ], None, None, "Call the hooks runner"),
523
  ("iallocator_runner", SINGLE, None, constants.RPC_TMO_NORMAL, [
524
    ("name", None, "Iallocator name"),
525
    ("idata", None, "JSON-encoded input string"),
526
    ], None, None, "Call an iallocator on a remote node"),
527
  ("test_delay", MULTI, None, _TestDelayTimeout, [
528
    ("duration", None, None),
529
    ], None, None, "Sleep for a fixed time on given node(s)"),
530
  ("hypervisor_validate_params", MULTI, None, constants.RPC_TMO_NORMAL, [
531
    ("hvname", None, "Hypervisor name"),
532
    ("hvfull", None, "Parameters to be validated"),
533
    ], None, None, "Validate hypervisor params"),
534
  ("get_watcher_pause", SINGLE, None, constants.RPC_TMO_URGENT, [],
535
    None, None, "Get watcher pause end"),
536
  ("set_watcher_pause", MULTI, None, constants.RPC_TMO_URGENT, [
537
    ("until", None, None),
538
    ], None, None, "Set watcher pause end"),
539
  ]
540

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