Statistics
| Branch: | Tag: | Revision:

root / lib / rpc_defs.py @ 8ca22fef

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

    
145

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

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

    
154

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

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

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

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

    
172
    result.payload = decoded
173

    
174
  return result
175

    
176

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

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

    
183

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

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

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

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

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

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

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

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

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

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

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