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