Statistics
| Branch: | Tag: | Revision:

root / lib / opcodes.py @ 435e4bd6

History | View | Annotate | Download (21.9 kB)

1 2f31098c Iustin Pop
#
2 a8083063 Iustin Pop
#
3 a8083063 Iustin Pop
4 8c35561f Iustin Pop
# Copyright (C) 2006, 2007, 2008, 2009, 2010 Google Inc.
5 a8083063 Iustin Pop
#
6 a8083063 Iustin Pop
# This program is free software; you can redistribute it and/or modify
7 a8083063 Iustin Pop
# it under the terms of the GNU General Public License as published by
8 a8083063 Iustin Pop
# the Free Software Foundation; either version 2 of the License, or
9 a8083063 Iustin Pop
# (at your option) any later version.
10 a8083063 Iustin Pop
#
11 a8083063 Iustin Pop
# This program is distributed in the hope that it will be useful, but
12 a8083063 Iustin Pop
# WITHOUT ANY WARRANTY; without even the implied warranty of
13 a8083063 Iustin Pop
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 a8083063 Iustin Pop
# General Public License for more details.
15 a8083063 Iustin Pop
#
16 a8083063 Iustin Pop
# You should have received a copy of the GNU General Public License
17 a8083063 Iustin Pop
# along with this program; if not, write to the Free Software
18 a8083063 Iustin Pop
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 a8083063 Iustin Pop
# 02110-1301, USA.
20 a8083063 Iustin Pop
21 a8083063 Iustin Pop
22 a8083063 Iustin Pop
"""OpCodes module
23 a8083063 Iustin Pop

24 a8083063 Iustin Pop
This module implements the data structures which define the cluster
25 a8083063 Iustin Pop
operations - the so-called opcodes.
26 a8083063 Iustin Pop

27 0e46916d Iustin Pop
Every operation which modifies the cluster state is expressed via
28 0e46916d Iustin Pop
opcodes.
29 a8083063 Iustin Pop

30 a8083063 Iustin Pop
"""
31 a8083063 Iustin Pop
32 a8083063 Iustin Pop
# this are practically structures, so disable the message about too
33 a8083063 Iustin Pop
# few public methods:
34 a8083063 Iustin Pop
# pylint: disable-msg=R0903
35 a8083063 Iustin Pop
36 df458e0b Iustin Pop
37 0e46916d Iustin Pop
class BaseOpCode(object):
38 df458e0b Iustin Pop
  """A simple serializable object.
39 df458e0b Iustin Pop

40 0e46916d Iustin Pop
  This object serves as a parent class for OpCode without any custom
41 0e46916d Iustin Pop
  field handling.
42 0e46916d Iustin Pop

43 df458e0b Iustin Pop
  """
44 a8083063 Iustin Pop
  __slots__ = []
45 a8083063 Iustin Pop
46 a8083063 Iustin Pop
  def __init__(self, **kwargs):
47 a7399f66 Iustin Pop
    """Constructor for BaseOpCode.
48 a7399f66 Iustin Pop

49 a7399f66 Iustin Pop
    The constructor takes only keyword arguments and will set
50 a7399f66 Iustin Pop
    attributes on this object based on the passed arguments. As such,
51 a7399f66 Iustin Pop
    it means that you should not pass arguments which are not in the
52 a7399f66 Iustin Pop
    __slots__ attribute for this class.
53 a7399f66 Iustin Pop

54 a7399f66 Iustin Pop
    """
55 adf385c7 Iustin Pop
    slots = self._all_slots()
56 a8083063 Iustin Pop
    for key in kwargs:
57 adf385c7 Iustin Pop
      if key not in slots:
58 df458e0b Iustin Pop
        raise TypeError("Object %s doesn't support the parameter '%s'" %
59 3ecf6786 Iustin Pop
                        (self.__class__.__name__, key))
60 a8083063 Iustin Pop
      setattr(self, key, kwargs[key])
61 a8083063 Iustin Pop
62 df458e0b Iustin Pop
  def __getstate__(self):
63 a7399f66 Iustin Pop
    """Generic serializer.
64 a7399f66 Iustin Pop

65 a7399f66 Iustin Pop
    This method just returns the contents of the instance as a
66 a7399f66 Iustin Pop
    dictionary.
67 a7399f66 Iustin Pop

68 a7399f66 Iustin Pop
    @rtype:  C{dict}
69 a7399f66 Iustin Pop
    @return: the instance attributes and their values
70 a7399f66 Iustin Pop

71 a7399f66 Iustin Pop
    """
72 df458e0b Iustin Pop
    state = {}
73 adf385c7 Iustin Pop
    for name in self._all_slots():
74 df458e0b Iustin Pop
      if hasattr(self, name):
75 df458e0b Iustin Pop
        state[name] = getattr(self, name)
76 df458e0b Iustin Pop
    return state
77 df458e0b Iustin Pop
78 df458e0b Iustin Pop
  def __setstate__(self, state):
79 a7399f66 Iustin Pop
    """Generic unserializer.
80 a7399f66 Iustin Pop

81 a7399f66 Iustin Pop
    This method just restores from the serialized state the attributes
82 a7399f66 Iustin Pop
    of the current instance.
83 a7399f66 Iustin Pop

84 a7399f66 Iustin Pop
    @param state: the serialized opcode data
85 a7399f66 Iustin Pop
    @type state:  C{dict}
86 a7399f66 Iustin Pop

87 a7399f66 Iustin Pop
    """
88 df458e0b Iustin Pop
    if not isinstance(state, dict):
89 df458e0b Iustin Pop
      raise ValueError("Invalid data to __setstate__: expected dict, got %s" %
90 df458e0b Iustin Pop
                       type(state))
91 df458e0b Iustin Pop
92 adf385c7 Iustin Pop
    for name in self._all_slots():
93 44db3a6f Iustin Pop
      if name not in state and hasattr(self, name):
94 df458e0b Iustin Pop
        delattr(self, name)
95 df458e0b Iustin Pop
96 df458e0b Iustin Pop
    for name in state:
97 df458e0b Iustin Pop
      setattr(self, name, state[name])
98 df458e0b Iustin Pop
99 adf385c7 Iustin Pop
  @classmethod
100 adf385c7 Iustin Pop
  def _all_slots(cls):
101 adf385c7 Iustin Pop
    """Compute the list of all declared slots for a class.
102 adf385c7 Iustin Pop

103 adf385c7 Iustin Pop
    """
104 adf385c7 Iustin Pop
    slots = []
105 adf385c7 Iustin Pop
    for parent in cls.__mro__:
106 adf385c7 Iustin Pop
      slots.extend(getattr(parent, "__slots__", []))
107 adf385c7 Iustin Pop
    return slots
108 adf385c7 Iustin Pop
109 df458e0b Iustin Pop
110 0e46916d Iustin Pop
class OpCode(BaseOpCode):
111 a7399f66 Iustin Pop
  """Abstract OpCode.
112 a7399f66 Iustin Pop

113 a7399f66 Iustin Pop
  This is the root of the actual OpCode hierarchy. All clases derived
114 a7399f66 Iustin Pop
  from this class should override OP_ID.
115 a7399f66 Iustin Pop

116 a7399f66 Iustin Pop
  @cvar OP_ID: The ID of this opcode. This should be unique amongst all
117 20777413 Iustin Pop
               children of this class.
118 20777413 Iustin Pop
  @ivar dry_run: Whether the LU should be run in dry-run mode, i.e. just
119 20777413 Iustin Pop
                 the check steps
120 8f5c488d Michael Hanselmann
  @ivar priority: Opcode priority for queue
121 a7399f66 Iustin Pop

122 a7399f66 Iustin Pop
  """
