Statistics
| Branch: | Tag: | Revision:

root / lib / opcodes.py @ 2467e0d3

History | View | Annotate | Download (10.8 kB)

1 2f31098c Iustin Pop
#
2 a8083063 Iustin Pop
#
3 a8083063 Iustin Pop
4 a8083063 Iustin Pop
# Copyright (C) 2006, 2007 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 a8083063 Iustin Pop

28 a8083063 Iustin Pop
This module implements the logic for doing operations in the cluster. There
29 a8083063 Iustin Pop
are two kinds of classes defined:
30 a8083063 Iustin Pop
  - opcodes, which are small classes only holding data for the task at hand
31 a8083063 Iustin Pop
  - logical units, which know how to deal with their specific opcode only
32 a8083063 Iustin Pop

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

43 df458e0b Iustin Pop
  This object serves as a parent class for both OpCode and Job since
44 df458e0b Iustin Pop
  they are serialized in the same way.
45 df458e0b Iustin Pop

46 df458e0b Iustin Pop
  """
47 a8083063 Iustin Pop
  __slots__ = []
48 a8083063 Iustin Pop
49 a8083063 Iustin Pop
  def __init__(self, **kwargs):
50 a8083063 Iustin Pop
    for key in kwargs:
51 a8083063 Iustin Pop
      if key not in self.__slots__:
52 df458e0b Iustin Pop
        raise TypeError("Object %s doesn't support the parameter '%s'" %
53 3ecf6786 Iustin Pop
                        (self.__class__.__name__, key))
54 a8083063 Iustin Pop
      setattr(self, key, kwargs[key])
55 a8083063 Iustin Pop
56 df458e0b Iustin Pop
  def __getstate__(self):
57 df458e0b Iustin Pop
    state = {}
58 df458e0b Iustin Pop
    for name in self.__slots__:
59 df458e0b Iustin Pop
      if hasattr(self, name):
60 df458e0b Iustin Pop
        state[name] = getattr(self, name)
61 df458e0b Iustin Pop
    return state
62 df458e0b Iustin Pop
63 df458e0b Iustin Pop
  def __setstate__(self, state):
64 df458e0b Iustin Pop
    if not isinstance(state, dict):
65 df458e0b Iustin Pop
      raise ValueError("Invalid data to __setstate__: expected dict, got %s" %
66 df458e0b Iustin Pop
                       type(state))
67 df458e0b Iustin Pop
68 df458e0b Iustin Pop
    for name in self.__slots__:
69 df458e0b Iustin Pop
      if name not in state:
70 df458e0b Iustin Pop
        delattr(self, name)
71 df458e0b Iustin Pop
72 df458e0b Iustin Pop
    for name in state:
73 df458e0b Iustin Pop
      setattr(self, name, state[name])
74 df458e0b Iustin Pop
75 df458e0b Iustin Pop
76 df458e0b Iustin Pop
class OpCode(BaseJO):
77 df458e0b Iustin Pop
  """Abstract OpCode"""
78 df458e0b Iustin Pop
  OP_ID = "OP_ABSTRACT"
79 df458e0b Iustin Pop
  __slots__ = []
80 df458e0b Iustin Pop
81 df458e0b Iustin Pop
  def __getstate__(self):
82 df458e0b Iustin Pop
    """Specialized getstate for opcodes.
83 df458e0b Iustin Pop

84 df458e0b Iustin Pop
    """
85 df458e0b Iustin Pop
    data = BaseJO.__getstate__(self)
86 df458e0b Iustin Pop
    data["OP_ID"] = self.OP_ID
87 df458e0b Iustin Pop
    return data
88 df458e0b Iustin Pop
89 df458e0b Iustin Pop
  @classmethod
90 00abdc96 Iustin Pop
  def LoadOpCode(cls, data):
91 df458e0b Iustin Pop
    """Generic load opcode method.
92 df458e0b Iustin Pop

