Statistics
| Branch: | Tag: | Revision:

root / lib / rpc_defs.py @ c5708931

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_DP,
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 _OsGetPostProc(result):
148
  """Post-processor for L{rpc.RpcRunner.call_os_get}.
149

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

    
155

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

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

163
  """
164
  if not result.fail_msg:
165
    decoded = []
166

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

    
173
    result.payload = decoded
174

    
175
  return result
176

    
177

    
178
def _TestDelayTimeout((duration, )):
179
  """Calculate timeout for "test_delay" RPC.
180

181
  """
182
  return int(duration + 5)
183

    
184

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

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

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

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

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

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

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

    
474
_EXTSTORAGE_CALLS = [
475
  ("extstorage_diagnose", MULTI, None, constants.RPC_TMO_FAST, [], None, None,
476
   "Request a diagnose of ExtStorage Providers"),
477
  ]
478

    
479
_NODE_CALLS = [
480
  ("node_has_ip_address", SINGLE, None, constants.RPC_TMO_FAST, [
481
    ("address", None, "IP address"),
482
    ], None, None, "Checks if a node has the given IP address"),
483
  ("node_info", MULTI, None, constants.RPC_TMO_URGENT, [
484
    ("storage_units", None,
485
     "List of tuples '<storage_type>,<key>,[<param>]' to ask for disk space"
486
     " information; the parameter list varies depending on the storage_type"),
487
    ("hv_specs", None,
488
     "List of hypervisor specification (name, hvparams) to ask for node "
489
     "information"),
490
    ], _NodeInfoPreProc, None, "Return node information"),
491
  ("node_verify", MULTI, None, constants.RPC_TMO_NORMAL, [
492
    ("checkdict", None, "What to verify"),
493
    ("cluster_name", None, "Cluster name"),
494
    ("all_hvparams", None, "Dictionary mapping hypervisor names to hvparams"),
495
    ], None, None, "Request verification of given parameters"),
496
  ("node_volumes", MULTI, None, constants.RPC_TMO_FAST, [], None, None,
497
   "Gets all volumes on node(s)"),
498
  ("node_demote_from_mc", SINGLE, None, constants.RPC_TMO_FAST, [], None, None,
499
   "Demote a node from the master candidate role"),
500
  ("node_powercycle", SINGLE, ACCEPT_OFFLINE_NODE, constants.RPC_TMO_NORMAL, [
501
    ("hypervisor", None, "Hypervisor type"),
502
    ("hvparams", None, "Hypervisor parameters"),
503
    ], None, None, "Tries to powercycle a node"),
504
  ("node_configure_ovs", SINGLE, None, constants.RPC_TMO_NORMAL, [
505
    ("ovs_name", None, "Name of the OpenvSwitch to create"),
506
    ("ovs_link", None, "Link of the OpenvSwitch to the outside"),
507
    ], None, None, "This will create and setup the OpenvSwitch"),
508
  ]
509

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

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