123 df458e0b Iustin Pop
  OP_ID = "OP_ABSTRACT"
124 8f5c488d Michael Hanselmann
  __slots__ = ["dry_run", "debug_level", "priority"]
125 df458e0b Iustin Pop
126 df458e0b Iustin Pop
  def __getstate__(self):
127 df458e0b Iustin Pop
    """Specialized getstate for opcodes.
128 df458e0b Iustin Pop

129 a7399f66 Iustin Pop
    This method adds to the state dictionary the OP_ID of the class,
130 a7399f66 Iustin Pop
    so that on unload we can identify the correct class for
131 a7399f66 Iustin Pop
    instantiating the opcode.
132 a7399f66 Iustin Pop

133 a7399f66 Iustin Pop
    @rtype:   C{dict}
134 a7399f66 Iustin Pop
    @return:  the state as a dictionary
135 a7399f66 Iustin Pop

136 df458e0b Iustin Pop
    """
137 0e46916d Iustin Pop
    data = BaseOpCode.__getstate__(self)
138 df458e0b Iustin Pop
    data["OP_ID"] = self.OP_ID
139 df458e0b Iustin Pop
    return data
140 df458e0b Iustin Pop
141 df458e0b Iustin Pop
  @classmethod
142 00abdc96 Iustin Pop
  def LoadOpCode(cls, data):
143 df458e0b Iustin Pop
    """Generic load opcode method.
144 df458e0b Iustin Pop

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

149 a7399f66 Iustin Pop
    @type data:  C{dict}
150 a7399f66 Iustin Pop
    @param data: the serialized opcode
151 a7399f66 Iustin Pop

152 df458e0b Iustin Pop
    """
153 df458e0b Iustin Pop
    if not isinstance(data, dict):
154 df458e0b Iustin Pop
      raise ValueError("Invalid data to LoadOpCode (%s)" % type(data))
155 df458e0b Iustin Pop
    if "OP_ID" not in data:
156 df458e0b Iustin Pop
      raise ValueError("Invalid data to LoadOpcode, missing OP_ID")
157 df458e0b Iustin Pop
    op_id = data["OP_ID"]
158 df458e0b Iustin Pop
    op_class = None
159 363acb1e Iustin Pop
    if op_id in OP_MAPPING:
160 363acb1e Iustin Pop
      op_class = OP_MAPPING[op_id]
161 363acb1e Iustin Pop
    else:
162 df458e0b Iustin Pop
      raise ValueError("Invalid data to LoadOpCode: OP_ID %s unsupported" %
163 df458e0b Iustin Pop
                       op_id)
164 df458e0b Iustin Pop
    op = op_class()
165 df458e0b Iustin Pop
    new_data = data.copy()
166 df458e0b Iustin Pop
    del new_data["OP_ID"]
167 df458e0b Iustin Pop
    op.__setstate__(new_data)
168 df458e0b Iustin Pop
    return op
169 df458e0b Iustin Pop
170 60dd1473 Iustin Pop
  def Summary(self):
171 60dd1473 Iustin Pop
    """Generates a summary description of this opcode.
172 60dd1473 Iustin Pop

173 60dd1473 Iustin Pop
    """
174 60dd1473 Iustin Pop
    # all OP_ID start with OP_, we remove that
175 60dd1473 Iustin Pop
    txt = self.OP_ID[3:]
176 60dd1473 Iustin Pop
    field_name = getattr(self, "OP_DSC_FIELD", None)
177 60dd1473 Iustin Pop
    if field_name:
178 60dd1473 Iustin Pop
      field_value = getattr(self, field_name, None)
179 bc8bbda1 Iustin Pop
      if isinstance(field_value, (list, tuple)):
180 bc8bbda1 Iustin Pop
        field_value = ",".join(str(i) for i in field_value)
181 60dd1473 Iustin Pop
      txt = "%s(%s)" % (txt, field_value)
182 60dd1473 Iustin Pop
    return txt
183 60dd1473 Iustin Pop
184 a8083063 Iustin Pop
185 afee0879 Iustin Pop
# cluster opcodes
186 afee0879 Iustin Pop
187 b5f5fae9 Luca Bigliardi
class OpPostInitCluster(OpCode):
188 b5f5fae9 Luca Bigliardi
  """Post cluster initialization.
189 b5f5fae9 Luca Bigliardi

190 b5f5fae9 Luca Bigliardi
  This opcode does not touch the cluster at all. Its purpose is to run hooks
191 b5f5fae9 Luca Bigliardi
  after the cluster has been initialized.
192 b5f5fae9 Luca Bigliardi

193 b5f5fae9 Luca Bigliardi
  """
194 b5f5fae9 Luca Bigliardi
  OP_ID = "OP_CLUSTER_POST_INIT"
195 154b9580 Balazs Lecz
  __slots__ = []
196 b5f5fae9 Luca Bigliardi
197 b5f5fae9 Luca Bigliardi
198 a8083063 Iustin Pop
class OpDestroyCluster(OpCode):
199 a7399f66 Iustin Pop
  """Destroy the cluster.
200 a7399f66 Iustin Pop

201 a7399f66 Iustin Pop
  This opcode has no other parameters. All the state is irreversibly
202 a7399f66 Iustin Pop
  lost after the execution of this opcode.
203 a7399f66 Iustin Pop

204 a7399f66 Iustin Pop
  """
205 a8083063 Iustin Pop
  OP_ID = "OP_CLUSTER_DESTROY"
206 154b9580 Balazs Lecz
  __slots__ = []
207 a8083063 Iustin Pop
208 a8083063 Iustin Pop
209 a8083063 Iustin Pop
class OpQueryClusterInfo(OpCode):
210 fdc267f4 Iustin Pop
  """Query cluster information."""
211 a8083063 Iustin Pop
  OP_ID = "OP_CLUSTER_QUERY"
212 154b9580 Balazs Lecz
  __slots__ = []
213 a8083063 Iustin Pop
214 a8083063 Iustin Pop
215 a8083063 Iustin Pop
class OpVerifyCluster(OpCode):
216 a7399f66 Iustin Pop
  """Verify the cluster state.
217 a7399f66 Iustin Pop

218 a7399f66 Iustin Pop
  @type skip_checks: C{list}
219 a7399f66 Iustin Pop
  @ivar skip_checks: steps to be skipped from the verify process; this
220 a7399f66 Iustin Pop
                     needs to be a subset of
221 a7399f66 Iustin Pop
                     L{constants.VERIFY_OPTIONAL_CHECKS}; currently
222 a7399f66 Iustin Pop
                     only L{constants.VERIFY_NPLUSONE_MEM} can be passed
223 a7399f66 Iustin Pop

224 a7399f66 Iustin Pop
  """
225 a8083063 Iustin Pop
  OP_ID = "OP_CLUSTER_VERIFY"
