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 """ 220 OpCode.Validate(self, set_defaults) 221 222 for inst in self.instances: # pylint: disable=E1101 223 inst.Validate(set_defaults)
224 -class OpClusterPostInit(OpCode):
225 """Post cluster initialization. 226 227 This opcode does not touch the cluster at all. Its purpose is to run hooks 228 after the cluster has been initialized. 229 230 """ 231 OP_PARAMS = [ 232 ] 233 OP_RESULT = ht.TBool
234
235 -class OpClusterDestroy(OpCode):
236 """Destroy the cluster. 237 238 This opcode has no other parameters. All the state is irreversibly 239 lost after the execution of this opcode. 240 241 """ 242 OP_PARAMS = [ 243 ] 244 OP_RESULT = ht.TNonEmptyString
245
246 -class OpClusterQuery(OpCode):
247 """Query cluster information.""" 248 OP_PARAMS = [ 249 ] 250 OP_RESULT = ht.TObject(ht.TAny)
251
252 -class OpClusterVerify(OpCode):
253 """Submits all jobs necessary to verify the cluster.""" 254 OP_PARAMS = [ 255 ("debug_simulate_errors", False, ht.TBool, "Whether to simulate errors (useful for debugging)"), 256 ("error_codes", False, ht.TBool, "Error codes"), 257 ("skip_checks", [], ht.TSetOf(ht.TVerifyOptionalChecks), "Which checks to skip"), 258 ("ignore_errors", [], ht.TSetOf(ht.TCVErrorCode), "List of error codes that should be treated as warnings"), 259 ("verbose", False, ht.TBool, "Verbose mode"), 260 ("group_name", None, ht.TMaybe(ht.TNonEmptyString), "Optional group name") 261 ] 262 OP_RESULT = ht.TJobIdListOnly
263
264 -class OpClusterVerifyConfig(OpCode):
265 """Verify the cluster config.""" 266 OP_PARAMS = [ 267 ("debug_simulate_errors", False, ht.TBool, "Whether to simulate errors (useful for debugging)"), 268 ("error_codes", False, ht.TBool, "Error codes"), 269 ("ignore_errors", [], ht.TSetOf(ht.TCVErrorCode), "List of error codes that should be treated as warnings"), 270 ("verbose", False, ht.TBool, "Verbose mode") 271 ] 272 OP_RESULT = ht.TBool
273
274 -class OpClusterVerifyGroup(OpCode):
275 """Run verify on a node group from the cluster. 276 277 @type skip_checks: C{list} 278 @ivar skip_checks: steps to be skipped from the verify process; this 279 needs to be a subset of 280 L{constants.VERIFY_OPTIONAL_CHECKS}; currently 281 only L{constants.VERIFY_NPLUSONE_MEM} can be passed 282 283 """ 284 OP_DSC_FIELD = "group_name" 285 OP_PARAMS = [ 286 ("group_name", None, ht.TNonEmptyString, "Group name"), 287 ("debug_simulate_errors", False, ht.TBool, "Whether to simulate errors (useful for debugging)"), 288 ("error_codes", False, ht.TBool, "Error codes"), 289 ("skip_checks", [], ht.TSetOf(ht.TVerifyOptionalChecks), "Which checks to skip"), 290 ("ignore_errors", [], ht.TSetOf(ht.TCVErrorCode), "List of error codes that should be treated as warnings"), 291 ("verbose", False, ht.TBool, "Verbose mode") 292 ] 293 OP_RESULT = ht.TBool
294
295 -class OpClusterVerifyDisks(OpCode):
296 """Verify the cluster disks.""" 297 OP_PARAMS = [ 298 ] 299 OP_RESULT = ht.TJobIdListOnly
300
301 -class OpGroupVerifyDisks(OpCode):
302 """Verifies the status of all disks in a node group. 303 304 Result: a tuple of three elements: 305 - dict of node names with issues (values: error msg) 306 - list of instances with degraded disks (that should be activated) 307 - dict of instances with missing logical volumes (values: (node, vol) 308 pairs with details about the missing volumes) 309 310 In normal operation, all lists should be empty. A non-empty instance 311 list (3rd element of the result) is still ok (errors were fixed) but 312 non-empty node list means some node is down, and probably there are 313 unfixable drbd errors. 314 315 Note that only instances that are drbd-based are taken into 316 consideration. This might need to be revisited in the future. 317 318 """ 319 OP_DSC_FIELD = "group_name" 320 OP_PARAMS = [ 321 ("group_name", None, ht.TNonEmptyString, "Group name") 322 ] 323 OP_RESULT = ht.TTupleOf(ht.TDictOf(ht.TString, ht.TString), ht.TListOf(ht.TString), ht.TDictOf(ht.TString, ht.TListOf(ht.TListOf(ht.TString))))
324
325 -class OpClusterRepairDiskSizes(OpCode):
326 """Verify the disk sizes of the instances and fixes configuration 327 mismatches. 328 329 Parameters: optional instances list, in case we want to restrict the 330 checks to only a subset of the instances. 331 332 Result: a list of tuples, (instance, disk, parameter, new-size) for 333 changed configurations. 334 335 In normal operation, the list should be empty. 336 337 @type instances: list 338 @ivar instances: the list of instances to check, or empty for all instances 339 340 """ 341 OP_PARAMS = [ 342 ("instances", [], ht.TListOf(ht.TNonEmptyString), "List of instances") 343 ] 344 OP_RESULT = ht.TListOf(ht.TTupleOf(ht.TNonEmptyString, ht.TNonNegative(ht.TInt), ht.TNonEmptyString, ht.TNonNegative(ht.TInt)))
345
346 -class OpClusterConfigQuery(OpCode):
347 """Query cluster configuration values.""" 348 OP_PARAMS = [ 349 ("output_fields", None, ht.TListOf(ht.TNonEmptyString), "Selected output fields") 350 ] 351 OP_RESULT = ht.TListOf(ht.TAny)
352
353 -class OpClusterRename(OpCode):
354 """Rename the cluster. 355 356 @type name: C{str} 357 @ivar name: The new name of the cluster. The name and/or the master IP 358 address will be changed to match the new name and its IP 359 address. 360 361 """ 362 OP_DSC_FIELD = "name" 363 OP_PARAMS = [ 364 ("name", None, ht.TNonEmptyString, "A generic name") 365 ] 366 OP_RESULT = ht.TNonEmptyString
367
368 -class OpClusterSetParams(OpCode):
369 """Change the parameters of the cluster. 370 371 @type vg_name: C{str} or C{None} 372 @ivar vg_name: The new volume group name or None to disable LVM usage. 373 374 """ 375 OP_PARAMS = [ 376 ("force", False, ht.TBool, "Whether to force the operation"), 377 ("hv_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set hypervisor states"), 378 ("disk_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set disk states"), 379 ("vg_name", None, ht.TMaybe(ht.TString), "Volume group name"), 380 ("enabled_hypervisors", None, ht.TMaybe(ht.TListOf(ht.THypervisor)), "List of enabled hypervisors"), 381 ("hvparams", None, ht.TMaybe(ht.TDictOf(ht.TString, ht.TObject(ht.TAny))), "Cluster-wide hypervisor parameters, hypervisor-dependent"), 382 ("beparams", None, ht.TMaybe(ht.TObject(ht.TAny)), "Cluster-wide backend parameter defaults"), 383 ("os_hvp", None, ht.TMaybe(ht.TDictOf(ht.TString, ht.TObject(ht.TAny))), "Cluster-wide per-OS hypervisor parameter defaults"), 384 ("osparams", None, ht.TMaybe(ht.TDictOf(ht.TString, ht.TObject(ht.TAny))), "Cluster-wide OS parameter defaults"), 385 ("diskparams", None, ht.TMaybe(ht.TDictOf(ht.TDiskTemplate, ht.TObject(ht.TAny))), "Disk templates' parameter defaults"), 386 ("candidate_pool_size", None, ht.TMaybe(ht.TPositive(ht.TInt)), "Master candidate pool size"), 387 ("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)"), 388 ("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)"), 389 ("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"), 390 ("maintain_node_health", None, ht.TMaybe(ht.TBool), "Whether to automatically maintain node health"), 391 ("prealloc_wipe_disks", None, ht.TMaybe(ht.TBool), "Whether to wipe disks before allocating them to instances"), 392 ("nicparams", None, ht.TMaybe(ht.TINicParams), "Cluster-wide NIC parameter defaults"), 393 ("ndparams", None, ht.TMaybe(ht.TObject(ht.TAny)), "Cluster-wide node parameter defaults"), 394 ("ipolicy", None, ht.TMaybe(ht.TObject(ht.TAny)), "Cluster-wide ipolicy specs"), 395 ("drbd_helper", None, ht.TMaybe(ht.TString), "DRBD helper program"), 396 ("default_iallocator", None, ht.TMaybe(ht.TString), "Default iallocator for cluster"), 397 ("master_netdev", None, ht.TMaybe(ht.TString), "Master network device"), 398 ("master_netmask", None, ht.TMaybe(ht.TNonNegative(ht.TInt)), "Netmask of the master IP"), 399 ("reserved_lvs", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "List of reserved LVs"), 400 ("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"), 401 ("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"), 402 ("use_external_mip_script", None, ht.TMaybe(ht.TBool), "Whether to use an external master IP address setup script"), 403 ("enabled_disk_templates", None, ht.TMaybe(ht.TListOf(ht.TDiskTemplate)), "List of enabled disk templates"), 404 ("modify_etc_hosts", None, ht.TMaybe(ht.TBool), ""), 405 ("file_storage_dir", None, ht.TMaybe(ht.TString), ""), 406 ("shared_file_storage_dir", None, ht.TMaybe(ht.TString), "") 407 ] 408 OP_RESULT = ht.TNone
409
410 -class OpClusterRedistConf(OpCode):
411 """Force a full push of the cluster configuration.""" 412 OP_PARAMS = [ 413 ] 414 OP_RESULT = ht.TNone
415
416 -class OpClusterActivateMasterIp(OpCode):
417 """Activate the master IP on the master node.""" 418 OP_PARAMS = [ 419 ] 420 OP_RESULT = ht.TNone
421
422 -class OpClusterDeactivateMasterIp(OpCode):
423 """Deactivate the master IP on the master node.""" 424 OP_PARAMS = [ 425 ] 426 OP_RESULT = ht.TNone
427
428 -class OpQuery(OpCode):
429 """Query for resources/items. 430 431 @ivar what: Resources to query for, must be one of L{constants.QR_VIA_OP} 432 @ivar fields: List of fields to retrieve 433 @ivar qfilter: Query filter 434 435 """ 436 OP_DSC_FIELD = "what" 437 OP_PARAMS = [ 438 ("what", None, ht.TQueryTypeOp, "Resource(s) to query for"), 439 ("use_locking", False, ht.TBool, "Whether to use synchronization"), 440 ("fields", None, ht.TListOf(ht.TNonEmptyString), "Requested fields"), 441 ("qfilter", None, ht.TMaybe(ht.TListOf(ht.TAny)), "Query filter") 442 ] 443 OP_RESULT = ht.TQueryResponse
444
445 -class OpQueryFields(OpCode):
446 """Query for available resource/item fields. 447 448 @ivar what: Resources to query for, must be one of L{constants.QR_VIA_OP} 449 @ivar fields: List of fields to retrieve 450 451 """ 452 OP_DSC_FIELD = "what" 453 OP_PARAMS = [ 454 ("what", None, ht.TQueryTypeOp, "Resource(s) to query for"), 455 ("fields", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "Requested fields; if not given, all are returned") 456 ] 457 OP_RESULT = ht.TQueryFieldsResponse
458
459 -class OpOobCommand(OpCode):
460 """Interact with OOB.""" 461 OP_PARAMS = [ 462 ("node_names", [], ht.TListOf(ht.TNonEmptyString), "List of node names to run the OOB command against"), 463 ("node_uuids", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "List of node UUIDs to run the OOB command against"), 464 ("command", None, ht.TOobCommand, "OOB command to run"), 465 ("timeout", 60, ht.TInt, "Timeout before the OOB helper will be terminated"), 466 ("ignore_status", False, ht.TBool, "Ignores the node offline status for power off"), 467 ("power_delay", 2.0, ht.TDouble, "Time in seconds to wait between powering on nodes") 468 ] 469 OP_RESULT = ht.TListOf(ht.TListOf(ht.TTupleOf(ht.TQueryResultCode, ht.TAny)))
470
471 -class OpRestrictedCommand(OpCode):
472 """Runs a restricted command on node(s).""" 473 OP_PARAMS = [ 474 ("use_locking", False, ht.TBool, "Whether to use synchronization"), 475 ("nodes", None, ht.TListOf(ht.TNonEmptyString), "Nodes on which the command should be run (at least one)"), 476 ("node_uuids", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "Node UUIDs on which the command should be run (at least one)"), 477 ("command", None, ht.TNonEmptyString, "Restricted command name") 478 ] 479 OP_RESULT = ht.TListOf(ht.TTupleOf(ht.TBool, ht.TString))
480
481 -class OpNodeRemove(OpCode):
482 """Remove a node. 483 484 @type node_name: C{str} 485 @ivar node_name: The name of the node to remove. If the node still has 486 instances on it, the operation will fail. 487 488 """ 489 OP_DSC_FIELD = "node_name" 490 OP_PARAMS = [ 491 ("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"), 492 ("node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "A node UUID (for single-node LUs)") 493 ] 494 OP_RESULT = ht.TNone
495
496 -class OpNodeAdd(OpCode):
497 """Add a node to the cluster. 498 499 @type node_name: C{str} 500 @ivar node_name: The name of the node to add. This can be a short name, 501 but it will be expanded to the FQDN. 502 @type primary_ip: IP address 503 @ivar primary_ip: The primary IP of the node. This will be ignored when 504 the opcode is submitted, but will be filled during the 505 node add (so it will be visible in the job query). 506 @type secondary_ip: IP address 507 @ivar secondary_ip: The secondary IP of the node. This needs to be passed 508 if the cluster has been initialized in 'dual-network' 509 mode, otherwise it must not be given. 510 @type readd: C{bool} 511 @ivar readd: Whether to re-add an existing node to the cluster. If 512 this is not passed, then the operation will abort if the node 513 name is already in the cluster; use this parameter to 514 'repair' a node that had its configuration broken, or was 515 reinstalled without removal from the cluster. 516 @type group: C{str} 517 @ivar group: The node group to which this node will belong. 518 @type vm_capable: C{bool} 519 @ivar vm_capable: The vm_capable node attribute 520 @type master_capable: C{bool} 521 @ivar master_capable: The master_capable node attribute 522 523 """ 524 OP_DSC_FIELD = "node_name" 525 OP_PARAMS = [ 526 ("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"), 527 ("hv_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set hypervisor states"), 528 ("disk_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set disk states"), 529 ("primary_ip", None, ht.TMaybe(ht.TNonEmptyString), "Primary IP address"), 530 ("secondary_ip", None, ht.TMaybe(ht.TNonEmptyString), "Secondary IP address"), 531 ("readd", False, ht.TBool, "Whether node is re-added to cluster"), 532 ("group", None, ht.TMaybe(ht.TNonEmptyString), "Initial node group"), 533 ("master_capable", None, ht.TMaybe(ht.TBool), "Whether node can become master or master candidate"), 534 ("vm_capable", None, ht.TMaybe(ht.TBool), "Whether node can host instances"), 535 ("ndparams", None, ht.TMaybe(ht.TObject(ht.TAny)), "Node parameters") 536 ] 537 OP_RESULT = ht.TNone
538
539 -class OpNodeQuery(OpCode):
540 """Compute the list of nodes.""" 541 OP_PARAMS = [ 542 ("output_fields", None, ht.TListOf(ht.TNonEmptyString), "Selected output fields"), 543 ("names", [], ht.TListOf(ht.TNonEmptyString), "Empty list to query all nodes, node names otherwise"), 544 ("use_locking", False, ht.TBool, "Whether to use synchronization") 545 ] 546 OP_RESULT = ht.TListOf(ht.TListOf(ht.TAny))
547
548 -class OpNodeQueryvols(OpCode):
549 """Get list of volumes on node.""" 550 OP_PARAMS = [ 551 ("output_fields", None, ht.TListOf(ht.TNonEmptyString), "Selected output fields"), 552 ("nodes", [], ht.TListOf(ht.TNonEmptyString), "Empty list to query all nodes, node names otherwise") 553 ] 554 OP_RESULT = ht.TListOf(ht.TAny)
555
556 -class OpNodeQueryStorage(OpCode):
557 """Get information on storage for node(s).""" 558 OP_PARAMS = [ 559 ("output_fields", None, ht.TListOf(ht.TNonEmptyString), "Selected output fields"), 560 ("storage_type", None, ht.TMaybe(ht.TStorageType), "Storage type"), 561 ("nodes", [], ht.TListOf(ht.TNonEmptyString), "Empty list to query all, list of names to query otherwise"), 562 ("name", None, ht.TMaybe(ht.TNonEmptyString), "Storage name") 563 ] 564 OP_RESULT = ht.TListOf(ht.TListOf(ht.TAny))
565
566 -class OpNodeModifyStorage(OpCode):
567 """Modifies the properies of a storage unit""" 568 OP_DSC_FIELD = "node_name" 569 OP_PARAMS = [ 570 ("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"), 571 ("node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "A node UUID (for single-node LUs)"), 572 ("storage_type", None, ht.TStorageType, "Storage type"), 573 ("name", None, ht.TMaybe(ht.TNonEmptyString), "Storage name"), 574 ("changes", None, ht.TObject(ht.TAny), "Requested storage changes") 575 ] 576 OP_RESULT = ht.TNone
577
578 -class OpRepairNodeStorage(OpCode):
579 """Repairs the volume group on a node.""" 580 OP_DSC_FIELD = "node_name" 581 OP_PARAMS = [ 582 ("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"), 583 ("node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "A node UUID (for single-node LUs)"), 584 ("storage_type", None, ht.TStorageType, "Storage type"), 585 ("name", None, ht.TMaybe(ht.TNonEmptyString), "Storage name"), 586 ("ignore_consistency", False, ht.TBool, "Whether to ignore disk consistency") 587 ] 588 OP_RESULT = ht.TNone
589
590 -class OpNodeSetParams(OpCode):
591 """Change the parameters of a node.""" 592 OP_DSC_FIELD = "node_name" 593 OP_PARAMS = [ 594 ("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"), 595 ("node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "A node UUID (for single-node LUs)"), 596 ("force", False, ht.TBool, "Whether to force the operation"), 597 ("hv_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set hypervisor states"), 598 ("disk_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set disk states"), 599 ("master_candidate", None, ht.TMaybe(ht.TBool), "Whether the node should become a master candidate"), 600 ("offline", None, ht.TMaybe(ht.TBool), "Whether to mark the node offline"), 601 ("drained", None, ht.TMaybe(ht.TBool), "Whether to mark the node as drained"), 602 ("auto_promote", False, ht.TBool, "Whether node(s) should be promoted to master candidate if necessary"), 603 ("master_capable", None, ht.TMaybe(ht.TBool), "Whether node can become master or master candidate"), 604 ("vm_capable", None, ht.TMaybe(ht.TBool), "Whether node can host instances"), 605 ("secondary_ip", None, ht.TMaybe(ht.TNonEmptyString), "Secondary IP address"), 606 ("ndparams", None, ht.TMaybe(ht.TObject(ht.TAny)), "Node parameters"), 607 ("powered", None, ht.TMaybe(ht.TBool), "Whether the node should be marked as powered") 608 ] 609 OP_RESULT = ht.TListOf(ht.TTupleOf(ht.TNonEmptyString, ht.TAny))
610
611 -class OpNodePowercycle(OpCode):
612 """Tries to powercycle a node.""" 613 OP_DSC_FIELD = "node_name" 614 OP_PARAMS = [ 615 ("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"), 616 ("node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "A node UUID (for single-node LUs)"), 617 ("force", False, ht.TBool, "Whether to force the operation") 618 ] 619 OP_RESULT = ht.TMaybe(ht.TNonEmptyString)
620
621 -class OpNodeMigrate(OpCode):
622 """Migrate all instances from a node.""" 623 OP_DSC_FIELD = "node_name" 624 OP_PARAMS = [ 625 ("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"), 626 ("node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "A node UUID (for single-node LUs)"), 627 ("mode", None, ht.TMaybe(ht.TMigrationMode), "Migration type (live/non-live)"), 628 ("live", None, ht.TMaybe(ht.TBool), "Obsolete 'live' migration mode (do not use)"), 629 ("target_node", None, ht.TMaybe(ht.TNonEmptyString), "Target node for instance migration/failover"), 630 ("target_node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Target node UUID for instance migration/failover"), 631 ("allow_runtime_changes", True, ht.TBool, "Whether to allow runtime changes while migrating"), 632 ("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"), 633 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances") 634 ] 635 OP_RESULT = ht.TJobIdListOnly
636
637 -class OpNodeEvacuate(OpCode):
638 """Evacuate instances off a number of nodes.""" 639 OP_DSC_FIELD = "node_name" 640 OP_PARAMS = [ 641 ("early_release", False, ht.TBool, "Whether to release locks as soon as possible"), 642 ("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"), 643 ("node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "A node UUID (for single-node LUs)"), 644 ("remote_node", None, ht.TMaybe(ht.TNonEmptyString), "New secondary node"), 645 ("remote_node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "New secondary node UUID"), 646 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances"), 647 ("mode", None, ht.TEvacMode, "Node evacuation mode") 648 ] 649 OP_RESULT = ht.TJobIdListOnly
650
651 -class OpInstanceCreate(OpCode):
652 """Create an instance. 653 654 @ivar instance_name: Instance name 655 @ivar mode: Instance creation mode (one of L{constants.INSTANCE_CREATE_MODES}) 656 @ivar source_handshake: Signed handshake from source (remote import only) 657 @ivar source_x509_ca: Source X509 CA in PEM format (remote import only) 658 @ivar source_instance_name: Previous name of instance (remote import only) 659 @ivar source_shutdown_timeout: Shutdown timeout used for source instance 660 (remote import only) 661 662 """ 663 OP_DSC_FIELD = "instance_name" 664 OP_PARAMS = [ 665 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 666 ("force_variant", False, ht.TBool, "Whether to force an unknown OS variant"), 667 ("wait_for_sync", True, ht.TBool, "Whether to wait for the disk to synchronize"), 668 ("name_check", True, ht.TBool, "Whether to check name"), 669 ("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"), 670 ("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)"), 671 ("beparams", {}, ht.TObject(ht.TAny), "Backend parameters for instance"), 672 ("disks", None, ht.TListOf(ht.TIDiskParams), "List of instance disks"), 673 ("disk_template", None, ht.TMaybe(ht.TDiskTemplate), "Instance disk template"), 674 ("file_driver", None, ht.TMaybe(ht.TFileDriver), "Driver for file-backed disks"), 675 ("file_storage_dir", None, ht.TMaybe(ht.TNonEmptyString), "Directory for storing file-backed disks"), 676 ("hvparams", {}, ht.TObject(ht.TAny), "Hypervisor parameters for instance, hypervisor-dependent"), 677 ("hypervisor", None, ht.TMaybe(ht.THypervisor), "Selected hypervisor for an instance"), 678 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances"), 679 ("identify_defaults", False, ht.TBool, "Reset instance parameters to default if equal"), 680 ("ip_check", True, ht.TBool, "Whether to ensure instance's IP address is inactive"), 681 ("conflicts_check", True, ht.TBool, "Whether to check for conflicting IP addresses"), 682 ("mode", None, ht.TInstCreateMode, "Instance creation mode"), 683 ("nics", None, ht.TListOf(ht.TINicParams), "List of NIC (network interface) definitions"), 684 ("no_install", None, ht.TMaybe(ht.TBool), "Do not install the OS (will disable automatic start)"), 685 ("osparams", {}, ht.TObject(ht.TAny), "OS parameters for instance"), 686 ("os_type", None, ht.TMaybe(ht.TNonEmptyString), "OS type for instance installation"), 687 ("pnode", None, ht.TMaybe(ht.TNonEmptyString), "Primary node for an instance"), 688 ("pnode_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Primary node UUID for an instance"), 689 ("snode", None, ht.TMaybe(ht.TNonEmptyString), "Secondary node for an instance"), 690 ("snode_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Secondary node UUID for an instance"), 691 ("source_handshake", None, ht.TMaybe(ht.TListOf(ht.TAny)), "Signed handshake from source (remote import only)"), 692 ("source_instance_name", None, ht.TMaybe(ht.TNonEmptyString), "Source instance name (remote import only)"), 693 ("source_shutdown_timeout", 120, ht.TNonNegative(ht.TInt), "How long source instance was given to shut down (remote import only)"), 694 ("source_x509_ca", None, ht.TMaybe(ht.TNonEmptyString), "Source X509 CA in PEM format (remote import only)"), 695 ("src_node", None, ht.TMaybe(ht.TNonEmptyString), "Source node for import"), 696 ("src_node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Source node UUID for import"), 697 ("src_path", None, ht.TMaybe(ht.TNonEmptyString), "Source directory for import"), 698 ("start", True, ht.TBool, "Whether to start instance after creation"), 699 ("tags", [], ht.TListOf(ht.TNonEmptyString), "Instance tags") 700 ] 701 OP_RESULT = ht.TListOf(ht.TNonEmptyString)
702
703 -class OpInstanceMultiAlloc(OpInstanceMultiAllocBase):
704 """Allocates multiple instances.""" 705 OP_PARAMS = [ 706 ("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)"), 707 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances"), 708 ("instances", [], ht.TListOf(ht.TAny), "List of instance create opcodes describing the instances to allocate") 709 ] 710 OP_RESULT = ht.TInstanceMultiAllocResponse
711
712 -class OpInstanceReinstall(OpCode):
713 """Reinstall an instance's OS.""" 714 OP_DSC_FIELD = "instance_name" 715 OP_PARAMS = [ 716 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 717 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 718 ("force_variant", False, ht.TBool, "Whether to force an unknown OS variant"), 719 ("os_type", None, ht.TMaybe(ht.TNonEmptyString), "OS type for instance installation"), 720 ("osparams", None, ht.TMaybe(ht.TObject(ht.TAny)), "Temporary OS parameters (currently only in reinstall, might be added to install as well)") 721 ] 722 OP_RESULT = ht.TNone
723
724 -class OpInstanceRemove(OpCode):
725 """Remove an instance.""" 726 OP_DSC_FIELD = "instance_name" 727 OP_PARAMS = [ 728 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 729 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 730 ("shutdown_timeout", 120, ht.TNonNegative(ht.TInt), "How long to wait for instance to shut down"), 731 ("ignore_failures", False, ht.TBool, "Whether to ignore failures during removal") 732 ] 733 OP_RESULT = ht.TNone
734
735 -class OpInstanceRename(OpCode):
736 """Rename an instance.""" 737 OP_PARAMS = [ 738 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 739 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 740 ("new_name", None, ht.TNonEmptyString, "New instance name"), 741 ("name_check", True, ht.TBool, "Whether to check name"), 742 ("ip_check", True, ht.TBool, "Whether to ensure instance's IP address is inactive") 743 ] 744 OP_RESULT = ht.TNonEmptyString
745
746 -class OpInstanceStartup(OpCode):
747 """Startup an instance.""" 748 OP_DSC_FIELD = "instance_name" 749 OP_PARAMS = [ 750 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 751 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 752 ("force", False, ht.TBool, "Whether to force the operation"), 753 ("ignore_offline_nodes", False, ht.TBool, "Whether to ignore offline nodes"), 754 ("hvparams", {}, ht.TObject(ht.TAny), "Temporary hypervisor parameters, hypervisor-dependent"), 755 ("beparams", {}, ht.TObject(ht.TAny), "Temporary backend parameters"), 756 ("no_remember", False, ht.TBool, "Do not remember instance state changes"), 757 ("startup_paused", False, ht.TBool, "Pause instance at startup") 758 ] 759 OP_RESULT = ht.TNone
760
761 -class OpInstanceShutdown(OpCode):
762 """Shutdown an instance.""" 763 OP_DSC_FIELD = "instance_name" 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 ("force", False, ht.TBool, "Whether to force the operation"), 768 ("ignore_offline_nodes", False, ht.TBool, "Whether to ignore offline nodes"), 769 ("timeout", 120, ht.TNonNegative(ht.TInt), "How long to wait for instance to shut down"), 770 ("no_remember", False, ht.TBool, "Do not remember instance state changes") 771 ] 772 OP_RESULT = ht.TNone
773
774 -class OpInstanceReboot(OpCode):
775 """Reboot an instance.""" 776 OP_DSC_FIELD = "instance_name" 777 OP_PARAMS = [ 778 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 779 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 780 ("shutdown_timeout", 120, ht.TNonNegative(ht.TInt), "How long to wait for instance to shut down"), 781 ("ignore_secondaries", False, ht.TBool, "Whether to start the instance even if secondary disks are failing"), 782 ("reboot_type", None, ht.TRebootType, "How to reboot the instance") 783 ] 784 OP_RESULT = ht.TNone
785
786 -class OpInstanceReplaceDisks(OpCode):
787 """Replace the disks of an instance.""" 788 OP_DSC_FIELD = "instance_name" 789 OP_PARAMS = [ 790 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 791 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 792 ("early_release", False, ht.TBool, "Whether to release locks as soon as possible"), 793 ("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"), 794 ("mode", None, ht.TReplaceDisksMode, "Replacement mode"), 795 ("disks", [], ht.TListOf(ht.TDiskIndex), "List of disk indices"), 796 ("remote_node", None, ht.TMaybe(ht.TNonEmptyString), "New secondary node"), 797 ("remote_node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "New secondary node UUID"), 798 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances") 799 ] 800 OP_RESULT = ht.TNone
801
802 -class OpInstanceFailover(OpCode):
803 """Failover an instance.""" 804 OP_DSC_FIELD = "instance_name" 805 OP_PARAMS = [ 806 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 807 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 808 ("shutdown_timeout", 120, ht.TNonNegative(ht.TInt), "How long to wait for instance to shut down"), 809 ("ignore_consistency", False, ht.TBool, "Whether to ignore disk consistency"), 810 ("target_node", None, ht.TMaybe(ht.TNonEmptyString), "Target node for instance migration/failover"), 811 ("target_node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Target node UUID for instance migration/failover"), 812 ("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"), 813 ("cleanup", False, ht.TBool, "Whether a previously failed migration should be cleaned up"), 814 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances") 815 ] 816 OP_RESULT = ht.TNone
817
818 -class OpInstanceMigrate(OpCode):
819 """Migrate an instance. 820 821 This migrates (without shutting down an instance) to its secondary 822 node. 823 824 @ivar instance_name: the name of the instance 825 @ivar mode: the migration mode (live, non-live or None for auto) 826 827 """ 828 OP_DSC_FIELD = "instance_name" 829 OP_PARAMS = [ 830 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 831 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 832 ("mode", None, ht.TMaybe(ht.TMigrationMode), "Migration type (live/non-live)"), 833 ("live", None, ht.TMaybe(ht.TBool), "Obsolete 'live' migration mode (do not use)"), 834 ("target_node", None, ht.TMaybe(ht.TNonEmptyString), "Target node for instance migration/failover"), 835 ("target_node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Target node UUID for instance migration/failover"), 836 ("allow_runtime_changes", True, ht.TBool, "Whether to allow runtime changes while migrating"), 837 ("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"), 838 ("cleanup", False, ht.TBool, "Whether a previously failed migration should be cleaned up"), 839 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances"), 840 ("allow_failover", False, ht.TBool, "Whether we can fallback to failover if migration is not possible") 841 ] 842 OP_RESULT = ht.TNone
843
844 -class OpInstanceMove(OpCode):
845 """Move an instance. 846 847 This move (with shutting down an instance and data copying) to an 848 arbitrary node. 849 850 @ivar instance_name: the name of the instance 851 @ivar target_node: the destination node 852 853 """ 854 OP_DSC_FIELD = "instance_name" 855 OP_PARAMS = [ 856 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 857 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 858 ("shutdown_timeout", 120, ht.TNonNegative(ht.TInt), "How long to wait for instance to shut down"), 859 ("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"), 860 ("target_node", None, ht.TNonEmptyString, "Target node for instance move"), 861 ("target_node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Target node UUID for instance move"), 862 ("ignore_consistency", False, ht.TBool, "Whether to ignore disk consistency") 863 ] 864 OP_RESULT = ht.TNone
865
866 -class OpInstanceConsole(OpCode):
867 """Connect to an instance's console.""" 868 OP_DSC_FIELD = "instance_name" 869 OP_PARAMS = [ 870 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 871 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)") 872 ] 873 OP_RESULT = ht.TObject(ht.TAny)
874
875 -class OpInstanceActivateDisks(OpCode):
876 """Activate an instance's disks.""" 877 OP_DSC_FIELD = "instance_name" 878 OP_PARAMS = [ 879 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 880 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 881 ("ignore_size", False, ht.TBool, "Whether to ignore recorded disk size"), 882 ("wait_for_sync", False, ht.TBool, "Whether to wait for the disk to synchronize (defaults to false)") 883 ] 884 OP_RESULT = ht.TListOf(ht.TTupleOf(ht.TNonEmptyString, ht.TNonEmptyString, ht.TNonEmptyString))
885
886 -class OpInstanceDeactivateDisks(OpCode):
887 """Deactivate an instance's disks.""" 888 OP_DSC_FIELD = "instance_name" 889 OP_PARAMS = [ 890 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 891 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 892 ("force", False, ht.TBool, "Whether to force the operation") 893 ] 894 OP_RESULT = ht.TNone
895
896 -class OpInstanceRecreateDisks(OpCode):
897 """Recreate an instance's disks.""" 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 ("disks", [], ht.TRecreateDisksInfo, "Disk list for recreate disks"), 903 ("nodes", [], ht.TListOf(ht.TNonEmptyString), "New instance nodes, if relocation is desired"), 904 ("node_uuids", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "New instance node UUIDs, if relocation is desired"), 905 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances") 906 ] 907 OP_RESULT = ht.TNone
908
909 -class OpInstanceQuery(OpCode):
910 """Compute the list of instances.""" 911 OP_PARAMS = [ 912 ("output_fields", None, ht.TListOf(ht.TNonEmptyString), "Selected output fields"), 913 ("use_locking", False, ht.TBool, "Whether to use synchronization"), 914 ("names", [], ht.TListOf(ht.TNonEmptyString), "Empty list to query all instances, instance names otherwise") 915 ] 916 OP_RESULT = ht.TListOf(ht.TListOf(ht.TAny))
917
918 -class OpInstanceQueryData(OpCode):
919 """Compute the run-time status of instances.""" 920 OP_PARAMS = [ 921 ("use_locking", False, ht.TBool, "Whether to use synchronization"), 922 ("instances", [], ht.TListOf(ht.TNonEmptyString), "List of instances"), 923 ("static", False, ht.TBool, "Whether to only return configuration data without querying nodes") 924 ] 925 OP_RESULT = ht.TObject(ht.TObject(ht.TAny))
926
927 -class OpInstanceSetParams(OpCode):
928 """Change the parameters of an instance.""" 929 OP_DSC_FIELD = "instance_name" 930 OP_PARAMS = [ 931 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 932 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 933 ("force", False, ht.TBool, "Whether to force the operation"), 934 ("force_variant", False, ht.TBool, "Whether to force an unknown OS variant"), 935 ("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"), 936 ("nics", [], ht.TSetParamsMods(ht.TINicParams), "List of NIC changes"), 937 ("disks", [], ht.TSetParamsMods(ht.TIDiskParams), "List of disk changes"), 938 ("beparams", {}, ht.TObject(ht.TAny), "Backend parameters for instance"), 939 ("runtime_mem", None, ht.TMaybe(ht.TPositive(ht.TInt)), "New runtime memory"), 940 ("hvparams", {}, ht.TObject(ht.TAny), "Hypervisor parameters for instance, hypervisor-dependent"), 941 ("disk_template", None, ht.TMaybe(ht.TDiskTemplate), "Instance disk template"), 942 ("pnode", None, ht.TMaybe(ht.TNonEmptyString), "Primary node for an instance"), 943 ("pnode_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Primary node UUID for an instance"), 944 ("remote_node", None, ht.TMaybe(ht.TNonEmptyString), "Secondary node (used when changing disk template)"), 945 ("remote_node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Secondary node UUID (used when changing disk template)"), 946 ("os_name", None, ht.TMaybe(ht.TNonEmptyString), "Change the instance's OS without reinstalling the instance"), 947 ("osparams", {}, ht.TObject(ht.TAny), "OS parameters for instance"), 948 ("wait_for_sync", True, ht.TBool, "Whether to wait for the disk to synchronize"), 949 ("offline", None, ht.TMaybe(ht.TBool), "Whether to mark the instance as offline"), 950 ("conflicts_check", True, ht.TBool, "Whether to check for conflicting IP addresses"), 951 ("hotplug", False, ht.TBool, ""), 952 ("hotplug_if_possible", False, ht.TBool, "") 953 ] 954 OP_RESULT = ht.TListOf(ht.TTupleOf(ht.TNonEmptyString, ht.TAny))
955
956 -class OpInstanceGrowDisk(OpCode):
957 """Grow a disk of an instance.""" 958 OP_DSC_FIELD = "instance_name" 959 OP_PARAMS = [ 960 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 961 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 962 ("wait_for_sync", True, ht.TBool, "Whether to wait for the disk to synchronize"), 963 ("disk", None, ht.TDiskIndex, "Disk index for e.g. grow disk"), 964 ("amount", None, ht.TNonNegative(ht.TInt), "Disk amount to add or grow to"), 965 ("absolute", False, ht.TBool, "Whether the amount parameter is an absolute target or a relative one") 966 ] 967 OP_RESULT = ht.TNone
968
969 -class OpInstanceChangeGroup(OpCode):
970 """Moves an instance to another node group.""" 971 OP_DSC_FIELD = "instance_name" 972 OP_PARAMS = [ 973 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 974 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 975 ("early_release", False, ht.TBool, "Whether to release locks as soon as possible"), 976 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances"), 977 ("target_groups", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "Destination group names or UUIDs (defaults to \"all but current group\")") 978 ] 979 OP_RESULT = ht.TJobIdListOnly
980
981 -class OpGroupAdd(OpCode):
982 """Add a node group to the cluster.""" 983 OP_DSC_FIELD = "group_name" 984 OP_PARAMS = [ 985 ("group_name", None, ht.TNonEmptyString, "Group name"), 986 ("alloc_policy", None, ht.TMaybe(ht.TAllocPolicy), "Instance allocation policy"), 987 ("ndparams", None, ht.TMaybe(ht.TObject(ht.TAny)), "Default node parameters for group"), 988 ("diskparams", None, ht.TMaybe(ht.TDictOf(ht.TDiskTemplate, ht.TObject(ht.TAny))), "Disk templates' parameter defaults"), 989 ("hv_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set hypervisor states"), 990 ("disk_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set disk states"), 991 ("ipolicy", None, ht.TMaybe(ht.TObject(ht.TAny)), "Group-wide ipolicy specs") 992 ] 993 OP_RESULT = ht.TNone
994
995 -class OpGroupAssignNodes(OpCode):
996 """Assign nodes to a node group.""" 997 OP_DSC_FIELD = "group_name" 998 OP_PARAMS = [ 999 ("group_name", None, ht.TNonEmptyString, "Group name"), 1000 ("force", False, ht.TBool, "Whether to force the operation"), 1001 ("nodes", None, ht.TListOf(ht.TNonEmptyString), "List of nodes to assign"), 1002 ("node_uuids", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "List of node UUIDs to assign") 1003 ] 1004 OP_RESULT = ht.TNone
1005
1006 -class OpGroupQuery(OpCode):
1007 """Compute the list of node groups.""" 1008 OP_PARAMS = [ 1009 ("output_fields", None, ht.TListOf(ht.TNonEmptyString), "Selected output fields"), 1010 ("names", [], ht.TListOf(ht.TNonEmptyString), "Empty list to query all groups, group names otherwise") 1011 ] 1012 OP_RESULT = ht.TListOf(ht.TListOf(ht.TAny))
1013
1014 -class OpGroupSetParams(OpCode):
1015 """Change the parameters of a node group.""" 1016 OP_DSC_FIELD = "group_name" 1017 OP_PARAMS = [ 1018 ("group_name", None, ht.TNonEmptyString, "Group name"), 1019 ("alloc_policy", None, ht.TMaybe(ht.TAllocPolicy), "Instance allocation policy"), 1020 ("ndparams", None, ht.TMaybe(ht.TObject(ht.TAny)), "Default node parameters for group"), 1021 ("diskparams", None, ht.TMaybe(ht.TDictOf(ht.TDiskTemplate, ht.TObject(ht.TAny))), "Disk templates' parameter defaults"), 1022 ("hv_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set hypervisor states"), 1023 ("disk_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set disk states"), 1024 ("ipolicy", None, ht.TMaybe(ht.TObject(ht.TAny)), "Group-wide ipolicy specs") 1025 ] 1026 OP_RESULT = ht.TListOf(ht.TTupleOf(ht.TNonEmptyString, ht.TAny))
1027
1028 -class OpGroupRemove(OpCode):
1029 """Remove a node group from the cluster.""" 1030 OP_DSC_FIELD = "group_name" 1031 OP_PARAMS = [ 1032 ("group_name", None, ht.TNonEmptyString, "Group name") 1033 ] 1034 OP_RESULT = ht.TNone
1035
1036 -class OpGroupRename(OpCode):
1037 """Rename a node group in the cluster.""" 1038 OP_PARAMS = [ 1039 ("group_name", None, ht.TNonEmptyString, "Group name"), 1040 ("new_name", None, ht.TNonEmptyString, "New group name") 1041 ] 1042 OP_RESULT = ht.TNonEmptyString
1043
1044 -class OpGroupEvacuate(OpCode):
1045 """Evacuate a node group in the cluster.""" 1046 OP_DSC_FIELD = "group_name" 1047 OP_PARAMS = [ 1048 ("group_name", None, ht.TNonEmptyString, "Group name"), 1049 ("early_release", False, ht.TBool, "Whether to release locks as soon as possible"), 1050 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances"), 1051 ("target_groups", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "Destination group names or UUIDs (defaults to \"all but current group\")"), 1052 ("sequential", False, ht.TBool, "Sequential job execution"), 1053 ("force_failover", False, ht.TBool, "Disallow migration moves and always use failovers") 1054 ] 1055 OP_RESULT = ht.TJobIdListOnly
1056
1057 -class OpOsDiagnose(OpCode):
1058 """Compute the list of guest operating systems.""" 1059 OP_PARAMS = [ 1060 ("output_fields", None, ht.TListOf(ht.TNonEmptyString), "Selected output fields"), 1061 ("names", [], ht.TListOf(ht.TNonEmptyString), "Which operating systems to diagnose") 1062 ] 1063 OP_RESULT = ht.TListOf(ht.TListOf(ht.TAny))
1064
1065 -class OpExtStorageDiagnose(OpCode):
1066 """Compute the list of external storage providers.""" 1067 OP_PARAMS = [ 1068 ("output_fields", None, ht.TListOf(ht.TNonEmptyString), "Selected output fields"), 1069 ("names", [], ht.TListOf(ht.TNonEmptyString), "Which ExtStorage Provider to diagnose") 1070 ] 1071 OP_RESULT = ht.TListOf(ht.TListOf(ht.TAny))
1072
1073 -class OpBackupQuery(OpCode):
1074 """Compute the list of exported images.""" 1075 OP_PARAMS = [ 1076 ("use_locking", False, ht.TBool, "Whether to use synchronization"), 1077 ("nodes", [], ht.TListOf(ht.TNonEmptyString), "Empty list to query all nodes, node names otherwise") 1078 ] 1079 OP_RESULT = ht.TObject(ht.TOr(ht.TBool, ht.TListOf(ht.TNonEmptyString)))
1080
1081 -class OpBackupPrepare(OpCode):
1082 """Prepares an instance export. 1083 1084 @ivar instance_name: Instance name 1085 @ivar mode: Export mode (one of L{constants.EXPORT_MODES}) 1086 1087 """ 1088 OP_DSC_FIELD = "instance_name" 1089 OP_PARAMS = [ 1090 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 1091 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 1092 ("mode", None, ht.TExportMode, "Export mode") 1093 ] 1094 OP_RESULT = ht.TMaybe(ht.TObject(ht.TAny))
1095
1096 -class OpBackupExport(OpCode):
1097 """Export an instance. 1098 1099 For local exports, the export destination is the node name. For 1100 remote exports, the export destination is a list of tuples, each 1101 consisting of hostname/IP address, port, magic, HMAC and HMAC 1102 salt. The HMAC is calculated using the cluster domain secret over 1103 the value "${index}:${hostname}:${port}". The destination X509 CA 1104 must be a signed certificate. 1105 1106 @ivar mode: Export mode (one of L{constants.EXPORT_MODES}) 1107 @ivar target_node: Export destination 1108 @ivar x509_key_name: X509 key to use (remote export only) 1109 @ivar destination_x509_ca: Destination X509 CA in PEM format (remote 1110 export only) 1111 1112 """ 1113 OP_DSC_FIELD = "instance_name" 1114 OP_PARAMS = [ 1115 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 1116 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 1117 ("shutdown_timeout", 120, ht.TNonNegative(ht.TInt), "How long to wait for instance to shut down"), 1118 ("target_node", None, ht.TExportTarget, "Target node (depends on export mode)"), 1119 ("target_node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Target node UUID (if local export)"), 1120 ("shutdown", True, ht.TBool, "Whether to shutdown the instance before export"), 1121 ("remove_instance", False, ht.TBool, "Whether to remove instance after export"), 1122 ("ignore_remove_failures", False, ht.TBool, "Whether to ignore failures while removing instances"), 1123 ("mode", "local", ht.TExportMode, "Export mode"), 1124 ("x509_key_name", None, ht.TMaybe(ht.TListOf(ht.TAny)), "Name of X509 key (remote export only)"), 1125 ("destination_x509_ca", None, ht.TMaybe(ht.TNonEmptyString), "Destination X509 CA (remote export only)") 1126 ] 1127 OP_RESULT = ht.TTupleOf(ht.TBool, ht.TListOf(ht.TBool))
1128
1129 -class OpBackupRemove(OpCode):
1130 """Remove an instance's export.""" 1131 OP_DSC_FIELD = "instance_name" 1132 OP_PARAMS = [ 1133 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 1134 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)") 1135 ] 1136 OP_RESULT = ht.TNone
1137
1138 -class OpTagsGet(OpCode):
1139 """Returns the tags of the given object.""" 1140 OP_DSC_FIELD = "name" 1141 OP_PARAMS = [ 1142 ("kind", None, ht.TTagKind, "Tag kind"), 1143 ("use_locking", False, ht.TBool, "Whether to use synchronization"), 1144 ("name", None, ht.TMaybe(ht.TString), "Name of object to retrieve tags from") 1145 ] 1146 OP_RESULT = ht.TListOf(ht.TNonEmptyString)
1147
1148 -class OpTagsSearch(OpCode):
1149 """Searches the tags in the cluster for a given pattern.""" 1150 OP_DSC_FIELD = "pattern" 1151 OP_PARAMS = [ 1152 ("pattern", None, ht.TNonEmptyString, "Search pattern (regular expression)") 1153 ] 1154 OP_RESULT = ht.TListOf(ht.TTupleOf(ht.TNonEmptyString, ht.TNonEmptyString))
1155
1156 -class OpTagsSet(OpCode):
1157 """Add a list of tags on a given object.""" 1158 OP_PARAMS = [ 1159 ("kind", None, ht.TTagKind, "Tag kind"), 1160 ("tags", None, ht.TListOf(ht.TString), "List of tag names"), 1161 ("name", None, ht.TMaybe(ht.TString), "Name of object where tag(s) should be added") 1162 ] 1163 OP_RESULT = ht.TNone
1164
1165 -class OpTagsDel(OpCode):
1166 """Remove a list of tags from a given object.""" 1167