objects: Add custom de-/serializing code for query responses
[ganeti-local] / lib / opcodes.py
index 4867706..6bf14d5 100644 (file)
@@ -115,6 +115,9 @@ class OpCode(BaseOpCode):
 
   @cvar OP_ID: The ID of this opcode. This should be unique amongst all
                children of this class.
+  @cvar 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).
   @ivar dry_run: Whether the LU should be run in dry-run mode, i.e. just
                  the check steps
   @ivar priority: Opcode priority for queue
@@ -170,6 +173,11 @@ class OpCode(BaseOpCode):
   def Summary(self):
     """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).
+
     """
     # all OP_ID start with OP_, we remove that
     txt = self.OP_ID[3:]
@@ -309,6 +317,7 @@ class OpSetClusterParams(OpCode):
     "beparams",
     "osparams",
     "nicparams",
+    "ndparams",
     "candidate_pool_size",
     "maintain_node_health",
     "uid_pool",
@@ -318,6 +327,8 @@ class OpSetClusterParams(OpCode):
     "reserved_lvs",
     "hidden_os",
     "blacklisted_os",
+    "prealloc_wipe_disks",
+    "master_netdev",
     ]
 
 
@@ -328,6 +339,47 @@ class OpRedistributeConfig(OpCode):
   OP_ID = "OP_CLUSTER_REDIST_CONF"
   __slots__ = []
 
+
+class OpQuery(OpCode):
+  """Query for resources/items.
+
+  @ivar what: Resources to query for, must be one of L{constants.QR_OP_QUERY}
+  @ivar fields: List of fields to retrieve
+  @ivar filter: Query filter
+
+  """
+  OP_ID = "OP_QUERY"
+  __slots__ = [
+    "what",
+    "fields",
+    "filter",
+    ]
+
+
+class OpQueryFields(OpCode):
+  """Query for available resource/item fields.
+
+  @ivar what: Resources to query for, must be one of L{constants.QR_OP_QUERY}
+  @ivar fields: List of fields to retrieve
+
+  """
+  OP_ID = "OP_QUERY_FIELDS"
+  __slots__ = [
+    "what",
+    "fields",
+    ]
+
+
+class OpOutOfBand(OpCode):
+  """Interact with OOB."""
+  OP_ID = "OP_OUT_OF_BAND"
+  __slots__ = [
+    "node_name",
+    "command",
+    "timeout",
+    ]
+
+
 # node opcodes
 
 class OpRemoveNode(OpCode):
@@ -363,11 +415,18 @@ class OpAddNode(OpCode):
                name is already in the cluster; use this parameter to 'repair'
                a node that had its configuration broken, or was reinstalled
                without removal from the cluster.
+  @type group: C{str}
+  @ivar group: The node group to which this node will belong.
+  @type vm_capable: C{bool}
+  @ivar vm_capable: The vm_capable node attribute
+  @type master_capable: C{bool}
+  @ivar master_capable: The master_capable node attribute
 
   """
   OP_ID = "OP_NODE_ADD"
   OP_DSC_FIELD = "node_name"
-  __slots__ = ["node_name", "primary_ip", "secondary_ip", "readd", "nodegroup"]
+  __slots__ = ["node_name", "primary_ip", "secondary_ip", "readd", "group",
+               "vm_capable", "master_capable", "ndparams"]
 
 
 class OpQueryNodes(OpCode):
@@ -427,6 +486,10 @@ class OpSetNodeParams(OpCode):
     "offline",
     "drained",
     "auto_promote",
+    "master_capable",
+    "vm_capable",
+    "secondary_ip",
+    "ndparams",
     ]
 
 
@@ -468,6 +531,8 @@ class OpCreateInstance(OpCode):
   @ivar source_handshake: Signed handshake from source (remote import only)
   @ivar source_x509_ca: Source X509 CA in PEM format (remote import only)
   @ivar source_instance_name: Previous name of instance (remote import only)
+  @ivar source_shutdown_timeout: Shutdown timeout used for source instance
+    (remote import only)
 
   """
   OP_ID = "OP_INSTANCE_CREATE"
@@ -485,6 +550,7 @@ class OpCreateInstance(OpCode):
     "source_handshake",
     "source_x509_ca",
     "source_instance_name",
+    "source_shutdown_timeout",
     ]
 
 
@@ -492,7 +558,7 @@ class OpReinstallInstance(OpCode):
   """Reinstall an instance's OS."""
   OP_ID = "OP_INSTANCE_REINSTALL"
   OP_DSC_FIELD = "instance_name"
-  __slots__ = ["instance_name", "os_type", "force_variant"]
+  __slots__ = ["instance_name", "os_type", "force_variant", "osparams"]
 
 
 class OpRemoveInstance(OpCode):
@@ -653,6 +719,35 @@ class OpGrowDisk(OpCode):
     ]
 
 
+# Node group opcodes
+
+class OpAddGroup(OpCode):
+  """Add a node group to the cluster."""
+  OP_ID = "OP_GROUP_ADD"
+  OP_DSC_FIELD = "group_name"
+  __slots__ = ["group_name"]
+
+
+class OpQueryGroups(OpCode):
+  """Compute the list of node groups."""
+  OP_ID = "OP_GROUP_QUERY"
+  __slots__ = ["output_fields", "names"]
+
+
+class OpRemoveGroup(OpCode):
+  """Remove a node group from the cluster."""
+  OP_ID = "OP_GROUP_REMOVE"
+  OP_DSC_FIELD = "group_name"
+  __slots__ = ["group_name"]
+
+
+class OpRenameGroup(OpCode):
+  """Rename a node group in the cluster."""
+  OP_ID = "OP_GROUP_RENAME"
+  OP_DSC_FIELD = "old_name"
+  __slots__ = ["old_name", "new_name"]
+
+
 # OS opcodes
 class OpDiagnoseOS(OpCode):
   """Compute the list of guest operating systems."""