226 154b9580 Balazs Lecz
  __slots__ = ["skip_checks", "verbose", "error_codes",
227 154b9580 Balazs Lecz
               "debug_simulate_errors"]
228 a8083063 Iustin Pop
229 a8083063 Iustin Pop
230 150e978f Iustin Pop
class OpVerifyDisks(OpCode):
231 150e978f Iustin Pop
  """Verify the cluster disks.
232 150e978f Iustin Pop

233 150e978f Iustin Pop
  Parameters: none
234 150e978f Iustin Pop

235 5188ab37 Iustin Pop
  Result: a tuple of four elements:
236 150e978f Iustin Pop
    - list of node names with bad data returned (unreachable, etc.)
237 a7399f66 Iustin Pop
    - dict of node names with broken volume groups (values: error msg)
238 150e978f Iustin Pop
    - list of instances with degraded disks (that should be activated)
239 b63ed789 Iustin Pop
    - dict of instances with missing logical volumes (values: (node, vol)
240 b63ed789 Iustin Pop
      pairs with details about the missing volumes)
241 150e978f Iustin Pop

242 b63ed789 Iustin Pop
  In normal operation, all lists should be empty. A non-empty instance
243 b63ed789 Iustin Pop
  list (3rd element of the result) is still ok (errors were fixed) but
244 b63ed789 Iustin Pop
  non-empty node list means some node is down, and probably there are
245 b63ed789 Iustin Pop
  unfixable drbd errors.
246 150e978f Iustin Pop

247 150e978f Iustin Pop
  Note that only instances that are drbd-based are taken into
248 150e978f Iustin Pop
  consideration. This might need to be revisited in the future.
249 150e978f Iustin Pop

250 150e978f Iustin Pop
  """
251 150e978f Iustin Pop
  OP_ID = "OP_CLUSTER_VERIFY_DISKS"
252 154b9580 Balazs Lecz
  __slots__ = []
253 150e978f Iustin Pop
254 150e978f Iustin Pop
255 60975797 Iustin Pop
class OpRepairDiskSizes(OpCode):
256 60975797 Iustin Pop
  """Verify the disk sizes of the instances and fixes configuration
257 60975797 Iustin Pop
  mimatches.
258 60975797 Iustin Pop

259 60975797 Iustin Pop
  Parameters: optional instances list, in case we want to restrict the
260 60975797 Iustin Pop
  checks to only a subset of the instances.
261 60975797 Iustin Pop

262 60975797 Iustin Pop
  Result: a list of tuples, (instance, disk, new-size) for changed
263 60975797 Iustin Pop
  configurations.
264 60975797 Iustin Pop

265 60975797 Iustin Pop
  In normal operation, the list should be empty.
266 60975797 Iustin Pop

267 60975797 Iustin Pop
  @type instances: list
268 60975797 Iustin Pop
  @ivar instances: the list of instances to check, or empty for all instances
269 60975797 Iustin Pop

270 60975797 Iustin Pop
  """
271 60975797 Iustin Pop
  OP_ID = "OP_CLUSTER_REPAIR_DISK_SIZES"
272 60975797 Iustin Pop
  __slots__ = ["instances"]
273 60975797 Iustin Pop
274 60975797 Iustin Pop
275 ae5849b5 Michael Hanselmann
class OpQueryConfigValues(OpCode):
276 ae5849b5 Michael Hanselmann
  """Query cluster configuration values."""
277 ae5849b5 Michael Hanselmann
  OP_ID = "OP_CLUSTER_CONFIG_QUERY"
278 154b9580 Balazs Lecz
  __slots__ = ["output_fields"]
279 a8083063 Iustin Pop
280 a8083063 Iustin Pop
281 07bd8a51 Iustin Pop
class OpRenameCluster(OpCode):
282 a7399f66 Iustin Pop
  """Rename the cluster.
283 a7399f66 Iustin Pop

284 a7399f66 Iustin Pop
  @type name: C{str}
285 a7399f66 Iustin Pop
  @ivar name: The new name of the cluster. The name and/or the master IP
286 a7399f66 Iustin Pop
              address will be changed to match the new name and its IP
287 a7399f66 Iustin Pop
              address.
288 a7399f66 Iustin Pop

289 a7399f66 Iustin Pop
  """
290 07bd8a51 Iustin Pop
  OP_ID = "OP_CLUSTER_RENAME"
291 60dd1473 Iustin Pop
  OP_DSC_FIELD = "name"
292 154b9580 Balazs Lecz
  __slots__ = ["name"]
293 07bd8a51 Iustin Pop
294 07bd8a51 Iustin Pop
295 12515db7 Manuel Franceschini
class OpSetClusterParams(OpCode):
296 a7399f66 Iustin Pop
  """Change the parameters of the cluster.
297 a7399f66 Iustin Pop

298 a7399f66 Iustin Pop
  @type vg_name: C{str} or C{None}
299 a7399f66 Iustin Pop
  @ivar vg_name: The new volume group name or None to disable LVM usage.
300 a7399f66 Iustin Pop

301 a7399f66 Iustin Pop
  """
302 12515db7 Manuel Franceschini
  OP_ID = "OP_CLUSTER_SET_PARAMS"
303 154b9580 Balazs Lecz
  __slots__ = [
304 4b7735f9 Iustin Pop
    "vg_name",
305 7b2cd2b4 Luca Bigliardi
    "drbd_helper",
306 4b7735f9 Iustin Pop
    "enabled_hypervisors",
307 4b7735f9 Iustin Pop
    "hvparams",
308 17463d22 Renรฉ Nussbaumer
    "os_hvp",
309 4b7735f9 Iustin Pop
    "beparams",
310 625ac113 Iustin Pop
    "osparams",
311 5af3da74 Guido Trotter
    "nicparams",
312 08a61d91 Renรฉ Nussbaumer
    "ndparams",
313 4b7735f9 Iustin Pop
    "candidate_pool_size",
314 3953242f Iustin Pop
    "maintain_node_health",
315 1338f2b4 Balazs Lecz
    "uid_pool",
316 fdad8c4d Balazs Lecz
    "add_uids",
317 fdad8c4d Balazs Lecz
    "remove_uids",
318 bf4af505 Apollon Oikonomopoulos
    "default_iallocator",
319 f38ea602 Iustin Pop
    "reserved_lvs",
320 87b2cd45 Iustin Pop
    "hidden_os",
321 87b2cd45 Iustin Pop
    "blacklisted_os",
322 b883637f Renรฉ Nussbaumer
    "prealloc_wipe_disks",
323 4b7735f9 Iustin Pop
    ]
324 12515db7 Manuel Franceschini
325 12515db7 Manuel Franceschini
326 afee0879 Iustin Pop
class OpRedistributeConfig(OpCode):
327 afee0879 Iustin Pop
  """Force a full push of the cluster configuration.
328 afee0879 Iustin Pop

329 afee0879 Iustin Pop
  """
330 afee0879 Iustin Pop
  OP_ID = "OP_CLUSTER_REDIST_CONF"
331 154b9580 Balazs Lecz
  __slots__ = []