93 df458e0b Iustin Pop
    """
94 df458e0b Iustin Pop
    if not isinstance(data, dict):
95 df458e0b Iustin Pop
      raise ValueError("Invalid data to LoadOpCode (%s)" % type(data))
96 df458e0b Iustin Pop
    if "OP_ID" not in data:
97 df458e0b Iustin Pop
      raise ValueError("Invalid data to LoadOpcode, missing OP_ID")
98 df458e0b Iustin Pop
    op_id = data["OP_ID"]
99 df458e0b Iustin Pop
    op_class = None
100 df458e0b Iustin Pop
    for item in globals().values():
101 df458e0b Iustin Pop
      if (isinstance(item, type) and
102 df458e0b Iustin Pop
          issubclass(item, cls) and
103 df458e0b Iustin Pop
          hasattr(item, "OP_ID") and
104 df458e0b Iustin Pop
          getattr(item, "OP_ID") == op_id):
105 df458e0b Iustin Pop
        op_class = item
106 df458e0b Iustin Pop
        break
107 df458e0b Iustin Pop
    if op_class is None:
108 df458e0b Iustin Pop
      raise ValueError("Invalid data to LoadOpCode: OP_ID %s unsupported" %
109 df458e0b Iustin Pop
                       op_id)
110 df458e0b Iustin Pop
    op = op_class()
111 df458e0b Iustin Pop
    new_data = data.copy()
112 df458e0b Iustin Pop
    del new_data["OP_ID"]
113 df458e0b Iustin Pop
    op.__setstate__(new_data)
114 df458e0b Iustin Pop
    return op
115 df458e0b Iustin Pop
116 a8083063 Iustin Pop
117 a8083063 Iustin Pop
class OpDestroyCluster(OpCode):
118 a8083063 Iustin Pop
  """Destroy the cluster."""
119 a8083063 Iustin Pop
  OP_ID = "OP_CLUSTER_DESTROY"
120 a8083063 Iustin Pop
  __slots__ = []
121 a8083063 Iustin Pop
122 a8083063 Iustin Pop
123 a8083063 Iustin Pop
class OpQueryClusterInfo(OpCode):
124 fdc267f4 Iustin Pop
  """Query cluster information."""
125 a8083063 Iustin Pop
  OP_ID = "OP_CLUSTER_QUERY"
126 a8083063 Iustin Pop
  __slots__ = []
127 a8083063 Iustin Pop
128 a8083063 Iustin Pop
129 a8083063 Iustin Pop
class OpVerifyCluster(OpCode):
130 fdc267f4 Iustin Pop
  """Verify the cluster state."""
131 a8083063 Iustin Pop
  OP_ID = "OP_CLUSTER_VERIFY"
132 e54c4c5e Guido Trotter
  __slots__ = ["skip_checks"]
133 a8083063 Iustin Pop
134 a8083063 Iustin Pop
135 150e978f Iustin Pop
class OpVerifyDisks(OpCode):
136 150e978f Iustin Pop
  """Verify the cluster disks.
137 150e978f Iustin Pop

138 150e978f Iustin Pop
  Parameters: none
139 150e978f Iustin Pop

140 150e978f Iustin Pop
  Result: two lists:
141 150e978f Iustin Pop
    - list of node names with bad data returned (unreachable, etc.)
142 b63ed789 Iustin Pop
    - dist of node names with broken volume groups (values: error msg)
143 150e978f Iustin Pop
    - list of instances with degraded disks (that should be activated)
144 b63ed789 Iustin Pop
    - dict of instances with missing logical volumes (values: (node, vol)
145 b63ed789 Iustin Pop
      pairs with details about the missing volumes)
146 150e978f Iustin Pop

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

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

