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 ("diskparams", None, ht.TMaybe(ht.TDictOf(ht.TDiskTemplate, ht.TObject(ht.TAny))), "Disk templates' parameter defaults"), 395 ("candidate_pool_size", None, ht.TMaybe(ht.TPositive(ht.TInt)), "Master candidate pool size"), 396 ("max_running_jobs", None, ht.TMaybe(ht.TPositive(ht.TInt)), "Maximal number of jobs to run simultaneously"), 397 ("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)"), 398 ("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)"), 399 ("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"), 400 ("maintain_node_health", None, ht.TMaybe(ht.TBool), "Whether to automatically maintain node health"), 401 ("prealloc_wipe_disks", None, ht.TMaybe(ht.TBool), "Whether to wipe disks before allocating them to instances"), 402 ("nicparams", None, ht.TMaybe(ht.TINicParams), "Cluster-wide NIC parameter defaults"), 403 ("ndparams", None, ht.TMaybe(ht.TObject(ht.TAny)), "Cluster-wide node parameter defaults"), 404 ("ipolicy", None, ht.TMaybe(ht.TObject(ht.TAny)), "Cluster-wide ipolicy specs"), 405 ("drbd_helper", None, ht.TMaybe(ht.TString), "DRBD helper program"), 406 ("default_iallocator", None, ht.TMaybe(ht.TString), "Default iallocator for cluster"), 407 ("default_iallocator_params", None, ht.TMaybe(ht.TObject(ht.TAny)), "Default iallocator parameters for cluster"), 408 ("master_netdev", None, ht.TMaybe(ht.TString), "Master network device"), 409 ("master_netmask", None, ht.TMaybe(ht.TNonNegative(ht.TInt)), "Netmask of the master IP"), 410 ("reserved_lvs", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "List of reserved LVs"), 411 ("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"), 412 ("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"), 413 ("use_external_mip_script", None, ht.TMaybe(ht.TBool), "Whether to use an external master IP address setup script"), 414 ("enabled_disk_templates", None, ht.TMaybe(ht.TListOf(ht.TDiskTemplate)), "List of enabled disk templates"), 415 ("modify_etc_hosts", None, ht.TMaybe(ht.TBool), ""), 416 ("file_storage_dir", None, ht.TMaybe(ht.TString), ""), 417 ("shared_file_storage_dir", None, ht.TMaybe(ht.TString), ""), 418 ("gluster_storage_dir", None, ht.TMaybe(ht.TString), ""), 419 ("enabled_user_shutdown", None, ht.TMaybe(ht.TBool), "Whether user shutdown is enabled cluster wide") 420 ] 421 OP_RESULT = ht.TNone
422
423 -class OpClusterRedistConf(OpCode):
424 """Force a full push of the cluster configuration.""" 425 OP_PARAMS = [ 426 ] 427 OP_RESULT = ht.TNone
428
429 -class OpClusterActivateMasterIp(OpCode):
430 """Activate the master IP on the master node.""" 431 OP_PARAMS = [ 432 ] 433 OP_RESULT = ht.TNone
434
435 -class OpClusterDeactivateMasterIp(OpCode):
436 """Deactivate the master IP on the master node.""" 437 OP_PARAMS = [ 438 ] 439 OP_RESULT = ht.TNone
440
441 -class OpClusterRenewCrypto(OpCode):
442 """Renews the cluster node's SSL client certificates.""" 443 OP_PARAMS = [ 444 ] 445 OP_RESULT = ht.TNone
446
447 -class OpQuery(OpCode):
448 """Query for resources/items. 449 450 @ivar what: Resources to query for, must be one of L{constants.QR_VIA_OP} 451 @ivar fields: List of fields to retrieve 452 @ivar qfilter: Query filter 453 454 """ 455 OP_DSC_FIELD = "what" 456 OP_PARAMS = [ 457 ("what", None, ht.TQueryTypeOp, "Resource(s) to query for"), 458 ("use_locking", False, ht.TBool, "Whether to use synchronization"), 459 ("fields", None, ht.TListOf(ht.TNonEmptyString), "Requested fields"), 460 ("qfilter", None, ht.TMaybe(ht.TListOf(ht.TAny)), "Query filter") 461 ] 462 OP_RESULT = ht.TQueryResponse
463
464 -class OpQueryFields(OpCode):
465 """Query for available resource/item fields. 466 467 @ivar what: Resources to query for, must be one of L{constants.QR_VIA_OP} 468 @ivar fields: List of fields to retrieve 469 470 """ 471 OP_DSC_FIELD = "what" 472 OP_PARAMS = [ 473 ("what", None, ht.TQueryTypeOp, "Resource(s) to query for"), 474 ("fields", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "Requested fields; if not given, all are returned") 475 ] 476 OP_RESULT = ht.TQueryFieldsResponse
477
478 -class OpOobCommand(OpCode):
479 """Interact with OOB.""" 480 OP_PARAMS = [ 481 ("node_names", [], ht.TListOf(ht.TNonEmptyString), "List of node names to run the OOB command against"), 482 ("node_uuids", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "List of node UUIDs to run the OOB command against"), 483 ("command", None, ht.TOobCommand, "OOB command to run"), 484 ("timeout", 60, ht.TInt, "Timeout before the OOB helper will be terminated"), 485 ("ignore_status", False, ht.TBool, "Ignores the node offline status for power off"), 486 ("power_delay", 2.0, ht.TDouble, "Time in seconds to wait between powering on nodes") 487 ] 488 OP_RESULT = ht.TListOf(ht.TListOf(ht.TTupleOf(ht.TQueryResultCode, ht.TAny)))
489
490 -class OpRestrictedCommand(OpCode):
491 """Runs a restricted command on node(s).""" 492 OP_PARAMS = [ 493 ("use_locking", False, ht.TBool, "Whether to use synchronization"), 494 ("nodes", None, ht.TListOf(ht.TNonEmptyString), "Nodes on which the command should be run (at least one)"), 495 ("node_uuids", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "Node UUIDs on which the command should be run (at least one)"), 496 ("command", None, ht.TNonEmptyString, "Restricted command name") 497 ] 498 OP_RESULT = ht.TListOf(ht.TTupleOf(ht.TBool, ht.TString))
499
500 -class OpNodeRemove(OpCode):
501 """Remove a node. 502 503 @type node_name: C{str} 504 @ivar node_name: The name of the node to remove. If the node still has 505 instances on it, the operation will fail. 506 507 """ 508 OP_DSC_FIELD = "node_name" 509 OP_PARAMS = [ 510 ("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"), 511 ("node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "A node UUID (for single-node LUs)") 512 ] 513 OP_RESULT = ht.TNone
514
515 -class OpNodeAdd(OpCode):
516 """Add a node to the cluster. 517 518 @type node_name: C{str} 519 @ivar node_name: The name of the node to add. This can be a short name, 520 but it will be expanded to the FQDN. 521 @type primary_ip: IP address 522 @ivar primary_ip: The primary IP of the node. This will be ignored when 523 the opcode is submitted, but will be filled during the 524 node add (so it will be visible in the job query). 525 @type secondary_ip: IP address 526 @ivar secondary_ip: The secondary IP of the node. This needs to be passed 527 if the cluster has been initialized in 'dual-network' 528 mode, otherwise it must not be given. 529 @type readd: C{bool} 530 @ivar readd: Whether to re-add an existing node to the cluster. If 531 this is not passed, then the operation will abort if the node 532 name is already in the cluster; use this parameter to 533 'repair' a node that had its configuration broken, or was 534 reinstalled without removal from the cluster. 535 @type group: C{str} 536 @ivar group: The node group to which this node will belong. 537 @type vm_capable: C{bool} 538 @ivar vm_capable: The vm_capable node attribute 539 @type master_capable: C{bool} 540 @ivar master_capable: The master_capable node attribute 541 542 """ 543 OP_DSC_FIELD = "node_name" 544 OP_PARAMS = [ 545 ("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"), 546 ("hv_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set hypervisor states"), 547 ("disk_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set disk states"), 548 ("primary_ip", None, ht.TMaybe(ht.TNonEmptyString), "Primary IP address"), 549 ("secondary_ip", None, ht.TMaybe(ht.TNonEmptyString), "Secondary IP address"), 550 ("readd", False, ht.TBool, "Whether node is re-added to cluster"), 551 ("group", None, ht.TMaybe(ht.TNonEmptyString), "Initial node group"), 552 ("master_capable", None, ht.TMaybe(ht.TBool), "Whether node can become master or master candidate"), 553 ("vm_capable", None, ht.TMaybe(ht.TBool), "Whether node can host instances"), 554 ("ndparams", None, ht.TMaybe(ht.TObject(ht.TAny)), "Node parameters") 555 ] 556 OP_RESULT = ht.TNone
557
558 -class OpNodeQueryvols(OpCode):
559 """Get list of volumes on node.""" 560 OP_PARAMS = [ 561 ("output_fields", None, ht.TListOf(ht.TNonEmptyString), "Selected output fields"), 562 ("nodes", [], ht.TListOf(ht.TNonEmptyString), "Empty list to query all nodes, node names otherwise") 563 ] 564 OP_RESULT = ht.TListOf(ht.TAny)
565
566 -class OpNodeQueryStorage(OpCode):
567 """Get information on storage for node(s).""" 568 OP_PARAMS = [ 569 ("output_fields", None, ht.TListOf(ht.TNonEmptyString), "Selected output fields"), 570 ("storage_type", None, ht.TMaybe(ht.TStorageType), "Storage type"), 571 ("nodes", [], ht.TListOf(ht.TNonEmptyString), "Empty list to query all, list of names to query otherwise"), 572 ("name", None, ht.TMaybe(ht.TNonEmptyString), "Storage name") 573 ] 574 OP_RESULT = ht.TListOf(ht.TListOf(ht.TAny))
575
576 -class OpNodeModifyStorage(OpCode):
577 """Modifies the properies of a storage unit""" 578 OP_DSC_FIELD = "node_name" 579 OP_PARAMS = [ 580 ("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"), 581 ("node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "A node UUID (for single-node LUs)"), 582 ("storage_type", None, ht.TStorageType, "Storage type"), 583 ("name", None, ht.TMaybe(ht.TNonEmptyString), "Storage name"), 584 ("changes", None, ht.TObject(ht.TAny), "Requested storage changes") 585 ] 586 OP_RESULT = ht.TNone
587
588 -class OpRepairNodeStorage(OpCode):
589 """Repairs the volume group on a node.""" 590 OP_DSC_FIELD = "node_name" 591 OP_PARAMS = [ 592 ("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"), 593 ("node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "A node UUID (for single-node LUs)"), 594 ("storage_type", None, ht.TStorageType, "Storage type"), 595 ("name", None, ht.TMaybe(ht.TNonEmptyString), "Storage name"), 596 ("ignore_consistency", False, ht.TBool, "Whether to ignore disk consistency") 597 ] 598 OP_RESULT = ht.TNone
599
600 -class OpNodeSetParams(OpCode):
601 """Change the parameters of a node.""" 602 OP_DSC_FIELD = "node_name" 603 OP_PARAMS = [ 604 ("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"), 605 ("node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "A node UUID (for single-node LUs)"), 606 ("force", False, ht.TBool, "Whether to force the operation"), 607 ("hv_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set hypervisor states"), 608 ("disk_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set disk states"), 609 ("master_candidate", None, ht.TMaybe(ht.TBool), "Whether the node should become a master candidate"), 610 ("offline", None, ht.TMaybe(ht.TBool), "Whether to mark the node offline"), 611 ("drained", None, ht.TMaybe(ht.TBool), "Whether to mark the node as drained"), 612 ("auto_promote", False, ht.TBool, "Whether node(s) should be promoted to master candidate if necessary"), 613 ("master_capable", None, ht.TMaybe(ht.TBool), "Whether node can become master or master candidate"), 614 ("vm_capable", None, ht.TMaybe(ht.TBool), "Whether node can host instances"), 615 ("secondary_ip", None, ht.TMaybe(ht.TNonEmptyString), "Secondary IP address"), 616 ("ndparams", None, ht.TMaybe(ht.TObject(ht.TAny)), "Node parameters"), 617 ("powered", None, ht.TMaybe(ht.TBool), "Whether the node should be marked as powered") 618 ] 619 OP_RESULT = ht.TListOf(ht.TTupleOf(ht.TNonEmptyString, ht.TAny))
620
621 -class OpNodePowercycle(OpCode):
622 """Tries to powercycle 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 ("force", False, ht.TBool, "Whether to force the operation") 628 ] 629 OP_RESULT = ht.TMaybe(ht.TNonEmptyString)
630
631 -class OpNodeMigrate(OpCode):
632 """Migrate all instances from a node.""" 633 OP_DSC_FIELD = "node_name" 634 OP_PARAMS = [ 635 ("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"), 636 ("node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "A node UUID (for single-node LUs)"), 637 ("mode", None, ht.TMaybe(ht.TMigrationMode), "Migration type (live/non-live)"), 638 ("live", None, ht.TMaybe(ht.TBool), "Obsolete 'live' migration mode (do not use)"), 639 ("target_node", None, ht.TMaybe(ht.TNonEmptyString), "Target node for instance migration/failover"), 640 ("target_node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Target node UUID for instance migration/failover"), 641 ("allow_runtime_changes", True, ht.TBool, "Whether to allow runtime changes while migrating"), 642 ("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"), 643 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances") 644 ] 645 OP_RESULT = ht.TJobIdListOnly
646
647 -class OpNodeEvacuate(OpCode):
648 """Evacuate instances off a number of nodes.""" 649 OP_DSC_FIELD = "node_name" 650 OP_PARAMS = [ 651 ("early_release", False, ht.TBool, "Whether to release locks as soon as possible"), 652 ("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"), 653 ("node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "A node UUID (for single-node LUs)"), 654 ("remote_node", None, ht.TMaybe(ht.TNonEmptyString), "New secondary node"), 655 ("remote_node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "New secondary node UUID"), 656 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances"), 657 ("mode", None, ht.TEvacMode, "Node evacuation mode") 658 ] 659 OP_RESULT = ht.TJobIdListOnly
660
661 -class OpInstanceCreate(OpCode):
662 """Create an instance. 663 664 @ivar instance_name: Instance name 665 @ivar mode: Instance creation mode (one of L{constants.INSTANCE_CREATE_MODES}) 666 @ivar source_handshake: Signed handshake from source (remote import only) 667 @ivar source_x509_ca: Source X509 CA in PEM format (remote import only) 668 @ivar source_instance_name: Previous name of instance (remote import only) 669 @ivar source_shutdown_timeout: Shutdown timeout used for source instance 670 (remote import only) 671 672 """ 673 OP_DSC_FIELD = "instance_name" 674 OP_PARAMS = [ 675 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 676 ("force_variant", False, ht.TBool, "Whether to force an unknown OS variant"), 677 ("wait_for_sync", True, ht.TBool, "Whether to wait for the disk to synchronize"), 678 ("name_check", True, ht.TBool, "Whether to check name"), 679 ("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"), 680 ("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)"), 681 ("beparams", {}, ht.TObject(ht.TAny), "Backend parameters for instance"), 682 ("disks", None, ht.TListOf(ht.TIDiskParams), "List of instance disks"), 683 ("disk_template", None, ht.TMaybe(ht.TDiskTemplate), "Instance disk template"), 684 ("file_driver", None, ht.TMaybe(ht.TFileDriver), "Driver for file-backed disks"), 685 ("file_storage_dir", None, ht.TMaybe(ht.TNonEmptyString), "Directory for storing file-backed disks"), 686 ("hvparams", {}, ht.TObject(ht.TAny), "Hypervisor parameters for instance, hypervisor-dependent"), 687 ("hypervisor", None, ht.TMaybe(ht.THypervisor), "Selected hypervisor for an instance"), 688 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances"), 689 ("identify_defaults", False, ht.TBool, "Reset instance parameters to default if equal"), 690 ("ip_check", True, ht.TBool, "Whether to ensure instance's IP address is inactive"), 691 ("conflicts_check", True, ht.TBool, "Whether to check for conflicting IP addresses"), 692 ("mode", None, ht.TInstCreateMode, "Instance creation mode"), 693 ("nics", None, ht.TListOf(ht.TINicParams), "List of NIC (network interface) definitions"), 694 ("no_install", None, ht.TMaybe(ht.TBool), "Do not install the OS (will disable automatic start)"), 695 ("osparams", {}, ht.TObject(ht.TAny), "OS parameters for instance"), 696 ("os_type", None, ht.TMaybe(ht.TNonEmptyString), "OS type for instance installation"), 697 ("pnode", None, ht.TMaybe(ht.TNonEmptyString), "Primary node for an instance"), 698 ("pnode_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Primary node UUID for an instance"), 699 ("snode", None, ht.TMaybe(ht.TNonEmptyString), "Secondary node for an instance"), 700 ("snode_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Secondary node UUID for an instance"), 701 ("source_handshake", None, ht.TMaybe(ht.TListOf(ht.TAny)), "Signed handshake from source (remote import only)"), 702 ("source_instance_name", None, ht.TMaybe(ht.TNonEmptyString), "Source instance name (remote import only)"), 703 ("source_shutdown_timeout", 120, ht.TNonNegative(ht.TInt), "How long source instance was given to shut down (remote import only)"), 704 ("source_x509_ca", None, ht.TMaybe(ht.TNonEmptyString), "Source X509 CA in PEM format (remote import only)"), 705 ("src_node", None, ht.TMaybe(ht.TNonEmptyString), "Source node for import"), 706 ("src_node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Source node UUID for import"), 707 ("src_path", None, ht.TMaybe(ht.TNonEmptyString), "Source directory for import"), 708 ("compress", "none", ht.TImportExportCompression, "Compression mode to use for moves during backups/imports"), 709 ("start", True, ht.TBool, "Whether to start instance after creation"), 710 ("tags", [], ht.TListOf(ht.TNonEmptyString), "Instance tags") 711 ] 712 OP_RESULT = ht.TListOf(ht.TNonEmptyString)
713
714 -class OpInstanceMultiAlloc(OpInstanceMultiAllocBase):
715 """Allocates multiple instances.""" 716 OP_PARAMS = [ 717 ("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)"), 718 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances"), 719 ("instances", [], ht.TListOf(ht.TAny), "List of instance create opcodes describing the instances to allocate") 720 ] 721 OP_RESULT = ht.TInstanceMultiAllocResponse
722
723 -class OpInstanceReinstall(OpCode):
724 """Reinstall an instance's OS.""" 725 OP_DSC_FIELD = "instance_name" 726 OP_PARAMS = [ 727 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 728 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 729 ("force_variant", False, ht.TBool, "Whether to force an unknown OS variant"), 730 ("os_type", None, ht.TMaybe(ht.TNonEmptyString), "OS type for instance installation"), 731 ("osparams", None, ht.TMaybe(ht.TObject(ht.TAny)), "Temporary OS parameters (currently only in reinstall, might be added to install as well)") 732 ] 733 OP_RESULT = ht.TNone
734
735 -class OpInstanceRemove(OpCode):
736 """Remove an instance.""" 737 OP_DSC_FIELD = "instance_name" 738 OP_PARAMS = [ 739 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 740 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 741 ("shutdown_timeout", 120, ht.TNonNegative(ht.TInt), "How long to wait for instance to shut down"), 742 ("ignore_failures", False, ht.TBool, "Whether to ignore failures during removal") 743 ] 744 OP_RESULT = ht.TNone
745
746 -class OpInstanceRename(OpCode):
747 """Rename an instance.""" 748 OP_PARAMS = [ 749 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 750 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 751 ("new_name", None, ht.TNonEmptyString, "New instance name"), 752 ("name_check", True, ht.TBool, "Whether to check name"), 753 ("ip_check", True, ht.TBool, "Whether to ensure instance's IP address is inactive") 754 ] 755 OP_RESULT = ht.TNonEmptyString
756
757 -class OpInstanceStartup(OpCode):
758 """Startup an instance.""" 759 OP_DSC_FIELD = "instance_name" 760 OP_PARAMS = [ 761 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 762 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 763 ("force", False, ht.TBool, "Whether to force the operation"), 764 ("ignore_offline_nodes", False, ht.TBool, "Whether to ignore offline nodes"), 765 ("hvparams", {}, ht.TObject(ht.TAny), "Temporary hypervisor parameters, hypervisor-dependent"), 766 ("beparams", {}, ht.TObject(ht.TAny), "Temporary backend parameters"), 767 ("no_remember", False, ht.TBool, "Do not remember instance state changes"), 768 ("startup_paused", False, ht.TBool, "Pause instance at startup"), 769 ("shutdown_timeout", 120, ht.TNonNegative(ht.TInt), "How long to wait for instance to shut down") 770 ] 771 OP_RESULT = ht.TNone
772
773 -class OpInstanceShutdown(OpCode):
774 """Shutdown 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 ("timeout", 120, ht.TNonNegative(ht.TInt), "How long to wait for instance to shut down"), 782 ("no_remember", False, ht.TBool, "Do not remember instance state changes"), 783 ("admin_state_source", None, ht.TMaybe(ht.TAdminStateSource), "Who last changed the instance admin state") 784 ] 785 OP_RESULT = ht.TNone
786
787 -class OpInstanceReboot(OpCode):
788 """Reboot an instance.""" 789 OP_DSC_FIELD = "instance_name" 790 OP_PARAMS = [ 791 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 792 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 793 ("shutdown_timeout", 120, ht.TNonNegative(ht.TInt), "How long to wait for instance to shut down"), 794 ("ignore_secondaries", False, ht.TBool, "Whether to start the instance even if secondary disks are failing"), 795 ("reboot_type", None, ht.TRebootType, "How to reboot the instance") 796 ] 797 OP_RESULT = ht.TNone
798
799 -class OpInstanceReplaceDisks(OpCode):
800 """Replace the disks of an instance.""" 801 OP_DSC_FIELD = "instance_name" 802 OP_PARAMS = [ 803 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 804 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 805 ("early_release", False, ht.TBool, "Whether to release locks as soon as possible"), 806 ("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"), 807 ("mode", None, ht.TReplaceDisksMode, "Replacement mode"), 808 ("disks", [], ht.TListOf(ht.TDiskIndex), "List of disk indices"), 809 ("remote_node", None, ht.TMaybe(ht.TNonEmptyString), "New secondary node"), 810 ("remote_node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "New secondary node UUID"), 811 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances") 812 ] 813 OP_RESULT = ht.TNone
814
815 -class OpInstanceFailover(OpCode):
816 """Failover 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 ("shutdown_timeout", 120, ht.TNonNegative(ht.TInt), "How long to wait for instance to shut down"), 822 ("ignore_consistency", False, ht.TBool, "Whether to ignore disk consistency"), 823 ("target_node", None, ht.TMaybe(ht.TNonEmptyString), "Target node for instance migration/failover"), 824 ("target_node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Target node UUID for instance migration/failover"), 825 ("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"), 826 ("cleanup", False, ht.TBool, "Whether a previously failed migration should be cleaned up"), 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 OpInstanceMigrate(OpCode):
832 """Migrate an instance. 833 834 This migrates (without shutting down an instance) to its secondary 835 node. 836 837 @ivar instance_name: the name of the instance 838 @ivar mode: the migration mode (live, non-live or None for auto) 839 840 """ 841 OP_DSC_FIELD = "instance_name" 842 OP_PARAMS = [ 843 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 844 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 845 ("mode", None, ht.TMaybe(ht.TMigrationMode), "Migration type (live/non-live)"), 846 ("live", None, ht.TMaybe(ht.TBool), "Obsolete 'live' migration mode (do not use)"), 847 ("target_node", None, ht.TMaybe(ht.TNonEmptyString), "Target node for instance migration/failover"), 848 ("target_node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Target node UUID for instance migration/failover"), 849 ("allow_runtime_changes", True, ht.TBool, "Whether to allow runtime changes while migrating"), 850 ("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"), 851 ("cleanup", False, ht.TBool, "Whether a previously failed migration should be cleaned up"), 852 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances"), 853 ("allow_failover", False, ht.TBool, "Whether we can fallback to failover if migration is not possible") 854 ] 855 OP_RESULT = ht.TNone
856
857 -class OpInstanceMove(OpCode):
858 """Move an instance. 859 860 This move (with shutting down an instance and data copying) to an 861 arbitrary node. 862 863 @ivar instance_name: the name of the instance 864 @ivar target_node: the destination node 865 866 """ 867 OP_DSC_FIELD = "instance_name" 868 OP_PARAMS = [ 869 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 870 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 871 ("shutdown_timeout", 120, ht.TNonNegative(ht.TInt), "How long to wait for instance to shut down"), 872 ("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"), 873 ("target_node", None, ht.TNonEmptyString, "Target node for instance move"), 874 ("target_node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Target node UUID for instance move"), 875 ("compress", "none", ht.TImportExportCompression, "Compression mode to use during instance moves"), 876 ("ignore_consistency", False, ht.TBool, "Whether to ignore disk consistency") 877 ] 878 OP_RESULT = ht.TNone
879
880 -class OpInstanceConsole(OpCode):
881 """Connect to an instance's console.""" 882 OP_DSC_FIELD = "instance_name" 883 OP_PARAMS = [ 884 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 885 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)") 886 ] 887 OP_RESULT = ht.TObject(ht.TAny)
888
889 -class OpInstanceActivateDisks(OpCode):
890 """Activate an instance's disks.""" 891 OP_DSC_FIELD = "instance_name" 892 OP_PARAMS = [ 893 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 894 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 895 ("ignore_size", False, ht.TBool, "Whether to ignore recorded disk size"), 896 ("wait_for_sync", False, ht.TBool, "Whether to wait for the disk to synchronize (defaults to false)") 897 ] 898 OP_RESULT = ht.TListOf(ht.TTupleOf(ht.TNonEmptyString, ht.TNonEmptyString, ht.TNonEmptyString))
899
900 -class OpInstanceDeactivateDisks(OpCode):
901 """Deactivate an instance's disks.""" 902 OP_DSC_FIELD = "instance_name" 903 OP_PARAMS = [ 904 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 905 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 906 ("force", False, ht.TBool, "Whether to force the operation") 907 ] 908 OP_RESULT = ht.TNone
909
910 -class OpInstanceRecreateDisks(OpCode):
911 """Recreate an instance's disks.""" 912 OP_DSC_FIELD = "instance_name" 913 OP_PARAMS = [ 914 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 915 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 916 ("disks", [], ht.TRecreateDisksInfo, "Disk list for recreate disks"), 917 ("nodes", [], ht.TListOf(ht.TNonEmptyString), "New instance nodes, if relocation is desired"), 918 ("node_uuids", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "New instance node UUIDs, if relocation is desired"), 919 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances") 920 ] 921 OP_RESULT = ht.TNone
922
923 -class OpInstanceQueryData(OpCode):
924 """Compute the run-time status of instances.""" 925 OP_PARAMS = [ 926 ("use_locking", False, ht.TBool, "Whether to use synchronization"), 927 ("instances", [], ht.TListOf(ht.TNonEmptyString), "List of instances"), 928 ("static", False, ht.TBool, "Whether to only return configuration data without querying nodes") 929 ] 930 OP_RESULT = ht.TObject(ht.TObject(ht.TAny))
931
932 -class OpInstanceSetParams(OpCode):
933 """Change the parameters of an instance.""" 934 OP_DSC_FIELD = "instance_name" 935 OP_PARAMS = [ 936 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 937 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 938 ("force", False, ht.TBool, "Whether to force the operation"), 939 ("force_variant", False, ht.TBool, "Whether to force an unknown OS variant"), 940 ("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"), 941 ("nics", [], ht.TSetParamsMods(ht.TINicParams), "List of NIC changes"), 942 ("disks", [], ht.TSetParamsMods(ht.TIDiskParams), "List of disk changes"), 943 ("beparams", {}, ht.TObject(ht.TAny), "Backend parameters for instance"), 944 ("runtime_mem", None, ht.TMaybe(ht.TPositive(ht.TInt)), "New runtime memory"), 945 ("hvparams", {}, ht.TObject(ht.TAny), "Hypervisor parameters for instance, hypervisor-dependent"), 946 ("disk_template", None, ht.TMaybe(ht.TDiskTemplate), "Instance disk template"), 947 ("pnode", None, ht.TMaybe(ht.TNonEmptyString), "Primary node for an instance"), 948 ("pnode_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Primary node UUID for an instance"), 949 ("remote_node", None, ht.TMaybe(ht.TNonEmptyString), "Secondary node (used when changing disk template)"), 950 ("remote_node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Secondary node UUID (used when changing disk template)"), 951 ("os_name", None, ht.TMaybe(ht.TNonEmptyString), "Change the instance's OS without reinstalling the instance"), 952 ("osparams", {}, ht.TObject(ht.TAny), "OS parameters for instance"), 953 ("wait_for_sync", True, ht.TBool, "Whether to wait for the disk to synchronize"), 954 ("offline", None, ht.TMaybe(ht.TBool), "Whether to mark the instance as offline"), 955 ("conflicts_check", True, ht.TBool, "Whether to check for conflicting IP addresses"), 956 ("hotplug", False, ht.TBool, ""), 957 ("hotplug_if_possible", False, ht.TBool, "") 958 ] 959 OP_RESULT = ht.TListOf(ht.TTupleOf(ht.TNonEmptyString, ht.TAny))
960
961 -class OpInstanceGrowDisk(OpCode):
962 """Grow a disk of an instance.""" 963 OP_DSC_FIELD = "instance_name" 964 OP_PARAMS = [ 965 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 966 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 967 ("wait_for_sync", True, ht.TBool, "Whether to wait for the disk to synchronize"), 968 ("disk", None, ht.TDiskIndex, "Disk index for e.g. grow disk"), 969 ("amount", None, ht.TNonNegative(ht.TInt), "Disk amount to add or grow to"), 970 ("absolute", False, ht.TBool, "Whether the amount parameter is an absolute target or a relative one") 971 ] 972 OP_RESULT = ht.TNone
973
974 -class OpInstanceChangeGroup(OpCode):
975 """Moves an instance to another node group.""" 976 OP_DSC_FIELD = "instance_name" 977 OP_PARAMS = [ 978 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 979 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 980 ("early_release", False, ht.TBool, "Whether to release locks as soon as possible"), 981 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances"), 982 ("target_groups", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "Destination group names or UUIDs (defaults to \"all but current group\")") 983 ] 984 OP_RESULT = ht.TJobIdListOnly
985
986 -class OpGroupAdd(OpCode):
987 """Add a node group to the cluster.""" 988 OP_DSC_FIELD = "group_name" 989 OP_PARAMS = [ 990 ("group_name", None, ht.TNonEmptyString, "Group name"), 991 ("alloc_policy", None, ht.TMaybe(ht.TAllocPolicy), "Instance allocation policy"), 992 ("ndparams", None, ht.TMaybe(ht.TObject(ht.TAny)), "Default node parameters for group"), 993 ("diskparams", None, ht.TMaybe(ht.TDictOf(ht.TDiskTemplate, ht.TObject(ht.TAny))), "Disk templates' parameter defaults"), 994 ("hv_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set hypervisor states"), 995 ("disk_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set disk states"), 996 ("ipolicy", None, ht.TMaybe(ht.TObject(ht.TAny)), "Group-wide ipolicy specs") 997 ] 998 OP_RESULT = ht.TNone
999
1000 -class OpGroupAssignNodes(OpCode):
1001 """Assign nodes to a node group.""" 1002 OP_DSC_FIELD = "group_name" 1003 OP_PARAMS = [ 1004 ("group_name", None, ht.TNonEmptyString, "Group name"), 1005 ("force", False, ht.TBool, "Whether to force the operation"), 1006 ("nodes", None, ht.TListOf(ht.TNonEmptyString), "List of nodes to assign"), 1007 ("node_uuids", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "List of node UUIDs to assign") 1008 ] 1009 OP_RESULT = ht.TNone
1010
1011 -class OpGroupSetParams(OpCode):
1012 """Change the parameters of a node group.""" 1013 OP_DSC_FIELD = "group_name" 1014 OP_PARAMS = [ 1015 ("group_name", None, ht.TNonEmptyString, "Group name"), 1016 ("alloc_policy", None, ht.TMaybe(ht.TAllocPolicy), "Instance allocation policy"), 1017 ("ndparams", None, ht.TMaybe(ht.TObject(ht.TAny)), "Default node parameters for group"), 1018 ("diskparams", None, ht.TMaybe(ht.TDictOf(ht.TDiskTemplate, ht.TObject(ht.TAny))), "Disk templates' parameter defaults"), 1019 ("hv_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set hypervisor states"), 1020 ("disk_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set disk states"), 1021 ("ipolicy", None, ht.TMaybe(ht.TObject(ht.TAny)), "Group-wide ipolicy specs") 1022 ] 1023 OP_RESULT = ht.TListOf(ht.TTupleOf(ht.TNonEmptyString, ht.TAny))
1024
1025 -class OpGroupRemove(OpCode):
1026 """Remove a node group from the cluster.""" 1027 OP_DSC_FIELD = "group_name" 1028 OP_PARAMS = [ 1029 ("group_name", None, ht.TNonEmptyString, "Group name") 1030 ] 1031 OP_RESULT = ht.TNone
1032
1033 -class OpGroupRename(OpCode):
1034 """Rename a node group in the cluster.""" 1035 OP_PARAMS = [ 1036 ("group_name", None, ht.TNonEmptyString, "Group name"), 1037 ("new_name", None, ht.TNonEmptyString, "New group name") 1038 ] 1039 OP_RESULT = ht.TNonEmptyString
1040
1041 -class OpGroupEvacuate(OpCode):
1042 """Evacuate a node group in the cluster.""" 1043 OP_DSC_FIELD = "group_name" 1044 OP_PARAMS = [ 1045 ("group_name", None, ht.TNonEmptyString, "Group name"), 1046 ("early_release", False, ht.TBool, "Whether to release locks as soon as possible"), 1047 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances"), 1048 ("target_groups", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "Destination group names or UUIDs (defaults to \"all but current group\")"), 1049 ("sequential", False, ht.TBool, "Sequential job execution"), 1050 ("force_failover", False, ht.TBool, "Disallow migration moves and always use failovers") 1051 ] 1052 OP_RESULT = ht.TJobIdListOnly
1053
1054 -class OpOsDiagnose(OpCode):
1055 """Compute the list of guest operating systems.""" 1056 OP_PARAMS = [ 1057 ("output_fields", None, ht.TListOf(ht.TNonEmptyString), "Selected output fields"), 1058 ("names", [], ht.TListOf(ht.TNonEmptyString), "Which operating systems to diagnose") 1059 ] 1060 OP_RESULT = ht.TListOf(ht.TListOf(ht.TAny))
1061
1062 -class OpExtStorageDiagnose(OpCode):
1063 """Compute the list of external storage providers.""" 1064 OP_PARAMS = [ 1065 ("output_fields", None, ht.TListOf(ht.TNonEmptyString), "Selected output fields"), 1066 ("names", [], ht.TListOf(ht.TNonEmptyString), "Which ExtStorage Provider to diagnose") 1067 ] 1068 OP_RESULT = ht.TListOf(ht.TListOf(ht.TAny))
1069
1070 -class OpBackupPrepare(OpCode):
1071 """Prepares an instance export. 1072 1073 @ivar instance_name: Instance name 1074 @ivar mode: Export mode (one of L{constants.EXPORT_MODES}) 1075 1076 """ 1077 OP_DSC_FIELD = "instance_name" 1078 OP_PARAMS = [ 1079 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 1080 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 1081 ("mode", None, ht.TExportMode, "Export mode") 1082 ] 1083 OP_RESULT = ht.TMaybe(ht.TObject(ht.TAny))
1084
1085 -class OpBackupExport(OpCode):
1086 """Export an instance. 1087 1088 For local exports, the export destination is the node name. For 1089 remote exports, the export destination is a list of tuples, each 1090 consisting of hostname/IP address, port, magic, HMAC and HMAC 1091 salt. The HMAC is calculated using the cluster domain secret over 1092 the value "${index}:${hostname}:${port}". The destination X509 CA 1093 must be a signed certificate. 1094 1095 @ivar mode: Export mode (one of L{constants.EXPORT_MODES}) 1096 @ivar target_node: Export destination 1097 @ivar x509_key_name: X509 key to use (remote export only) 1098 @ivar destination_x509_ca: Destination X509 CA in PEM format (remote 1099 export only) 1100 1101 """ 1102 OP_DSC_FIELD = "instance_name" 1103 OP_PARAMS = [ 1104 ("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"), 1105 ("instance_uuid", None, ht.TMaybe(ht.TNonEmptyString), "An instance UUID (for single-instance LUs)"), 1106 ("compress", "none", ht.TImportExportCompression, "Compression mode to use for moves during backups/imports"), 1107 ("shutdown_timeout", 120, ht.TNonNegative(ht.TInt), "How long to wait for instance to shut down"), 1108 ("target_node", None, ht.TExportTarget, "Target node (depends on export mode)"), 1109 ("target_node_uuid", None, ht.TMaybe(ht.TNonEmptyString), "Target node UUID (if local export)"), 1110 ("shutdown", True, ht.TBool, "Whether to shutdown the instance before export"), 1111 ("remove_instance", False, ht.TBool, "Whether to remove instance after export"), 1112 ("ignore_remove_failures", False, ht.TBool, "Whether to ignore failures while removing instances"), 1113 ("mode", "local", ht.TExportMode, "Export mode"), 1114 ("x509_key_name", None, ht.TMaybe(ht.TListOf(ht.TAny)), "Name of X509 key (remote export only)"), 1115 ("destination_x509_ca", None, ht.TMaybe(ht.TNonEmptyString), "Destination X509 CA (remote export only)") 1116 ] 1117 OP_RESULT = ht.TTupleOf(ht.TBool, ht.TListOf(ht.TBool))
1118
1119 -class OpBackupRemove(OpCode):
1120 """Remove an instance's export.""" 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 ] 1126 OP_RESULT = ht.TNone
1127
1128 -class OpTagsGet(OpCode):
1129 """Returns the tags of the given object.""" 1130 OP_DSC_FIELD = "name" 1131 OP_PARAMS = [ 1132 ("kind", None, ht.TTagKind, "Tag kind"), 1133 ("use_locking", False, ht.TBool, "Whether to use synchronization"), 1134 ("name", None, ht.TMaybe(ht.TString), "Name of object to retrieve tags from") 1135 ] 1136 OP_RESULT = ht.TListOf(ht.TNonEmptyString)
1137
1138 -class OpTagsSearch(OpCode):
1139 """Searches the tags in the cluster for a given pattern.""" 1140 OP_DSC_FIELD = "pattern" 1141 OP_PARAMS = [ 1142 ("pattern", None, ht.TNonEmptyString, "Search pattern (regular expression)") 1143 ] 1144 OP_RESULT = ht.TListOf(ht.TTupleOf(ht.TNonEmptyString, ht.TNonEmptyString))
1145
1146 -class OpTagsSet(OpCode):
1147 """Add a list of tags on a given object.""" 1148 OP_PARAMS = [ 1149 ("kind", None, ht.TTagKind, "Tag kind"), 1150 ("tags", None, ht.TListOf(ht.TString), "List of tag names"), 1151 ("name", None, ht.TMaybe(ht.TString), "Name of object where tag(s) should be added") 1152 ] 1153 OP_RESULT = ht.TNone
1154
1155 -class OpTagsDel(OpCode):
1156 """Remove a list of tags from a given object.""" 1157 OP_PARAMS = [ 1158 ("kind", None, ht.TTagKind, "Tag kind"), 1159 ("tags", None, ht.TListOf(ht.TString), "List of tag names"), 1160 ("name", None, ht.TMaybe(ht.TString), "Name of object where tag(s) should be deleted") 1161 ] 1162 OP_RESULT = ht.TNone
1163
1164 -class OpTestDelay(OpCode):
1165 """Sleeps for a configured amount of time. 1166 1167 This is used just for debugging and testing. 1168 1169 Parameters: 1170 - duration: the time to sleep, in seconds 1171 - on_master: if true, sleep on the master 1172 - on_nodes: list of nodes in which to sleep 1173 1174 If the on_master parameter is true, it will execute a sleep on the 1175 master (before any node sleep). 1176 1177 If the on_nodes list is not empty, it will sleep on those nodes 1178 (after the sleep on the master, if that is enabled). 1179 1180 As an additional feature, the case of duration < 0 will be reported 1181 as an execution error, so this opcode can be used as a failure 1182 generator. The case of duration == 0 will not be treated specially. 1183 1184 """ 1185 OP_DSC_FIELD = "duration" 1186 OP_PARAMS = [ 1187 ("duration", None, ht.TDouble, "Duration parameter for 'OpTestDelay'"), 1188 ("on_master", True, ht.TBool, "on_master field for 'OpTestDelay'"), 1189 ("on_nodes", [], ht.TListOf(ht.TNonEmptyString), "on_nodes field for 'OpTestDelay'"), 1190 ("on_node_uuids", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "on_node_uuids field for 'OpTestDelay'"), 1191 ("repeat", 0, ht.TNonNegative(ht.TInt), "Repeat parameter for OpTestDelay"), 1192 ("no_locks", True, ht.TBool, "Don't take locks during the delay") 1193 ] 1194 OP_RESULT = ht.TNone
1195
1196 -class OpTestAllocator(OpCode):
1197 """Allocator framework testing. 1198 1199 This opcode has two modes: 1200 - gather and return allocator input for a given mode (allocate new 1201 or replace secondary) and a given instance definition (direction 1202 'in') 1203 - run a selected allocator for a given operation (as above) and 1204 return the allocator output (direction 'out') 1205 1206 """ 1207 OP_DSC_FIELD = "iallocator" 1208 OP_PARAMS = [ 1209 ("direction", None, ht.TIAllocatorTestDir, "IAllocator test direction"), 1210 ("mode", None, ht.TIAllocatorMode, "IAllocator test mode"), 1211 ("name", None, ht.TNonEmptyString, "IAllocator target name (new instance, node to evac, etc.)"), 1212 ("nics", None, ht.TMaybe(ht.TListOf(ht.TINicParams)), "Custom OpTestIAllocator nics"), 1213 ("disks", None, ht.TMaybe(ht.TListOf(ht.TAny)), "Custom OpTestAllocator disks"), 1214 ("hypervisor", None, ht.TMaybe(ht.THypervisor), "Selected hypervisor for an instance"), 1215 ("iallocator", None, ht.TMaybe(ht.TNonEmptyString), "Iallocator for deciding the target node for shared-storage instances"), 1216 ("tags", [], ht.TListOf(ht.TNonEmptyString), "Instance tags"), 1217 ("memory", None, ht.TMaybe(ht.TNonNegative(ht.TInt)), "IAllocator memory field"), 1218 ("vcpus", None, ht.TMaybe(ht.TNonNegative(ht.TInt)), "IAllocator vcpus field"), 1219 ("os", None, ht.TMaybe(ht.TNonEmptyString), "IAllocator os field"), 1220 ("disk_template", None, ht.TDiskTemplate, "Disk template"), 1221 ("instances", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "IAllocator instances field"), 1222 ("evac_mode", None, ht.TMaybe(ht.TEvacMode), "IAllocator evac mode"), 1223 ("target_groups", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "Destination group names or UUIDs (defaults to \"all but current group\")"), 1224 ("spindle_use", 1, ht.TNonNegative(ht.TInt), "IAllocator spindle use"), 1225 ("count", 1, ht.TNonNegative(ht.TInt), "IAllocator count field") 1226 ] 1227 OP_RESULT = ht.TString
1228
1229 -class OpTestJqueue(OpCode):
1230 """Utility opcode to test some aspects of the job queue.""" 1231 OP_PARAMS = [ 1232 ("notify_waitlock", False, ht.TBool, "'OpTestJqueue' notify_waitlock"), 1233 ("notify_exec", False, ht.TBool, "'OpTestJQueue' notify_exec"), 1234 ("log_messages", [], ht.TListOf(ht.TString), "'OpTestJQueue' log_messages"), 1235 ("fail", False, ht.TBool, "'OpTestJQueue' fail attribute") 1236 ] 1237 OP_RESULT = ht.TBool
1238
1239 -class OpTestDummy(OpCode):
1240 """Utility opcode used by unittests.""" 1241 OP_PARAMS = [ 1242 ("result", None, ht.TAny, "'OpTestDummy' result field"), 1243 ("messages", None, ht.TAny, "'OpTestDummy' messages field"), 1244 ("fail", None, ht.TAny, "'OpTestDummy' fail field"), 1245 ("submit_jobs", None, ht.TAny, "'OpTestDummy' submit_jobs field") 1246 ] 1247 OP_RESULT = ht.TNone 1248 WITH_LU = False
1249
1250 -class OpNetworkAdd(OpCode):
1251 """Add an IP network to the cluster.""" 1252 OP_DSC_FIELD = "network_name" 1253 OP_PARAMS = [ 1254 ("network_name", None, ht.TNonEmptyString, "Network name"), 1255 ("network", None, ht.TIPv4Network, "Network address (IPv4 subnet)"), 1256 ("gateway", None, ht.TMaybe(ht.TIPv4Address), "Network gateway (IPv4 address)"), 1257 ("network6", None, ht.TMaybe(ht.TIPv6Network), "Network address (IPv6 subnet)"), 1258 ("gateway6", None, ht.TMaybe(ht.TIPv6Address), "Network gateway (IPv6 address)"), 1259 ("mac_prefix", None, ht.TMaybe(ht.TNonEmptyString), "Network specific mac prefix (that overrides the cluster one)"), 1260 ("add_reserved_ips", None, ht.TMaybe(ht.TListOf(ht.TIPv4Address)), "Which IP addresses to reserve"), 1261 ("conflicts_check", True, ht.TBool, "Whether to check for conflicting IP addresses"), 1262 ("tags", [], ht.TListOf(ht.TNonEmptyString), "Network tags") 1263 ] 1264 OP_RESULT = ht.TNone
1265
1266 -class OpNetworkRemove(OpCode):
1267 """Remove an existing network from the cluster. 1268 Must not be connected to any nodegroup. 1269 1270 """ 1271 OP_DSC_FIELD = "network_name" 1272 OP_PARAMS = [ 1273 ("network_name", None, ht.TNonEmptyString, "Network name"), 1274 ("force", False, ht.TBool, "Whether to force the operation") 1275 ] 1276 OP_RESULT = ht.TNone
1277
1278 -class OpNetworkSetParams(OpCode):
1279 """Modify Network's parameters except for IPv4 subnet""" 1280 OP_DSC_FIELD = "network_name" 1281 OP_PARAMS = [ 1282 ("network_name", None, ht.TNonEmptyString, "Network name"), 1283 ("gateway", None, ht.TMaybe(ht.TIPv4Address), "Network gateway (IPv4 address)"), 1284 ("network6", None, ht.TMaybe(ht.TIPv6Network), "Network address (IPv6 subnet)"), 1285 ("gateway6", None, ht.TMaybe(ht.TIPv6Address), "Network gateway (IPv6 address)"), 1286 ("mac_prefix", None, ht.TMaybe(ht.TNonEmptyString), "Network specific mac prefix (that overrides the cluster one)"), 1287 ("add_reserved_ips", None, ht.TMaybe(ht.TListOf(ht.TIPv4Address)), "Which external IP addresses to reserve"), 1288 ("remove_reserved_ips", None, ht.TMaybe(ht.TListOf(ht.TIPv4Address)), "Which external IP addresses to release") 1289 ] 1290 OP_RESULT = ht.TNone
1291
1292 -class OpNetworkConnect(OpCode):
1293 """Connect a Network to a specific Nodegroup with the defined netparams 1294 (mode, link). Nics in this Network will inherit those params. 1295 Produce errors if a NIC (that its not already assigned to a network) 1296 has an IP that is contained in the Network this will produce error unless 1297 --no-conflicts-check is passed. 1298 1299 """ 1300 OP_DSC_FIELD = "network_name" 1301 OP_PARAMS = [ 1302 ("group_name", None, ht.TNonEmptyString, "Group name"), 1303 ("network_name", None, ht.TNonEmptyString, "Network name"), 1304 ("network_mode", None, ht.TNICMode, "Network mode when connecting to a group"), 1305 ("network_link", None, ht.TNonEmptyString, "Network link when connecting to a group"), 1306 ("network_vlan", "", ht.TString, "Network vlan when connecting to a group"), 1307 ("conflicts_check", True, ht.TBool, "Whether to check for conflicting IP addresses") 1308 ] 1309 OP_RESULT = ht.TNone
1310
1311 -class OpNetworkDisconnect(OpCode):
1312 """Disconnect a Network from a Nodegroup. Produce errors if NICs are 1313 present in the Network unless --no-conficts-check option is passed. 1314 1315 """ 1316 OP_DSC_FIELD = "network_name" 1317 OP_PARAMS = [ 1318 ("group_name", None, ht.TNonEmptyString, "Group name"), 1319 ("network_name", None, ht.TNonEmptyString, "Network name") 1320 ] 1321 OP_RESULT = ht.TNone
1322
1323 1324 1325 1326 -def _GetOpList():
1327 """Returns list of all defined opcodes. 1328 1329 Does not eliminate duplicates by C{OP_ID}. 1330 1331 """ 1332 return [v for v in globals().values() 1333 if (isinstance(v, type) and issubclass(v, OpCode) and 1334 hasattr(v, "OP_ID") and v is not OpCode and 1335 v.OP_ID != 'OP_INSTANCE_MULTI_ALLOC_BASE')]
1336 1337 1338 OP_MAPPING = dict((v.OP_ID, v) for v in _GetOpList()) 1339