332 afee0879 Iustin Pop
333 07bd8a51 Iustin Pop
# node opcodes
334 07bd8a51 Iustin Pop
335 a8083063 Iustin Pop
class OpRemoveNode(OpCode):
336 a7399f66 Iustin Pop
  """Remove a node.
337 a7399f66 Iustin Pop

338 a7399f66 Iustin Pop
  @type node_name: C{str}
339 a7399f66 Iustin Pop
  @ivar node_name: The name of the node to remove. If the node still has
340 a7399f66 Iustin Pop
                   instances on it, the operation will fail.
341 a7399f66 Iustin Pop

342 a7399f66 Iustin Pop
  """
343 a8083063 Iustin Pop
  OP_ID = "OP_NODE_REMOVE"
344 60dd1473 Iustin Pop
  OP_DSC_FIELD = "node_name"
345 154b9580 Balazs Lecz
  __slots__ = ["node_name"]
346 a8083063 Iustin Pop
347 a8083063 Iustin Pop
348 a8083063 Iustin Pop
class OpAddNode(OpCode):
349 a7399f66 Iustin Pop
  """Add a node to the cluster.
350 a7399f66 Iustin Pop

351 a7399f66 Iustin Pop
  @type node_name: C{str}
352 a7399f66 Iustin Pop
  @ivar node_name: The name of the node to add. This can be a short name,
353 a7399f66 Iustin Pop
                   but it will be expanded to the FQDN.
354 a7399f66 Iustin Pop
  @type primary_ip: IP address
355 a7399f66 Iustin Pop
  @ivar primary_ip: The primary IP of the node. This will be ignored when the
356 a7399f66 Iustin Pop
                    opcode is submitted, but will be filled during the node
357 a7399f66 Iustin Pop
                    add (so it will be visible in the job query).
358 a7399f66 Iustin Pop
  @type secondary_ip: IP address
359 a7399f66 Iustin Pop
  @ivar secondary_ip: The secondary IP of the node. This needs to be passed
360 a7399f66 Iustin Pop
                      if the cluster has been initialized in 'dual-network'
361 a7399f66 Iustin Pop
                      mode, otherwise it must not be given.
362 a7399f66 Iustin Pop
  @type readd: C{bool}
363 a7399f66 Iustin Pop
  @ivar readd: Whether to re-add an existing node to the cluster. If
364 a7399f66 Iustin Pop
               this is not passed, then the operation will abort if the node
365 a7399f66 Iustin Pop
               name is already in the cluster; use this parameter to 'repair'
366 a7399f66 Iustin Pop
               a node that had its configuration broken, or was reinstalled
367 a7399f66 Iustin Pop
               without removal from the cluster.
368 f936c153 Iustin Pop
  @type group: C{str}
369 f936c153 Iustin Pop
  @ivar group: The node group to which this node will belong.
370 fd3d37b6 Iustin Pop
  @type vm_capable: C{bool}
371 fd3d37b6 Iustin Pop
  @ivar vm_capable: The vm_capable node attribute
372 fd3d37b6 Iustin Pop
  @type master_capable: C{bool}
373 fd3d37b6 Iustin Pop
  @ivar master_capable: The master_capable node attribute
374 a7399f66 Iustin Pop

375 a7399f66 Iustin Pop
  """
376 a8083063 Iustin Pop
  OP_ID = "OP_NODE_ADD"
377 60dd1473 Iustin Pop
  OP_DSC_FIELD = "node_name"
378 fd3d37b6 Iustin Pop
  __slots__ = ["node_name", "primary_ip", "secondary_ip", "readd", "group",
379 08a61d91 Renรฉ Nussbaumer
               "vm_capable", "master_capable", "ndparams"]
380 a8083063 Iustin Pop
381 a8083063 Iustin Pop
382 a8083063 Iustin Pop
class OpQueryNodes(OpCode):
383 a8083063 Iustin Pop
  """Compute the list of nodes."""
384 a8083063 Iustin Pop
  OP_ID = "OP_NODE_QUERY"
385 154b9580 Balazs Lecz
  __slots__ = ["output_fields", "names", "use_locking"]
386 a8083063 Iustin Pop
387 a8083063 Iustin Pop
388 dcb93971 Michael Hanselmann
class OpQueryNodeVolumes(OpCode):
389 dcb93971 Michael Hanselmann
  """Get list of volumes on node."""
390 dcb93971 Michael Hanselmann
  OP_ID = "OP_NODE_QUERYVOLS"
391 154b9580 Balazs Lecz
  __slots__ = ["nodes", "output_fields"]
392 dcb93971 Michael Hanselmann
393 dcb93971 Michael Hanselmann
394 9e5442ce Michael Hanselmann
class OpQueryNodeStorage(OpCode):
395 9e5442ce Michael Hanselmann
  """Get information on storage for node(s)."""
396 9e5442ce Michael Hanselmann
  OP_ID = "OP_NODE_QUERY_STORAGE"
397 154b9580 Balazs Lecz
  __slots__ = [
398 9e5442ce Michael Hanselmann
    "nodes",
399 9e5442ce Michael Hanselmann
    "storage_type",
400 9e5442ce Michael Hanselmann
    "name",
401 9e5442ce Michael Hanselmann
    "output_fields",
402 9e5442ce Michael Hanselmann
    ]
403 9e5442ce Michael Hanselmann
404 9e5442ce Michael Hanselmann
405 efb8da02 Michael Hanselmann
class OpModifyNodeStorage(OpCode):
406 099c52ad Iustin Pop
  """Modifies the properies of a storage unit"""
407 efb8da02 Michael Hanselmann
  OP_ID = "OP_NODE_MODIFY_STORAGE"
408 154b9580 Balazs Lecz
  __slots__ = [
409 efb8da02 Michael Hanselmann
    "node_name",
410 efb8da02 Michael Hanselmann
    "storage_type",
411 efb8da02 Michael Hanselmann
    "name",
412 efb8da02 Michael Hanselmann
    "changes",
413 efb8da02 Michael Hanselmann
    ]
414 efb8da02 Michael Hanselmann
415 efb8da02 Michael Hanselmann
416 76aef8fc Michael Hanselmann
class OpRepairNodeStorage(OpCode):
417 76aef8fc Michael Hanselmann
  """Repairs the volume group on a node."""
418 76aef8fc Michael Hanselmann
  OP_ID = "OP_REPAIR_NODE_STORAGE"
419 76aef8fc Michael Hanselmann
  OP_DSC_FIELD = "node_name"
420 154b9580 Balazs Lecz
  __slots__ = [
421 76aef8fc Michael Hanselmann
    "node_name",
422 76aef8fc Michael Hanselmann
    "storage_type",
423 76aef8fc Michael Hanselmann
    "name",
424 7e9c6a78 Iustin Pop
    "ignore_consistency",
425 76aef8fc Michael Hanselmann
    ]
426 76aef8fc Michael Hanselmann
427 76aef8fc Michael Hanselmann
428 b31c8676 Iustin Pop
class OpSetNodeParams(OpCode):
429 b31c8676 Iustin Pop
  """Change the parameters of a node."""
430 b31c8676 Iustin Pop
  OP_ID = "OP_NODE_SET_PARAMS"
431 b31c8676 Iustin Pop
  OP_DSC_FIELD = "node_name"