155 150e978f Iustin Pop
  """
156 150e978f Iustin Pop
  OP_ID = "OP_CLUSTER_VERIFY_DISKS"
157 150e978f Iustin Pop
  __slots__ = []
158 150e978f Iustin Pop
159 150e978f Iustin Pop
160 a8083063 Iustin Pop
class OpMasterFailover(OpCode):
161 fdc267f4 Iustin Pop
  """Do a master failover."""
162 a8083063 Iustin Pop
  OP_ID = "OP_CLUSTER_MASTERFAILOVER"
163 a8083063 Iustin Pop
  __slots__ = []
164 a8083063 Iustin Pop
165 a8083063 Iustin Pop
166 a8083063 Iustin Pop
class OpDumpClusterConfig(OpCode):
167 fdc267f4 Iustin Pop
  """Dump the cluster configuration."""
168 a8083063 Iustin Pop
  OP_ID = "OP_CLUSTER_DUMPCONFIG"
169 a8083063 Iustin Pop
  __slots__ = []
170 a8083063 Iustin Pop
171 a8083063 Iustin Pop
172 07bd8a51 Iustin Pop
class OpRenameCluster(OpCode):
173 07bd8a51 Iustin Pop
  """Rename the cluster."""
174 07bd8a51 Iustin Pop
  OP_ID = "OP_CLUSTER_RENAME"
175 07bd8a51 Iustin Pop
  __slots__ = ["name"]
176 07bd8a51 Iustin Pop
177 07bd8a51 Iustin Pop
178 12515db7 Manuel Franceschini
class OpSetClusterParams(OpCode):
179 12515db7 Manuel Franceschini
  """Change the parameters of the cluster."""
180 12515db7 Manuel Franceschini
  OP_ID = "OP_CLUSTER_SET_PARAMS"
181 12515db7 Manuel Franceschini
  __slots__ = ["vg_name"]
182 12515db7 Manuel Franceschini
183 12515db7 Manuel Franceschini
184 07bd8a51 Iustin Pop
# node opcodes
185 07bd8a51 Iustin Pop
186 a8083063 Iustin Pop
class OpRemoveNode(OpCode):
187 a8083063 Iustin Pop
  """Remove a node."""
188 a8083063 Iustin Pop
  OP_ID = "OP_NODE_REMOVE"
189 a8083063 Iustin Pop
  __slots__ = ["node_name"]
190 a8083063 Iustin Pop
191 a8083063 Iustin Pop
192 a8083063 Iustin Pop
class OpAddNode(OpCode):
193 a8083063 Iustin Pop
  """Add a node."""
194 a8083063 Iustin Pop
  OP_ID = "OP_NODE_ADD"
195 e7c6e02b Michael Hanselmann
  __slots__ = ["node_name", "primary_ip", "secondary_ip", "readd"]
196 a8083063 Iustin Pop
197 a8083063 Iustin Pop
198 a8083063 Iustin Pop
class OpQueryNodes(OpCode):
199 a8083063 Iustin Pop
  """Compute the list of nodes."""
200 a8083063 Iustin Pop
  OP_ID = "OP_NODE_QUERY"
201 246e180a Iustin Pop
  __slots__ = ["output_fields", "names"]
202 a8083063 Iustin Pop
203 a8083063 Iustin Pop
204 dcb93971 Michael Hanselmann
class OpQueryNodeVolumes(OpCode):
205 dcb93971 Michael Hanselmann
  """Get list of volumes on node."""
206 dcb93971 Michael Hanselmann
  OP_ID = "OP_NODE_QUERYVOLS"
207 dcb93971 Michael Hanselmann
  __slots__ = ["nodes", "output_fields"]
208 dcb93971 Michael Hanselmann
209 dcb93971 Michael Hanselmann
210 a8083063 Iustin Pop
# instance opcodes
211 a8083063 Iustin Pop
212 a8083063 Iustin Pop
class OpCreateInstance(OpCode):
213 fdc267f4 Iustin Pop
  """Create an instance."""
214 a8083063 Iustin Pop
  OP_ID = "OP_INSTANCE_CREATE"
215 3b6d8c9b Iustin Pop
  __slots__ = [
216 3b6d8c9b Iustin Pop
    "instance_name", "mem_size", "disk_size", "os_type", "pnode",
217 3b6d8c9b Iustin Pop
    "disk_template", "snode", "swap_size", "mode",
218 3b6d8c9b Iustin Pop
    "vcpus", "ip", "bridge", "src_node", "src_path", "start",
219 3b6d8c9b Iustin Pop
    "wait_for_sync", "ip_check", "mac",
220 31a853d2 Iustin Pop
    "kernel_path", "initrd_path", "hvm_boot_order", "hvm_acpi",
221 31a853d2 Iustin Pop
    "hvm_pae", "hvm_cdrom_image_path", "vnc_bind_address",
222 dc936b49 Manuel Franceschini
    "file_storage_dir", "file_driver",
223 538475ca Iustin Pop
    "iallocator",
224 3b6d8c9b Iustin Pop
    ]
225 a8083063 Iustin Pop
226 a8083063 Iustin Pop
227 fe7b0351 Michael Hanselmann
class OpReinstallInstance(OpCode):
228 fdc267f4 Iustin Pop
  """Reinstall an instance's OS."""
