Package ganeti :: Module rpc_defs
[hide private]
[frames] | no frames]

Source Code for Module ganeti.rpc_defs

  1  # 
  2  # 
  3   
  4  # Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2014 Google Inc. 
  5  # All rights reserved. 
  6  # 
  7  # Redistribution and use in source and binary forms, with or without 
  8  # modification, are permitted provided that the following conditions are 
  9  # met: 
 10  # 
 11  # 1. Redistributions of source code must retain the above copyright notice, 
 12  # this list of conditions and the following disclaimer. 
 13  # 
 14  # 2. Redistributions in binary form must reproduce the above copyright 
 15  # notice, this list of conditions and the following disclaimer in the 
 16  # documentation and/or other materials provided with the distribution. 
 17  # 
 18  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 
 19  # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 
 20  # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
 21  # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
 22  # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
 23  # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
 24  # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
 25  # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
 26  # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
 27  # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
 28  # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 29   
 30  """RPC definitions for communication between master and node daemons. 
 31   
 32  RPC definition fields: 
 33   
 34    - Name as string 
 35    - L{SINGLE} for single-node calls, L{MULTI} for multi-node 
 36    - Name resolver option(s), can be callable receiving all arguments in a tuple 
 37    - Timeout (e.g. L{constants.RPC_TMO_NORMAL}), or callback receiving all 
 38      arguments in a tuple to calculate timeout 
 39    - List of arguments as tuples 
 40   
 41      - Name as string 
 42      - Argument kind used for encoding/decoding 
 43      - Description for docstring (can be C{None}) 
 44   
 45    - Custom body encoder (e.g. for preparing per-node bodies) 
 46    - Return value wrapper (e.g. for deserializing into L{objects}-based objects) 
 47    - Short call description for docstring 
 48   
 49  """ 
 50   
 51  from ganeti import constants 
 52  from ganeti import utils 
 53  from ganeti import objects 
 54   
 55   
 56  # Guidelines for choosing timeouts: 
 57  # - call used during watcher: timeout of 1min, constants.RPC_TMO_URGENT 
 58  # - trivial (but be sure it is trivial) 
 59  #     (e.g. reading a file): 5min, constants.RPC_TMO_FAST 
 60  # - other calls: 15 min, constants.RPC_TMO_NORMAL 
 61  # - special calls (instance add, etc.): 
 62  #     either constants.RPC_TMO_SLOW (1h) or huge timeouts 
 63   
 64  SINGLE = "single-node" 
 65  MULTI = "multi-node" 
 66   
 67  ACCEPT_OFFLINE_NODE = object() 
 68   
 69  # Constants for encoding/decoding 
 70  (ED_OBJECT_DICT, 
 71   ED_OBJECT_DICT_LIST, 
 72   ED_INST_DICT, 
 73   ED_INST_DICT_HVP_BEP_DP, 
 74   ED_NODE_TO_DISK_DICT_DP, 
 75   ED_INST_DICT_OSP_DP, 
 76   ED_IMPEXP_IO, 
 77   ED_FILE_DETAILS, 
 78   ED_FINALIZE_EXPORT_DISKS, 
 79   ED_COMPRESS, 
 80   ED_BLOCKDEV_RENAME, 
 81   ED_DISKS_DICT_DP, 
 82   ED_MULTI_DISKS_DICT_DP, 
 83   ED_SINGLE_DISK_DICT_DP, 
 84   ED_NIC_DICT, 
 85   ED_DEVICE_DICT) = range(1, 17) 
 86   
 87   