432 154b9580 Balazs Lecz
  __slots__ = [
433 b31c8676 Iustin Pop
    "node_name",
434 b31c8676 Iustin Pop
    "force",
435 b31c8676 Iustin Pop
    "master_candidate",
436 3a5ba66a Iustin Pop
    "offline",
437 c9d443ea Iustin Pop
    "drained",
438 601908d0 Iustin Pop
    "auto_promote",
439 197e3bb2 Iustin Pop
    "master_capable",
440 077114cd Iustin Pop
    "vm_capable",
441 4d32c211 Guido Trotter
    "secondary_ip",
442 08a61d91 Renรฉ Nussbaumer
    "ndparams",
443 b31c8676 Iustin Pop
    ]
444 b31c8676 Iustin Pop
445 f5118ade Iustin Pop
446 f5118ade Iustin Pop
class OpPowercycleNode(OpCode):
447 f5118ade Iustin Pop
  """Tries to powercycle a node."""
448 f5118ade Iustin Pop
  OP_ID = "OP_NODE_POWERCYCLE"
449 f5118ade Iustin Pop
  OP_DSC_FIELD = "node_name"
450 154b9580 Balazs Lecz
  __slots__ = [
451 f5118ade Iustin Pop
    "node_name",
452 f5118ade Iustin Pop
    "force",
453 f5118ade Iustin Pop
    ]
454 f5118ade Iustin Pop
455 7ffc5a86 Michael Hanselmann
456 80cb875c Michael Hanselmann
class OpMigrateNode(OpCode):
457 80cb875c Michael Hanselmann
  """Migrate all instances from a node."""
458 80cb875c Michael Hanselmann
  OP_ID = "OP_NODE_MIGRATE"
459 80cb875c Michael Hanselmann
  OP_DSC_FIELD = "node_name"
460 154b9580 Balazs Lecz
  __slots__ = [
461 80cb875c Michael Hanselmann
    "node_name",
462 8c35561f Iustin Pop
    "mode",
463 46d2d8a2 Iustin Pop
    "live",
464 80cb875c Michael Hanselmann
    ]
465 80cb875c Michael Hanselmann
466 80cb875c Michael Hanselmann
467 d6aaa598 Iustin Pop
class OpNodeEvacuationStrategy(OpCode):
468 d6aaa598 Iustin Pop
  """Compute the evacuation strategy for a list of nodes."""
469 d6aaa598 Iustin Pop
  OP_ID = "OP_NODE_EVAC_STRATEGY"
470 d6aaa598 Iustin Pop
  OP_DSC_FIELD = "nodes"
471 d6aaa598 Iustin Pop
  __slots__ = ["nodes", "iallocator", "remote_node"]
472 d6aaa598 Iustin Pop
473 d6aaa598 Iustin Pop
474 a8083063 Iustin Pop
# instance opcodes
475 a8083063 Iustin Pop
476 a8083063 Iustin Pop
class OpCreateInstance(OpCode):
477 9bf56d77 Michael Hanselmann
  """Create an instance.
478 9bf56d77 Michael Hanselmann

479 9bf56d77 Michael Hanselmann
  @ivar instance_name: Instance name
480 9bf56d77 Michael Hanselmann
  @ivar mode: Instance creation mode (one of L{constants.INSTANCE_CREATE_MODES})
481 9bf56d77 Michael Hanselmann
  @ivar source_handshake: Signed handshake from source (remote import only)
482 9bf56d77 Michael Hanselmann
  @ivar source_x509_ca: Source X509 CA in PEM format (remote import only)
483 9bf56d77 Michael Hanselmann
  @ivar source_instance_name: Previous name of instance (remote import only)
484 dae91d02 Michael Hanselmann
  @ivar source_shutdown_timeout: Shutdown timeout used for source instance
485 dae91d02 Michael Hanselmann
    (remote import only)
486 9bf56d77 Michael Hanselmann

487 9bf56d77 Michael Hanselmann
  """
488 a8083063 Iustin Pop
  OP_ID = "OP_INSTANCE_CREATE"
489 60dd1473 Iustin Pop
  OP_DSC_FIELD = "instance_name"
490 154b9580 Balazs Lecz
  __slots__ = [
491 25a8792c Iustin Pop
    "instance_name",
492 25a8792c Iustin Pop
    "os_type", "force_variant", "no_install",
493 47804ec9 Guido Trotter
    "pnode", "disk_template", "snode", "mode",
494 08db7c5c Iustin Pop
    "disks", "nics",
495 e588764d Iustin Pop
    "src_node", "src_path", "start", "identify_defaults",
496 5f23e043 Iustin Pop
    "wait_for_sync", "ip_check", "name_check",
497 dc936b49 Manuel Franceschini
    "file_storage_dir", "file_driver",
498 6785674e Iustin Pop
    "iallocator",
499 062a7100 Iustin Pop
    "hypervisor", "hvparams", "beparams", "osparams",
500 9bf56d77 Michael Hanselmann
    "source_handshake",
501 9bf56d77 Michael Hanselmann
    "source_x509_ca",
502 9bf56d77 Michael Hanselmann
    "source_instance_name",
503 dae91d02 Michael Hanselmann
    "source_shutdown_timeout",
504 3b6d8c9b Iustin Pop
    ]
505 a8083063 Iustin Pop
506 a8083063 Iustin Pop
507 fe7b0351 Michael Hanselmann
class OpReinstallInstance(OpCode):
508 fdc267f4 Iustin Pop
  """Reinstall an instance's OS."""
509 fe7b0351 Michael Hanselmann
  OP_ID = "OP_INSTANCE_REINSTALL"
510 60dd1473 Iustin Pop
  OP_DSC_FIELD = "instance_name"
511 8d8c4eff Michael Hanselmann
  __slots__ = ["instance_name", "os_type", "force_variant", "osparams"]
512 fe7b0351 Michael Hanselmann
513 fe7b0351 Michael Hanselmann
514 a8083063 Iustin Pop
class OpRemoveInstance(OpCode):
515 a8083063 Iustin Pop
  """Remove an instance."""
516 a8083063 Iustin Pop
  OP_ID = "OP_INSTANCE_REMOVE"
517 60dd1473 Iustin Pop
  OP_DSC_FIELD = "instance_name"
518 154b9580 Balazs Lecz
  __slots__ = [
519 fc1baca9 Michael Hanselmann
    "instance_name",
520 fc1baca9 Michael Hanselmann
    "ignore_failures",
521 fc1baca9 Michael Hanselmann
    "shutdown_timeout",
522 fc1baca9 Michael Hanselmann
    ]
523 a8083063 Iustin Pop
524 a8083063 Iustin Pop
525 decd5f45 Iustin Pop
class OpRenameInstance(OpCode):
526 decd5f45 Iustin Pop
  """Rename an instance."""
527 decd5f45 Iustin Pop
  OP_ID = "OP_INSTANCE_RENAME"
528 154b9580 Balazs Lecz
  __slots__ = [
529 3fe11ba3 Manuel Franceschini
    "instance_name", "ip_check", "new_name", "name_check",
530 4f05fd3b Iustin Pop
    ]
531 decd5f45 Iustin Pop
532 decd5f45 Iustin Pop
533 a8083063 Iustin Pop
class OpStartupInstance(OpCode):
534 fdc267f4 Iustin Pop
  """Startup an instance."""