229 fe7b0351 Michael Hanselmann
  OP_ID = "OP_INSTANCE_REINSTALL"
230 d0834de3 Michael Hanselmann
  __slots__ = ["instance_name", "os_type"]
231 fe7b0351 Michael Hanselmann
232 fe7b0351 Michael Hanselmann
233 a8083063 Iustin Pop
class OpRemoveInstance(OpCode):
234 a8083063 Iustin Pop
  """Remove an instance."""
235 a8083063 Iustin Pop
  OP_ID = "OP_INSTANCE_REMOVE"
236 1d67656e Iustin Pop
  __slots__ = ["instance_name", "ignore_failures"]
237 a8083063 Iustin Pop
238 a8083063 Iustin Pop
239 decd5f45 Iustin Pop
class OpRenameInstance(OpCode):
240 decd5f45 Iustin Pop
  """Rename an instance."""
241 decd5f45 Iustin Pop
  OP_ID = "OP_INSTANCE_RENAME"
242 decd5f45 Iustin Pop
  __slots__ = ["instance_name", "ignore_ip", "new_name"]
243 decd5f45 Iustin Pop
244 decd5f45 Iustin Pop
245 a8083063 Iustin Pop
class OpStartupInstance(OpCode):
246 fdc267f4 Iustin Pop
  """Startup an instance."""
247 a8083063 Iustin Pop
  OP_ID = "OP_INSTANCE_STARTUP"
248 a8083063 Iustin Pop
  __slots__ = ["instance_name", "force", "extra_args"]
249 a8083063 Iustin Pop
250 a8083063 Iustin Pop
251 a8083063 Iustin Pop
class OpShutdownInstance(OpCode):
252 fdc267f4 Iustin Pop
  """Shutdown an instance."""
253 a8083063 Iustin Pop
  OP_ID = "OP_INSTANCE_SHUTDOWN"
254 a8083063 Iustin Pop
  __slots__ = ["instance_name"]
255 a8083063 Iustin Pop
256 a8083063 Iustin Pop
257 bf6929a2 Alexander Schreiber
class OpRebootInstance(OpCode):
258 bf6929a2 Alexander Schreiber
  """Reboot an instance."""
259 eeb3a5f9 Iustin Pop
  OP_ID = "OP_INSTANCE_REBOOT"
260 bf6929a2 Alexander Schreiber
  __slots__ = ["instance_name", "reboot_type", "extra_args",
261 bf6929a2 Alexander Schreiber
               "ignore_secondaries" ]
262 bf6929a2 Alexander Schreiber
263 bf6929a2 Alexander Schreiber
264 a8083063 Iustin Pop
class OpReplaceDisks(OpCode):
265 fdc267f4 Iustin Pop
  """Replace the disks of an instance."""
266 a8083063 Iustin Pop
  OP_ID = "OP_INSTANCE_REPLACE_DISKS"
267 b6e82a65 Iustin Pop
  __slots__ = ["instance_name", "remote_node", "mode", "disks", "iallocator"]
268 a8083063 Iustin Pop
269 a8083063 Iustin Pop
270 a8083063 Iustin Pop
class OpFailoverInstance(OpCode):
271 a8083063 Iustin Pop
  """Failover an instance."""
272 a8083063 Iustin Pop
  OP_ID = "OP_INSTANCE_FAILOVER"
273 a8083063 Iustin Pop
  __slots__ = ["instance_name", "ignore_consistency"]
274 a8083063 Iustin Pop
275 a8083063 Iustin Pop
276 a8083063 Iustin Pop
class OpConnectConsole(OpCode):
277 fdc267f4 Iustin Pop
  """Connect to an instance's console."""
278 a8083063 Iustin Pop
  OP_ID = "OP_INSTANCE_CONSOLE"
279 a8083063 Iustin Pop
  __slots__ = ["instance_name"]
280 a8083063 Iustin Pop
281 a8083063 Iustin Pop
282 a8083063 Iustin Pop
class OpActivateInstanceDisks(OpCode):
283 fdc267f4 Iustin Pop
  """Activate an instance's disks."""