88 -def _Prepare(calls):
89 """Converts list of calls to dictionary. 90 91 """ 92 return utils.SequenceToDict(calls)
93 94
95 -def _MigrationStatusPostProc(result):
96 """Post-processor for L{rpc.node.RpcRunner.call_instance_get_migration_status} 97 98 """ 99 if not result.fail_msg and result.payload is not None: 100 result.payload = objects.MigrationStatus.FromDict(result.payload) 101 return result
102 103
104 -def _BlockdevFindPostProc(result):
105 """Post-processor for L{rpc.node.RpcRunner.call_blockdev_find}. 106 107 """ 108 if not result.fail_msg and result.payload is not None: 109 result.payload = objects.BlockDevStatus.FromDict(result.payload) 110 return result
111 112
113 -def _BlockdevGetMirrorStatusPostProc(result):
114 """Post-processor for call_blockdev_getmirrorstatus. 115 116 """ 117 if not result.fail_msg: 118 result.payload = map(objects.BlockDevStatus.FromDict, result.payload) 119 return result
120 121
122 -def _BlockdevGetMirrorStatusMultiPreProc(node, args):
123 """Prepares the appropriate node values for blockdev_getmirrorstatus_multi. 124 125 """ 126 # there should be only one argument to this RPC, already holding a 127 # node->disks dictionary, we just need to extract the value for the 128 # current node 129 assert len(args) == 1 130 return [args[0][node]]
131 132
133 -def _BlockdevGetMirrorStatusMultiPostProc(result):
134 """Post-processor for call_blockdev_getmirrorstatus_multi. 135 136 """ 137 if not result.fail_msg: 138 for idx, (success, status) in enumerate(result.payload): 139 if success: 140 result.payload[idx] = (success, objects.BlockDevStatus.FromDict(status)) 141 142 return result
143 144
145 -def _NodeInfoPreProc(node, args):
146 """Prepare the storage_units argument for node_info calls.""" 147 assert len(args) == 2 148 # The storage_units argument is either a dictionary with one value for each 149 # node, or a fixed value to be used for all the nodes 150 if type(args[0]) is dict: 151 return [args[0][node], args[1]] 152 else: 153 return args
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, "Tuple: (target instance," 292 " temporary OS parameters" 293 " overriding configuration)"), 294 ("reinstall", None, "Whether the instance is being reinstalled"), 295 ("debug", None, "Debug level for the OS install script to use"), 296 ], None, None, "Installs an operative system onto an instance"), 297 ("hotplug_device", SINGLE, None, constants.RPC_TMO_NORMAL, [ 298 ("instance", ED_INST_DICT, "Instance object"), 299 ("action", None, "Hotplug Action"), 300 ("dev_type", None, "Device type"), 301 ("device", ED_DEVICE_DICT, "Device dict"), 302 ("extra", None, "Extra info for device (dev_path for disk)"), 303 ("seq", None, "Device seq"), 304 ], None, None, "Hoplug a device to a running instance"), 305 ("hotplug_supported", SINGLE, None, constants.RPC_TMO_NORMAL, [ 306 ("instance", ED_INST_DICT, "Instance object"), 307 ], None, None, "Check if hotplug is supported"), 308 ("instance_metadata_modify", SINGLE, None, constants.RPC_TMO_URGENT, [ 309 ("instance", None, "Instance object"), 310 ], None, None, "Modify instance metadata"), 311 ] 312 313 _IMPEXP_CALLS = [ 314 ("import_start", SINGLE, None, constants.RPC_TMO_NORMAL, [ 315 ("opts", ED_OBJECT_DICT, None), 316 ("instance", ED_INST_DICT, None), 317 ("component", None, None), 318 ("dest", ED_IMPEXP_IO, "Import destination"), 319 ], None, None, "Starts an import daemon"), 320 ("export_start", SINGLE, None, constants.RPC_TMO_NORMAL, [ 321 ("opts", ED_OBJECT_DICT, None), 322 ("host", None, None), 323 ("port", None, None), 324 ("instance", ED_INST_DICT, None), 325 ("component", None, None), 326 ("source", ED_IMPEXP_IO, "Export source"), 327 ], None, None, "Starts an export daemon"), 328 ("impexp_status", SINGLE, None, constants.RPC_TMO_FAST, [ 329 ("names", None, "Import/export names"), 330 ], None, _ImpExpStatusPostProc, "Gets the status of an import or export"), 331 ("impexp_abort", SINGLE, None, constants.RPC_TMO_NORMAL, [ 332 ("name", None, "Import/export name"), 333 ], None, None, "Aborts an import or export"), 334 ("impexp_cleanup", SINGLE, None, constants.RPC_TMO_NORMAL, [ 335 ("name", None, "Import/export name"), 336 ], None, None, "Cleans up after an import or export"), 337 ("export_info", SINGLE, None, constants.RPC_TMO_FAST, [ 338 ("path", None, None), 339 ], None, None, "Queries the export information in a given path"), 340 ("finalize_export", SINGLE, None, constants.RPC_TMO_NORMAL, [ 341 ("instance", ED_INST_DICT, None), 342 ("snap_disks", ED_FINALIZE_EXPORT_DISKS, None), 343 ], None, None, "Request the completion of an export operation"), 344 ("export_list", MULTI, None, constants.RPC_TMO_FAST, [], None, None, 345 "Gets the stored exports list"), 346 ("export_remove", SINGLE, None, constants.RPC_TMO_FAST, [ 347 ("export", None, None), 348 ], None, None, "Requests removal of a given export"), 349 ] 350 351 _X509_CALLS = [ 352 ("x509_cert_create", SINGLE, None, constants.RPC_TMO_NORMAL, [ 353 ("validity", None, "Validity in seconds"), 354 ], None, None, "Creates a new X509 certificate for SSL/TLS"), 355 ("x509_cert_remove", SINGLE, None, constants.RPC_TMO_NORMAL, [ 356 ("name", None, "Certificate name"), 357 ], None, None, "Removes a X509 certificate"), 358 ] 359 360 _BLOCKDEV_CALLS = [ 361 ("bdev_sizes", MULTI, None, constants.RPC_TMO_URGENT, [ 362 ("devices", None, None), 363 ], None, None, 364 "Gets the sizes of requested block devices present on a node"), 365 ("blockdev_create", SINGLE, None, constants.RPC_TMO_NORMAL, [ 366 ("bdev", ED_SINGLE_DISK_DICT_DP, None), 367 ("size", None, None), 368 ("owner", None, None), 369 ("on_primary", None, None), 370 ("info", None, None), 371 ("exclusive_storage", None, None), 372 ], None, None, "Request creation of a given block device"), 373 ("blockdev_convert", SINGLE, None, constants.RPC_TMO_SLOW, [ 374 ("bdev_src", ED_SINGLE_DISK_DICT_DP, None), 375 ("bdev_dest", ED_SINGLE_DISK_DICT_DP, None), 376 ], None, None, 377 "Request the copy of the source block device to the destination one"), 378 ("blockdev_image", SINGLE, None, constants.RPC_TMO_SLOW, [ 379 ("bdev", ED_SINGLE_DISK_DICT_DP, None), 380 ("image", None, None), 381 ("size", None, None), 382 ], None, None, 383 "Request to dump an image with given size onto a block device"), 384 ("blockdev_wipe", SINGLE, None, constants.RPC_TMO_SLOW, [ 385 ("bdev", ED_SINGLE_DISK_DICT_DP, None), 386 ("offset", None, None), 387 ("size", None, None), 388 ], None, None, 389 "Request wipe at given offset with given size of a block device"), 390 ("blockdev_remove", SINGLE, None, constants.RPC_TMO_NORMAL, [ 391 ("bdev", ED_SINGLE_DISK_DICT_DP, None), 392 ], None, None, "Request removal of a given block device"), 393 ("blockdev_pause_resume_sync", SINGLE, None, constants.RPC_TMO_NORMAL, [ 394 ("disks", ED_DISKS_DICT_DP, None), 395 ("pause", None, None), 396 ], None, None, "Request a pause/resume of given block device"), 397 ("blockdev_assemble", SINGLE, None, constants.RPC_TMO_NORMAL, [ 398 ("disk", ED_SINGLE_DISK_DICT_DP, None), 399 ("instance", ED_INST_DICT, None), 400 ("on_primary", None, None), 401 ("idx", None, None), 402 ], None, None, "Request assembling of a given block device"), 403 ("blockdev_shutdown", SINGLE, None, constants.RPC_TMO_NORMAL, [ 404 ("disk", ED_SINGLE_DISK_DICT_DP, None), 405 ], None, None, "Request shutdown of a given block device"), 406 ("blockdev_addchildren", SINGLE, None, constants.RPC_TMO_NORMAL, [ 407 ("bdev", ED_SINGLE_DISK_DICT_DP, None), 408 ("ndevs", ED_DISKS_DICT_DP, None), 409 ], None, None, 410 "Request adding a list of children to a (mirroring) device"), 411 ("blockdev_removechildren", SINGLE, None, constants.RPC_TMO_NORMAL, [ 412 ("bdev", ED_SINGLE_DISK_DICT_DP, None), 413 ("ndevs", ED_DISKS_DICT_DP, None), 414 ], None, None, 415 "Request removing a list of children from a (mirroring) device"), 416 ("blockdev_close", SINGLE, None, constants.RPC_TMO_NORMAL, [ 417 ("instance_name", None, None), 418 ("disks", ED_DISKS_DICT_DP, None), 419 ], None, None, "Closes the given block devices"), 420 ("blockdev_open", SINGLE, None, constants.RPC_TMO_NORMAL, [ 421 ("instance_name", None, None), 422 ("disks", ED_DISKS_DICT_DP, None), 423 ("exclusive", None, None), 424 ], None, None, "Opens the given block devices in required mode"), 425 ("blockdev_getdimensions", SINGLE, None, constants.RPC_TMO_NORMAL, [ 426 ("disks", ED_MULTI_DISKS_DICT_DP, None), 427 ], None, None, "Returns size and spindles of the given disks"), 428 ("drbd_disconnect_net", MULTI, None, constants.RPC_TMO_NORMAL, [ 429 ("disks", ED_DISKS_DICT_DP, None), 430 ], None, None, 431 "Disconnects the network of the given drbd devices"), 432 ("drbd_attach_net", MULTI, None, constants.RPC_TMO_NORMAL, [ 433 ("disks", ED_DISKS_DICT_DP, None), 434 ("multimaster", None, None), 435 ], None, None, "Connects the given DRBD devices"), 436 ("drbd_wait_sync", MULTI, None, constants.RPC_TMO_SLOW, [ 437 ("disks", ED_DISKS_DICT_DP, None), 438 ], None, None, 439 "Waits for the synchronization of drbd devices is complete"), 440 ("drbd_needs_activation", SINGLE, None, constants.RPC_TMO_NORMAL, [ 441 ("disks", ED_MULTI_DISKS_DICT_DP, None), 442 ], None, None, 443 "Returns the drbd disks which need activation"), 444 ("blockdev_grow", SINGLE, None, constants.RPC_TMO_NORMAL, [ 445 ("cf_bdev", ED_SINGLE_DISK_DICT_DP, None), 446 ("amount", None, None), 447 ("dryrun", None, None), 448 ("backingstore", None, None), 449 ("es_flag", None, None), 450 ], None, None, "Request growing of the given block device by a" 451 " given amount"), 452 ("blockdev_snapshot", SINGLE, None, constants.RPC_TMO_NORMAL, [ 453 ("cf_bdev", ED_SINGLE_DISK_DICT_DP, None), 454 ("snap_name", None, None), 455 ("snap_size", None, None), 456 ], None, None, "Export a given disk to another node"), 457 ("blockdev_rename", SINGLE, None, constants.RPC_TMO_NORMAL, [ 458 ("devlist", ED_BLOCKDEV_RENAME, None), 459 ], None, None, "Request rename of the given block devices"), 460 ("blockdev_find", SINGLE, None, constants.RPC_TMO_NORMAL, [ 461 ("disk", ED_SINGLE_DISK_DICT_DP, None), 462 ], None, _BlockdevFindPostProc, 463 "Request identification of a given block device"), 464 ("blockdev_getmirrorstatus", SINGLE, None, constants.RPC_TMO_NORMAL, [ 465 ("disks", ED_DISKS_DICT_DP, None), 466 ], None, _BlockdevGetMirrorStatusPostProc, 467 "Request status of a (mirroring) device"), 468 ("blockdev_getmirrorstatus_multi", MULTI, None, constants.RPC_TMO_NORMAL, [ 469 ("node_disks", ED_NODE_TO_DISK_DICT_DP, None), 470 ], _BlockdevGetMirrorStatusMultiPreProc, 471 _BlockdevGetMirrorStatusMultiPostProc, 472 "Request status of (mirroring) devices from multiple nodes"), 473 ("blockdev_setinfo", SINGLE, None, constants.RPC_TMO_NORMAL, [ 474 ("disk", ED_SINGLE_DISK_DICT_DP, None), 475 ("info", None, None), 476 ], None, None, "Sets metadata information on a given block device"), 477 ] 478 479 _OS_CALLS = [ 480 ("os_diagnose", MULTI, None, constants.RPC_TMO_FAST, [], None, None, 481 "Request a diagnose of OS definitions"), 482 ("os_validate", MULTI, None, constants.RPC_TMO_FAST, [ 483 ("required", None, None), 484 ("name", None, None), 485 ("checks", None, None), 486 ("params", None, None), 487 ("force_variant", None, None), 488 ], None, None, "Run a validation routine for a given OS"), 489 ("os_export", SINGLE, None, constants.RPC_TMO_FAST, [ 490 ("instance", ED_INST_DICT, None), 491 ("override_env", None, None), 492 ], None, None, "Export an OS for a given instance"), 493 ] 494 495 _EXTSTORAGE_CALLS = [ 496 ("extstorage_diagnose", MULTI, None, constants.RPC_TMO_FAST, [], None, None, 497 "Request a diagnose of ExtStorage Providers"), 498 ] 499 500 _NODE_CALLS = [ 501 ("node_has_ip_address", SINGLE, None, constants.RPC_TMO_FAST, [ 502 ("address", None, "IP address"), 503 ], None, None, "Checks if a node has the given IP address"), 504 ("node_info", MULTI, None, constants.RPC_TMO_URGENT, [ 505 ("storage_units", None, 506 "List of tuples '<storage_type>,<key>,[<param>]' to ask for disk space" 507 " information; the parameter list varies depending on the storage_type"), 508 ("hv_specs", None, 509 "List of hypervisor specification (name, hvparams) to ask for node " 510 "information"), 511 ], _NodeInfoPreProc, None, "Return node information"), 512 ("node_verify", MULTI, None, constants.RPC_TMO_NORMAL, [ 513 ("checkdict", None, "What to verify"), 514 ("cluster_name", None, "Cluster name"), 515 ("all_hvparams", None, "Dictionary mapping hypervisor names to hvparams"), 516 ], None, None, "Request verification of given parameters"), 517 ("node_volumes", MULTI, None, constants.RPC_TMO_FAST, [], None, None, 518 "Gets all volumes on node(s)"), 519 ("node_demote_from_mc", SINGLE, None, constants.RPC_TMO_FAST, [], None, None, 520 "Demote a node from the master candidate role"), 521 ("node_powercycle", SINGLE, ACCEPT_OFFLINE_NODE, constants.RPC_TMO_NORMAL, [ 522 ("hypervisor", None, "Hypervisor type"), 523 ("hvparams", None, "Hypervisor parameters"), 524 ], None, None, "Tries to powercycle a node"), 525 ("node_configure_ovs", SINGLE, None, constants.RPC_TMO_NORMAL, [ 526 ("ovs_name", None, "Name of the OpenvSwitch to create"), 527 ("ovs_link", None, "Link of the OpenvSwitch to the outside"), 528 ], None, None, "This will create and setup the OpenvSwitch"), 529 ("node_crypto_tokens", SINGLE, None, constants.RPC_TMO_SLOW, [ 530 ("token_request", None, 531 "List of tuples of requested crypto token types, actions"), 532 ], None, None, "Handle crypto tokens of the node."), 533 ("node_ensure_daemon", MULTI, None, constants.RPC_TMO_URGENT, [ 534 ("daemon", None, "Daemon name"), 535 ("run", None, "Whether the daemon should be running or stopped"), 536 ], None, None, "Ensure daemon is running on the node."), 537 ("node_ssh_key_add", MULTI, None, constants.RPC_TMO_FAST, [ 538 ("node_uuid", None, "UUID of the node whose key is distributed"), 539 ("node_name", None, "Name of the node whose key is distributed"), 540 ("potential_master_candidates", None, "Potential master candidates"), 541 ("to_authorized_keys", None, "Whether the node's key should be added" 542 " to all nodes' 'authorized_keys' file"), 543 ("to_public_keys", None, "Whether the node's key should be added" 544 " to all nodes' public key file"), 545 ("get_public_keys", None, "Whether the node should get the other nodes'" 546 " public keys")], 547 None, None, "Distribute a new node's public SSH key on the cluster."), 548 ("node_ssh_key_remove", MULTI, None, constants.RPC_TMO_FAST, [ 549 ("node_uuid", None, "UUID of the node whose key is removed"), 550 ("node_name", None, "Name of the node whose key is removed"), 551 ("master_candidate_uuids", None, "List of UUIDs of master candidates."), 552 ("potential_master_candidates", None, "Potential master candidates"), 553 ("from_authorized_keys", None, 554 "If the key should be removed from the 'authorized_keys' file."), 555 ("from_public_keys", None, 556 "If the key should be removed from the public key file."), 557 ("clear_authorized_keys", None, 558 "If the 'authorized_keys' file of the node should be cleared."), 559 ("clear_public_keys", None, 560 "If the 'ganeti_pub_keys' file of the node should be cleared."), 561 ("readd", None, 562 "Whether this is a readd operation.")], 563 None, None, "Remove a node's SSH key from the other nodes' key files."), 564 ("node_ssh_keys_renew", MULTI, None, constants.RPC_TMO_4HRS, [ 565 ("node_uuids", None, "UUIDs of the nodes whose key is renewed"), 566 ("node_names", None, "Names of the nodes whose key is renewed"), 567 ("master_candidate_uuids", None, "List of UUIDs of master candidates."), 568 ("potential_master_candidates", None, "Potential master candidates"), 569 ("old_key_type", None, "The type of key previously used"), 570 ("new_key_type", None, "The type of key to generate"), 571 ("new_key_bits", None, "The length of the key to generate")], 572 None, None, "Renew all SSH key pairs of all nodes nodes."), 573 ] 574 575 _MISC_CALLS = [ 576 ("lv_list", MULTI, None, constants.RPC_TMO_URGENT, [ 577 ("vg_name", None, None), 578 ], None, None, "Gets the logical volumes present in a given volume group"), 579 ("vg_list", MULTI, None, constants.RPC_TMO_URGENT, [], None, None, 580 "Gets the volume group list"), 581 ("bridges_exist", SINGLE, None, constants.RPC_TMO_URGENT, [ 582 ("bridges_list", None, "Bridges which must be present on remote node"), 583 ], None, None, "Checks if a node has all the bridges given"), 584 ("etc_hosts_modify", SINGLE, None, constants.RPC_TMO_NORMAL, [ 585 ("mode", None, 586 "Mode to operate; currently L{constants.ETC_HOSTS_ADD} or" 587 " L{constants.ETC_HOSTS_REMOVE}"), 588 ("name", None, "Hostname to be modified"), 589 ("ip", None, "IP address (L{constants.ETC_HOSTS_ADD} only)"), 590 ], None, None, "Modify hosts file with name"), 591 ("drbd_helper", MULTI, None, constants.RPC_TMO_URGENT, [], 592 None, None, "Gets DRBD helper"), 593 ("restricted_command", MULTI, None, constants.RPC_TMO_SLOW, [ 594 ("cmd", None, "Command name"), 595 ], None, None, "Runs restricted command"), 596 ("run_oob", SINGLE, None, constants.RPC_TMO_NORMAL, [ 597 ("oob_program", None, None), 598 ("command", None, None), 599 ("remote_node", None, None), 600 ("timeout", None, None), 601 ], None, None, "Runs out-of-band command"), 602 ("hooks_runner", MULTI, None, constants.RPC_TMO_NORMAL, [ 603 ("hpath", None, None), 604 ("phase", None, None), 605 ("env", None, None), 606 ], None, None, "Call the hooks runner"), 607 ("iallocator_runner", SINGLE, None, constants.RPC_TMO_NORMAL, [ 608 ("name", None, "Iallocator name"), 609 ("idata", None, "JSON-encoded input string"), 610 ("default_iallocator_params", None, "Additional iallocator parameters"), 611 ], None, None, "Call an iallocator on a remote node"), 612 ("test_delay", MULTI, None, _TestDelayTimeout, [ 613 ("duration", None, None), 614 ], None, None, "Sleep for a fixed time on given node(s)"), 615 ("hypervisor_validate_params", MULTI, None, constants.RPC_TMO_NORMAL, [ 616 ("hvname", None, "Hypervisor name"), 617 ("hvfull", None, "Parameters to be validated"), 618 ], None, None, "Validate hypervisor params"), 619 ("get_watcher_pause", SINGLE, None, constants.RPC_TMO_URGENT, [], 620 None, None, "Get watcher pause end"), 621 ("set_watcher_pause", MULTI, None, constants.RPC_TMO_URGENT, [ 622 ("until", None, None), 623 ], None, None, "Set watcher pause end"), 624 ("get_file_info", SINGLE, None, constants.RPC_TMO_FAST, [ 625 ("file_path", None, None), 626 ], None, None, "Checks if a file exists and reports on it"), 627 ] 628 629 CALLS = { 630 "RpcClientDefault": 631 _Prepare(_IMPEXP_CALLS + _X509_CALLS + _OS_CALLS + _NODE_CALLS + 632 _FILE_STORAGE_CALLS + _MISC_CALLS + _INSTANCE_CALLS + 633 _BLOCKDEV_CALLS + _STORAGE_CALLS + _EXTSTORAGE_CALLS), 634 "RpcClientJobQueue": _Prepare([ 635 ("jobqueue_update", MULTI, None, constants.RPC_TMO_URGENT, [ 636 ("file_name", None, None), 637 ("content", ED_COMPRESS, None), 638 ], None, None, "Update job queue file"), 639 ("jobqueue_purge", SINGLE, None, constants.RPC_TMO_NORMAL, [], None, None, 640 "Purge job queue"), 641 ("jobqueue_rename", MULTI, None, constants.RPC_TMO_URGENT, [ 642 ("rename", None, None), 643 ], None, None, "Rename job queue file"), 644 ("jobqueue_set_drain_flag", MULTI, None, constants.RPC_TMO_URGENT, [ 645 ("flag", None, None), 646 ], None, None, "Set job queue drain flag"), 647 ]), 648 "RpcClientBootstrap": _Prepare([ 649 ("node_start_master_daemons", SINGLE, None, constants.RPC_TMO_FAST, [ 650 ("no_voting", None, None), 651 ], None, None, "Starts master daemons on a node"), 652 ("node_activate_master_ip", SINGLE, None, constants.RPC_TMO_FAST, [ 653 ("master_params", ED_OBJECT_DICT, "Network parameters of the master"), 654 ("use_external_mip_script", None, 655 "Whether to use the user-provided master IP address setup script"), 656 ], None, None, 657 "Activates master IP on a node"), 658 ("node_stop_master", SINGLE, None, constants.RPC_TMO_FAST, [], None, None, 659 "Deactivates master IP and stops master daemons on a node"), 660 ("node_deactivate_master_ip", SINGLE, None, constants.RPC_TMO_FAST, [ 661 ("master_params", ED_OBJECT_DICT, "Network parameters of the master"), 662 ("use_external_mip_script", None, 663 "Whether to use the user-provided master IP address setup script"), 664 ], None, None, 665 "Deactivates master IP on a node"), 666 ("node_change_master_netmask", SINGLE, None, constants.RPC_TMO_FAST, [ 667 ("old_netmask", None, "The old value of the netmask"), 668 ("netmask", None, "The new value of the netmask"), 669 ("master_ip", None, "The master IP"), 670 ("master_netdev", None, "The master network device"), 671 ], None, None, "Change master IP netmask"), 672 ("node_leave_cluster", SINGLE, None, constants.RPC_TMO_NORMAL, [ 673 ("modify_ssh_setup", None, None), 674 ], None, None, 675 "Requests a node to clean the cluster information it has"), 676 ("master_node_name", MULTI, None, constants.RPC_TMO_URGENT, [], None, None, 677 "Returns the master node name"), 678 ]), 679 "RpcClientDnsOnly": _Prepare([ 680 ("version", MULTI, ACCEPT_OFFLINE_NODE, constants.RPC_TMO_URGENT, [], None, 681 None, "Query node version"), 682 ("node_verify_light", MULTI, None, constants.RPC_TMO_NORMAL, [ 683 ("checkdict", None, "What to verify"), 684 ("cluster_name", None, "Cluster name"), 685 ("hvparams", None, "Dictionary mapping hypervisor names to hvparams"), 686 ], None, None, "Request verification of given parameters"), 687 ]), 688 "RpcClientConfig": _Prepare([ 689 ("upload_file", MULTI, None, constants.RPC_TMO_NORMAL, [ 690 ("file_name", ED_FILE_DETAILS, None), 691 ], None, None, "Upload files"), 692 ("upload_file_single", MULTI, None, constants.RPC_TMO_NORMAL, [ 693 ("file_name", None, "The name of the file"), 694 ("content", ED_COMPRESS, "The data to be uploaded"), 695 ("mode", None, "The mode of the file or None"), 696 ("uid", None, "The owner of the file"), 697 ("gid", None, "The group of the file"), 698 ("atime", None, "The file's last access time"), 699 ("mtime", None, "The file's last modification time"), 700 ], None, None, "Upload files"), 701 ("write_ssconf_files", MULTI, None, constants.RPC_TMO_NORMAL, [ 702 ("values", None, None), 703 ], None, None, "Write ssconf files"), 704 ]), 705 } 706