root / lib / opcodes.py @ 5c983ee5
History | View | Annotate | Download (19.3 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 | 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 | a8083063 | Iustin Pop | for key in kwargs: |
56 | a8083063 | Iustin Pop | if key not in self.__slots__: |
57 | df458e0b | Iustin Pop | raise TypeError("Object %s doesn't support the parameter '%s'" % |
58 | 3ecf6786 | Iustin Pop | (self.__class__.__name__, key))
|
59 | a8083063 | Iustin Pop | setattr(self, key, kwargs[key]) |
60 | a8083063 | Iustin Pop | |
61 | df458e0b | Iustin Pop | def __getstate__(self): |
62 | a7399f66 | Iustin Pop | """Generic serializer.
|
63 | a7399f66 | Iustin Pop |
|
64 | a7399f66 | Iustin Pop | This method just returns the contents of the instance as a
|
65 | a7399f66 | Iustin Pop | dictionary.
|
66 | a7399f66 | Iustin Pop |
|
67 | a7399f66 | Iustin Pop | @rtype: C{dict}
|
68 | a7399f66 | Iustin Pop | @return: the instance attributes and their values
|
69 | a7399f66 | Iustin Pop |
|
70 | a7399f66 | Iustin Pop | """
|
71 | df458e0b | Iustin Pop | state = {} |
72 | df458e0b | Iustin Pop | for name in self.__slots__: |
73 | df458e0b | Iustin Pop | if hasattr(self, name): |
74 | df458e0b | Iustin Pop | state[name] = getattr(self, name) |
75 | df458e0b | Iustin Pop | return state
|
76 | df458e0b | Iustin Pop | |
77 | df458e0b | Iustin Pop | def __setstate__(self, state): |
78 | a7399f66 | Iustin Pop | """Generic unserializer.
|
79 | a7399f66 | Iustin Pop |
|
80 | a7399f66 | Iustin Pop | This method just restores from the serialized state the attributes
|
81 | a7399f66 | Iustin Pop | of the current instance.
|
82 | a7399f66 | Iustin Pop |
|
83 | a7399f66 | Iustin Pop | @param state: the serialized opcode data
|
84 | a7399f66 | Iustin Pop | @type state: C{dict}
|
85 | a7399f66 | Iustin Pop |
|
86 | a7399f66 | Iustin Pop | """
|
87 | df458e0b | Iustin Pop | if not isinstance(state, dict): |
88 | df458e0b | Iustin Pop | raise ValueError("Invalid data to __setstate__: expected dict, got %s" % |
89 | df458e0b | Iustin Pop | type(state))
|
90 | df458e0b | Iustin Pop | |
91 | df458e0b | Iustin Pop | for name in self.__slots__: |
92 | df458e0b | Iustin Pop | if name not in state: |
93 | df458e0b | Iustin Pop | delattr(self, name) |
94 | df458e0b | Iustin Pop | |
95 | df458e0b | Iustin Pop | for name in state: |
96 | df458e0b | Iustin Pop | setattr(self, name, state[name]) |
97 | df458e0b | Iustin Pop | |
98 | df458e0b | Iustin Pop | |
99 | 0e46916d | Iustin Pop | class OpCode(BaseOpCode): |
100 | a7399f66 | Iustin Pop | """Abstract OpCode.
|
101 | a7399f66 | Iustin Pop |
|
102 | a7399f66 | Iustin Pop | This is the root of the actual OpCode hierarchy. All clases derived
|
103 | a7399f66 | Iustin Pop | from this class should override OP_ID.
|
104 | a7399f66 | Iustin Pop |
|
105 | a7399f66 | Iustin Pop | @cvar OP_ID: The ID of this opcode. This should be unique amongst all
|
106 | 20777413 | Iustin Pop | children of this class.
|
107 | 20777413 | Iustin Pop | @ivar dry_run: Whether the LU should be run in dry-run mode, i.e. just
|
108 | 20777413 | Iustin Pop | the check steps
|
109 | a7399f66 | Iustin Pop |
|
110 | a7399f66 | Iustin Pop | """
|
111 | df458e0b | Iustin Pop | OP_ID = "OP_ABSTRACT"
|
112 | 20777413 | Iustin Pop | __slots__ = BaseOpCode.__slots__ + ["dry_run"]
|
113 | df458e0b | Iustin Pop | |
114 | df458e0b | Iustin Pop | def __getstate__(self): |
115 | df458e0b | Iustin Pop | """Specialized getstate for opcodes.
|
116 | df458e0b | Iustin Pop |
|
117 | a7399f66 | Iustin Pop | This method adds to the state dictionary the OP_ID of the class,
|
118 | a7399f66 | Iustin Pop | so that on unload we can identify the correct class for
|
119 | a7399f66 | Iustin Pop | instantiating the opcode.
|
120 | a7399f66 | Iustin Pop |
|
121 | a7399f66 | Iustin Pop | @rtype: C{dict}
|
122 | a7399f66 | Iustin Pop | @return: the state as a dictionary
|
123 | a7399f66 | Iustin Pop |
|
124 | df458e0b | Iustin Pop | """
|
125 | 0e46916d | Iustin Pop | data = BaseOpCode.__getstate__(self)
|
126 | df458e0b | Iustin Pop | data["OP_ID"] = self.OP_ID |
127 | df458e0b | Iustin Pop | return data
|
128 | df458e0b | Iustin Pop | |
129 | df458e0b | Iustin Pop | @classmethod
|
130 | 00abdc96 | Iustin Pop | def LoadOpCode(cls, data): |
131 | df458e0b | Iustin Pop | """Generic load opcode method.
|
132 | df458e0b | Iustin Pop |
|
133 | a7399f66 | Iustin Pop | The method identifies the correct opcode class from the dict-form
|
134 | a7399f66 | Iustin Pop | by looking for a OP_ID key, if this is not found, or its value is
|
135 | a7399f66 | Iustin Pop | not available in this module as a child of this class, we fail.
|
136 | a7399f66 | Iustin Pop |
|
137 | a7399f66 | Iustin Pop | @type data: C{dict}
|
138 | a7399f66 | Iustin Pop | @param data: the serialized opcode
|
139 | a7399f66 | Iustin Pop |
|
140 | df458e0b | Iustin Pop | """
|
141 | df458e0b | Iustin Pop | if not isinstance(data, dict): |
142 | df458e0b | Iustin Pop | raise ValueError("Invalid data to LoadOpCode (%s)" % type(data)) |
143 | df458e0b | Iustin Pop | if "OP_ID" not in data: |
144 | df458e0b | Iustin Pop | raise ValueError("Invalid data to LoadOpcode, missing OP_ID") |
145 | df458e0b | Iustin Pop | op_id = data["OP_ID"]
|
146 | df458e0b | Iustin Pop | op_class = None
|
147 | 363acb1e | Iustin Pop | if op_id in OP_MAPPING: |
148 | 363acb1e | Iustin Pop | op_class = OP_MAPPING[op_id] |
149 | 363acb1e | Iustin Pop | else:
|
150 | df458e0b | Iustin Pop | raise ValueError("Invalid data to LoadOpCode: OP_ID %s unsupported" % |
151 | df458e0b | Iustin Pop | op_id) |
152 | df458e0b | Iustin Pop | op = op_class() |
153 | df458e0b | Iustin Pop | new_data = data.copy() |
154 | df458e0b | Iustin Pop | del new_data["OP_ID"] |
155 | df458e0b | Iustin Pop | op.__setstate__(new_data) |
156 | df458e0b | Iustin Pop | return op
|
157 | df458e0b | Iustin Pop | |
158 | 60dd1473 | Iustin Pop | def Summary(self): |
159 | 60dd1473 | Iustin Pop | """Generates a summary description of this opcode.
|
160 | 60dd1473 | Iustin Pop |
|
161 | 60dd1473 | Iustin Pop | """
|
162 | 60dd1473 | Iustin Pop | # all OP_ID start with OP_, we remove that
|
163 | 60dd1473 | Iustin Pop | txt = self.OP_ID[3:] |
164 | 60dd1473 | Iustin Pop | field_name = getattr(self, "OP_DSC_FIELD", None) |
165 | 60dd1473 | Iustin Pop | if field_name:
|
166 | 60dd1473 | Iustin Pop | field_value = getattr(self, field_name, None) |
167 | 60dd1473 | Iustin Pop | txt = "%s(%s)" % (txt, field_value)
|
168 | 60dd1473 | Iustin Pop | return txt
|
169 | 60dd1473 | Iustin Pop | |
170 | a8083063 | Iustin Pop | |
171 | afee0879 | Iustin Pop | # cluster opcodes
|
172 | afee0879 | Iustin Pop | |
173 | b5f5fae9 | Luca Bigliardi | class OpPostInitCluster(OpCode): |
174 | b5f5fae9 | Luca Bigliardi | """Post cluster initialization.
|
175 | b5f5fae9 | Luca Bigliardi |
|
176 | b5f5fae9 | Luca Bigliardi | This opcode does not touch the cluster at all. Its purpose is to run hooks
|
177 | b5f5fae9 | Luca Bigliardi | after the cluster has been initialized.
|
178 | b5f5fae9 | Luca Bigliardi |
|
179 | b5f5fae9 | Luca Bigliardi | """
|
180 | b5f5fae9 | Luca Bigliardi | OP_ID = "OP_CLUSTER_POST_INIT"
|
181 | b5f5fae9 | Luca Bigliardi | __slots__ = OpCode.__slots__ + [] |
182 | b5f5fae9 | Luca Bigliardi | |
183 | b5f5fae9 | Luca Bigliardi | |
184 | a8083063 | Iustin Pop | class OpDestroyCluster(OpCode): |
185 | a7399f66 | Iustin Pop | """Destroy the cluster.
|
186 | a7399f66 | Iustin Pop |
|
187 | a7399f66 | Iustin Pop | This opcode has no other parameters. All the state is irreversibly
|
188 | a7399f66 | Iustin Pop | lost after the execution of this opcode.
|
189 | a7399f66 | Iustin Pop |
|
190 | a7399f66 | Iustin Pop | """
|
191 | a8083063 | Iustin Pop | OP_ID = "OP_CLUSTER_DESTROY"
|
192 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [] |
193 | a8083063 | Iustin Pop | |
194 | a8083063 | Iustin Pop | |
195 | a8083063 | Iustin Pop | class OpQueryClusterInfo(OpCode): |
196 | fdc267f4 | Iustin Pop | """Query cluster information."""
|
197 | a8083063 | Iustin Pop | OP_ID = "OP_CLUSTER_QUERY"
|
198 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [] |
199 | a8083063 | Iustin Pop | |
200 | a8083063 | Iustin Pop | |
201 | a8083063 | Iustin Pop | class OpVerifyCluster(OpCode): |
202 | a7399f66 | Iustin Pop | """Verify the cluster state.
|
203 | a7399f66 | Iustin Pop |
|
204 | a7399f66 | Iustin Pop | @type skip_checks: C{list}
|
205 | a7399f66 | Iustin Pop | @ivar skip_checks: steps to be skipped from the verify process; this
|
206 | a7399f66 | Iustin Pop | needs to be a subset of
|
207 | a7399f66 | Iustin Pop | L{constants.VERIFY_OPTIONAL_CHECKS}; currently
|
208 | a7399f66 | Iustin Pop | only L{constants.VERIFY_NPLUSONE_MEM} can be passed
|
209 | a7399f66 | Iustin Pop |
|
210 | a7399f66 | Iustin Pop | """
|
211 | a8083063 | Iustin Pop | OP_ID = "OP_CLUSTER_VERIFY"
|
212 | a0c9776a | Iustin Pop | __slots__ = OpCode.__slots__ + ["skip_checks", "verbose", "error_codes", |
213 | a0c9776a | Iustin Pop | "debug_simulate_errors"]
|
214 | a8083063 | Iustin Pop | |
215 | a8083063 | Iustin Pop | |
216 | 150e978f | Iustin Pop | class OpVerifyDisks(OpCode): |
217 | 150e978f | Iustin Pop | """Verify the cluster disks.
|
218 | 150e978f | Iustin Pop |
|
219 | 150e978f | Iustin Pop | Parameters: none
|
220 | 150e978f | Iustin Pop |
|
221 | 5188ab37 | Iustin Pop | Result: a tuple of four elements:
|
222 | 150e978f | Iustin Pop | - list of node names with bad data returned (unreachable, etc.)
|
223 | a7399f66 | Iustin Pop | - dict of node names with broken volume groups (values: error msg)
|
224 | 150e978f | Iustin Pop | - list of instances with degraded disks (that should be activated)
|
225 | b63ed789 | Iustin Pop | - dict of instances with missing logical volumes (values: (node, vol)
|
226 | b63ed789 | Iustin Pop | pairs with details about the missing volumes)
|
227 | 150e978f | Iustin Pop |
|
228 | b63ed789 | Iustin Pop | In normal operation, all lists should be empty. A non-empty instance
|
229 | b63ed789 | Iustin Pop | list (3rd element of the result) is still ok (errors were fixed) but
|
230 | b63ed789 | Iustin Pop | non-empty node list means some node is down, and probably there are
|
231 | b63ed789 | Iustin Pop | unfixable drbd errors.
|
232 | 150e978f | Iustin Pop |
|
233 | 150e978f | Iustin Pop | Note that only instances that are drbd-based are taken into
|
234 | 150e978f | Iustin Pop | consideration. This might need to be revisited in the future.
|
235 | 150e978f | Iustin Pop |
|
236 | 150e978f | Iustin Pop | """
|
237 | 150e978f | Iustin Pop | OP_ID = "OP_CLUSTER_VERIFY_DISKS"
|
238 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [] |
239 | 150e978f | Iustin Pop | |
240 | 150e978f | Iustin Pop | |
241 | 60975797 | Iustin Pop | class OpRepairDiskSizes(OpCode): |
242 | 60975797 | Iustin Pop | """Verify the disk sizes of the instances and fixes configuration
|
243 | 60975797 | Iustin Pop | mimatches.
|
244 | 60975797 | Iustin Pop |
|
245 | 60975797 | Iustin Pop | Parameters: optional instances list, in case we want to restrict the
|
246 | 60975797 | Iustin Pop | checks to only a subset of the instances.
|
247 | 60975797 | Iustin Pop |
|
248 | 60975797 | Iustin Pop | Result: a list of tuples, (instance, disk, new-size) for changed
|
249 | 60975797 | Iustin Pop | configurations.
|
250 | 60975797 | Iustin Pop |
|
251 | 60975797 | Iustin Pop | In normal operation, the list should be empty.
|
252 | 60975797 | Iustin Pop |
|
253 | 60975797 | Iustin Pop | @type instances: list
|
254 | 60975797 | Iustin Pop | @ivar instances: the list of instances to check, or empty for all instances
|
255 | 60975797 | Iustin Pop |
|
256 | 60975797 | Iustin Pop | """
|
257 | 60975797 | Iustin Pop | OP_ID = "OP_CLUSTER_REPAIR_DISK_SIZES"
|
258 | 60975797 | Iustin Pop | __slots__ = ["instances"]
|
259 | 60975797 | Iustin Pop | |
260 | 60975797 | Iustin Pop | |
261 | ae5849b5 | Michael Hanselmann | class OpQueryConfigValues(OpCode): |
262 | ae5849b5 | Michael Hanselmann | """Query cluster configuration values."""
|
263 | ae5849b5 | Michael Hanselmann | OP_ID = "OP_CLUSTER_CONFIG_QUERY"
|
264 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["output_fields"]
|
265 | a8083063 | Iustin Pop | |
266 | a8083063 | Iustin Pop | |
267 | 07bd8a51 | Iustin Pop | class OpRenameCluster(OpCode): |
268 | a7399f66 | Iustin Pop | """Rename the cluster.
|
269 | a7399f66 | Iustin Pop |
|
270 | a7399f66 | Iustin Pop | @type name: C{str}
|
271 | a7399f66 | Iustin Pop | @ivar name: The new name of the cluster. The name and/or the master IP
|
272 | a7399f66 | Iustin Pop | address will be changed to match the new name and its IP
|
273 | a7399f66 | Iustin Pop | address.
|
274 | a7399f66 | Iustin Pop |
|
275 | a7399f66 | Iustin Pop | """
|
276 | 07bd8a51 | Iustin Pop | OP_ID = "OP_CLUSTER_RENAME"
|
277 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "name"
|
278 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["name"]
|
279 | 07bd8a51 | Iustin Pop | |
280 | 07bd8a51 | Iustin Pop | |
281 | 12515db7 | Manuel Franceschini | class OpSetClusterParams(OpCode): |
282 | a7399f66 | Iustin Pop | """Change the parameters of the cluster.
|
283 | a7399f66 | Iustin Pop |
|
284 | a7399f66 | Iustin Pop | @type vg_name: C{str} or C{None}
|
285 | a7399f66 | Iustin Pop | @ivar vg_name: The new volume group name or None to disable LVM usage.
|
286 | a7399f66 | Iustin Pop |
|
287 | a7399f66 | Iustin Pop | """
|
288 | 12515db7 | Manuel Franceschini | OP_ID = "OP_CLUSTER_SET_PARAMS"
|
289 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [ |
290 | 4b7735f9 | Iustin Pop | "vg_name",
|
291 | 4b7735f9 | Iustin Pop | "enabled_hypervisors",
|
292 | 4b7735f9 | Iustin Pop | "hvparams",
|
293 | 4b7735f9 | Iustin Pop | "beparams",
|
294 | 5af3da74 | Guido Trotter | "nicparams",
|
295 | 4b7735f9 | Iustin Pop | "candidate_pool_size",
|
296 | 4b7735f9 | Iustin Pop | ] |
297 | 12515db7 | Manuel Franceschini | |
298 | 12515db7 | Manuel Franceschini | |
299 | afee0879 | Iustin Pop | class OpRedistributeConfig(OpCode): |
300 | afee0879 | Iustin Pop | """Force a full push of the cluster configuration.
|
301 | afee0879 | Iustin Pop |
|
302 | afee0879 | Iustin Pop | """
|
303 | afee0879 | Iustin Pop | OP_ID = "OP_CLUSTER_REDIST_CONF"
|
304 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [ |
305 | afee0879 | Iustin Pop | ] |
306 | afee0879 | Iustin Pop | |
307 | 07bd8a51 | Iustin Pop | # node opcodes
|
308 | 07bd8a51 | Iustin Pop | |
309 | a8083063 | Iustin Pop | class OpRemoveNode(OpCode): |
310 | a7399f66 | Iustin Pop | """Remove a node.
|
311 | a7399f66 | Iustin Pop |
|
312 | a7399f66 | Iustin Pop | @type node_name: C{str}
|
313 | a7399f66 | Iustin Pop | @ivar node_name: The name of the node to remove. If the node still has
|
314 | a7399f66 | Iustin Pop | instances on it, the operation will fail.
|
315 | a7399f66 | Iustin Pop |
|
316 | a7399f66 | Iustin Pop | """
|
317 | a8083063 | Iustin Pop | OP_ID = "OP_NODE_REMOVE"
|
318 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "node_name"
|
319 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["node_name"]
|
320 | a8083063 | Iustin Pop | |
321 | a8083063 | Iustin Pop | |
322 | a8083063 | Iustin Pop | class OpAddNode(OpCode): |
323 | a7399f66 | Iustin Pop | """Add a node to the cluster.
|
324 | a7399f66 | Iustin Pop |
|
325 | a7399f66 | Iustin Pop | @type node_name: C{str}
|
326 | a7399f66 | Iustin Pop | @ivar node_name: The name of the node to add. This can be a short name,
|
327 | a7399f66 | Iustin Pop | but it will be expanded to the FQDN.
|
328 | a7399f66 | Iustin Pop | @type primary_ip: IP address
|
329 | a7399f66 | Iustin Pop | @ivar primary_ip: The primary IP of the node. This will be ignored when the
|
330 | a7399f66 | Iustin Pop | opcode is submitted, but will be filled during the node
|
331 | a7399f66 | Iustin Pop | add (so it will be visible in the job query).
|
332 | a7399f66 | Iustin Pop | @type secondary_ip: IP address
|
333 | a7399f66 | Iustin Pop | @ivar secondary_ip: The secondary IP of the node. This needs to be passed
|
334 | a7399f66 | Iustin Pop | if the cluster has been initialized in 'dual-network'
|
335 | a7399f66 | Iustin Pop | mode, otherwise it must not be given.
|
336 | a7399f66 | Iustin Pop | @type readd: C{bool}
|
337 | a7399f66 | Iustin Pop | @ivar readd: Whether to re-add an existing node to the cluster. If
|
338 | a7399f66 | Iustin Pop | this is not passed, then the operation will abort if the node
|
339 | a7399f66 | Iustin Pop | name is already in the cluster; use this parameter to 'repair'
|
340 | a7399f66 | Iustin Pop | a node that had its configuration broken, or was reinstalled
|
341 | a7399f66 | Iustin Pop | without removal from the cluster.
|
342 | a7399f66 | Iustin Pop |
|
343 | a7399f66 | Iustin Pop | """
|
344 | a8083063 | Iustin Pop | OP_ID = "OP_NODE_ADD"
|
345 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "node_name"
|
346 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [ |
347 | 4f05fd3b | Iustin Pop | "node_name", "primary_ip", "secondary_ip", "readd", |
348 | 4f05fd3b | Iustin Pop | ] |
349 | a8083063 | Iustin Pop | |
350 | a8083063 | Iustin Pop | |
351 | a8083063 | Iustin Pop | class OpQueryNodes(OpCode): |
352 | a8083063 | Iustin Pop | """Compute the list of nodes."""
|
353 | a8083063 | Iustin Pop | OP_ID = "OP_NODE_QUERY"
|
354 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["output_fields", "names", "use_locking"] |
355 | a8083063 | Iustin Pop | |
356 | a8083063 | Iustin Pop | |
357 | dcb93971 | Michael Hanselmann | class OpQueryNodeVolumes(OpCode): |
358 | dcb93971 | Michael Hanselmann | """Get list of volumes on node."""
|
359 | dcb93971 | Michael Hanselmann | OP_ID = "OP_NODE_QUERYVOLS"
|
360 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["nodes", "output_fields"] |
361 | dcb93971 | Michael Hanselmann | |
362 | dcb93971 | Michael Hanselmann | |
363 | 9e5442ce | Michael Hanselmann | class OpQueryNodeStorage(OpCode): |
364 | 9e5442ce | Michael Hanselmann | """Get information on storage for node(s)."""
|
365 | 9e5442ce | Michael Hanselmann | OP_ID = "OP_NODE_QUERY_STORAGE"
|
366 | 9e5442ce | Michael Hanselmann | __slots__ = OpCode.__slots__ + [ |
367 | 9e5442ce | Michael Hanselmann | "nodes",
|
368 | 9e5442ce | Michael Hanselmann | "storage_type",
|
369 | 9e5442ce | Michael Hanselmann | "name",
|
370 | 9e5442ce | Michael Hanselmann | "output_fields",
|
371 | 9e5442ce | Michael Hanselmann | ] |
372 | 9e5442ce | Michael Hanselmann | |
373 | 9e5442ce | Michael Hanselmann | |
374 | efb8da02 | Michael Hanselmann | class OpModifyNodeStorage(OpCode): |
375 | efb8da02 | Michael Hanselmann | """"""
|
376 | efb8da02 | Michael Hanselmann | OP_ID = "OP_NODE_MODIFY_STORAGE"
|
377 | efb8da02 | Michael Hanselmann | __slots__ = OpCode.__slots__ + [ |
378 | efb8da02 | Michael Hanselmann | "node_name",
|
379 | efb8da02 | Michael Hanselmann | "storage_type",
|
380 | efb8da02 | Michael Hanselmann | "name",
|
381 | efb8da02 | Michael Hanselmann | "changes",
|
382 | efb8da02 | Michael Hanselmann | ] |
383 | efb8da02 | Michael Hanselmann | |
384 | efb8da02 | Michael Hanselmann | |
385 | 76aef8fc | Michael Hanselmann | class OpRepairNodeStorage(OpCode): |
386 | 76aef8fc | Michael Hanselmann | """Repairs the volume group on a node."""
|
387 | 76aef8fc | Michael Hanselmann | OP_ID = "OP_REPAIR_NODE_STORAGE"
|
388 | 76aef8fc | Michael Hanselmann | OP_DSC_FIELD = "node_name"
|
389 | 76aef8fc | Michael Hanselmann | __slots__ = OpCode.__slots__ + [ |
390 | 76aef8fc | Michael Hanselmann | "node_name",
|
391 | 76aef8fc | Michael Hanselmann | "storage_type",
|
392 | 76aef8fc | Michael Hanselmann | "name",
|
393 | 76aef8fc | Michael Hanselmann | ] |
394 | 76aef8fc | Michael Hanselmann | |
395 | 76aef8fc | Michael Hanselmann | |
396 | b31c8676 | Iustin Pop | class OpSetNodeParams(OpCode): |
397 | b31c8676 | Iustin Pop | """Change the parameters of a node."""
|
398 | b31c8676 | Iustin Pop | OP_ID = "OP_NODE_SET_PARAMS"
|
399 | b31c8676 | Iustin Pop | OP_DSC_FIELD = "node_name"
|
400 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [ |
401 | b31c8676 | Iustin Pop | "node_name",
|
402 | b31c8676 | Iustin Pop | "force",
|
403 | b31c8676 | Iustin Pop | "master_candidate",
|
404 | 3a5ba66a | Iustin Pop | "offline",
|
405 | c9d443ea | Iustin Pop | "drained",
|
406 | b31c8676 | Iustin Pop | ] |
407 | b31c8676 | Iustin Pop | |
408 | f5118ade | Iustin Pop | |
409 | f5118ade | Iustin Pop | class OpPowercycleNode(OpCode): |
410 | f5118ade | Iustin Pop | """Tries to powercycle a node."""
|
411 | f5118ade | Iustin Pop | OP_ID = "OP_NODE_POWERCYCLE"
|
412 | f5118ade | Iustin Pop | OP_DSC_FIELD = "node_name"
|
413 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [ |
414 | f5118ade | Iustin Pop | "node_name",
|
415 | f5118ade | Iustin Pop | "force",
|
416 | f5118ade | Iustin Pop | ] |
417 | f5118ade | Iustin Pop | |
418 | 7ffc5a86 | Michael Hanselmann | |
419 | 7ffc5a86 | Michael Hanselmann | class OpEvacuateNode(OpCode): |
420 | 7ffc5a86 | Michael Hanselmann | """Relocate secondary instances from a node."""
|
421 | 7ffc5a86 | Michael Hanselmann | OP_ID = "OP_NODE_EVACUATE"
|
422 | 7ffc5a86 | Michael Hanselmann | OP_DSC_FIELD = "node_name"
|
423 | 7ffc5a86 | Michael Hanselmann | __slots__ = OpCode.__slots__ + [ |
424 | 7ffc5a86 | Michael Hanselmann | "node_name", "remote_node", "iallocator", |
425 | 7ffc5a86 | Michael Hanselmann | ] |
426 | 7ffc5a86 | Michael Hanselmann | |
427 | 7ffc5a86 | Michael Hanselmann | |
428 | 80cb875c | Michael Hanselmann | class OpMigrateNode(OpCode): |
429 | 80cb875c | Michael Hanselmann | """Migrate all instances from a node."""
|
430 | 80cb875c | Michael Hanselmann | OP_ID = "OP_NODE_MIGRATE"
|
431 | 80cb875c | Michael Hanselmann | OP_DSC_FIELD = "node_name"
|
432 | 80cb875c | Michael Hanselmann | __slots__ = OpCode.__slots__ + [ |
433 | 80cb875c | Michael Hanselmann | "node_name",
|
434 | 80cb875c | Michael Hanselmann | "live",
|
435 | 80cb875c | Michael Hanselmann | ] |
436 | 80cb875c | Michael Hanselmann | |
437 | 80cb875c | Michael Hanselmann | |
438 | a8083063 | Iustin Pop | # instance opcodes
|
439 | a8083063 | Iustin Pop | |
440 | a8083063 | Iustin Pop | class OpCreateInstance(OpCode): |
441 | fdc267f4 | Iustin Pop | """Create an instance."""
|
442 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_CREATE"
|
443 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
444 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [ |
445 | 47804ec9 | Guido Trotter | "instance_name", "os_type", "force_variant", |
446 | 47804ec9 | Guido Trotter | "pnode", "disk_template", "snode", "mode", |
447 | 08db7c5c | Iustin Pop | "disks", "nics", |
448 | 08db7c5c | Iustin Pop | "src_node", "src_path", "start", |
449 | 08db7c5c | Iustin Pop | "wait_for_sync", "ip_check", |
450 | dc936b49 | Manuel Franceschini | "file_storage_dir", "file_driver", |
451 | 6785674e | Iustin Pop | "iallocator",
|
452 | 6785674e | Iustin Pop | "hypervisor", "hvparams", "beparams", |
453 | 4f05fd3b | Iustin Pop | "dry_run",
|
454 | 3b6d8c9b | Iustin Pop | ] |
455 | a8083063 | Iustin Pop | |
456 | a8083063 | Iustin Pop | |
457 | fe7b0351 | Michael Hanselmann | class OpReinstallInstance(OpCode): |
458 | fdc267f4 | Iustin Pop | """Reinstall an instance's OS."""
|
459 | fe7b0351 | Michael Hanselmann | OP_ID = "OP_INSTANCE_REINSTALL"
|
460 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
461 | 47804ec9 | Guido Trotter | __slots__ = OpCode.__slots__ + ["instance_name", "os_type", "force_variant"] |
462 | fe7b0351 | Michael Hanselmann | |
463 | fe7b0351 | Michael Hanselmann | |
464 | a8083063 | Iustin Pop | class OpRemoveInstance(OpCode): |
465 | a8083063 | Iustin Pop | """Remove an instance."""
|
466 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_REMOVE"
|
467 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
468 | fc1baca9 | Michael Hanselmann | __slots__ = OpCode.__slots__ + [ |
469 | fc1baca9 | Michael Hanselmann | "instance_name",
|
470 | fc1baca9 | Michael Hanselmann | "ignore_failures",
|
471 | fc1baca9 | Michael Hanselmann | "shutdown_timeout",
|
472 | fc1baca9 | Michael Hanselmann | ] |
473 | a8083063 | Iustin Pop | |
474 | a8083063 | Iustin Pop | |
475 | decd5f45 | Iustin Pop | class OpRenameInstance(OpCode): |
476 | decd5f45 | Iustin Pop | """Rename an instance."""
|
477 | decd5f45 | Iustin Pop | OP_ID = "OP_INSTANCE_RENAME"
|
478 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [ |
479 | 4f05fd3b | Iustin Pop | "instance_name", "ignore_ip", "new_name", |
480 | 4f05fd3b | Iustin Pop | ] |
481 | decd5f45 | Iustin Pop | |
482 | decd5f45 | Iustin Pop | |
483 | a8083063 | Iustin Pop | class OpStartupInstance(OpCode): |
484 | fdc267f4 | Iustin Pop | """Startup an instance."""
|
485 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_STARTUP"
|
486 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
487 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [ |
488 | 4f05fd3b | Iustin Pop | "instance_name", "force", "hvparams", "beparams", |
489 | 4f05fd3b | Iustin Pop | ] |
490 | a8083063 | Iustin Pop | |
491 | a8083063 | Iustin Pop | |
492 | a8083063 | Iustin Pop | class OpShutdownInstance(OpCode): |
493 | fdc267f4 | Iustin Pop | """Shutdown an instance."""
|
494 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_SHUTDOWN"
|
495 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
496 | 6263189c | Guido Trotter | __slots__ = OpCode.__slots__ + ["instance_name", "timeout"] |
497 | a8083063 | Iustin Pop | |
498 | a8083063 | Iustin Pop | |
499 | bf6929a2 | Alexander Schreiber | class OpRebootInstance(OpCode): |
500 | bf6929a2 | Alexander Schreiber | """Reboot an instance."""
|
501 | eeb3a5f9 | Iustin Pop | OP_ID = "OP_INSTANCE_REBOOT"
|
502 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
503 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [ |
504 | 17c3f802 | Guido Trotter | "instance_name", "reboot_type", "ignore_secondaries", "shutdown_timeout", |
505 | 4f05fd3b | Iustin Pop | ] |
506 | bf6929a2 | Alexander Schreiber | |
507 | bf6929a2 | Alexander Schreiber | |
508 | a8083063 | Iustin Pop | class OpReplaceDisks(OpCode): |
509 | fdc267f4 | Iustin Pop | """Replace the disks of an instance."""
|
510 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_REPLACE_DISKS"
|
511 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
512 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [ |
513 | 4f05fd3b | Iustin Pop | "instance_name", "remote_node", "mode", "disks", "iallocator", |
514 | 4f05fd3b | Iustin Pop | ] |
515 | a8083063 | Iustin Pop | |
516 | a8083063 | Iustin Pop | |
517 | a8083063 | Iustin Pop | class OpFailoverInstance(OpCode): |
518 | a8083063 | Iustin Pop | """Failover an instance."""
|
519 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_FAILOVER"
|
520 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
521 | 17c3f802 | Guido Trotter | __slots__ = OpCode.__slots__ + [ |
522 | 17c3f802 | Guido Trotter | "instance_name", "ignore_consistency", "shutdown_timeout", |
523 | 17c3f802 | Guido Trotter | ] |
524 | a8083063 | Iustin Pop | |
525 | a8083063 | Iustin Pop | |
526 | 53c776b5 | Iustin Pop | class OpMigrateInstance(OpCode): |
527 | 53c776b5 | Iustin Pop | """Migrate an instance.
|
528 | 53c776b5 | Iustin Pop |
|
529 | 53c776b5 | Iustin Pop | This migrates (without shutting down an instance) to its secondary
|
530 | 53c776b5 | Iustin Pop | node.
|
531 | 53c776b5 | Iustin Pop |
|
532 | 2f907a8c | Iustin Pop | @ivar instance_name: the name of the instance
|
533 | 53c776b5 | Iustin Pop |
|
534 | 53c776b5 | Iustin Pop | """
|
535 | 53c776b5 | Iustin Pop | OP_ID = "OP_INSTANCE_MIGRATE"
|
536 | ee69c97f | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
537 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["instance_name", "live", "cleanup"] |
538 | 53c776b5 | Iustin Pop | |
539 | 53c776b5 | Iustin Pop | |
540 | 313bcead | Iustin Pop | class OpMoveInstance(OpCode): |
541 | 313bcead | Iustin Pop | """Move an instance.
|
542 | 313bcead | Iustin Pop |
|
543 | 313bcead | Iustin Pop | This move (with shutting down an instance and data copying) to an
|
544 | 313bcead | Iustin Pop | arbitrary node.
|
545 | 313bcead | Iustin Pop |
|
546 | 313bcead | Iustin Pop | @ivar instance_name: the name of the instance
|
547 | 313bcead | Iustin Pop | @ivar target_node: the destination node
|
548 | 313bcead | Iustin Pop |
|
549 | 313bcead | Iustin Pop | """
|
550 | 313bcead | Iustin Pop | OP_ID = "OP_INSTANCE_MOVE"
|
551 | 313bcead | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
552 | 17c3f802 | Guido Trotter | __slots__ = OpCode.__slots__ + [ |
553 | 17c3f802 | Guido Trotter | "instance_name", "target_node", "shutdown_timeout", |
554 | 17c3f802 | Guido Trotter | ] |
555 | 313bcead | Iustin Pop | |
556 | 313bcead | Iustin Pop | |
557 | a8083063 | Iustin Pop | class OpConnectConsole(OpCode): |
558 | fdc267f4 | Iustin Pop | """Connect to an instance's console."""
|
559 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_CONSOLE"
|
560 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
561 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["instance_name"]
|
562 | a8083063 | Iustin Pop | |
563 | a8083063 | Iustin Pop | |
564 | a8083063 | Iustin Pop | class OpActivateInstanceDisks(OpCode): |
565 | fdc267f4 | Iustin Pop | """Activate an instance's disks."""
|
566 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_ACTIVATE_DISKS"
|
567 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
568 | b142ef15 | Iustin Pop | __slots__ = OpCode.__slots__ + ["instance_name", "ignore_size"] |
569 | a8083063 | Iustin Pop | |
570 | a8083063 | Iustin Pop | |
571 | a8083063 | Iustin Pop | class OpDeactivateInstanceDisks(OpCode): |
572 | fdc267f4 | Iustin Pop | """Deactivate an instance's disks."""
|
573 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_DEACTIVATE_DISKS"
|
574 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
575 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["instance_name"]
|
576 | a8083063 | Iustin Pop | |
577 | a8083063 | Iustin Pop | |
578 | bd315bfa | Iustin Pop | class OpRecreateInstanceDisks(OpCode): |
579 | bd315bfa | Iustin Pop | """Deactivate an instance's disks."""
|
580 | bd315bfa | Iustin Pop | OP_ID = "OP_INSTANCE_RECREATE_DISKS"
|
581 | bd315bfa | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
582 | bd315bfa | Iustin Pop | __slots__ = OpCode.__slots__ + ["instance_name", "disks"] |
583 | bd315bfa | Iustin Pop | |
584 | bd315bfa | Iustin Pop | |
585 | a8083063 | Iustin Pop | class OpQueryInstances(OpCode): |
586 | a8083063 | Iustin Pop | """Compute the list of instances."""
|
587 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_QUERY"
|
588 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["output_fields", "names", "use_locking"] |
589 | a8083063 | Iustin Pop | |
590 | a8083063 | Iustin Pop | |
591 | a8083063 | Iustin Pop | class OpQueryInstanceData(OpCode): |
592 | a8083063 | Iustin Pop | """Compute the run-time status of instances."""
|
593 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_QUERY_DATA"
|
594 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["instances", "static"] |
595 | a8083063 | Iustin Pop | |
596 | a8083063 | Iustin Pop | |
597 | 7767bbf5 | Manuel Franceschini | class OpSetInstanceParams(OpCode): |
598 | a8083063 | Iustin Pop | """Change the parameters of an instance."""
|
599 | 7767bbf5 | Manuel Franceschini | OP_ID = "OP_INSTANCE_SET_PARAMS"
|
600 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
601 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [ |
602 | 24991749 | Iustin Pop | "instance_name",
|
603 | 338e51e8 | Iustin Pop | "hvparams", "beparams", "force", |
604 | 24991749 | Iustin Pop | "nics", "disks", |
605 | 973d7867 | Iustin Pop | ] |
606 | a8083063 | Iustin Pop | |
607 | a8083063 | Iustin Pop | |
608 | 8729e0d7 | Iustin Pop | class OpGrowDisk(OpCode): |
609 | 8729e0d7 | Iustin Pop | """Grow a disk of an instance."""
|
610 | 8729e0d7 | Iustin Pop | OP_ID = "OP_INSTANCE_GROW_DISK"
|
611 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
612 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [ |
613 | 4f05fd3b | Iustin Pop | "instance_name", "disk", "amount", "wait_for_sync", |
614 | 4f05fd3b | Iustin Pop | ] |
615 | 8729e0d7 | Iustin Pop | |
616 | 8729e0d7 | Iustin Pop | |
617 | a8083063 | Iustin Pop | # OS opcodes
|
618 | a8083063 | Iustin Pop | class OpDiagnoseOS(OpCode): |
619 | a8083063 | Iustin Pop | """Compute the list of guest operating systems."""
|
620 | a8083063 | Iustin Pop | OP_ID = "OP_OS_DIAGNOSE"
|
621 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["output_fields", "names"] |
622 | a8083063 | Iustin Pop | |
623 | 7c0d6283 | Michael Hanselmann | |
624 | a8083063 | Iustin Pop | # Exports opcodes
|
625 | a8083063 | Iustin Pop | class OpQueryExports(OpCode): |
626 | a8083063 | Iustin Pop | """Compute the list of exported images."""
|
627 | a8083063 | Iustin Pop | OP_ID = "OP_BACKUP_QUERY"
|
628 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["nodes", "use_locking"] |
629 | a8083063 | Iustin Pop | |
630 | 7c0d6283 | Michael Hanselmann | |
631 | a8083063 | Iustin Pop | class OpExportInstance(OpCode): |
632 | a8083063 | Iustin Pop | """Export an instance."""
|
633 | a8083063 | Iustin Pop | OP_ID = "OP_BACKUP_EXPORT"
|
634 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
635 | 17c3f802 | Guido Trotter | __slots__ = OpCode.__slots__ + [ |
636 | 17c3f802 | Guido Trotter | "instance_name", "target_node", "shutdown", "shutdown_timeout", |
637 | 17c3f802 | Guido Trotter | ] |
638 | 5c947f38 | Iustin Pop | |
639 | 0a7bed64 | Michael Hanselmann | |
640 | 9ac99fda | Guido Trotter | class OpRemoveExport(OpCode): |
641 | 9ac99fda | Guido Trotter | """Remove an instance's export."""
|
642 | 9ac99fda | Guido Trotter | OP_ID = "OP_BACKUP_REMOVE"
|
643 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
644 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["instance_name"]
|
645 | 5c947f38 | Iustin Pop | |
646 | 0a7bed64 | Michael Hanselmann | |
647 | 5c947f38 | Iustin Pop | # Tags opcodes
|
648 | 5c947f38 | Iustin Pop | class OpGetTags(OpCode): |
649 | 5c947f38 | Iustin Pop | """Returns the tags of the given object."""
|
650 | 5c947f38 | Iustin Pop | OP_ID = "OP_TAGS_GET"
|
651 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "name"
|
652 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["kind", "name"] |
653 | 5c947f38 | Iustin Pop | |
654 | 5c947f38 | Iustin Pop | |
655 | 73415719 | Iustin Pop | class OpSearchTags(OpCode): |
656 | 73415719 | Iustin Pop | """Searches the tags in the cluster for a given pattern."""
|
657 | 73415719 | Iustin Pop | OP_ID = "OP_TAGS_SEARCH"
|
658 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "pattern"
|
659 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["pattern"]
|
660 | 73415719 | Iustin Pop | |
661 | 73415719 | Iustin Pop | |
662 | f27302fa | Iustin Pop | class OpAddTags(OpCode): |
663 | f27302fa | Iustin Pop | """Add a list of tags on a given object."""
|
664 | 5c947f38 | Iustin Pop | OP_ID = "OP_TAGS_SET"
|
665 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["kind", "name", "tags"] |
666 | 5c947f38 | Iustin Pop | |
667 | 5c947f38 | Iustin Pop | |
668 | f27302fa | Iustin Pop | class OpDelTags(OpCode): |
669 | f27302fa | Iustin Pop | """Remove a list of tags from a given object."""
|
670 | 5c947f38 | Iustin Pop | OP_ID = "OP_TAGS_DEL"
|
671 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["kind", "name", "tags"] |
672 | 06009e27 | Iustin Pop | |
673 | 06009e27 | Iustin Pop | |
674 | 06009e27 | Iustin Pop | # Test opcodes
|
675 | 06009e27 | Iustin Pop | class OpTestDelay(OpCode): |
676 | 06009e27 | Iustin Pop | """Sleeps for a configured amount of time.
|
677 | 06009e27 | Iustin Pop |
|
678 | 06009e27 | Iustin Pop | This is used just for debugging and testing.
|
679 | 06009e27 | Iustin Pop |
|
680 | 06009e27 | Iustin Pop | Parameters:
|
681 | 06009e27 | Iustin Pop | - duration: the time to sleep
|
682 | 06009e27 | Iustin Pop | - on_master: if true, sleep on the master
|
683 | 06009e27 | Iustin Pop | - on_nodes: list of nodes in which to sleep
|
684 | 06009e27 | Iustin Pop |
|
685 | 06009e27 | Iustin Pop | If the on_master parameter is true, it will execute a sleep on the
|
686 | 06009e27 | Iustin Pop | master (before any node sleep).
|
687 | 06009e27 | Iustin Pop |
|
688 | 06009e27 | Iustin Pop | If the on_nodes list is not empty, it will sleep on those nodes
|
689 | 06009e27 | Iustin Pop | (after the sleep on the master, if that is enabled).
|
690 | 06009e27 | Iustin Pop |
|
691 | 06009e27 | Iustin Pop | As an additional feature, the case of duration < 0 will be reported
|
692 | 06009e27 | Iustin Pop | as an execution error, so this opcode can be used as a failure
|
693 | 06009e27 | Iustin Pop | generator. The case of duration == 0 will not be treated specially.
|
694 | 06009e27 | Iustin Pop |
|
695 | 06009e27 | Iustin Pop | """
|
696 | 06009e27 | Iustin Pop | OP_ID = "OP_TEST_DELAY"
|
697 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "duration"
|
698 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["duration", "on_master", "on_nodes"] |
699 | d61df03e | Iustin Pop | |
700 | d61df03e | Iustin Pop | |
701 | d61df03e | Iustin Pop | class OpTestAllocator(OpCode): |
702 | d61df03e | Iustin Pop | """Allocator framework testing.
|
703 | d61df03e | Iustin Pop |
|
704 | d61df03e | Iustin Pop | This opcode has two modes:
|
705 | d61df03e | Iustin Pop | - gather and return allocator input for a given mode (allocate new
|
706 | d61df03e | Iustin Pop | or replace secondary) and a given instance definition (direction
|
707 | d61df03e | Iustin Pop | 'in')
|
708 | d61df03e | Iustin Pop | - run a selected allocator for a given operation (as above) and
|
709 | d61df03e | Iustin Pop | return the allocator output (direction 'out')
|
710 | d61df03e | Iustin Pop |
|
711 | d61df03e | Iustin Pop | """
|
712 | d61df03e | Iustin Pop | OP_ID = "OP_TEST_ALLOCATOR"
|
713 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "allocator"
|
714 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [ |
715 | d61df03e | Iustin Pop | "direction", "mode", "allocator", "name", |
716 | d61df03e | Iustin Pop | "mem_size", "disks", "disk_template", |
717 | 8cc7e742 | Guido Trotter | "os", "tags", "nics", "vcpus", "hypervisor", |
718 | d61df03e | Iustin Pop | ] |
719 | 363acb1e | Iustin Pop | |
720 | 76aef8fc | Michael Hanselmann | |
721 | 363acb1e | Iustin Pop | OP_MAPPING = dict([(v.OP_ID, v) for v in globals().values() |
722 | 363acb1e | Iustin Pop | if (isinstance(v, type) and issubclass(v, OpCode) and |
723 | 363acb1e | Iustin Pop | hasattr(v, "OP_ID"))]) |