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

Source Code for Module ganeti.opcodes

   1  # 
   2  # 
   3   
   4  # Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 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   
  31  """OpCodes module 
  32   
  33  Note that this file is autogenerated using @src/hs2py@ with a header 
  34  from @lib/opcodes.py.in_before@ and a footer from @lib/opcodes.py.in_after@. 
  35   
  36  This module implements part of the data structures which define the 
  37  cluster operations - the so-called opcodes. 
  38   
  39  Every operation which modifies the cluster state is expressed via 
  40  opcodes. 
  41   
  42  """ 
  43   
  44  # this are practically structures, so disable the message about too 
  45  # few public methods: 
  46  # pylint: disable=R0903 
  47  # pylint: disable=C0301 
  48   
  49  from ganeti import constants 
  50  from ganeti import ht 
  51   
  52  from ganeti import opcodes_base 
53 54 55 -class OpCode(opcodes_base.BaseOpCode):
56 """Abstract OpCode. 57 58 This is the root of the actual OpCode hierarchy. All clases derived 59 from this class should override OP_ID. 60 61 @cvar OP_ID: The ID of this opcode. This should be unique amongst all 62 children of this class. 63 @cvar OP_DSC_FIELD: The name of a field whose value will be included in the 64 string returned by Summary(); see the docstring of that 65 method for details). 66 @cvar OP_DSC_FORMATTER: A callable that should format the OP_DSC_FIELD; if 67 not present, then the field will be simply converted 68 to string 69 @cvar OP_PARAMS: List of opcode attributes, the default values they should 70 get if not already defined, and types they must match. 71 @cvar OP_RESULT: Callable to verify opcode result 72 @cvar WITH_LU: Boolean that specifies whether this should be included in 73 mcpu's dispatch table 74 @ivar dry_run: Whether the LU should be run in dry-run mode, i.e. just 75 the check steps 76 @ivar priority: Opcode priority for queue 77 78 """ 79 # pylint: disable=E1101 80 # as OP_ID is dynamically defined 81 WITH_LU = True 82 OP_PARAMS = [ 83 ("dry_run", None, ht.TMaybe(ht.TBool), "Run checks only, don't execute"), 84 ("debug_level", None, ht.TMaybe(ht.TNonNegative(ht.TInt)), "Debug level"), 85 ("priority", constants.OP_PRIO_DEFAULT, 86 ht.TElemOf(constants.OP_PRIO_SUBMIT_VALID), "Opcode priority"), 87 (opcodes_base.DEPEND_ATTR, None, opcodes_base.BuildJobDepCheck(True), 88 "Job dependencies; if used through ``SubmitManyJobs`` relative (negative)" 89 " job IDs can be used; see :doc:`design document <design-chained-jobs>`" 90 " for details"), 91 (opcodes_base.COMMENT_ATTR, None, ht.TMaybe(ht.TString), 92 "Comment describing the purpose of the opcode"), 93 (constants.OPCODE_REASON, [], ht.TMaybe(ht.TListOf(ht.TAny)), 94 "The reason trail, describing why the OpCode is executed"), 95 ] 96 OP_RESULT = None 97
98 - def __getstate__(self):
99 """Specialized getstate for opcodes. 100 101 This method adds to the state dictionary the OP_ID of the class, 102 so that on unload we can identify the correct class for 103 instantiating the opcode. 104 105 @rtype: C{dict} 106 @return: the state as a dictionary 107 108 """ 109 data = opcodes_base.BaseOpCode.__getstate__(self) 110 data["OP_ID"] = self.OP_ID 111 return data
112 113 @classmethod
114 - def LoadOpCode(cls, data):
115 """Generic load opcode method. 116 117 The method identifies the correct opcode class from the dict-form 118 by looking for a OP_ID key, if this is not found, or its value is 119 not available in this module as a child of this class, we fail. 120 121 @type data: C{dict} 122 @param data: the serialized opcode 123 124 """ 125 if not isinstance(data, dict): 126 raise ValueError("Invalid data to LoadOpCode (%s)" % type(data)) 127 if "OP_ID" not in data: 128 raise ValueError("Invalid data to LoadOpcode, missing OP_ID") 129 op_id = data["OP_ID"] 130 op_class = None 131 if op_id in OP_MAPPING: 132 op_class = OP_MAPPING[op_id] 133 else: 134 raise ValueError("Invalid data to LoadOpCode: OP_ID %s unsupported" % 135 op_id) 136 op = op_class() 137 new_data = data.copy() 138 del new_data["OP_ID"] 139 op.__setstate__(new_data) 140 return op
141
142 - def Summary(self):
143 """Generates a summary description of this opcode. 144 145 The summary is the value of the OP_ID attribute (without the "OP_" 146 prefix), plus the value of the OP_DSC_FIELD attribute, if one was 147 defined; this field should allow to easily identify the operation 148 (for an instance creation job, e.g., it would be the instance 149 name). 150 151 """ 152 assert self.OP_ID is not None and len(self.OP_ID) > 3 153 # all OP_ID start with OP_, we remove that 154 txt = self.OP_ID[3:] 155 field_name = getattr(self, "OP_DSC_FIELD", None) 156 if field_name: 157 field_value = getattr(self, field_name, None) 158 field_formatter = getattr(self, "OP_DSC_FORMATTER", None) 159 if callable(field_formatter): 160 field_value = field_formatter(field_value) 161 elif isinstance(field_value, (list, tuple)): 162 field_value = ",".join(str(i) for i in field_value) 163 txt = "%s(%s)" % (txt, field_value) 164 return txt
165
166 - def TinySummary(self):
167 """Generates a compact summary description of the opcode. 168 169 """ 170 assert self.OP_ID.startswith("OP_") 171 172 text = self.OP_ID[3:] 173 174 for (prefix, supplement) in opcodes_base.SUMMARY_PREFIX.items(): 175 if text.startswith(prefix): 176 return supplement + text[len(prefix):] 177 178 return text
179
180 181 -class OpInstanceMultiAllocBase(OpCode):
182 """Allocates multiple instances. 183 184 """
185 - def __getstate__(self):
186 """Generic serializer. 187 188 """ 189 state = OpCode.__getstate__(self) 190 if hasattr(self, "instances"): 191 # pylint: disable=E1101 192 state["instances"] = [inst.__getstate__() for inst in self.instances] 193 return state
194
195 - def __setstate__(self, state):
196 """Generic unserializer. 197 198 This method just restores from the serialized state the attributes 199 of the current instance. 200 201 @param state: the serialized opcode data 202 @type state: C{dict} 203 204 """ 205 if not isinstance(state, dict): 206 raise ValueError("Invalid data to __setstate__: expected dict, got %s" % 207 type(state)) 208 209 if "instances" in state: 210 state["instances"] = map(OpCode.LoadOpCode, state["instances"]) 211 212 return OpCode.__setstate__(self, state)
213
214 - def Validate(self, set_defaults):
215 """Validates this opcode. 216 217 We do this recursively. 218 219 @type set_defaults: bool 220 @param set_defaults: whether to set default values 221 222 @rtype: NoneType 223 @return: L{None}, if the validation succeeds 224 225 @raise errors.OpPrereqError: when a parameter value doesn't match 226 requirements 227 228 """ 229 OpCode.Validate(self, set_defaults) 230 231 for inst in self.instances: # pylint: disable=E1101 232 inst.Validate(set_defaults)
233 -class OpClusterPostInit(OpCode):
234 """Post cluster initialization. 235 236 This opcode does not touch the cluster at all. Its purpose is to run hooks 237 after the cluster has been initialized. 238 239 """ 240 OP_PARAMS = [ 241 ] 242 OP_RESULT = ht.TBool
243
244 -class OpClusterDestroy(OpCode):
245 """Destroy the cluster. 246 247 This opcode has no other parameters. All the state is irreversibly 248 lost after the execution of this opcode. 249 250 """ 251 OP_PARAMS = [ 252 ] 253 OP_RESULT = ht.TNonEmptyString
254
255 -class OpClusterQuery(OpCode):
256 """Query cluster information.""" 257 OP_PARAMS = [ 258 ] 259 OP_RESULT = ht.TObject(ht.TAny)
260
261 -class OpClusterVerify(OpCode):
262 """Submits all jobs necessary to verify the cluster.""" 263 OP_PARAMS = [ 264 ("debug_simulate_errors", False, ht.TBool, "Whether to simulate errors (useful for debugging)"), 265 ("error_codes", False, ht.TBool, "Error codes"), 266 ("skip_checks", [], ht.TSetOf(ht.TVerifyOptionalChecks), "Which checks to skip"), 267 ("ignore_errors", [], ht.TSetOf(ht.TCVErrorCode), "List of error codes that should be treated as warnings"), 268 ("verbose", False, ht.TBool, "Verbose mode"), 269 ("group_name", None, ht.TMaybe(ht.TNonEmptyString), "Optional group name") 270 ] 271 OP_RESULT = ht.TJobIdListOnly
272
273 -class OpClusterVerifyConfig(OpCode):
274 """Verify the cluster config.""" 275 OP_PARAMS = [ 276 ("debug_simulate_errors", False, ht.TBool, "Whether to simulate errors (useful for debugging)"), 277 ("error_codes", False, ht.TBool, "Error codes"), 278 ("ignore_errors", [], ht.TSetOf(ht.TCVErrorCode), "List of error codes that should be treated as warnings"), 279 ("verbose", False, ht.TBool, "Verbose mode") 280 ] 281 OP_RESULT = ht.TBool
282
283 -class OpClusterVerifyGroup(OpCode):
284 """Run verify on a node group from the cluster. 285 286 @type skip_checks: C{list} 287 @ivar skip_checks: steps to be skipped from the verify process; this 288 needs to be a subset of 289 L{constants.VERIFY_OPTIONAL_CHECKS}; currently 290 only L{constants.VERIFY_NPLUSONE_MEM} can be passed 291 292 """ 293 OP_DSC_FIELD = "group_name" 294 OP_PARAMS = [ 295 ("group_name", None, ht.TNonEmptyString, "Group name"), 296 ("debug_simulate_errors", False, ht.TBool, "Whether to simulate errors (useful for debugging)"), 297 ("error_codes", False, ht.TBool, "Error codes"), 298 ("skip_checks", [], ht.TSetOf(ht.TVerifyOptionalChecks), "Which checks to skip"), 299 ("ignore_errors", [], ht.TSetOf(ht.TCVErrorCode), "List of error codes that should be treated as warnings"), 300 ("verbose", False, ht.TBool, "Verbose mode") 301 ] 302 OP_RESULT = ht.TBool
303
304 -class OpClusterVerifyDisks(OpCode):
305 """Verify the cluster disks.""" 306 OP_PARAMS = [ 307 ] 308 OP_RESULT = ht.TJobIdListOnly
309
310 -class OpGroupVerifyDisks(OpCode):
311 """Verifies the status of all disks in a node group. 312 313 Result: a tuple of three elements: 314 - dict of node names with issues (values: error msg) 315 - list of instances with degraded disks (that should be activated) 316 - dict of instances with missing logical volumes (values: (node, vol) 317 pairs with details about the missing volumes) 318 319 In normal operation, all lists should be empty. A non-empty instance 320 list (3rd element of the result) is still ok (errors were fixed) but 321 non-empty node list means some node is down, and probably there are 322 unfixable drbd errors. 323 324 Note that only instances that are drbd-based are taken into 325 consideration. This might need to be revisited in the future. 326 327 """ 328 OP_DSC_FIELD = "group_name" 329 OP_PARAMS = [ 330 ("group_name", None, ht.TNonEmptyString, "Group name") 331 ] 332 OP_RESULT = ht.TTupleOf(ht.TDictOf(ht.TString, ht.TString), ht.TListOf(ht.TString), ht.TDictOf(ht.TString, ht.TListOf(ht.TListOf(ht.TString))))
333
334 -class OpClusterRepairDiskSizes(OpCode):
335 """Verify the disk sizes of the instances and fixes configuration 336 mismatches. 337 338 Parameters: optional instances list, in case we want to restrict the 339 checks to only a subset of the instances. 340 341 Result: a list of tuples, (instance, disk, parameter, new-size) for 342 changed configurations. 343 344 In normal operation, the list should be empty. 345 346 @type instances: list 347 @ivar instances: the list of instances to check, or empty for all instances 348 349 """ 350 OP_PARAMS = [ 351 ("instances", [], ht.TListOf(ht.TNonEmptyString), "List of instances") 352 ] 353 OP_RESULT = ht.TListOf(ht.TTupleOf(ht.TNonEmptyString, ht.TNonNegative(ht.TInt), ht.TNonEmptyString, ht.TNonNegative(ht.TInt)))
354
355 -class OpClusterConfigQuery(OpCode):
356 """Query cluster configuration values.""" 357 OP_PARAMS = [ 358 ("output_fields", None, ht.TListOf(ht.TNonEmptyString), "Selected output fields") 359 ] 360 OP_RESULT = ht.TListOf(ht.TAny)
361
362 -class OpClusterRename(OpCode):
363 """Rename the cluster. 364 365 @type name: C{str} 366 @ivar name: The new name of the cluster. The name and/or the master IP 367 address will be changed to match the new name and its IP 368 address. 369 370 """ 371 OP_DSC_FIELD = "name" 372 OP_PARAMS = [ 373 ("name", None, ht.TNonEmptyString, "A generic name") 374 ] 375 OP_RESULT = ht.TNonEmptyString
376
377 -class OpClusterSetParams(OpCode):
378 """Change the parameters of the cluster. 379 380 @type vg_name: C{str} or C{None} 381 @ivar vg_name: The new volume group name or None to disable LVM usage. 382 383 """ 384 OP_PARAMS = [ 385 ("force", False, ht.TBool, "Whether to force the operation"), 386 ("hv_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set hypervisor states"), 387 ("disk_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set disk states"), 388 ("vg_name", None, ht.TMaybe(ht.TString), "Volume group name"), 389 ("enabled_hypervisors", None, ht.TMaybe(ht.TListOf(ht.THypervisor)), "List of enabled hypervisors"), 390 ("hvparams", None, ht.TMaybe(ht.TDictOf(ht.TString, ht.TObject(ht.TAny))), "Cluster-wide hypervisor parameters, hypervisor-dependent"), 391 ("beparams", None, ht.TMaybe(ht.TObject(ht.TAny)), "Cluster-wide backend parameter defaults"), 392 ("os_hvp", None, ht.TMaybe(ht.TDictOf(ht.TString, ht.TObject(ht.TAny))), "Cluster-wide per-OS hypervisor parameter defaults"), 393 ("osparams", None, ht.TMaybe(ht.TDictOf(ht.TString, ht.TObject(ht.TAny))), "Cluster-wide OS parameter defaults"), 394 ("osparams_private_cluster", None, ht.TMaybe(ht.TDictOf(ht.TString, ht.TObject(ht.TPrivate(ht.TAny)))), "Cluster-wide private OS parameter defaults"), 395 ("diskparams", None, ht.TMaybe(ht.TDictOf(ht.TDiskTemplate, ht.TObject(ht.TAny))), "Disk templates' parameter defaults"), 396 ("candidate_pool_size", None, ht.TMaybe(ht.TPositive(ht.TInt)), "Master candidate pool size"), 397 ("max_running_jobs", None, ht.TMaybe(ht.TPositive(ht.TInt)), "Maximal number of jobs to run simultaneously"), 398 ("max_tracked_jobs", None, ht.TMaybe(ht.TPositive(ht.TInt)), "Maximal number of jobs tracked in the job queue"), 399 ("uid_pool", None, ht.TMaybe(ht.TListOf(ht.TTupleOf(ht.TInt, ht.TInt))), "Set UID pool, must be list of lists describing UID ranges (two items, start and end inclusive)"), 400 ("add_uids", None, ht.TMaybe(ht.TListOf(ht.TTupleOf(ht.TInt, ht.TInt))), "Extend UID pool, must be list of lists describing UID ranges (two items, start and end inclusive)"), 401 ("remove_uids", None, ht.TMaybe(ht.TListOf(ht.TTupleOf(ht.TInt, ht.TInt))), "Shrink UID pool, must be list of lists describing UID ranges (two items, start and end inclusive) to be removed"), 402 ("maintain_node_health", None, ht.TMaybe(ht.TBool), "Whether to automatically maintain node health"), 403 ("prealloc_wipe_disks", None, ht.TMaybe(ht.TBool), "Whether to wipe disks before allocating them to instances"), 404 ("nicparams", None, ht.TMaybe(ht.TINicParams), "Cluster-wide NIC parameter defaults"), 405 ("ndparams", None, ht.TMaybe(ht.TObject(ht.TAny)), "Cluster-wide node parameter defaults"), 406 ("ipolicy", None, ht.TMaybe(ht.TObject(ht.TAny)), "Cluster-wide ipolicy specs"), 407 ("drbd_helper", None, ht.TMaybe(ht.TString), "DRBD helper program"), 408 ("default_iallocator", None, ht.TMaybe(ht.TString), "Default iallocator for cluster"), 409 ("default_iallocator_params", None, ht.TMaybe(ht.TObject(ht.TAny)), "Default iallocator parameters for cluster"), 410 ("mac_prefix", None, ht.TMaybe(ht.TNonEmptyString), "Network specific mac prefix (that overrides the cluster one)"), 411 ("master_netdev", None, ht.TMaybe(ht.TString), "Master network device"), 412 ("master_netmask", None, ht.TMaybe(ht.TNonNegative(ht.TInt)), "Netmask of the master IP"), 413 ("reserved_lvs", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "List of reserved LVs"), 414 ("hidden_os", None, ht.TMaybe(ht.TListOf(ht.TTupleOf(ht.TDdmSimple, ht.TNonEmptyString))), "Modify list of hidden operating systems: each modification must have two items, the operation and the OS name; the operation can be add or remove"), 415 ("blacklisted_os", None, ht.TMaybe(ht.TListOf(ht.TTupleOf(ht.TDdmSimple, ht.TNonEmptyString))), "Modify list of blacklisted operating systems: each modification must have two items, the operation and the OS name; the operation can be add or remove"), 416 ("use_external_mip_script", None, ht.TMaybe(ht.TBool), "Whether to use an external master IP address setup script"), 417 ("enabled_disk_templates", None, ht.TMaybe(ht.TListOf(ht.TDiskTemplate)), "List of enabled disk templates"), 418 ("modify_etc_hosts", None, ht.TMaybe(ht.TBool), ""), 419 ("file_storage_dir", None, ht.TMaybe(ht.TString), ""), 420 ("shared_file_storage_dir", None, ht.TMaybe(ht.TString), ""), 421 ("gluster_storage_dir", None, ht.TMaybe(ht.TString), ""), 422 ("install_image", None, ht.TMaybe(ht.TString), "OS image for running OS scripts in a safe environment"), 423 ("instance_communication_network", None, ht.TMaybe(ht.TString), ""), 424 ("zeroing_image", None, ht.TMaybe(ht.TString), ""), 425 ("compression_tools", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "List of enabled compression tools"), 426 ("enabled_user_shutdown", None, ht.TMaybe(ht.TBool), "Whether user shutdown is enabled cluster wide") 427 ] 428 OP_RESULT = ht.TOr(ht.TNone, ht.TJobIdListOnly)
429
430 -class OpClusterRedistConf(OpCode):
431 """Force a full push of the cluster configuration.""" 432 OP_PARAMS = [ 433 ] 434 OP_RESULT = ht.TNone
435
436 -class OpClusterActivateMasterIp(OpCode):
437 """Activate the master IP on the master node.""" 438 OP_PARAMS = [ 439 ] 440 OP_RESULT = ht.TNone
441
442 -class OpClusterDeactivateMasterIp(OpCode):
443 """Deactivate the master IP on the master node.""" 444 OP_PARAMS = [ 445 ] 446 OP_RESULT = ht.TNone
447
448 -class OpClusterRenewCrypto(OpCode):
449 """Renews the cluster node's SSL client certificates.""" 450 OP_PARAMS = [ 451 ("verbose", False, ht.TBool, "Verbose mode"), 452 ("debug", False, ht.TBool, "Debug mode") 453 ] 454 OP_RESULT = ht.TNone
455
456 -class OpQuery(OpCode):
457 """Query for resources/items. 458 459 @ivar what: Resources to query for, must be one of L{constants.QR_VIA_OP} 460 @ivar fields: List of fields to retrieve 461 @ivar qfilter: Query filter 462 463 """ 464 OP_DSC_FIELD = "what" 465 OP_PARAMS = [ 466 ("what", None, ht.TQueryTypeOp, "Resource(s) to query for"), 467 ("use_locking", False, ht.TBool, "Whether to use synchronization"), 468 ("fields", None, ht.TListOf(ht.TNonEmptyString), "Requested fields"), 469 ("qfilter", None, ht.TMaybe(ht.TListOf(ht.TAny)), "Query filter") 470 ] 471 OP_RESULT = ht.TQueryResponse
472
473 -class OpQueryFields(OpCode):
474 """Query for available resource/item fields. 475 476 @ivar what: Resources to query for, must be one of L{constants.QR_VIA_OP} 477 @ivar fields: List of fields to retrieve 478 479 """ 480 OP_DSC_FIELD = "what" 481 OP_PARAMS = [ 482 ("what", None, ht.TQueryTypeOp, "Resource(s) to query for"), 483 ("fields", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "Requested fields; if not given, all are returned") 484 ] 485 OP_RESULT = ht.TQueryFieldsResponse
486
487 -class OpOobCommand(OpCode):
488 """Interact with OOB.""" 489 OP_PARAMS = [ 490 ("node_names", [], ht.TListOf(ht.TNonEmptyString), "List of node names to run the OOB command against"), 491 ("node_uuids", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "List of node UUIDs to run the OOB command against"), 492 ("command", None, ht.TOobCommand, "OOB command to run"), 493 ("timeout", 60, ht.TInt, "Timeout before the OOB helper will be terminated"), 494 ("ignore_status", False, ht.TBool, "Ignores the node offline status for power off"), 495 ("power_delay", 2.0, ht.TDouble, "Time in seconds to wait between powering on nodes") 496 ] 497 OP_RESULT = ht.TListOf(ht.TListOf(ht.TTupleOf(ht.TQueryResultCode, ht.TAny)))
498
499 -class OpRestrictedCommand(OpCode):
500 """Runs a restricted command on node(s).""" 501 OP_PARAMS = [ 502 ("use_locking", False, ht.TBool, "Whether to use synchronization"), 503 ("nodes", None, ht.TListOf(ht.TNonEmptyString), "Nodes on which the command should be run (at least one)"), 504 ("node_uuids", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "Node UUIDs on which the command should be run (at least one)"), 505 ("command", None, ht.TNonEmptyString, "Restricted command name") 506 ] 507 OP_RESULT = ht.TListOf(ht.TTupleOf(ht.TBool, ht.TString))
508
509 -class OpNodeRemove(OpCode):
510 """Remove a node. 511 512 @type node_name: C{str} 513 @ivar node_name: The name of the node to remove. If the node still has 514 instances on it, the operation will fail. 515 516 """ 517 OP_DSC_FIELD = "node_name" 518 OP_PARAMS = [ 519 ("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"), 520 ("node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "A node UUID (for single-node LUs)") 521 ] 522 OP_RESULT = ht.TNone
523
524 -class OpNodeAdd(OpCode):
525 """Add a node to the cluster. 526 527 @type node_name: C{str} 528 @ivar node_name: The name of the node to add. This can be a short name, 529 but it will be expanded to the FQDN. 530 @type primary_ip: IP address 531 @ivar primary_ip: The primary IP of the node. This will be ignored when 532 the opcode is submitted, but will be filled during the 533 node add (so it will be visible in the job query). 534 @type secondary_ip: IP address 535 @ivar secondary_ip: The secondary IP of the node. This needs to be passed 536 if the cluster has been initialized in 'dual-network' 537 mode, otherwise it must not be given. 538 @type readd: C{bool} 539 @ivar readd: Whether to re-add an existing node to the cluster. If 540 this is not passed, then the operation will abort if the node 541 name is already in the cluster; use this parameter to 542 'repair' a node that had its configuration broken, or was 543 reinstalled without removal from the cluster. 544 @type group: C{str} 545 @ivar group: The node group to which this node will belong. 546 @type vm_capable: C{bool} 547 @ivar vm_capable: The vm_capable node attribute 548 @type master_capable: C{bool} 549 @ivar master_capable: The master_capable node attribute 550 551 """ 552 OP_DSC_FIELD = "node_name" 553 OP_PARAMS = [ 554 ("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"), 555 ("hv_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set hypervisor states"), 556 ("disk_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set disk states"), 557 ("primary_ip", None, ht.TMaybe(ht.TNonEmptyString), "Primary IP address"), 558 ("secondary_ip", None, ht.TMaybe(ht.TNonEmptyString), "Secondary IP address"), 559 ("readd", False, ht.TBool, "Whether node is re-added to cluster"), 560 ("group", None, ht.TMaybe(ht.TNonEmptyString), "Initial node group"), 561 ("master_capable", None, ht.TMaybe(ht.TBool), "Whether node can become master or master candidate"), 562 ("vm_capable", None, ht.TMaybe(ht.TBool), "Whether node can host instances"), 563 ("ndparams", None, ht.TMaybe(ht.TObject(ht.TAny)), "Node parameters") 564 ] 565 OP_RESULT = ht.TNone
566
567 -class OpNodeQueryvols(OpCode):
568 """Get list of volumes on node.""" 569 OP_PARAMS = [ 570 ("output_fields", None, ht.TListOf(ht.TNonEmptyString), "Selected output fields"), 571 ("nodes", [], ht.TListOf(ht.TNonEmptyString), "Empty list to query all nodes, node names otherwise") 572 ] 573 OP_RESULT = ht.TListOf(ht.TAny)
574
575 -class OpNodeQueryStorage(OpCode):
576 """Get information on storage for node(s).""" 577 OP_PARAMS = [ 578 ("output_fields", None, ht.TListOf(ht.TNonEmptyString), "Selected output fields"), 579 ("storage_type", None, ht.TMaybe(ht.TStorageType), "Storage type"), 580 ("nodes", [], ht.TListOf(ht.TNonEmptyString), "Empty list to query all, list of names to query otherwise"), 581 ("name", None, ht.TMaybe(ht.TNonEmptyString), "Storage name") 582 ] 583 OP_RESULT = ht.TListOf(ht.TListOf(ht.TAny))
584
585 -class OpNodeModifyStorage(OpCode):
586 """Modifies the properies of a storage unit""" 587 OP_DSC_FIELD = "node_name" 588 OP_PARAMS = [ 589 ("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"), 590 ("node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "A node UUID (for single-node LUs)"), 591 ("storage_type", None, ht.TStorageType, "Storage type"), 592 ("name", None, ht.TMaybe(ht.TNonEmptyString), "Storage name"), 593 ("changes", None, ht.TObject(ht.TAny), "Requested storage changes") 594 ] 595 OP_RESULT = ht.TNone
596
597 -class OpRepairNodeStorage(OpCode):
598 """Repairs the volume group on a node.""" 599 OP_DSC_FIELD = "node_name" 600 OP_PARAMS = [ 601 ("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"), 602 ("node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "A node UUID (for single-node LUs)"), 603 ("storage_type", None, ht.TStorageType, "Storage type"), 604 ("name", None, ht.TMaybe(ht.TNonEmptyString), "Storage name"), 605 ("ignore_consistency", False, ht.TBool, "Whether to ignore disk consistency") 606 ] 607 OP_RESULT = ht.TNone
608
609 -class OpNodeSetParams(OpCode):
610 """Change the parameters of a node.""" 611 OP_DSC_FIELD = "node_name" 612 OP_PARAMS = [ 613 ("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"), 614 ("node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "A node UUID (for single-node LUs)"), 615 ("force", False, ht.TBool, "Whether to force the operation"), 616 ("hv_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set hypervisor states"), 617 ("disk_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set disk states"), 618 ("master_candidate", None, ht.TMaybe(ht.TBool), "Whether the node should become a master candidate"), 619 ("offline", None, ht.TMaybe(ht.TBool), "Whether to mark the node offline"), 620 ("drained", None, ht.TMaybe(ht.TBool), "Whether to mark the node as drained"), 621 ("auto_promote", False, ht.TBool, "Whether node(s) should be promoted to master candidate if necessary"), 622 ("master_capable", None, ht.TMaybe(ht.TBool), "Whether node can become master or master candidate"), 623 ("vm_capable", None, ht.TMaybe(ht.TBool), "Whether node can host instances"), 624 ("secondary_ip", None, ht.TMaybe(ht.TNonEmptyString), "Secondary IP address"), 625 ("ndparams", None, ht.TMaybe(ht.TObject(ht.TAny)), "Node parameters"), 626 ("powered", None, ht.TMaybe(ht.TBool), "Whether the node should be marked as powered") 627 ] 628 OP_RESULT = ht.TListOf(ht.TTupleOf(ht.TNonEmptyString, ht.TAny))
629
630 -class OpNodePowercycle(OpCode):
631 """Tries to powercycle a node.""" 632 OP_DSC_FIELD = "node_name" 633 OP_PARAMS = [ 634 ("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"), 635 ("node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "A node UUID (for single-node LUs)"), 636 ("force", False, ht.TBool, "Whether to force the operation") 637 ] 638 OP_RESULT = ht.TMaybe(ht.TNonEmptyString)
639
640 -class OpNodeMigrate(OpCode):
641 """Migrate all instances from a node.""" 642 OP_DSC_FIELD = "node_name" 643 OP_PARAMS = [ 644 ("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"), 645 ("node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "A node UUID (for single-node LUs)"), 646 ("mode", None, ht.TMaybe(ht.TMigrationMode), "Migration type (live/non-live)"), 647 ("live", None, ht.TMaybe(ht.TBool), "Obsolete 'live' migration mode (do not use)"), 648 ("target_node", None, ht.TMaybe(ht.TNonEmptyString), "Target node for instance migration/failover"), 649 ("target_node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Target node UUID for instance migration/failover"), 650 ("allow_runtime_changes", True, ht.TBool, "Whether to allow runtime changes while migrating"), 651 ("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"), 652 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances") 653 ] 654 OP_RESULT = ht.TJobIdListOnly
655
656 -class OpNodeEvacuate(OpCode):
657 """Evacuate instances off a number of nodes.""" 658 OP_DSC_FIELD = "node_name" 659 OP_PARAMS = [ 660 ("early_release", False, ht.TBool, "Whether to release locks as soon as possible"), 661 ("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"), 662 ("node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "A node UUID (for single-node LUs)"), 663 ("remote_node", None, ht.TMaybe(ht.TNonEmptyString), "New secondary node"), 664 ("remote_node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "New secondary node UUID"), 665 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances"), 666 ("mode", None, ht.TEvacMode, "Node evacuation mode") 667 ] 668 OP_RESULT = ht.TJobIdListOnly
669
670 -class OpInstanceCreate(OpCode):
671 """Create an instance. 672 673 @ivar instance_name: Instance name 674 @ivar mode: Instance creation mode (one of L{constants.INSTANCE_CREATE_MODES}) 675 @ivar source_handshake: Signed handshake from source (remote import only) 676 @ivar source_x509_ca: Source X509 CA in PEM format (remote import only) 677 @ivar source_instance_name: Previous name of instance (remote import only) 678 @ivar source_shutdown_timeout: Shutdown timeout used for source instance 679 (remote import only) 680 681 """ 682 OP_DSC_FIELD = "instance_name" 683 OP_PARAMS = [ 684 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 685 ("force_variant", False, ht.TBool, "Whether to force an unknown OS variant"), 686 ("wait_for_sync", True, ht.TBool, "Whether to wait for the disk to synchronize"), 687 ("name_check", True, ht.TBool, "Whether to check name"), 688 ("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"), 689 ("opportunistic_locking", False, ht.TBool, "Whether to employ opportunistic locking for nodes, meaning nodes already locked by another opcode won't be considered for instance allocation (only when an iallocator is used)"), 690 ("beparams", {}, ht.TObject(ht.TAny), "Backend parameters for instance"), 691 ("disks", None, ht.TListOf(ht.TIDiskParams), "List of instance disks"), 692 ("disk_template", None, ht.TMaybe(ht.TDiskTemplate), "Instance disk template"), 693 ("file_driver", None, ht.TMaybe(ht.TFileDriver), "Driver for file-backed disks"), 694 ("file_storage_dir", None, ht.TMaybe(ht.TNonEmptyString), "Directory for storing file-backed disks"), 695 ("hvparams", {}, ht.TObject(ht.TAny), "Hypervisor parameters for instance, hypervisor-dependent"), 696 ("hypervisor", None, ht.TMaybe(ht.THypervisor), "Selected hypervisor for an instance"), 697 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances"), 698 ("identify_defaults", False, ht.TBool, "Reset instance parameters to default if equal"), 699 ("ip_check", True, ht.TBool, "Whether to ensure instance's IP address is inactive"), 700 ("conflicts_check", True, ht.TBool, "Whether to check for conflicting IP addresses"), 701 ("mode", None, ht.TInstCreateMode, "Instance creation mode"), 702 ("nics", None, ht.TListOf(ht.TINicParams), "List of NIC (network interface) definitions"), 703 ("no_install", None, ht.TMaybe(ht.TBool), "Do not install the OS (will disable automatic start)"), 704 ("osparams", {}, ht.TObject(ht.TAny), "OS parameters for instance"), 705 ("osparams_private", None, ht.TMaybe(ht.TObject(ht.TPrivate(ht.TAny))), "Private OS parameters for instance"), 706 ("osparams_secret", None, ht.TMaybe(ht.TObject(ht.TPrivate(ht.TAny))), "Secret OS parameters for instance"), 707 ("os_type", None, ht.TMaybe(ht.TNonEmptyString), "OS type for instance installation"), 708 ("pnode", None, ht.TMaybe(ht.TNonEmptyString), "Primary node for an instance"), 709 ("pnode_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Primary node UUID for an instance"), 710 ("snode", None, ht.TMaybe(ht.TNonEmptyString), "Secondary node for an instance"), 711 ("snode_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Secondary node UUID for an instance"), 712 ("source_handshake", None, ht.TMaybe(ht.TListOf(ht.TAny)), "Signed handshake from source (remote import only)"), 713 ("source_instance_name", None, ht.TMaybe(ht.TNonEmptyString), "Source instance name (remote import only)"), 714 ("source_shutdown_timeout", 120, ht.TNonNegative(ht.TInt), "How long source instance was given to shut down (remote import only)"), 715 ("source_x509_ca", None, ht.TMaybe(ht.TNonEmptyString), "Source X509 CA in PEM format (remote import only)"), 716 ("src_node", None, ht.TMaybe(ht.TNonEmptyString), "Source node for import"), 717 ("src_node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Source node UUID for import"), 718 ("src_path", None, ht.TMaybe(ht.TNonEmptyString), "Source directory for import"), 719 ("compress", "none", ht.TString, "Compression mode to use for moves during backups/imports"), 720 ("start", True, ht.TBool, "Whether to start instance after creation"), 721 ("tags", [], ht.TListOf(ht.TNonEmptyString), "Instance tags"), 722 ("instance_communication", False, ht.TBool, "Enable or disable the communication mechanism for an instance"), 723 ("helper_startup_timeout", None, ht.TMaybe(ht.TInt), "Startup timeout for the helper VM"), 724 ("helper_shutdown_timeout", None, ht.TMaybe(ht.TInt), "Shutdown timeout for the helper VM") 725 ] 726 OP_RESULT = ht.TListOf(ht.TNonEmptyString)
727
728 -class OpInstanceMultiAlloc(OpInstanceMultiAllocBase):
729 """Allocates multiple instances.""" 730 OP_PARAMS = [ 731 ("opportunistic_locking", False, ht.TBool, "Whether to employ opportunistic locking for nodes, meaning nodes already locked by another opcode won't be considered for instance allocation (only when an iallocator is used)"), 732 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances"), 733 ("instances", [], ht.TListOf(ht.TAny), "List of instance create opcodes describing the instances to allocate") 734 ] 735 OP_RESULT = ht.TInstanceMultiAllocResponse
736
737 -class OpInstanceReinstall(OpCode):
738 """Reinstall an instance's OS.""" 739 OP_DSC_FIELD = "instance_name" 740 OP_PARAMS = [ 741 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 742 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 743 ("force_variant", False, ht.TBool, "Whether to force an unknown OS variant"), 744 ("os_type", None, ht.TMaybe(ht.TNonEmptyString), "OS type for instance installation"), 745 ("osparams", None, ht.TMaybe(ht.TObject(ht.TAny)), "Temporary OS parameters (currently only in reinstall, might be added to install as well)"), 746 ("osparams_private", None, ht.TMaybe(ht.TObject(ht.TPrivate(ht.TAny))), "Private OS parameters for instance reinstalls"), 747 ("osparams_secret", None, ht.TMaybe(ht.TObject(ht.TPrivate(ht.TAny))), "Secret OS parameters for instance reinstalls") 748 ] 749 OP_RESULT = ht.TNone
750
751 -class OpInstanceRemove(OpCode):
752 """Remove an instance.""" 753 OP_DSC_FIELD = "instance_name" 754 OP_PARAMS = [ 755 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 756 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 757 ("shutdown_timeout", 120, ht.TNonNegative(ht.TInt), "How long to wait for instance to shut down"), 758 ("ignore_failures", False, ht.TBool, "Whether to ignore failures during removal") 759 ] 760 OP_RESULT = ht.TNone
761
762 -class OpInstanceRename(OpCode):
763 """Rename an instance.""" 764 OP_PARAMS = [ 765 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 766 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 767 ("new_name", None, ht.TNonEmptyString, "New instance name"), 768 ("name_check", True, ht.TBool, "Whether to check name"), 769 ("ip_check", True, ht.TBool, "Whether to ensure instance's IP address is inactive") 770 ] 771 OP_RESULT = ht.TNonEmptyString
772
773 -class OpInstanceStartup(OpCode):
774 """Startup an instance.""" 775 OP_DSC_FIELD = "instance_name" 776 OP_PARAMS = [ 777 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 778 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 779 ("force", False, ht.TBool, "Whether to force the operation"), 780 ("ignore_offline_nodes", False, ht.TBool, "Whether to ignore offline nodes"), 781 ("hvparams", {}, ht.TObject(ht.TAny), "Temporary hypervisor parameters, hypervisor-dependent"), 782 ("beparams", {}, ht.TObject(ht.TAny), "Temporary backend parameters"), 783 ("no_remember", False, ht.TBool, "Do not remember instance state changes"), 784 ("startup_paused", False, ht.TBool, "Pause instance at startup"), 785 ("shutdown_timeout", 120, ht.TNonNegative(ht.TInt), "How long to wait for instance to shut down") 786 ] 787 OP_RESULT = ht.TNone
788
789 -class OpInstanceShutdown(OpCode):
790 """Shutdown an instance.""" 791 OP_DSC_FIELD = "instance_name" 792 OP_PARAMS = [ 793 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 794 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 795 ("force", False, ht.TBool, "Whether to force the operation"), 796 ("ignore_offline_nodes", False, ht.TBool, "Whether to ignore offline nodes"), 797 ("timeout", 120, ht.TNonNegative(ht.TInt), "How long to wait for instance to shut down"), 798 ("no_remember", False, ht.TBool, "Do not remember instance state changes"), 799 ("admin_state_source", None, ht.TMaybe(ht.TAdminStateSource), "Who last changed the instance admin state") 800 ] 801 OP_RESULT = ht.TNone
802
803 -class OpInstanceReboot(OpCode):
804 """Reboot an instance.""" 805 OP_DSC_FIELD = "instance_name" 806 OP_PARAMS = [ 807 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 808 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 809 ("shutdown_timeout", 120, ht.TNonNegative(ht.TInt), "How long to wait for instance to shut down"), 810 ("ignore_secondaries", False, ht.TBool, "Whether to start the instance even if secondary disks are failing"), 811 ("reboot_type", None, ht.TRebootType, "How to reboot the instance") 812 ] 813 OP_RESULT = ht.TNone
814
815 -class OpInstanceReplaceDisks(OpCode):
816 """Replace the disks of an instance.""" 817 OP_DSC_FIELD = "instance_name" 818 OP_PARAMS = [ 819 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 820 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 821 ("early_release", False, ht.TBool, "Whether to release locks as soon as possible"), 822 ("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"), 823 ("mode", None, ht.TReplaceDisksMode, "Replacement mode"), 824 ("disks", [], ht.TListOf(ht.TDiskIndex), "List of disk indices"), 825 ("remote_node", None, ht.TMaybe(ht.TNonEmptyString), "New secondary node"), 826 ("remote_node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "New secondary node UUID"), 827 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances") 828 ] 829 OP_RESULT = ht.TNone
830
831 -class OpInstanceFailover(OpCode):
832 """Failover an instance.""" 833 OP_DSC_FIELD = "instance_name" 834 OP_PARAMS = [ 835 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 836 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 837 ("shutdown_timeout", 120, ht.TNonNegative(ht.TInt), "How long to wait for instance to shut down"), 838 ("ignore_consistency", False, ht.TBool, "Whether to ignore disk consistency"), 839 ("target_node", None, ht.TMaybe(ht.TNonEmptyString), "Target node for instance migration/failover"), 840 ("target_node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Target node UUID for instance migration/failover"), 841 ("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"), 842 ("cleanup", False, ht.TBool, "Whether a previously failed migration should be cleaned up"), 843 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances") 844 ] 845 OP_RESULT = ht.TNone
846
847 -class OpInstanceMigrate(OpCode):
848 """Migrate an instance. 849 850 This migrates (without shutting down an instance) to its secondary 851 node. 852 853 @ivar instance_name: the name of the instance 854 @ivar mode: the migration mode (live, non-live or None for auto) 855 856 """ 857 OP_DSC_FIELD = "instance_name" 858 OP_PARAMS = [ 859 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 860 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 861 ("mode", None, ht.TMaybe(ht.TMigrationMode), "Migration type (live/non-live)"), 862 ("live", None, ht.TMaybe(ht.TBool), "Obsolete 'live' migration mode (do not use)"), 863 ("target_node", None, ht.TMaybe(ht.TNonEmptyString), "Target node for instance migration/failover"), 864 ("target_node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Target node UUID for instance migration/failover"), 865 ("allow_runtime_changes", True, ht.TBool, "Whether to allow runtime changes while migrating"), 866 ("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"), 867 ("cleanup", False, ht.TBool, "Whether a previously failed migration should be cleaned up"), 868 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances"), 869 ("allow_failover", False, ht.TBool, "Whether we can fallback to failover if migration is not possible") 870 ] 871 OP_RESULT = ht.TNone
872
873 -class OpInstanceMove(OpCode):
874 """Move an instance. 875 876 This move (with shutting down an instance and data copying) to an 877 arbitrary node. 878 879 @ivar instance_name: the name of the instance 880 @ivar target_node: the destination node 881 882 """ 883 OP_DSC_FIELD = "instance_name" 884 OP_PARAMS = [ 885 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 886 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 887 ("shutdown_timeout", 120, ht.TNonNegative(ht.TInt), "How long to wait for instance to shut down"), 888 ("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"), 889 ("target_node", None, ht.TNonEmptyString, "Target node for instance move"), 890 ("target_node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Target node UUID for instance move"), 891 ("compress", "none", ht.TString, "Compression mode to use during instance moves"), 892 ("ignore_consistency", False, ht.TBool, "Whether to ignore disk consistency") 893 ] 894 OP_RESULT = ht.TNone
895
896 -class OpInstanceConsole(OpCode):
897 """Connect to an instance's console.""" 898 OP_DSC_FIELD = "instance_name" 899 OP_PARAMS = [ 900 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 901 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)") 902 ] 903 OP_RESULT = ht.TObject(ht.TAny)
904
905 -class OpInstanceActivateDisks(OpCode):
906 """Activate an instance's disks.""" 907 OP_DSC_FIELD = "instance_name" 908 OP_PARAMS = [ 909 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 910 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 911 ("ignore_size", False, ht.TBool, "Whether to ignore recorded disk size"), 912 ("wait_for_sync", False, ht.TBool, "Whether to wait for the disk to synchronize (defaults to false)") 913 ] 914 OP_RESULT = ht.TListOf(ht.TTupleOf(ht.TNonEmptyString, ht.TNonEmptyString, ht.TNonEmptyString))
915
916 -class OpInstanceDeactivateDisks(OpCode):
917 """Deactivate an instance's disks.""" 918 OP_DSC_FIELD = "instance_name" 919 OP_PARAMS = [ 920 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 921 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 922 ("force", False, ht.TBool, "Whether to force the operation") 923 ] 924 OP_RESULT = ht.TNone
925
926 -class OpInstanceRecreateDisks(OpCode):
927 """Recreate an instance's disks.""" 928 OP_DSC_FIELD = "instance_name" 929 OP_PARAMS = [ 930 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 931 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 932 ("disks", [], ht.TRecreateDisksInfo, "Disk list for recreate disks"), 933 ("nodes", [], ht.TListOf(ht.TNonEmptyString), "New instance nodes, if relocation is desired"), 934 ("node_uuids", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "New instance node UUIDs, if relocation is desired"), 935 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances") 936 ] 937 OP_RESULT = ht.TNone
938
939 -class OpInstanceQueryData(OpCode):
940 """Compute the run-time status of instances.""" 941 OP_PARAMS = [ 942 ("use_locking", False, ht.TBool, "Whether to use synchronization"), 943 ("instances", [], ht.TListOf(ht.TNonEmptyString), "List of instances"), 944 ("static", False, ht.TBool, "Whether to only return configuration data without querying nodes") 945 ] 946 OP_RESULT = ht.TObject(ht.TObject(ht.TAny))
947
948 -class OpInstanceSetParams(OpCode):
949 """Change the parameters of an instance.""" 950 OP_DSC_FIELD = "instance_name" 951 OP_PARAMS = [ 952 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 953 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 954 ("force", False, ht.TBool, "Whether to force the operation"), 955 ("force_variant", False, ht.TBool, "Whether to force an unknown OS variant"), 956 ("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"), 957 ("nics", [], ht.TSetParamsMods(ht.TINicParams), "List of NIC changes"), 958 ("disks", [], ht.TSetParamsMods(ht.TIDiskParams), "List of disk changes"), 959 ("beparams", {}, ht.TObject(ht.TAny), "Backend parameters for instance"), 960 ("runtime_mem", None, ht.TMaybe(ht.TPositive(ht.TInt)), "New runtime memory"), 961 ("hvparams", {}, ht.TObject(ht.TAny), "Hypervisor parameters for instance, hypervisor-dependent"), 962 ("disk_template", None, ht.TMaybe(ht.TDiskTemplate), "Instance disk template"), 963 ("pnode", None, ht.TMaybe(ht.TNonEmptyString), "Primary node for an instance"), 964 ("pnode_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Primary node UUID for an instance"), 965 ("remote_node", None, ht.TMaybe(ht.TNonEmptyString), "Secondary node (used when changing disk template)"), 966 ("remote_node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Secondary node UUID (used when changing disk template)"), 967 ("os_name", None, ht.TMaybe(ht.TNonEmptyString), "Change the instance's OS without reinstalling the instance"), 968 ("osparams", {}, ht.TObject(ht.TAny), "OS parameters for instance"), 969 ("osparams_private", None, ht.TMaybe(ht.TObject(ht.TPrivate(ht.TAny))), "Private OS parameters for instance"), 970 ("wait_for_sync", True, ht.TBool, "Whether to wait for the disk to synchronize"), 971 ("offline", None, ht.TMaybe(ht.TBool), "Whether to mark the instance as offline"), 972 ("conflicts_check", True, ht.TBool, "Whether to check for conflicting IP addresses"), 973 ("hotplug", False, ht.TBool, ""), 974 ("hotplug_if_possible", False, ht.TBool, ""), 975 ("instance_communication", None, ht.TMaybe(ht.TBool), "Enable or disable the communication mechanism for an instance") 976 ] 977 OP_RESULT = ht.TListOf(ht.TTupleOf(ht.TNonEmptyString, ht.TAny))
978
979 -class OpInstanceGrowDisk(OpCode):
980 """Grow a disk of an instance.""" 981 OP_DSC_FIELD = "instance_name" 982 OP_PARAMS = [ 983 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 984 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 985 ("wait_for_sync", True, ht.TBool, "Whether to wait for the disk to synchronize"), 986 ("disk", None, ht.TDiskIndex, "Disk index for e.g. grow disk"), 987 ("amount", None, ht.TNonNegative(ht.TInt), "Disk amount to add or grow to"), 988 ("absolute", False, ht.TBool, "Whether the amount parameter is an absolute target or a relative one"), 989 ("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations") 990 ] 991 OP_RESULT = ht.TNone
992
993 -class OpInstanceChangeGroup(OpCode):
994 """Moves an instance to another node group.""" 995 OP_DSC_FIELD = "instance_name" 996 OP_PARAMS = [ 997 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 998 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 999 ("early_release", False, ht.TBool, "Whether to release locks as soon as possible"), 1000 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances"), 1001 ("target_groups", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "Destination group names or UUIDs (defaults to \"all but current group\")") 1002 ] 1003 OP_RESULT = ht.TJobIdListOnly
1004
1005 -class OpGroupAdd(OpCode):
1006 """Add a node group to the cluster.""" 1007 OP_DSC_FIELD = "group_name" 1008 OP_PARAMS = [ 1009 ("group_name", None, ht.TNonEmptyString, "Group name"), 1010 ("alloc_policy", None, ht.TMaybe(ht.TAllocPolicy), "Instance allocation policy"), 1011 ("ndparams", None, ht.TMaybe(ht.TObject(ht.TAny)), "Default node parameters for group"), 1012 ("diskparams", None, ht.TMaybe(ht.TDictOf(ht.TDiskTemplate, ht.TObject(ht.TAny))), "Disk templates' parameter defaults"), 1013 ("hv_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set hypervisor states"), 1014 ("disk_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set disk states"), 1015 ("ipolicy", None, ht.TMaybe(ht.TObject(ht.TAny)), "Group-wide ipolicy specs") 1016 ] 1017 OP_RESULT = ht.TOr(ht.TNone, ht.TJobIdListOnly)
1018
1019 -class OpGroupAssignNodes(OpCode):
1020 """Assign nodes to a node group.""" 1021 OP_DSC_FIELD = "group_name" 1022 OP_PARAMS = [ 1023 ("group_name", None, ht.TNonEmptyString, "Group name"), 1024 ("force", False, ht.TBool, "Whether to force the operation"), 1025 ("nodes", None, ht.TListOf(ht.TNonEmptyString), "List of nodes to assign"), 1026 ("node_uuids", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "List of node UUIDs to assign") 1027 ] 1028 OP_RESULT = ht.TNone
1029
1030 -class OpGroupSetParams(OpCode):
1031 """Change the parameters of a node group.""" 1032 OP_DSC_FIELD = "group_name" 1033 OP_PARAMS = [ 1034 ("group_name", None, ht.TNonEmptyString, "Group name"), 1035 ("alloc_policy", None, ht.TMaybe(ht.TAllocPolicy), "Instance allocation policy"), 1036 ("ndparams", None, ht.TMaybe(ht.TObject(ht.TAny)), "Default node parameters for group"), 1037 ("diskparams", None, ht.TMaybe(ht.TDictOf(ht.TDiskTemplate, ht.TObject(ht.TAny))), "Disk templates' parameter defaults"), 1038 ("hv_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set hypervisor states"), 1039 ("disk_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set disk states"), 1040 ("ipolicy", None, ht.TMaybe(ht.TObject(ht.TAny)), "Group-wide ipolicy specs") 1041 ] 1042 OP_RESULT = ht.TListOf(ht.TTupleOf(ht.TNonEmptyString, ht.TAny))
1043
1044 -class OpGroupRemove(OpCode):
1045 """Remove a node group from the cluster.""" 1046 OP_DSC_FIELD = "group_name" 1047 OP_PARAMS = [ 1048 ("group_name", None, ht.TNonEmptyString, "Group name") 1049 ] 1050 OP_RESULT = ht.TNone
1051
1052 -class OpGroupRename(OpCode):
1053 """Rename a node group in the cluster.""" 1054 OP_PARAMS = [ 1055 ("group_name", None, ht.TNonEmptyString, "Group name"), 1056 ("new_name", None, ht.TNonEmptyString, "New group name") 1057 ] 1058 OP_RESULT = ht.TNonEmptyString
1059
1060 -class OpGroupEvacuate(OpCode):
1061 """Evacuate a node group in the cluster.""" 1062 OP_DSC_FIELD = "group_name" 1063 OP_PARAMS = [ 1064 ("group_name", None, ht.TNonEmptyString, "Group name"), 1065 ("early_release", False, ht.TBool, "Whether to release locks as soon as possible"), 1066 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances"), 1067 ("target_groups", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "Destination group names or UUIDs (defaults to \"all but current group\")"), 1068 ("sequential", False, ht.TBool, "Sequential job execution"), 1069 ("force_failover", False, ht.TBool, "Disallow migration moves and always use failovers") 1070 ] 1071 OP_RESULT = ht.TJobIdListOnly
1072
1073 -class OpOsDiagnose(OpCode):
1074 """Compute the list of guest operating systems.""" 1075 OP_PARAMS = [ 1076 ("output_fields", None, ht.TListOf(ht.TNonEmptyString), "Selected output fields"), 1077 ("names", [], ht.TListOf(ht.TNonEmptyString), "Which operating systems to diagnose") 1078 ] 1079 OP_RESULT = ht.TListOf(ht.TListOf(ht.TAny))
1080
1081 -class OpExtStorageDiagnose(OpCode):
1082 """Compute the list of external storage providers.""" 1083 OP_PARAMS = [ 1084 ("output_fields", None, ht.TListOf(ht.TNonEmptyString), "Selected output fields"), 1085 ("names", [], ht.TListOf(ht.TNonEmptyString), "Which ExtStorage Provider to diagnose") 1086 ] 1087 OP_RESULT = ht.TListOf(ht.TListOf(ht.TAny))
1088
1089 -class OpBackupPrepare(OpCode):
1090 """Prepares an instance export. 1091 1092 @ivar instance_name: Instance name 1093 @ivar mode: Export mode (one of L{constants.EXPORT_MODES}) 1094 1095 """ 1096 OP_DSC_FIELD = "instance_name" 1097 OP_PARAMS = [ 1098 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 1099 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 1100 ("mode", None, ht.TExportMode, "Export mode") 1101 ] 1102 OP_RESULT = ht.TMaybe(ht.TObject(ht.TAny))
1103
1104 -class OpBackupExport(OpCode):
1105 """Export an instance. 1106 1107 For local exports, the export destination is the node name. For 1108 remote exports, the export destination is a list of tuples, each 1109 consisting of hostname/IP address, port, magic, HMAC and HMAC 1110 salt. The HMAC is calculated using the cluster domain secret over 1111 the value "${index}:${hostname}:${port}". The destination X509 CA 1112 must be a signed certificate. 1113 1114 @ivar mode: Export mode (one of L{constants.EXPORT_MODES}) 1115 @ivar target_node: Export destination 1116 @ivar x509_key_name: X509 key to use (remote export only) 1117 @ivar destination_x509_ca: Destination X509 CA in PEM format (remote 1118 export only) 1119 1120 """ 1121 OP_DSC_FIELD = "instance_name" 1122 OP_PARAMS = [ 1123 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 1124 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 1125 ("compress", "none", ht.TString, "Compression mode to use for moves during backups/imports"), 1126 ("shutdown_timeout", 120, ht.TNonNegative(ht.TInt), "How long to wait for instance to shut down"), 1127 ("target_node", None, ht.TExportTarget, "Target node (depends on export mode)"), 1128 ("target_node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Target node UUID (if local export)"), 1129 ("shutdown", True, ht.TBool, "Whether to shutdown the instance before export"), 1130 ("remove_instance", False, ht.TBool, "Whether to remove instance after export"), 1131 ("ignore_remove_failures", False, ht.TBool, "Whether to ignore failures while removing instances"), 1132 ("mode", "local", ht.TExportMode, "Export mode"), 1133 ("x509_key_name", None, ht.TMaybe(ht.TListOf(ht.TAny)), "Name of X509 key (remote export only)"), 1134 ("destination_x509_ca", None, ht.TMaybe(ht.TNonEmptyString), "Destination X509 CA (remote export only)"), 1135 ("zero_free_space", False, ht.TBool, "Whether to zero the free space on the disks of the instance"), 1136 ("zeroing_timeout_fixed", None, ht.TMaybe(ht.TInt), "The fixed part of time to wait before declaring the zeroing operation to have failed"), 1137 ("zeroing_timeout_per_mib", None, ht.TMaybe(ht.TDouble), "The variable part of time to wait before declaring the zeroing operation to have failed, dependent on total size of disks") 1138 ] 1139 OP_RESULT = ht.TTupleOf(ht.TBool, ht.TListOf(ht.TBool))
1140
1141 -class OpBackupRemove(OpCode):
1142 """Remove an instance's export.""" 1143 OP_DSC_FIELD = "instance_name" 1144 OP_PARAMS = [ 1145 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 1146 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)") 1147 ] 1148 OP_RESULT = ht.TNone
1149
1150 -class OpTagsGet(OpCode):
1151 """Returns the tags of the given object.""" 1152 OP_DSC_FIELD = "name" 1153 OP_PARAMS = [ 1154 ("kind", None, ht.TTagKind, "Tag kind"), 1155 ("use_locking", False, ht.TBool, "Whether to use synchronization"), 1156 ("name", None, ht.TMaybe(ht.TString), "Name of object to retrieve tags from") 1157 ] 1158 OP_RESULT = ht.TListOf(ht.TNonEmptyString)
1159
1160 -class OpTagsSearch(OpCode):
1161 """Searches the tags in the cluster for a given pattern.""" 1162 OP_DSC_FIELD = "pattern" 1163 OP_PARAMS = [ 1164 ("pattern", None, ht.TNonEmptyString, "Search pattern (regular expression)") 1165 ] 1166 OP_RESULT = ht.TListOf(ht.TTupleOf(ht.TNonEmptyString, ht.TNonEmptyString))
1167
1168 -class OpTagsSet(OpCode):
1169 """Add a list of tags on a given object.""" 1170 OP_PARAMS = [ 1171 ("kind", None, ht.TTagKind, "Tag kind"), 1172 ("tags", None, ht.TListOf(ht.TString), "List of tag names"), 1173 ("name", None, ht.TMaybe(ht.TString), "Name of object where tag(s) should be added") 1174 ] 1175 OP_RESULT = ht.TNone
1176
1177 -class OpTagsDel(OpCode):
1178 """Remove a list of tags from a given object.""" 1179 OP_PARAMS = [ 1180 ("kind", None, ht.TTagKind, "Tag kind"), 1181 ("tags", None, ht.TListOf(ht.TString), "List of tag names"), 1182 ("name", None, ht.TMaybe(ht.TString), "Name of object where tag(s) should be deleted") 1183 ] 1184 OP_RESULT = ht.TNone
1185
1186 -class OpTestDelay(OpCode):
1187 """Sleeps for a configured amount of time. 1188 1189 This is used just for debugging and testing. 1190 1191 Parameters: 1192 - duration: the time to sleep, in seconds 1193 - on_master: if true, sleep on the master 1194 - on_nodes: list of nodes in which to sleep 1195 1196 If the on_master parameter is true, it will execute a sleep on the 1197 master (before any node sleep). 1198 1199 If the on_nodes list is not empty, it will sleep on those nodes 1200 (after the sleep on the master, if that is enabled). 1201 1202 As an additional feature, the case of duration < 0 will be reported 1203 as an execution error, so this opcode can be used as a failure 1204 generator. The case of duration == 0 will not be treated specially. 1205 1206 """ 1207