535 a8083063 Iustin Pop
  OP_ID = "OP_INSTANCE_STARTUP"
536 60dd1473 Iustin Pop
  OP_DSC_FIELD = "instance_name"
537 154b9580 Balazs Lecz
  __slots__ = [
538 b44bd844 Michael Hanselmann
    "instance_name", "force", "hvparams", "beparams", "ignore_offline_nodes",
539 4f05fd3b Iustin Pop
    ]
540 a8083063 Iustin Pop
541 a8083063 Iustin Pop
542 a8083063 Iustin Pop
class OpShutdownInstance(OpCode):
543 fdc267f4 Iustin Pop
  """Shutdown an instance."""
544 a8083063 Iustin Pop
  OP_ID = "OP_INSTANCE_SHUTDOWN"
545 60dd1473 Iustin Pop
  OP_DSC_FIELD = "instance_name"
546 b44bd844 Michael Hanselmann
  __slots__ = [
547 b44bd844 Michael Hanselmann
    "instance_name", "timeout", "ignore_offline_nodes",
548 b44bd844 Michael Hanselmann
    ]
549 a8083063 Iustin Pop
550 a8083063 Iustin Pop
551 bf6929a2 Alexander Schreiber
class OpRebootInstance(OpCode):
552 bf6929a2 Alexander Schreiber
  """Reboot an instance."""
553 eeb3a5f9 Iustin Pop
  OP_ID = "OP_INSTANCE_REBOOT"
554 60dd1473 Iustin Pop
  OP_DSC_FIELD = "instance_name"
555 154b9580 Balazs Lecz
  __slots__ = [
556 17c3f802 Guido Trotter
    "instance_name", "reboot_type", "ignore_secondaries", "shutdown_timeout",
557 4f05fd3b Iustin Pop
    ]
558 bf6929a2 Alexander Schreiber
559 bf6929a2 Alexander Schreiber
560 a8083063 Iustin Pop
class OpReplaceDisks(OpCode):
561 fdc267f4 Iustin Pop
  """Replace the disks of an instance."""
562 a8083063 Iustin Pop
  OP_ID = "OP_INSTANCE_REPLACE_DISKS"
563 60dd1473 Iustin Pop
  OP_DSC_FIELD = "instance_name"
564 154b9580 Balazs Lecz
  __slots__ = [
565 4f05fd3b Iustin Pop
    "instance_name", "remote_node", "mode", "disks", "iallocator",
566 7ea7bcf6 Iustin Pop
    "early_release",
567 4f05fd3b Iustin Pop
    ]
568 a8083063 Iustin Pop
569 a8083063 Iustin Pop
570 a8083063 Iustin Pop
class OpFailoverInstance(OpCode):
571 a8083063 Iustin Pop
  """Failover an instance."""
572 a8083063 Iustin Pop
  OP_ID = "OP_INSTANCE_FAILOVER"
573 60dd1473 Iustin Pop
  OP_DSC_FIELD = "instance_name"
574 154b9580 Balazs Lecz
  __slots__ = [
575 17c3f802 Guido Trotter
    "instance_name", "ignore_consistency", "shutdown_timeout",
576 17c3f802 Guido Trotter
    ]
577 a8083063 Iustin Pop
578 a8083063 Iustin Pop
579 53c776b5 Iustin Pop
class OpMigrateInstance(OpCode):
580 53c776b5 Iustin Pop
  """Migrate an instance.
581 53c776b5 Iustin Pop

582 53c776b5 Iustin Pop
  This migrates (without shutting down an instance) to its secondary
583 53c776b5 Iustin Pop
  node.
584 53c776b5 Iustin Pop

585 2f907a8c Iustin Pop
  @ivar instance_name: the name of the instance
586 8c35561f Iustin Pop
  @ivar mode: the migration mode (live, non-live or None for auto)
587 53c776b5 Iustin Pop

588 53c776b5 Iustin Pop
  """
589 53c776b5 Iustin Pop
  OP_ID = "OP_INSTANCE_MIGRATE"
590 ee69c97f Iustin Pop
  OP_DSC_FIELD = "instance_name"
591 46d2d8a2 Iustin Pop
  __slots__ = ["instance_name", "mode", "cleanup", "live"]
592 53c776b5 Iustin Pop
593 53c776b5 Iustin Pop
594 313bcead Iustin Pop
class OpMoveInstance(OpCode):
595 313bcead Iustin Pop
  """Move an instance.
596 313bcead Iustin Pop

597 313bcead Iustin Pop
  This move (with shutting down an instance and data copying) to an
598 313bcead Iustin Pop
  arbitrary node.
599 313bcead Iustin Pop

600 313bcead Iustin Pop
  @ivar instance_name: the name of the instance
601 313bcead Iustin Pop
  @ivar target_node: the destination node
602 313bcead Iustin Pop

603 313bcead Iustin Pop
  """
604 313bcead Iustin Pop
  OP_ID = "OP_INSTANCE_MOVE"
605 313bcead Iustin Pop
  OP_DSC_FIELD = "instance_name"
606 154b9580 Balazs Lecz
  __slots__ = [
607 17c3f802 Guido Trotter
    "instance_name", "target_node", "shutdown_timeout",
608 154b9580 Balazs Lecz
    ]
609 313bcead Iustin Pop
610 313bcead Iustin Pop
611 a8083063 Iustin Pop
class OpConnectConsole(OpCode):
612 fdc267f4 Iustin Pop
  """Connect to an instance's console."""
613 a8083063 Iustin Pop
  OP_ID = "OP_INSTANCE_CONSOLE"
614 60dd1473 Iustin Pop
  OP_DSC_FIELD = "instance_name"
615 154b9580 Balazs Lecz
  __slots__ = ["instance_name"]
616 a8083063 Iustin Pop
617 a8083063 Iustin Pop
618 a8083063 Iustin Pop
class OpActivateInstanceDisks(OpCode):
619 fdc267f4 Iustin Pop
  """Activate an instance's disks."""
620 a8083063 Iustin Pop
  OP_ID = "OP_INSTANCE_ACTIVATE_DISKS"
621 60dd1473 Iustin Pop
  OP_DSC_FIELD = "instance_name"
622 154b9580 Balazs Lecz
  __slots__ = ["instance_name", "ignore_size"]
623 a8083063 Iustin Pop
624 a8083063 Iustin Pop
625 a8083063 Iustin Pop
class OpDeactivateInstanceDisks(OpCode):
626 fdc267f4 Iustin Pop
  """Deactivate an instance's disks."""
627 a8083063 Iustin Pop
  OP_ID = "OP_INSTANCE_DEACTIVATE_DISKS"
628 60dd1473 Iustin Pop
  OP_DSC_FIELD = "instance_name"
629 154b9580 Balazs Lecz
  __slots__ = ["instance_name"]
630 a8083063 Iustin Pop
631 a8083063 Iustin Pop
632 bd315bfa Iustin Pop
class OpRecreateInstanceDisks(OpCode):
633 bd315bfa Iustin Pop
  """Deactivate an instance's disks."""
634 bd315bfa Iustin Pop
  OP_ID = "OP_INSTANCE_RECREATE_DISKS"
635 bd315bfa Iustin Pop
  OP_DSC_FIELD = "instance_name"
636 154b9580 Balazs Lecz
  __slots__ = ["instance_name", "disks"]
