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 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.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.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 L{rpc.RpcRunner.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 L{rpc.RpcRunner.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 _OsGetPostProc(result):
157 """Post-processor for L{rpc.RpcRunner.call_os_get}. 158 159 """ 160 if not result.fail_msg and isinstance(result.payload, dict): 161 result.payload = objects.OS.FromDict(result.payload) 162 return result
163 164
165 -def _ImpExpStatusPostProc(result):
166 """Post-processor for import/export status. 167 168 @rtype: Payload containing list of L{objects.ImportExportStatus} instances 169 @return: Returns a list of the state of each named import/export or None if 170 a status couldn't be retrieved 171 172 """ 173 if not result.fail_msg: 174 decoded = [] 175 176 for i in result.payload: 177 if i is None: 178 decoded.append(None) 179 continue 180 decoded.append(objects.ImportExportStatus.FromDict(i)) 181 182 result.payload = decoded 183 184 return result
185 186
187 -def _TestDelayTimeout((duration, )):
188 """Calculate timeout for "test_delay" RPC. 189 190 """ 191 return int(duration + 5)
192 193 194 _FILE_STORAGE_CALLS = [ 195 ("file_storage_dir_create", SINGLE, None, constants.RPC_TMO_FAST, [ 196 ("file_storage_dir", None, "File storage directory"), 197 ], None, None, "Create the given file storage directory"), 198 ("file_storage_dir_remove", SINGLE, None, constants.RPC_TMO_FAST, [ 199 ("file_storage_dir", None, "File storage directory"), 200 ], None, None, "Remove the given file storage directory"), 201 ("file_storage_dir_rename", SINGLE, None, constants.RPC_TMO_FAST, [ 202 ("old_file_storage_dir", None, "Old name"), 203 ("new_file_storage_dir", None, "New name"), 204 ], None, None, "Rename file storage directory"), 205 ] 206 207 _STORAGE_CALLS = [ 208 ("storage_list", MULTI, None, constants.RPC_TMO_NORMAL, [ 209 ("su_name", None, None), 210 ("su_args", None, None), 211 ("name", None, None), 212 ("fields", None, None), 213 ], None, None, "Get list of storage units"), 214 ("storage_modify", SINGLE, None, constants.RPC_TMO_NORMAL, [ 215 ("su_name", None, None), 216 ("su_args", None, None), 217 ("name", None, None), 218 ("changes", None, None), 219 ], None, None, "Modify a storage unit"), 220 ("storage_execute", SINGLE, None, constants.RPC_TMO_NORMAL, [ 221 ("su_name", None, None), 222 ("su_args", None, None), 223 ("name", None, None), 224 ("op", None, None), 225 ], None, None, "Executes an operation on a storage unit"), 226 ] 227 228 _INSTANCE_CALLS = [ 229 ("instance_info", SINGLE, None, constants.RPC_TMO_URGENT, [ 230 ("instance", None, "Instance name"), 231 ("hname", None, "Hypervisor type"), 232 ("hvparams", None, "Hypervisor parameters"), 233 ], None, None, "Returns information about a single instance"), 234 ("all_instances_info", MULTI, None, constants.RPC_TMO_URGENT, [ 235 ("hypervisor_list", None, "Hypervisors to query for instances"), 236 ("all_hvparams", None, "Dictionary mapping hypervisor names to hvparams"), 237 ], None, None, 238 "Returns information about all instances on the given nodes"), 239 ("instance_list", MULTI, None, constants.RPC_TMO_URGENT, [ 240 ("hypervisor_list", None, "Hypervisors to query for instances"), 241 ("hvparams", None, "Hvparams of all hypervisors"), 242 ], None, None, "Returns the list of running instances on the given nodes"), 243 ("instance_reboot", SINGLE, None, constants.RPC_TMO_NORMAL, [ 244 ("inst", ED_INST_DICT, "Instance object"), 245 ("reboot_type", None, None), 246 ("shutdown_timeout", None, None), 247 ("reason", None, "The reason for the reboot"), 248 ], None, None, "Returns the list of running instances on the given nodes"), 249 ("instance_shutdown", SINGLE, None, constants.RPC_TMO_NORMAL, [ 250 ("instance", ED_INST_DICT, "Instance object"), 251 ("timeout", None, None), 252 ("reason", None, "The reason for the shutdown"), 253 ], None, None, "Stops an instance"), 254 ("instance_balloon_memory", SINGLE, None, constants.RPC_TMO_NORMAL, [ 255 ("instance", ED_INST_DICT, "Instance object"), 256 ("memory", None, None), 257 ], None, None, "Modify the amount of an instance's runtime memory"), 258 ("instance_run_rename", SINGLE, None, constants.RPC_TMO_SLOW, [ 259 ("instance", ED_INST_DICT, "Instance object"), 260 ("old_name", None, None), 261 ("debug", None, None), 262 ], None, None, "Run the OS rename script for an instance"), 263 ("instance_migratable", SINGLE, None, constants.RPC_TMO_NORMAL, [ 264 ("instance", ED_INST_DICT, "Instance object"), 265 ], None, None, "Checks whether the given instance can be migrated"), 266 ("migration_info", SINGLE, None, constants.RPC_TMO_NORMAL, [ 267 ("instance", ED_INST_DICT, "Instance object"), 268 ], None, None, 269 "Gather the information necessary to prepare an instance migration"), 270 ("accept_instance", SINGLE, None, constants.RPC_TMO_NORMAL, [ 271 ("instance", ED_INST_DICT, "Instance object"), 272 ("info", None, "Result for the call_migration_info call"), 273 ("target", None, "Target hostname (usually an IP address)"), 274 ], None, None, "Prepare a node to accept an instance"), 275 ("instance_finalize_migration_dst", SINGLE, None, constants.RPC_TMO_NORMAL, [ 276 ("instance", ED_INST_DICT, "Instance object"), 277 ("info", None, "Result for the call_migration_info call"), 278 ("success", None, "Whether the migration was a success or failure"), 279 ], None, None, "Finalize any target-node migration specific operation"), 280 ("instance_migrate", SINGLE, None, constants.RPC_TMO_SLOW, [ 281 ("cluster_name", None, "Cluster name"), 282 ("instance", ED_INST_DICT, "Instance object"), 283 ("target", None, "Target node name"), 284 ("live", None, "Whether the migration should be done live or not"), 285 ], None, None, "Migrate an instance"), 286 ("instance_finalize_migration_src", SINGLE, None, constants.RPC_TMO_SLOW, [ 287 ("instance", ED_INST_DICT, "Instance object"), 288 ("success", None, "Whether the migration succeeded or not"), 289 ("live", None, "Whether the user requested a live migration or not"), 290 ], None, None, "Finalize the instance migration on the source node"), 291 ("instance_get_migration_status", SINGLE, None, constants.RPC_TMO_SLOW, [ 292 ("instance", ED_INST_DICT, "Instance object"), 293 ], None, _MigrationStatusPostProc, "Report migration status"), 294 ("instance_start", SINGLE, None, constants.RPC_TMO_NORMAL, [ 295 ("instance_hvp_bep", ED_INST_DICT_HVP_BEP_DP, None), 296 ("startup_paused", None, None), 297 ("reason", None, "The reason for the startup"), 298 ], None, None, "Starts an instance"), 299 ("instance_os_add", SINGLE, None, constants.RPC_TMO_1DAY, [ 300 ("instance_osp", ED_INST_DICT_OSP_DP, None), 301 ("reinstall", None, None), 302 ("debug", None, None), 303 ], None, None, "Starts an instance"), 304 ("hotplug_device", SINGLE, None, constants.RPC_TMO_NORMAL, [ 305 ("instance", ED_INST_DICT, "Instance object"), 306 ("action", None, "Hotplug Action"), 307 ("dev_type", None, "Device type"), 308 ("device", ED_DEVICE_DICT, "Device dict"), 309 ("extra", None, "Extra info for device (dev_path for disk)"), 310 ("seq", None, "Device seq"), 311 ], None, None, "Hoplug a device to a running instance"), 312 ("hotplug_supported", SINGLE, None, constants.RPC_TMO_NORMAL, [ 313 ("instance", ED_INST_DICT, "Instance object"), 314 ], None, None, "Check if hotplug is supported"), 315 ] 316 317 _IMPEXP_CALLS = [ 318 ("import_start", SINGLE, None, constants.RPC_TMO_NORMAL, [ 319 ("opts", ED_OBJECT_DICT, None), 320 ("instance", ED_INST_DICT, None), 321 ("component", None, None), 322 ("dest", ED_IMPEXP_IO, "Import destination"), 323 ], None, None, "Starts an import daemon"), 324 ("export_start", SINGLE, None, constants.RPC_TMO_NORMAL, [ 325 ("opts", ED_OBJECT_DICT, None), 326 ("host", None, None), 327 ("port", None, None), 328 ("instance", ED_INST_DICT, None), 329 ("component", None, None), 330 ("source", ED_IMPEXP_IO, "Export source"), 331 ], None, None, "Starts an export daemon"), 332 ("impexp_status", SINGLE, None, constants.RPC_TMO_FAST, [ 333 ("names", None, "Import/export names"), 334 ], None, _ImpExpStatusPostProc, "Gets the status of an import or export"), 335 ("impexp_abort", SINGLE, None, constants.RPC_TMO_NORMAL, [ 336 ("name", None, "Import/export name"), 337 ], None, None, "Aborts an import or export"), 338 ("impexp_cleanup", SINGLE, None, constants.RPC_TMO_NORMAL, [ 339 ("name", None, "Import/export name"), 340 ], None, None, "Cleans up after an import or export"), 341 ("export_info", SINGLE, None, constants.RPC_TMO_FAST, [ 342 ("path", None, None), 343 ], None, None, "Queries the export information in a given path"), 344 ("finalize_export", SINGLE, None, constants.RPC_TMO_NORMAL, [ 345 ("instance", ED_INST_DICT, None), 346 ("snap_disks", ED_FINALIZE_EXPORT_DISKS, None), 347 ], None, None, "Request the completion of an export operation"), 348 ("export_list", MULTI, None, constants.RPC_TMO_FAST, [], None, None, 349 "Gets the stored exports list"), 350 ("export_remove", SINGLE, None, constants.RPC_TMO_FAST, [ 351 ("export", None, None), 352 ], None, None, "Requests removal of a given export"), 353 ] 354 355 _X509_CALLS = [ 356 ("x509_cert_create", SINGLE, None, constants.RPC_TMO_NORMAL, [ 357 ("validity", None, "Validity in seconds"), 358 ], None, None, "Creates a new X509 certificate for SSL/TLS"), 359 ("x509_cert_remove", SINGLE, None, constants.RPC_TMO_NORMAL, [ 360 ("name", None, "Certificate name"), 361 ], None, None, "Removes a X509 certificate"), 362 ] 363 364 _BLOCKDEV_CALLS = [ 365 ("bdev_sizes", MULTI, None, constants.RPC_TMO_URGENT, [ 366 ("devices", None, None), 367 ], None, None, 368 "Gets the sizes of requested block devices present on a node"), 369 ("blockdev_create", SINGLE, None, constants.RPC_TMO_NORMAL, [ 370 ("bdev", ED_SINGLE_DISK_DICT_DP, None), 371 ("size", None, None), 372 ("owner", None, None), 373 ("on_primary", None, None), 374 ("info", None, None), 375 ("exclusive_storage", None, None), 376 ], None, None, "Request creation of a given block device"), 377 ("blockdev_wipe", SINGLE, None, constants.RPC_TMO_SLOW, [ 378 ("bdev", ED_SINGLE_DISK_DICT_DP, None), 379 ("offset", None, None), 380 ("size", None, None), 381 ], None, None, 382 "Request wipe at given offset with given size of a block device"), 383 ("blockdev_remove", SINGLE, None, constants.RPC_TMO_NORMAL, [ 384 ("bdev", ED_SINGLE_DISK_DICT_DP, None), 385 ], None, None, "Request removal of a given block device"), 386 ("blockdev_pause_resume_sync", SINGLE, None, constants.RPC_TMO_NORMAL, [ 387 ("disks", ED_DISKS_DICT_DP, None), 388 ("pause", None, None), 389 ], None, None, "Request a pause/resume of given block device"), 390 ("blockdev_assemble", SINGLE, None, constants.RPC_TMO_NORMAL, [ 391 ("disk", ED_SINGLE_DISK_DICT_DP, None), 392 ("instance", ED_INST_DICT, None), 393 ("on_primary", None, None), 394 ("idx", None, None), 395 ], None, None, "Request assembling of a given block device"), 396 ("blockdev_shutdown", SINGLE, None, constants.RPC_TMO_NORMAL, [ 397 ("disk", ED_SINGLE_DISK_DICT_DP, None), 398 ], None, None, "Request shutdown of a given block device"), 399 ("blockdev_addchildren", SINGLE, None, constants.RPC_TMO_NORMAL, [ 400 ("bdev", ED_SINGLE_DISK_DICT_DP, None), 401 ("ndevs", ED_DISKS_DICT_DP, None), 402 ], None, None, 403 "Request adding a list of children to a (mirroring) device"), 404 ("blockdev_removechildren", SINGLE, None, constants.RPC_TMO_NORMAL, [ 405 ("bdev", ED_SINGLE_DISK_DICT_DP, None), 406 ("ndevs", ED_DISKS_DICT_DP, None), 407 ], None, None, 408 "Request removing a list of children from a (mirroring) device"), 409 ("blockdev_close", SINGLE, None, constants.RPC_TMO_NORMAL, [ 410 ("instance_name", None, None), 411 ("disks", ED_DISKS_DICT_DP, None), 412 ], None, None, "Closes the given block devices"), 413 ("blockdev_getdimensions", SINGLE, None, constants.RPC_TMO_NORMAL, [ 414 ("disks", ED_MULTI_DISKS_DICT_DP, None), 415 ], None, None, "Returns size and spindles of the given disks"), 416 ("drbd_disconnect_net", MULTI, None, constants.RPC_TMO_NORMAL, [ 417 ("disks", ED_DISKS_DICT_DP, None), 418 ], None, None, 419 "Disconnects the network of the given drbd devices"), 420 ("drbd_attach_net", MULTI, None, constants.RPC_TMO_NORMAL, [ 421 ("disks", ED_DISKS_DICT_DP, None), 422 ("instance_name", None, None), 423 ("multimaster", None, None), 424 ], None, None, "Connects the given DRBD devices"), 425 ("drbd_wait_sync", MULTI, None, constants.RPC_TMO_SLOW, [ 426 ("disks", ED_DISKS_DICT_DP, None), 427 ], None, None, 428 "Waits for the synchronization of drbd devices is complete"), 429 ("drbd_needs_activation", SINGLE, None, constants.RPC_TMO_NORMAL, [ 430 ("disks", ED_MULTI_DISKS_DICT_DP, None), 431 ], None, None, 432 "Returns the drbd disks which need activation"), 433 ("blockdev_grow", SINGLE, None, constants.RPC_TMO_NORMAL, [ 434 ("cf_bdev", ED_SINGLE_DISK_DICT_DP, None), 435 ("amount", None, None), 436 ("dryrun", None, None), 437 ("backingstore", None, None), 438 ("es_flag", None, None), 439 ], None, None, "Request growing of the given block device by a" 440 " given amount"), 441 ("blockdev_export", SINGLE, None, constants.RPC_TMO_1DAY, [ 442 ("cf_bdev", ED_SINGLE_DISK_DICT_DP, None), 443 ("dest_node_ip", None, None), 444 ("dest_path", None, None), 445 ("cluster_name", None, None), 446 ], None, None, "Export a given disk to another node"), 447 ("blockdev_snapshot", SINGLE, None, constants.RPC_TMO_NORMAL, [ 448 ("cf_bdev", ED_SINGLE_DISK_DICT_DP, None), 449 ], None, None, "Export a given disk to another node"), 450 ("blockdev_rename", SINGLE, None, constants.RPC_TMO_NORMAL, [ 451 ("devlist", ED_BLOCKDEV_RENAME, None), 452 ], None, None, "Request rename of the given block devices"), 453 ("blockdev_find", SINGLE, None, constants.RPC_TMO_NORMAL, [ 454 ("disk", ED_SINGLE_DISK_DICT_DP, None), 455 ], None, _BlockdevFindPostProc, 456 "Request identification of a given block device"), 457 ("blockdev_getmirrorstatus", SINGLE, None, constants.RPC_TMO_NORMAL, [ 458 ("disks", ED_DISKS_DICT_DP, None), 459 ], None, _BlockdevGetMirrorStatusPostProc, 460 "Request status of a (mirroring) device"), 461 ("blockdev_getmirrorstatus_multi", MULTI, None, constants.RPC_TMO_NORMAL, [ 462 ("node_disks", ED_NODE_TO_DISK_DICT_DP, None), 463 ], _BlockdevGetMirrorStatusMultiPreProc, 464 _BlockdevGetMirrorStatusMultiPostProc, 465 "Request status of (mirroring) devices from multiple nodes"), 466 ("blockdev_setinfo", SINGLE, None, constants.RPC_TMO_NORMAL, [ 467 ("disk", ED_SINGLE_DISK_DICT_DP, None), 468 ("info", None, None), 469 ], None, None, "Sets metadata information on a given block device"), 470 ] 471 472 _OS_CALLS = [ 473 ("os_diagnose", MULTI, None, constants.RPC_TMO_FAST, [], None, None, 474 "Request a diagnose of OS definitions"), 475 ("os_validate", MULTI, None, constants.RPC_TMO_FAST, [ 476 ("required", None, None), 477 ("name", None, None), 478 ("checks", None, None), 479 ("params", None, None), 480 ], None, None, "Run a validation routine for a given OS"), 481 ("os_get", SINGLE, None, constants.RPC_TMO_FAST, [ 482 ("name", None, None), 483 ], None, _OsGetPostProc, "Returns an OS definition"), 484 ] 485 486 _EXTSTORAGE_CALLS = [ 487 ("extstorage_diagnose", MULTI, None, constants.RPC_TMO_FAST, [], None, None, 488 "Request a diagnose of ExtStorage Providers"), 489 ] 490 491 _NODE_CALLS = [ 492 ("node_has_ip_address", SINGLE, None, constants.RPC_TMO_FAST, [ 493 ("address", None, "IP address"), 494 ], None, None, "Checks if a node has the given IP address"), 495 ("node_info", MULTI, None, constants.RPC_TMO_URGENT, [ 496 ("storage_units", None, 497 "List of tuples '<storage_type>,<key>,[<param>]' to ask for disk space" 498 " information; the parameter list varies depending on the storage_type"), 499 ("hv_specs", None, 500 "List of hypervisor specification (name, hvparams) to ask for node " 501 "information"), 502 ], _NodeInfoPreProc, None, "Return node information"), 503 ("node_verify", MULTI, None, constants.RPC_TMO_NORMAL, [ 504 ("checkdict", None, "What to verify"), 505 ("cluster_name", None, "Cluster name"), 506 ("all_hvparams", None, "Dictionary mapping hypervisor names to hvparams"), 507 ], None, None, "Request verification of given parameters"), 508 ("node_volumes", MULTI, None, constants.RPC_TMO_FAST, [], None, None, 509 "Gets all volumes on node(s)"), 510 ("node_demote_from_mc", SINGLE, None, constants.RPC_TMO_FAST, [], None, None, 511 "Demote a node from the master candidate role"), 512 ("node_powercycle", SINGLE, ACCEPT_OFFLINE_NODE, constants.RPC_TMO_NORMAL, [ 513 ("hypervisor", None, "Hypervisor type"), 514 ("hvparams", None, "Hypervisor parameters"), 515 ], None, None, "Tries to powercycle a node"), 516 ("node_configure_ovs", SINGLE, None, constants.RPC_TMO_NORMAL, [ 517 ("ovs_name", None, "Name of the OpenvSwitch to create"), 518 ("ovs_link", None, "Link of the OpenvSwitch to the outside"), 519 ], None, None, "This will create and setup the OpenvSwitch"), 520 ] 521 522 _MISC_CALLS = [ 523 ("lv_list", MULTI, None, constants.RPC_TMO_URGENT, [ 524 ("vg_name", None, None), 525 ], None, None, "Gets the logical volumes present in a given volume group"), 526 ("vg_list", MULTI, None, constants.RPC_TMO_URGENT, [], None, None, 527 "Gets the volume group list"), 528 ("bridges_exist", SINGLE, None, constants.RPC_TMO_URGENT, [ 529 ("bridges_list", None, "Bridges which must be present on remote node"), 530 ], None, None, "Checks if a node has all the bridges given"), 531 ("etc_hosts_modify", SINGLE, None, constants.RPC_TMO_NORMAL, [ 532 ("mode", None, 533 "Mode to operate; currently L{constants.ETC_HOSTS_ADD} or" 534 " L{constants.ETC_HOSTS_REMOVE}"), 535 ("name", None, "Hostname to be modified"), 536 ("ip", None, "IP address (L{constants.ETC_HOSTS_ADD} only)"), 537 ], None, None, "Modify hosts file with name"), 538 ("drbd_helper", MULTI, None, constants.RPC_TMO_URGENT, [], 539 None, None, "Gets DRBD helper"), 540 ("restricted_command", MULTI, None, constants.RPC_TMO_SLOW, [ 541 ("cmd", None, "Command name"), 542 ], None, None, "Runs restricted command"), 543 ("run_oob", SINGLE, None, constants.RPC_TMO_NORMAL, [ 544 ("oob_program", None, None), 545 ("command", None, None), 546 ("remote_node", None, None), 547 ("timeout", None, None), 548 ], None, None, "Runs out-of-band command"), 549 ("hooks_runner", MULTI, None, constants.RPC_TMO_NORMAL, [ 550 ("hpath", None, None), 551 ("phase", None, None), 552 ("env", None, None), 553 ], None, None, "Call the hooks runner"), 554 ("iallocator_runner", SINGLE, None, constants.RPC_TMO_NORMAL, [ 555 ("name", None, "Iallocator name"), 556 ("idata", None, "JSON-encoded input string"), 557 ], None, None, "Call an iallocator on a remote node"), 558 ("test_delay", MULTI, None, _TestDelayTimeout, [ 559 ("duration", None, None), 560 ], None, None, "Sleep for a fixed time on given node(s)"), 561 ("hypervisor_validate_params", MULTI, None, constants.RPC_TMO_NORMAL, [ 562 ("hvname", None, "Hypervisor name"), 563 ("hvfull", None, "Parameters to be validated"), 564 ], None, None, "Validate hypervisor params"), 565 ("get_watcher_pause", SINGLE, None, constants.RPC_TMO_URGENT, [], 566 None, None, "Get watcher pause end"), 567 ("set_watcher_pause", MULTI, None, constants.RPC_TMO_URGENT, [ 568 ("until", None, None), 569 ], None, None, "Set watcher pause end"), 570 ] 571 572 CALLS = { 573 "RpcClientDefault": 574 _Prepare(_IMPEXP_CALLS + _X509_CALLS + _OS_CALLS + _NODE_CALLS + 575 _FILE_STORAGE_CALLS + _MISC_CALLS + _INSTANCE_CALLS + 576 _BLOCKDEV_CALLS + _STORAGE_CALLS + _EXTSTORAGE_CALLS), 577 "RpcClientJobQueue": _Prepare([ 578 ("jobqueue_update", MULTI, None, constants.RPC_TMO_URGENT, [ 579 ("file_name", None, None), 580 ("content", ED_COMPRESS, None), 581 ], None, None, "Update job queue file"), 582 ("jobqueue_purge", SINGLE, None, constants.RPC_TMO_NORMAL, [], None, None, 583 "Purge job queue"), 584 ("jobqueue_rename", MULTI, None, constants.RPC_TMO_URGENT, [ 585 ("rename", None, None), 586 ], None, None, "Rename job queue file"), 587 ("jobqueue_set_drain_flag", MULTI, None, constants.RPC_TMO_URGENT, [ 588 ("flag", None, None), 589 ], None, None, "Set job queue drain flag"), 590 ]), 591 "RpcClientBootstrap": _Prepare([ 592 ("node_start_master_daemons", SINGLE, None, constants.RPC_TMO_FAST, [ 593 ("no_voting", None, None), 594 ], None, None, "Starts master daemons on a node"), 595 ("node_activate_master_ip", SINGLE, None, constants.RPC_TMO_FAST, [ 596 ("master_params", ED_OBJECT_DICT, "Network parameters of the master"), 597 ("use_external_mip_script", None, 598 "Whether to use the user-provided master IP address setup script"), 599 ], None, None, 600 "Activates master IP on a node"), 601 ("node_stop_master", SINGLE, None, constants.RPC_TMO_FAST, [], None, None, 602 "Deactivates master IP and stops master daemons on a node"), 603 ("node_deactivate_master_ip", SINGLE, None, constants.RPC_TMO_FAST, [ 604 ("master_params", ED_OBJECT_DICT, "Network parameters of the master"), 605 ("use_external_mip_script", None, 606 "Whether to use the user-provided master IP address setup script"), 607 ], None, None, 608 "Deactivates master IP on a node"), 609 ("node_change_master_netmask", SINGLE, None, constants.RPC_TMO_FAST, [ 610 ("old_netmask", None, "The old value of the netmask"), 611 ("netmask", None, "The new value of the netmask"), 612 ("master_ip", None, "The master IP"), 613 ("master_netdev", None, "The master network device"), 614 ], None, None, "Change master IP netmask"), 615 ("node_leave_cluster", SINGLE, None, constants.RPC_TMO_NORMAL, [ 616 ("modify_ssh_setup", None, None), 617 ], None, None, 618 "Requests a node to clean the cluster information it has"), 619 ("master_info", MULTI, None, constants.RPC_TMO_URGENT, [], None, None, 620 "Query master info"), 621 ]), 622 "RpcClientDnsOnly": _Prepare([ 623 ("version", MULTI, ACCEPT_OFFLINE_NODE, constants.RPC_TMO_URGENT, [], None, 624 None, "Query node version"), 625 ("node_verify_light", MULTI, None, constants.RPC_TMO_NORMAL, [ 626 ("checkdict", None, "What to verify"), 627 ("cluster_name", None, "Cluster name"), 628 ("hvparams", None, "Dictionary mapping hypervisor names to hvparams"), 629 ], None, None, "Request verification of given parameters"), 630 ]), 631 "RpcClientConfig": _Prepare([ 632 ("upload_file", MULTI, None, constants.RPC_TMO_NORMAL, [ 633 ("file_name", ED_FILE_DETAILS, None), 634 ], None, None, "Upload a file"), 635 ("write_ssconf_files", MULTI, None, constants.RPC_TMO_NORMAL, [ 636 ("values", None, None), 637 ], None, None, "Write ssconf files"), 638 ]), 639 } 640