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