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

Class OpCode

source code


Abstract OpCode.

This is the root of the actual OpCode hierarchy. All clases derived from this class should override OP_ID.

Nested Classes [hide private]

Inherited from opcodes_base.BaseOpCode: __metaclass__

Instance Methods [hide private]
dict
__getstate__(self)
Specialized getstate for opcodes.
source code
 
Summary(self)
Generates a summary description of this opcode.
source code
 
TinySummary(self)
Generates a compact summary description of the opcode.
source code

Inherited from opcodes_base.BaseOpCode: Validate, __setstate__

Inherited from outils.ValidatedSlots: __init__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]
 
LoadOpCode(cls, data)
Generic load opcode method.
source code

Inherited from opcodes_base.BaseOpCode: GetAllParams

Inherited from outils.ValidatedSlots: GetAllSlots

Class Variables [hide private]
  WITH_LU = True
Boolean that specifies whether this should be included in mcpu's dispatch table
  OP_PARAMS = [("dry_run", None, ht.TMaybe(ht.TBool), "Run check...
List of opcode attributes, the default values they should get if not already defined, and types they must match.
  OP_RESULT = None
Callable to verify opcode result
  OP_DSC_FIELD
The name of a field whose value will be included in the string returned by Summary(); see the docstring of that method for details).
  OP_DSC_FORMATTER
A callable that should format the OP_DSC_FIELD; if not present, then the field will be simply converted to string
  OP_ID
The ID of this opcode.
Instance Variables [hide private]
  dry_run
Whether the LU should be run in dry-run mode, i.e.
  priority
Opcode priority for queue
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__getstate__(self)

source code 

Specialized getstate for opcodes.

This method adds to the state dictionary the OP_ID of the class, so that on unload we can identify the correct class for instantiating the opcode.

Returns: dict
the state as a dictionary
Overrides: opcodes_base.BaseOpCode.__getstate__

LoadOpCode(cls, data)
Class Method

source code 

Generic load opcode method.

The method identifies the correct opcode class from the dict-form by looking for a OP_ID key, if this is not found, or its value is not available in this module as a child of this class, we fail.

Parameters:
  • data (dict) - the serialized opcode

Summary(self)

source code 

Generates a summary description of this opcode.

The summary is the value of the OP_ID attribute (without the "OP_" prefix), plus the value of the OP_DSC_FIELD attribute, if one was defined; this field should allow to easily identify the operation (for an instance creation job, e.g., it would be the instance name).


Class Variable Details [hide private]

OP_PARAMS

List of opcode attributes, the default values they should get if not already defined, and types they must match.
Value:
[("dry_run", None, ht.TMaybe(ht.TBool), "Run checks only, don't execut\
e"), ("debug_level", None, ht.TMaybe(ht.TNonNegative(ht.TInt)), "Debug\
 level"), ("priority", constants.OP_PRIO_DEFAULT, ht.TElemOf(constants\
.OP_PRIO_SUBMIT_VALID), "Opcode priority"), (opcodes_base.DEPEND_ATTR,\
 None, opcodes_base.BuildJobDepCheck(True), "Job dependencies; if used\
 through ``SubmitManyJobs`` relative (negative)" " job IDs can be used\
; see :doc:`design document <design-chained-jobs>`" " for details"), (\
opcodes_base.COMMENT_ATTR, None, ht.TMaybe(ht.TString), "Comment descr\
...

OP_ID

The ID of this opcode. This should be unique amongst all children of this class.

Instance Variable Details [hide private]

dry_run

Whether the LU should be run in dry-run mode, i.e. just the check steps