284 a8083063 Iustin Pop
  OP_ID = "OP_INSTANCE_ACTIVATE_DISKS"
285 a8083063 Iustin Pop
  __slots__ = ["instance_name"]
286 a8083063 Iustin Pop
287 a8083063 Iustin Pop
288 a8083063 Iustin Pop
class OpDeactivateInstanceDisks(OpCode):
289 fdc267f4 Iustin Pop
  """Deactivate an instance's disks."""
290 a8083063 Iustin Pop
  OP_ID = "OP_INSTANCE_DEACTIVATE_DISKS"
291 a8083063 Iustin Pop
  __slots__ = ["instance_name"]
292 a8083063 Iustin Pop
293 a8083063 Iustin Pop
294 a8083063 Iustin Pop
class OpQueryInstances(OpCode):
295 a8083063 Iustin Pop
  """Compute the list of instances."""
296 a8083063 Iustin Pop
  OP_ID = "OP_INSTANCE_QUERY"
297 069dcc86 Iustin Pop
  __slots__ = ["output_fields", "names"]
298 a8083063 Iustin Pop
299 a8083063 Iustin Pop
300 a8083063 Iustin Pop
class OpQueryInstanceData(OpCode):
301 a8083063 Iustin Pop
  """Compute the run-time status of instances."""
302 a8083063 Iustin Pop
  OP_ID = "OP_INSTANCE_QUERY_DATA"
303 a8083063 Iustin Pop
  __slots__ = ["instances"]
304 a8083063 Iustin Pop
305 a8083063 Iustin Pop
306 7767bbf5 Manuel Franceschini
class OpSetInstanceParams(OpCode):
307 a8083063 Iustin Pop
  """Change the parameters of an instance."""
308 7767bbf5 Manuel Franceschini
  OP_ID = "OP_INSTANCE_SET_PARAMS"
309 973d7867 Iustin Pop
  __slots__ = [
310 973d7867 Iustin Pop
    "instance_name", "mem", "vcpus", "ip", "bridge", "mac",
311 31a853d2 Iustin Pop
    "kernel_path", "initrd_path", "hvm_boot_order", "hvm_acpi",
312 31a853d2 Iustin Pop
    "hvm_pae", "hvm_cdrom_image_path", "vnc_bind_address"
313 973d7867 Iustin Pop
    ]
314 a8083063 Iustin Pop
315 a8083063 Iustin Pop
316 8729e0d7 Iustin Pop
class OpGrowDisk(OpCode):
317 8729e0d7 Iustin Pop
  """Grow a disk of an instance."""
318 8729e0d7 Iustin Pop
  OP_ID = "OP_INSTANCE_GROW_DISK"
319 8729e0d7 Iustin Pop
  __slots__ = ["instance_name", "disk", "amount"]
320 8729e0d7 Iustin Pop
321 8729e0d7 Iustin Pop
322 a8083063 Iustin Pop
# OS opcodes
323 a8083063 Iustin Pop
class OpDiagnoseOS(OpCode):
324 a8083063 Iustin Pop
  """Compute the list of guest operating systems."""
325 a8083063 Iustin Pop
  OP_ID = "OP_OS_DIAGNOSE"
326 1f9430d6 Iustin Pop
  __slots__ = ["output_fields", "names"]
327 a8083063 Iustin Pop
328 7c0d6283 Michael Hanselmann
329 a8083063 Iustin Pop
# Exports opcodes
330 a8083063 Iustin Pop
class OpQueryExports(OpCode):
331 a8083063 Iustin Pop
  """Compute the list of exported images."""
332 a8083063 Iustin Pop
  OP_ID = "OP_BACKUP_QUERY"
333 a8083063 Iustin Pop
  __slots__ = ["nodes"]
334 a8083063 Iustin Pop
335 7c0d6283 Michael Hanselmann
336 a8083063 Iustin Pop
class OpExportInstance(OpCode):
337 a8083063 Iustin Pop
  """Export an instance."""
338 a8083063 Iustin Pop
  OP_ID = "OP_BACKUP_EXPORT"
339 a8083063 Iustin Pop
  __slots__ = ["instance_name", "target_node", "shutdown"]