637 bd315bfa Iustin Pop
638 bd315bfa Iustin Pop
639 a8083063 Iustin Pop
class OpQueryInstances(OpCode):
640 a8083063 Iustin Pop
  """Compute the list of instances."""
641 a8083063 Iustin Pop
  OP_ID = "OP_INSTANCE_QUERY"
642 154b9580 Balazs Lecz
  __slots__ = ["output_fields", "names", "use_locking"]
643 a8083063 Iustin Pop
644 a8083063 Iustin Pop
645 a8083063 Iustin Pop
class OpQueryInstanceData(OpCode):
646 a8083063 Iustin Pop
  """Compute the run-time status of instances."""
647 a8083063 Iustin Pop
  OP_ID = "OP_INSTANCE_QUERY_DATA"
648 154b9580 Balazs Lecz
  __slots__ = ["instances", "static"]
649 a8083063 Iustin Pop
650 a8083063 Iustin Pop
651 7767bbf5 Manuel Franceschini
class OpSetInstanceParams(OpCode):
652 a8083063 Iustin Pop
  """Change the parameters of an instance."""
653 7767bbf5 Manuel Franceschini
  OP_ID = "OP_INSTANCE_SET_PARAMS"
654 60dd1473 Iustin Pop
  OP_DSC_FIELD = "instance_name"
655 154b9580 Balazs Lecz
  __slots__ = [
656 24991749 Iustin Pop
    "instance_name",
657 1052d622 Iustin Pop
    "hvparams", "beparams", "osparams", "force",
658 e29e9550 Iustin Pop
    "nics", "disks", "disk_template",
659 96b39bcc Iustin Pop
    "remote_node", "os_name", "force_variant",
660 973d7867 Iustin Pop
    ]
661 a8083063 Iustin Pop
662 a8083063 Iustin Pop
663 8729e0d7 Iustin Pop
class OpGrowDisk(OpCode):
664 8729e0d7 Iustin Pop
  """Grow a disk of an instance."""
665 8729e0d7 Iustin Pop
  OP_ID = "OP_INSTANCE_GROW_DISK"
666 60dd1473 Iustin Pop
  OP_DSC_FIELD = "instance_name"
667 154b9580 Balazs Lecz
  __slots__ = [
668 4f05fd3b Iustin Pop
    "instance_name", "disk", "amount", "wait_for_sync",
669 4f05fd3b Iustin Pop
    ]
670 8729e0d7 Iustin Pop
671 8729e0d7 Iustin Pop
672 a8083063 Iustin Pop
# OS opcodes
673 a8083063 Iustin Pop
class OpDiagnoseOS(OpCode):
674 a8083063 Iustin Pop
  """Compute the list of guest operating systems."""
675 a8083063 Iustin Pop
  OP_ID = "OP_OS_DIAGNOSE"
676 154b9580 Balazs Lecz
  __slots__ = ["output_fields", "names"]
677 a8083063 Iustin Pop
678 7c0d6283 Michael Hanselmann
679 a8083063 Iustin Pop
# Exports opcodes
680 a8083063 Iustin Pop
class OpQueryExports(OpCode):
681 a8083063 Iustin Pop
  """Compute the list of exported images."""
682 a8083063 Iustin Pop
  OP_ID = "OP_BACKUP_QUERY"
683 154b9580 Balazs Lecz
  __slots__ = ["nodes", "use_locking"]
684 a8083063 Iustin Pop
685 7c0d6283 Michael Hanselmann
686 1410fa8d Michael Hanselmann
class OpPrepareExport(OpCode):
687 1410fa8d Michael Hanselmann
  """Prepares an instance export.
688 1410fa8d Michael Hanselmann

689 1410fa8d Michael Hanselmann
  @ivar instance_name: Instance name
690 1410fa8d Michael Hanselmann
  @ivar mode: Export mode (one of L{constants.EXPORT_MODES})
691 1410fa8d Michael Hanselmann

692 1410fa8d Michael Hanselmann
  """
693 1410fa8d Michael Hanselmann
  OP_ID = "OP_BACKUP_PREPARE"
694 1410fa8d Michael Hanselmann
  OP_DSC_FIELD = "instance_name"
695 1410fa8d Michael Hanselmann
  __slots__ = [
696 1410fa8d Michael Hanselmann
    "instance_name", "mode",
697 1410fa8d Michael Hanselmann
    ]
698 1410fa8d Michael Hanselmann
699 1410fa8d Michael Hanselmann
700 a8083063 Iustin Pop
class OpExportInstance(OpCode):
701 4a96f1d1 Michael Hanselmann
  """Export an instance.
702 4a96f1d1 Michael Hanselmann

703 4a96f1d1 Michael Hanselmann
  For local exports, the export destination is the node name. For remote
704 4a96f1d1 Michael Hanselmann
  exports, the export destination is a list of tuples, each consisting of
705 4a96f1d1 Michael Hanselmann
  hostname/IP address, port, HMAC and HMAC salt. The HMAC is calculated using
706 4a96f1d1 Michael Hanselmann
  the cluster domain secret over the value "${index}:${hostname}:${port}". The
707 4a96f1d1 Michael Hanselmann
  destination X509 CA must be a signed certificate.
708 4a96f1d1 Michael Hanselmann

709 4a96f1d1 Michael Hanselmann
  @ivar mode: Export mode (one of L{constants.EXPORT_MODES})
710 4a96f1d1 Michael Hanselmann
  @ivar target_node: Export destination
711 4a96f1d1 Michael Hanselmann
  @ivar x509_key_name: X509 key to use (remote export only)
712 4a96f1d1 Michael Hanselmann
  @ivar destination_x509_ca: Destination X509 CA in PEM format (remote export
713 4a96f1d1 Michael Hanselmann
                             only)
714 4a96f1d1 Michael Hanselmann

715 4a96f1d1 Michael Hanselmann
  """
716 a8083063 Iustin Pop
  OP_ID = "OP_BACKUP_EXPORT"
717 60dd1473 Iustin Pop
  OP_DSC_FIELD = "instance_name"
718 154b9580 Balazs Lecz
  __slots__ = [
719 4a96f1d1 Michael Hanselmann
    # TODO: Rename target_node as it changes meaning for different export modes
720 4a96f1d1 Michael Hanselmann
    # (e.g. "destination")
721 17c3f802 Guido Trotter
    "instance_name", "target_node", "shutdown", "shutdown_timeout",
722 faba00cb Michael Hanselmann
    "remove_instance",
723 faba00cb Michael Hanselmann
    "ignore_remove_failures",
724 4a96f1d1 Michael Hanselmann
    "mode",
725 4a96f1d1 Michael Hanselmann
    "x509_key_name",
726 4a96f1d1 Michael Hanselmann
    "destination_x509_ca",
727 17c3f802 Guido Trotter
    ]
728 5c947f38 Iustin Pop
729 0a7bed64 Michael Hanselmann
730 9ac99fda Guido Trotter
class OpRemoveExport(OpCode):
731 9ac99fda Guido Trotter
  """Remove an instance's export."""
732 9ac99fda Guido Trotter
  OP_ID = "OP_BACKUP_REMOVE"
733 60dd1473 Iustin Pop
  OP_DSC_FIELD = "instance_name"
