Statistics
| Branch: | Tag: | Revision:

root / lib / rpc_defs.py @ da803ff1

History | View | Annotate | Download (24.9 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 storage_units argument for node_info calls."""
136
  assert len(args) == 2
137
  # The storage_units argument is either a dictionary with one value for each
138
  # node, or a fixed value to be used for all the nodes
139
  if type(args[0]) is dict:
140
    return [args[0][node], args[1]]
141
  else:
142
    return args
143

    
144

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

    
149

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

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

    
158

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

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

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

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

    
176
    result.payload = decoded
177

    
178
  return result
179

    
180

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

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

    
187

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

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

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

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

    
338
_X509_CALLS = [
339
  ("x509_cert_create", SINGLE, None, constants.RPC_TMO_NORMAL, [
340
    ("validity", None, "Validity in seconds"),
341
    ], None, None, "Creates a new X509 certificate for SSL/TLS"),
342
  ("x509_cert_remove", SINGLE, None, constants.RPC_TMO_NORMAL, [
343
    ("name", None, "Certificate name"),
344
    ], None, None, "Removes a X509 certificate"),
345
  ]
346

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

    
454
_OS_CALLS = [
455
  ("os_diagnose", MULTI, None, constants.RPC_TMO_FAST, [], None, None,
456
   "Request a diagnose of OS definitions"),
457
  ("os_validate", MULTI, None, constants.RPC_TMO_FAST, [
458
    ("required", None, None),
459
    ("name", None, None),
460
    ("checks", None, None),
461
    ("params", None, None),
462
    ], None, None, "Run a validation routine for a given OS"),
463
  ("os_get", SINGLE, None, constants.RPC_TMO_FAST, [
464
    ("name", None, None),
465
    ], None, _OsGetPostProc, "Returns an OS definition"),
466
  ]
467

    
468
_EXTSTORAGE_CALLS = [
469
  ("extstorage_diagnose", MULTI, None, constants.RPC_TMO_FAST, [], None, None,
470
   "Request a diagnose of ExtStorage Providers"),
471
  ]
472

    
473
_NODE_CALLS = [
474
  ("node_has_ip_address", SINGLE, None, constants.RPC_TMO_FAST, [
475
    ("address", None, "IP address"),
476
    ], None, None, "Checks if a node has the given IP address"),
477
  ("node_info", MULTI, None, constants.RPC_TMO_URGENT, [
478
    ("storage_units", None,
479
     "List of tuples '<storage_type>,<key>,[<param>]' to ask for disk space"
480
     " information; the parameter list varies depending on the storage_type"),
481
    ("hv_specs", None,
482
     "List of hypervisor specification (name, hvparams) to ask for node "
483
     "information"),
484
    ], _NodeInfoPreProc, None, "Return node information"),
485
  ("node_verify", MULTI, None, constants.RPC_TMO_NORMAL, [
486
    ("checkdict", None, "What to verify"),
487
    ("cluster_name", None, "Cluster name"),
488
    ("all_hvparams", None, "Dictionary mapping hypervisor names to hvparams"),
489
    ], None, None, "Request verification of given parameters"),
490
  ("node_volumes", MULTI, None, constants.RPC_TMO_FAST, [], None, None,
491
   "Gets all volumes on node(s)"),
492
  ("node_demote_from_mc", SINGLE, None, constants.RPC_TMO_FAST, [], None, None,
493
   "Demote a node from the master candidate role"),
494
  ("node_powercycle", SINGLE, ACCEPT_OFFLINE_NODE, constants.RPC_TMO_NORMAL, [
495
    ("hypervisor", None, "Hypervisor type"),
496
    ("hvparams", None, "Hypervisor parameters"),
497
    ], None, None, "Tries to powercycle a node"),
498
  ]
499

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

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