340 5c947f38 Iustin Pop
341 9ac99fda Guido Trotter
class OpRemoveExport(OpCode):
342 9ac99fda Guido Trotter
  """Remove an instance's export."""
343 9ac99fda Guido Trotter
  OP_ID = "OP_BACKUP_REMOVE"
344 9ac99fda Guido Trotter
  __slots__ = ["instance_name"]
345 5c947f38 Iustin Pop
346 5c947f38 Iustin Pop
# Tags opcodes
347 5c947f38 Iustin Pop
class OpGetTags(OpCode):
348 5c947f38 Iustin Pop
  """Returns the tags of the given object."""
349 5c947f38 Iustin Pop
  OP_ID = "OP_TAGS_GET"
350 5c947f38 Iustin Pop
  __slots__ = ["kind", "name"]
351 5c947f38 Iustin Pop
352 5c947f38 Iustin Pop
353 73415719 Iustin Pop
class OpSearchTags(OpCode):
354 73415719 Iustin Pop
  """Searches the tags in the cluster for a given pattern."""
355 73415719 Iustin Pop
  OP_ID = "OP_TAGS_SEARCH"
356 73415719 Iustin Pop
  __slots__ = ["pattern"]
357 73415719 Iustin Pop
358 73415719 Iustin Pop
359 f27302fa Iustin Pop
class OpAddTags(OpCode):
360 f27302fa Iustin Pop
  """Add a list of tags on a given object."""
361 5c947f38 Iustin Pop
  OP_ID = "OP_TAGS_SET"
362 f27302fa Iustin Pop
  __slots__ = ["kind", "name", "tags"]
363 5c947f38 Iustin Pop
364 5c947f38 Iustin Pop
365 f27302fa Iustin Pop
class OpDelTags(OpCode):
366 f27302fa Iustin Pop
  """Remove a list of tags from a given object."""
367 5c947f38 Iustin Pop
  OP_ID = "OP_TAGS_DEL"
368 f27302fa Iustin Pop
  __slots__ = ["kind", "name", "tags"]
369 06009e27 Iustin Pop
370 06009e27 Iustin Pop
371 06009e27 Iustin Pop
# Test opcodes
372 06009e27 Iustin Pop
class OpTestDelay(OpCode):
373 06009e27 Iustin Pop
  """Sleeps for a configured amount of time.
374 06009e27 Iustin Pop

375 06009e27 Iustin Pop
  This is used just for debugging and testing.
376 06009e27 Iustin Pop

377 06009e27 Iustin Pop
  Parameters:
378 06009e27 Iustin Pop
    - duration: the time to sleep
379 06009e27 Iustin Pop
    - on_master: if true, sleep on the master
380 06009e27 Iustin Pop
    - on_nodes: list of nodes in which to sleep
381 06009e27 Iustin Pop

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

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

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

392 06009e27 Iustin Pop
  """
393 06009e27 Iustin Pop
  OP_ID = "OP_TEST_DELAY"
394 06009e27 Iustin Pop
  __slots__ = ["duration", "on_master", "on_nodes"]
395 d61df03e Iustin Pop
396 d61df03e Iustin Pop
397 d61df03e Iustin Pop
class OpTestAllocator(OpCode):
398 d61df03e Iustin Pop
  """Allocator framework testing.
399 d61df03e Iustin Pop

400 d61df03e Iustin Pop
  This opcode has two modes:
401 d61df03e Iustin Pop
    - gather and return allocator input for a given mode (allocate new
402 d61df03e Iustin Pop
      or replace secondary) and a given instance definition (direction
403 d61df03e Iustin Pop
      'in')
404 d61df03e Iustin Pop
    - run a selected allocator for a given operation (as above) and
405 d61df03e Iustin Pop
      return the allocator output (direction 'out')
406 d61df03e Iustin Pop

407 d61df03e Iustin Pop
  """
408 d61df03e Iustin Pop
  OP_ID = "OP_TEST_ALLOCATOR"
409 d61df03e Iustin Pop
  __slots__ = [
410 d61df03e Iustin Pop
    "direction", "mode", "allocator", "name",
411 d61df03e Iustin Pop
    "mem_size", "disks", "disk_template",
412 d61df03e Iustin Pop
    "os", "tags", "nics", "vcpus",
413 d61df03e Iustin Pop
    ]