734 154b9580 Balazs Lecz
  __slots__ = ["instance_name"]
735 5c947f38 Iustin Pop
736 0a7bed64 Michael Hanselmann
737 5c947f38 Iustin Pop
# Tags opcodes
738 5c947f38 Iustin Pop
class OpGetTags(OpCode):
739 5c947f38 Iustin Pop
  """Returns the tags of the given object."""
740 5c947f38 Iustin Pop
  OP_ID = "OP_TAGS_GET"
741 60dd1473 Iustin Pop
  OP_DSC_FIELD = "name"
742 154b9580 Balazs Lecz
  __slots__ = ["kind", "name"]
743 5c947f38 Iustin Pop
744 5c947f38 Iustin Pop
745 73415719 Iustin Pop
class OpSearchTags(OpCode):
746 73415719 Iustin Pop
  """Searches the tags in the cluster for a given pattern."""
747 73415719 Iustin Pop
  OP_ID = "OP_TAGS_SEARCH"
748 60dd1473 Iustin Pop
  OP_DSC_FIELD = "pattern"
749 154b9580 Balazs Lecz
  __slots__ = ["pattern"]
750 73415719 Iustin Pop
751 73415719 Iustin Pop
752 f27302fa Iustin Pop
class OpAddTags(OpCode):
753 f27302fa Iustin Pop
  """Add a list of tags on a given object."""
754 5c947f38 Iustin Pop
  OP_ID = "OP_TAGS_SET"
755 154b9580 Balazs Lecz
  __slots__ = ["kind", "name", "tags"]
756 5c947f38 Iustin Pop
757 5c947f38 Iustin Pop
758 f27302fa Iustin Pop
class OpDelTags(OpCode):
759 f27302fa Iustin Pop
  """Remove a list of tags from a given object."""
760 5c947f38 Iustin Pop
  OP_ID = "OP_TAGS_DEL"
761 154b9580 Balazs Lecz
  __slots__ = ["kind", "name", "tags"]
762 06009e27 Iustin Pop
763 06009e27 Iustin Pop
764 06009e27 Iustin Pop
# Test opcodes
765 06009e27 Iustin Pop
class OpTestDelay(OpCode):
766 06009e27 Iustin Pop
  """Sleeps for a configured amount of time.
767 06009e27 Iustin Pop

768 06009e27 Iustin Pop
  This is used just for debugging and testing.
769 06009e27 Iustin Pop

770 06009e27 Iustin Pop
  Parameters:
771 06009e27 Iustin Pop
    - duration: the time to sleep
772 06009e27 Iustin Pop
    - on_master: if true, sleep on the master
773 06009e27 Iustin Pop
    - on_nodes: list of nodes in which to sleep
774 06009e27 Iustin Pop

775 06009e27 Iustin Pop
  If the on_master parameter is true, it will execute a sleep on the
776 06009e27 Iustin Pop
  master (before any node sleep).
777 06009e27 Iustin Pop

778 06009e27 Iustin Pop
  If the on_nodes list is not empty, it will sleep on those nodes
779 06009e27 Iustin Pop
  (after the sleep on the master, if that is enabled).
780 06009e27 Iustin Pop

781 06009e27 Iustin Pop
  As an additional feature, the case of duration < 0 will be reported
782 06009e27 Iustin Pop
  as an execution error, so this opcode can be used as a failure
783 06009e27 Iustin Pop
  generator. The case of duration == 0 will not be treated specially.
784 06009e27 Iustin Pop

785 06009e27 Iustin Pop
  """
786 06009e27 Iustin Pop
  OP_ID = "OP_TEST_DELAY"
787 60dd1473 Iustin Pop
  OP_DSC_FIELD = "duration"
788 85a87e21 Guido Trotter
  __slots__ = ["duration", "on_master", "on_nodes", "repeat"]
789 d61df03e Iustin Pop
790 d61df03e Iustin Pop
791 d61df03e Iustin Pop
class OpTestAllocator(OpCode):
792 d61df03e Iustin Pop
  """Allocator framework testing.
793 d61df03e Iustin Pop

794 d61df03e Iustin Pop
  This opcode has two modes:
795 d61df03e Iustin Pop
    - gather and return allocator input for a given mode (allocate new
796 d61df03e Iustin Pop
      or replace secondary) and a given instance definition (direction
797 d61df03e Iustin Pop
      'in')
798 d61df03e Iustin Pop
    - run a selected allocator for a given operation (as above) and
799 d61df03e Iustin Pop
      return the allocator output (direction 'out')
800 d61df03e Iustin Pop

801 d61df03e Iustin Pop
  """
802 d61df03e Iustin Pop
  OP_ID = "OP_TEST_ALLOCATOR"
803 60dd1473 Iustin Pop
  OP_DSC_FIELD = "allocator"
804 154b9580 Balazs Lecz
  __slots__ = [
805 d61df03e Iustin Pop
    "direction", "mode", "allocator", "name",
806 d61df03e Iustin Pop
    "mem_size", "disks", "disk_template",
807 8cc7e742 Guido Trotter
    "os", "tags", "nics", "vcpus", "hypervisor",
808 823a72bc Iustin Pop
    "evac_nodes",
809 d61df03e Iustin Pop
    ]
810 363acb1e Iustin Pop
811 76aef8fc Michael Hanselmann
812 e58f87a9 Michael Hanselmann
class OpTestJobqueue(OpCode):
813 e58f87a9 Michael Hanselmann
  """Utility opcode to test some aspects of the job queue.
814 e58f87a9 Michael Hanselmann

815 e58f87a9 Michael Hanselmann
  """
816 e58f87a9 Michael Hanselmann
  OP_ID = "OP_TEST_JQUEUE"
817 e58f87a9 Michael Hanselmann
  __slots__ = [
818 e58f87a9 Michael Hanselmann
    "notify_waitlock",
819 e58f87a9 Michael Hanselmann
    "notify_exec",
820 e58f87a9 Michael Hanselmann
    "log_messages",
821 e58f87a9 Michael Hanselmann
    "fail",
822 e58f87a9 Michael Hanselmann
    ]
823 e58f87a9 Michael Hanselmann
824 e58f87a9 Michael Hanselmann
825 be760ba8 Michael Hanselmann
class OpTestDummy(OpCode):
826 be760ba8 Michael Hanselmann
  """Utility opcode used by unittests.
827 be760ba8 Michael Hanselmann

828 be760ba8 Michael Hanselmann
  """
829 be760ba8 Michael Hanselmann
  OP_ID = "OP_TEST_DUMMY"
830 be760ba8 Michael Hanselmann
  __slots__ = [
831 be760ba8 Michael Hanselmann
    "result",
832 be760ba8 Michael Hanselmann
    "messages",
833 be760ba8 Michael Hanselmann
    "fail",
834 be760ba8 Michael Hanselmann
    ]
835 be760ba8 Michael Hanselmann
836 be760ba8 Michael Hanselmann
837 363acb1e Iustin Pop
OP_MAPPING = dict([(v.OP_ID, v) for v in globals().values()
838 363acb1e Iustin Pop
                   if (isinstance(v, type) and issubclass(v, OpCode) and
839 363acb1e Iustin Pop
                       hasattr(v, "OP_ID"))])