root / lib / opcodes.py @ c772d142
History | View | Annotate | Download (16.6 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 | df458e0b | Iustin Pop | for item in globals().values(): |
148 | df458e0b | Iustin Pop | if (isinstance(item, type) and |
149 | df458e0b | Iustin Pop | issubclass(item, cls) and |
150 | df458e0b | Iustin Pop | hasattr(item, "OP_ID") and |
151 | df458e0b | Iustin Pop | getattr(item, "OP_ID") == op_id): |
152 | df458e0b | Iustin Pop | op_class = item |
153 | df458e0b | Iustin Pop | break
|
154 | df458e0b | Iustin Pop | if op_class is None: |
155 | df458e0b | Iustin Pop | raise ValueError("Invalid data to LoadOpCode: OP_ID %s unsupported" % |
156 | df458e0b | Iustin Pop | op_id) |
157 | df458e0b | Iustin Pop | op = op_class() |
158 | df458e0b | Iustin Pop | new_data = data.copy() |
159 | df458e0b | Iustin Pop | del new_data["OP_ID"] |
160 | df458e0b | Iustin Pop | op.__setstate__(new_data) |
161 | df458e0b | Iustin Pop | return op
|
162 | df458e0b | Iustin Pop | |
163 | 60dd1473 | Iustin Pop | def Summary(self): |
164 | 60dd1473 | Iustin Pop | """Generates a summary description of this opcode.
|
165 | 60dd1473 | Iustin Pop |
|
166 | 60dd1473 | Iustin Pop | """
|
167 | 60dd1473 | Iustin Pop | # all OP_ID start with OP_, we remove that
|
168 | 60dd1473 | Iustin Pop | txt = self.OP_ID[3:] |
169 | 60dd1473 | Iustin Pop | field_name = getattr(self, "OP_DSC_FIELD", None) |
170 | 60dd1473 | Iustin Pop | if field_name:
|
171 | 60dd1473 | Iustin Pop | field_value = getattr(self, field_name, None) |
172 | 60dd1473 | Iustin Pop | txt = "%s(%s)" % (txt, field_value)
|
173 | 60dd1473 | Iustin Pop | return txt
|
174 | 60dd1473 | Iustin Pop | |
175 | a8083063 | Iustin Pop | |
176 | afee0879 | Iustin Pop | # cluster opcodes
|
177 | afee0879 | Iustin Pop | |
178 | a8083063 | Iustin Pop | class OpDestroyCluster(OpCode): |
179 | a7399f66 | Iustin Pop | """Destroy the cluster.
|
180 | a7399f66 | Iustin Pop |
|
181 | a7399f66 | Iustin Pop | This opcode has no other parameters. All the state is irreversibly
|
182 | a7399f66 | Iustin Pop | lost after the execution of this opcode.
|
183 | a7399f66 | Iustin Pop |
|
184 | a7399f66 | Iustin Pop | """
|
185 | a8083063 | Iustin Pop | OP_ID = "OP_CLUSTER_DESTROY"
|
186 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [] |
187 | a8083063 | Iustin Pop | |
188 | a8083063 | Iustin Pop | |
189 | a8083063 | Iustin Pop | class OpQueryClusterInfo(OpCode): |
190 | fdc267f4 | Iustin Pop | """Query cluster information."""
|
191 | a8083063 | Iustin Pop | OP_ID = "OP_CLUSTER_QUERY"
|
192 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [] |
193 | a8083063 | Iustin Pop | |
194 | a8083063 | Iustin Pop | |
195 | a8083063 | Iustin Pop | class OpVerifyCluster(OpCode): |
196 | a7399f66 | Iustin Pop | """Verify the cluster state.
|
197 | a7399f66 | Iustin Pop |
|
198 | a7399f66 | Iustin Pop | @type skip_checks: C{list}
|
199 | a7399f66 | Iustin Pop | @ivar skip_checks: steps to be skipped from the verify process; this
|
200 | a7399f66 | Iustin Pop | needs to be a subset of
|
201 | a7399f66 | Iustin Pop | L{constants.VERIFY_OPTIONAL_CHECKS}; currently
|
202 | a7399f66 | Iustin Pop | only L{constants.VERIFY_NPLUSONE_MEM} can be passed
|
203 | a7399f66 | Iustin Pop |
|
204 | a7399f66 | Iustin Pop | """
|
205 | a8083063 | Iustin Pop | OP_ID = "OP_CLUSTER_VERIFY"
|
206 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["skip_checks"]
|
207 | a8083063 | Iustin Pop | |
208 | a8083063 | Iustin Pop | |
209 | 150e978f | Iustin Pop | class OpVerifyDisks(OpCode): |
210 | 150e978f | Iustin Pop | """Verify the cluster disks.
|
211 | 150e978f | Iustin Pop |
|
212 | 150e978f | Iustin Pop | Parameters: none
|
213 | 150e978f | Iustin Pop |
|
214 | 5188ab37 | Iustin Pop | Result: a tuple of four elements:
|
215 | 150e978f | Iustin Pop | - list of node names with bad data returned (unreachable, etc.)
|
216 | a7399f66 | Iustin Pop | - dict of node names with broken volume groups (values: error msg)
|
217 | 150e978f | Iustin Pop | - list of instances with degraded disks (that should be activated)
|
218 | b63ed789 | Iustin Pop | - dict of instances with missing logical volumes (values: (node, vol)
|
219 | b63ed789 | Iustin Pop | pairs with details about the missing volumes)
|
220 | 150e978f | Iustin Pop |
|
221 | b63ed789 | Iustin Pop | In normal operation, all lists should be empty. A non-empty instance
|
222 | b63ed789 | Iustin Pop | list (3rd element of the result) is still ok (errors were fixed) but
|
223 | b63ed789 | Iustin Pop | non-empty node list means some node is down, and probably there are
|
224 | b63ed789 | Iustin Pop | unfixable drbd errors.
|
225 | 150e978f | Iustin Pop |
|
226 | 150e978f | Iustin Pop | Note that only instances that are drbd-based are taken into
|
227 | 150e978f | Iustin Pop | consideration. This might need to be revisited in the future.
|
228 | 150e978f | Iustin Pop |
|
229 | 150e978f | Iustin Pop | """
|
230 | 150e978f | Iustin Pop | OP_ID = "OP_CLUSTER_VERIFY_DISKS"
|
231 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [] |
232 | 150e978f | Iustin Pop | |
233 | 150e978f | Iustin Pop | |
234 | ae5849b5 | Michael Hanselmann | class OpQueryConfigValues(OpCode): |
235 | ae5849b5 | Michael Hanselmann | """Query cluster configuration values."""
|
236 | ae5849b5 | Michael Hanselmann | OP_ID = "OP_CLUSTER_CONFIG_QUERY"
|
237 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["output_fields"]
|
238 | a8083063 | Iustin Pop | |
239 | a8083063 | Iustin Pop | |
240 | 07bd8a51 | Iustin Pop | class OpRenameCluster(OpCode): |
241 | a7399f66 | Iustin Pop | """Rename the cluster.
|
242 | a7399f66 | Iustin Pop |
|
243 | a7399f66 | Iustin Pop | @type name: C{str}
|
244 | a7399f66 | Iustin Pop | @ivar name: The new name of the cluster. The name and/or the master IP
|
245 | a7399f66 | Iustin Pop | address will be changed to match the new name and its IP
|
246 | a7399f66 | Iustin Pop | address.
|
247 | a7399f66 | Iustin Pop |
|
248 | a7399f66 | Iustin Pop | """
|
249 | 07bd8a51 | Iustin Pop | OP_ID = "OP_CLUSTER_RENAME"
|
250 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "name"
|
251 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["name"]
|
252 | 07bd8a51 | Iustin Pop | |
253 | 07bd8a51 | Iustin Pop | |
254 | 12515db7 | Manuel Franceschini | class OpSetClusterParams(OpCode): |
255 | a7399f66 | Iustin Pop | """Change the parameters of the cluster.
|
256 | a7399f66 | Iustin Pop |
|
257 | a7399f66 | Iustin Pop | @type vg_name: C{str} or C{None}
|
258 | a7399f66 | Iustin Pop | @ivar vg_name: The new volume group name or None to disable LVM usage.
|
259 | a7399f66 | Iustin Pop |
|
260 | a7399f66 | Iustin Pop | """
|
261 | 12515db7 | Manuel Franceschini | OP_ID = "OP_CLUSTER_SET_PARAMS"
|
262 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [ |
263 | 4b7735f9 | Iustin Pop | "vg_name",
|
264 | 4b7735f9 | Iustin Pop | "enabled_hypervisors",
|
265 | 4b7735f9 | Iustin Pop | "hvparams",
|
266 | 4b7735f9 | Iustin Pop | "beparams",
|
267 | 5af3da74 | Guido Trotter | "nicparams",
|
268 | 4b7735f9 | Iustin Pop | "candidate_pool_size",
|
269 | 4b7735f9 | Iustin Pop | ] |
270 | 12515db7 | Manuel Franceschini | |
271 | 12515db7 | Manuel Franceschini | |
272 | afee0879 | Iustin Pop | class OpRedistributeConfig(OpCode): |
273 | afee0879 | Iustin Pop | """Force a full push of the cluster configuration.
|
274 | afee0879 | Iustin Pop |
|
275 | afee0879 | Iustin Pop | """
|
276 | afee0879 | Iustin Pop | OP_ID = "OP_CLUSTER_REDIST_CONF"
|
277 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [ |
278 | afee0879 | Iustin Pop | ] |
279 | afee0879 | Iustin Pop | |
280 | 07bd8a51 | Iustin Pop | # node opcodes
|
281 | 07bd8a51 | Iustin Pop | |
282 | a8083063 | Iustin Pop | class OpRemoveNode(OpCode): |
283 | a7399f66 | Iustin Pop | """Remove a node.
|
284 | a7399f66 | Iustin Pop |
|
285 | a7399f66 | Iustin Pop | @type node_name: C{str}
|
286 | a7399f66 | Iustin Pop | @ivar node_name: The name of the node to remove. If the node still has
|
287 | a7399f66 | Iustin Pop | instances on it, the operation will fail.
|
288 | a7399f66 | Iustin Pop |
|
289 | a7399f66 | Iustin Pop | """
|
290 | a8083063 | Iustin Pop | OP_ID = "OP_NODE_REMOVE"
|
291 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "node_name"
|
292 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["node_name"]
|
293 | a8083063 | Iustin Pop | |
294 | a8083063 | Iustin Pop | |
295 | a8083063 | Iustin Pop | class OpAddNode(OpCode): |
296 | a7399f66 | Iustin Pop | """Add a node to the cluster.
|
297 | a7399f66 | Iustin Pop |
|
298 | a7399f66 | Iustin Pop | @type node_name: C{str}
|
299 | a7399f66 | Iustin Pop | @ivar node_name: The name of the node to add. This can be a short name,
|
300 | a7399f66 | Iustin Pop | but it will be expanded to the FQDN.
|
301 | a7399f66 | Iustin Pop | @type primary_ip: IP address
|
302 | a7399f66 | Iustin Pop | @ivar primary_ip: The primary IP of the node. This will be ignored when the
|
303 | a7399f66 | Iustin Pop | opcode is submitted, but will be filled during the node
|
304 | a7399f66 | Iustin Pop | add (so it will be visible in the job query).
|
305 | a7399f66 | Iustin Pop | @type secondary_ip: IP address
|
306 | a7399f66 | Iustin Pop | @ivar secondary_ip: The secondary IP of the node. This needs to be passed
|
307 | a7399f66 | Iustin Pop | if the cluster has been initialized in 'dual-network'
|
308 | a7399f66 | Iustin Pop | mode, otherwise it must not be given.
|
309 | a7399f66 | Iustin Pop | @type readd: C{bool}
|
310 | a7399f66 | Iustin Pop | @ivar readd: Whether to re-add an existing node to the cluster. If
|
311 | a7399f66 | Iustin Pop | this is not passed, then the operation will abort if the node
|
312 | a7399f66 | Iustin Pop | name is already in the cluster; use this parameter to 'repair'
|
313 | a7399f66 | Iustin Pop | a node that had its configuration broken, or was reinstalled
|
314 | a7399f66 | Iustin Pop | without removal from the cluster.
|
315 | a7399f66 | Iustin Pop |
|
316 | a7399f66 | Iustin Pop | """
|
317 | a8083063 | Iustin Pop | OP_ID = "OP_NODE_ADD"
|
318 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "node_name"
|
319 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [ |
320 | 4f05fd3b | Iustin Pop | "node_name", "primary_ip", "secondary_ip", "readd", |
321 | 4f05fd3b | Iustin Pop | ] |
322 | a8083063 | Iustin Pop | |
323 | a8083063 | Iustin Pop | |
324 | a8083063 | Iustin Pop | class OpQueryNodes(OpCode): |
325 | a8083063 | Iustin Pop | """Compute the list of nodes."""
|
326 | a8083063 | Iustin Pop | OP_ID = "OP_NODE_QUERY"
|
327 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["output_fields", "names", "use_locking"] |
328 | a8083063 | Iustin Pop | |
329 | a8083063 | Iustin Pop | |
330 | dcb93971 | Michael Hanselmann | class OpQueryNodeVolumes(OpCode): |
331 | dcb93971 | Michael Hanselmann | """Get list of volumes on node."""
|
332 | dcb93971 | Michael Hanselmann | OP_ID = "OP_NODE_QUERYVOLS"
|
333 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["nodes", "output_fields"] |
334 | dcb93971 | Michael Hanselmann | |
335 | dcb93971 | Michael Hanselmann | |
336 | b31c8676 | Iustin Pop | class OpSetNodeParams(OpCode): |
337 | b31c8676 | Iustin Pop | """Change the parameters of a node."""
|
338 | b31c8676 | Iustin Pop | OP_ID = "OP_NODE_SET_PARAMS"
|
339 | b31c8676 | Iustin Pop | OP_DSC_FIELD = "node_name"
|
340 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [ |
341 | b31c8676 | Iustin Pop | "node_name",
|
342 | b31c8676 | Iustin Pop | "force",
|
343 | b31c8676 | Iustin Pop | "master_candidate",
|
344 | 3a5ba66a | Iustin Pop | "offline",
|
345 | c9d443ea | Iustin Pop | "drained",
|
346 | b31c8676 | Iustin Pop | ] |
347 | b31c8676 | Iustin Pop | |
348 | f5118ade | Iustin Pop | |
349 | f5118ade | Iustin Pop | class OpPowercycleNode(OpCode): |
350 | f5118ade | Iustin Pop | """Tries to powercycle a node."""
|
351 | f5118ade | Iustin Pop | OP_ID = "OP_NODE_POWERCYCLE"
|
352 | f5118ade | Iustin Pop | OP_DSC_FIELD = "node_name"
|
353 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [ |
354 | f5118ade | Iustin Pop | "node_name",
|
355 | f5118ade | Iustin Pop | "force",
|
356 | f5118ade | Iustin Pop | ] |
357 | f5118ade | Iustin Pop | |
358 | a8083063 | Iustin Pop | # instance opcodes
|
359 | a8083063 | Iustin Pop | |
360 | a8083063 | Iustin Pop | class OpCreateInstance(OpCode): |
361 | fdc267f4 | Iustin Pop | """Create an instance."""
|
362 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_CREATE"
|
363 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
364 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [ |
365 | 08db7c5c | Iustin Pop | "instance_name", "os_type", "pnode", |
366 | 08db7c5c | Iustin Pop | "disk_template", "snode", "mode", |
367 | 08db7c5c | Iustin Pop | "disks", "nics", |
368 | 08db7c5c | Iustin Pop | "src_node", "src_path", "start", |
369 | 08db7c5c | Iustin Pop | "wait_for_sync", "ip_check", |
370 | dc936b49 | Manuel Franceschini | "file_storage_dir", "file_driver", |
371 | 6785674e | Iustin Pop | "iallocator",
|
372 | 6785674e | Iustin Pop | "hypervisor", "hvparams", "beparams", |
373 | 4f05fd3b | Iustin Pop | "dry_run",
|
374 | 3b6d8c9b | Iustin Pop | ] |
375 | a8083063 | Iustin Pop | |
376 | a8083063 | Iustin Pop | |
377 | fe7b0351 | Michael Hanselmann | class OpReinstallInstance(OpCode): |
378 | fdc267f4 | Iustin Pop | """Reinstall an instance's OS."""
|
379 | fe7b0351 | Michael Hanselmann | OP_ID = "OP_INSTANCE_REINSTALL"
|
380 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
381 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["instance_name", "os_type"] |
382 | fe7b0351 | Michael Hanselmann | |
383 | fe7b0351 | Michael Hanselmann | |
384 | a8083063 | Iustin Pop | class OpRemoveInstance(OpCode): |
385 | a8083063 | Iustin Pop | """Remove an instance."""
|
386 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_REMOVE"
|
387 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
388 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["instance_name", "ignore_failures"] |
389 | a8083063 | Iustin Pop | |
390 | a8083063 | Iustin Pop | |
391 | decd5f45 | Iustin Pop | class OpRenameInstance(OpCode): |
392 | decd5f45 | Iustin Pop | """Rename an instance."""
|
393 | decd5f45 | Iustin Pop | OP_ID = "OP_INSTANCE_RENAME"
|
394 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [ |
395 | 4f05fd3b | Iustin Pop | "instance_name", "ignore_ip", "new_name", |
396 | 4f05fd3b | Iustin Pop | ] |
397 | decd5f45 | Iustin Pop | |
398 | decd5f45 | Iustin Pop | |
399 | a8083063 | Iustin Pop | class OpStartupInstance(OpCode): |
400 | fdc267f4 | Iustin Pop | """Startup an instance."""
|
401 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_STARTUP"
|
402 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
403 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [ |
404 | 4f05fd3b | Iustin Pop | "instance_name", "force", "hvparams", "beparams", |
405 | 4f05fd3b | Iustin Pop | ] |
406 | a8083063 | Iustin Pop | |
407 | a8083063 | Iustin Pop | |
408 | a8083063 | Iustin Pop | class OpShutdownInstance(OpCode): |
409 | fdc267f4 | Iustin Pop | """Shutdown an instance."""
|
410 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_SHUTDOWN"
|
411 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
412 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["instance_name"]
|
413 | a8083063 | Iustin Pop | |
414 | a8083063 | Iustin Pop | |
415 | bf6929a2 | Alexander Schreiber | class OpRebootInstance(OpCode): |
416 | bf6929a2 | Alexander Schreiber | """Reboot an instance."""
|
417 | eeb3a5f9 | Iustin Pop | OP_ID = "OP_INSTANCE_REBOOT"
|
418 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
419 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [ |
420 | 4f05fd3b | Iustin Pop | "instance_name", "reboot_type", "ignore_secondaries", |
421 | 4f05fd3b | Iustin Pop | ] |
422 | bf6929a2 | Alexander Schreiber | |
423 | bf6929a2 | Alexander Schreiber | |
424 | a8083063 | Iustin Pop | class OpReplaceDisks(OpCode): |
425 | fdc267f4 | Iustin Pop | """Replace the disks of an instance."""
|
426 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_REPLACE_DISKS"
|
427 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
428 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [ |
429 | 4f05fd3b | Iustin Pop | "instance_name", "remote_node", "mode", "disks", "iallocator", |
430 | 4f05fd3b | Iustin Pop | ] |
431 | a8083063 | Iustin Pop | |
432 | a8083063 | Iustin Pop | |
433 | a8083063 | Iustin Pop | class OpFailoverInstance(OpCode): |
434 | a8083063 | Iustin Pop | """Failover an instance."""
|
435 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_FAILOVER"
|
436 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
437 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["instance_name", "ignore_consistency"] |
438 | a8083063 | Iustin Pop | |
439 | a8083063 | Iustin Pop | |
440 | 53c776b5 | Iustin Pop | class OpMigrateInstance(OpCode): |
441 | 53c776b5 | Iustin Pop | """Migrate an instance.
|
442 | 53c776b5 | Iustin Pop |
|
443 | 53c776b5 | Iustin Pop | This migrates (without shutting down an instance) to its secondary
|
444 | 53c776b5 | Iustin Pop | node.
|
445 | 53c776b5 | Iustin Pop |
|
446 | 2f907a8c | Iustin Pop | @ivar instance_name: the name of the instance
|
447 | 53c776b5 | Iustin Pop |
|
448 | 53c776b5 | Iustin Pop | """
|
449 | 53c776b5 | Iustin Pop | OP_ID = "OP_INSTANCE_MIGRATE"
|
450 | ee69c97f | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
451 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["instance_name", "live", "cleanup"] |
452 | 53c776b5 | Iustin Pop | |
453 | 53c776b5 | Iustin Pop | |
454 | a8083063 | Iustin Pop | class OpConnectConsole(OpCode): |
455 | fdc267f4 | Iustin Pop | """Connect to an instance's console."""
|
456 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_CONSOLE"
|
457 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
458 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["instance_name"]
|
459 | a8083063 | Iustin Pop | |
460 | a8083063 | Iustin Pop | |
461 | a8083063 | Iustin Pop | class OpActivateInstanceDisks(OpCode): |
462 | fdc267f4 | Iustin Pop | """Activate an instance's disks."""
|
463 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_ACTIVATE_DISKS"
|
464 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
465 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["instance_name"]
|
466 | a8083063 | Iustin Pop | |
467 | a8083063 | Iustin Pop | |
468 | a8083063 | Iustin Pop | class OpDeactivateInstanceDisks(OpCode): |
469 | fdc267f4 | Iustin Pop | """Deactivate an instance's disks."""
|
470 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_DEACTIVATE_DISKS"
|
471 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
472 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["instance_name"]
|
473 | a8083063 | Iustin Pop | |
474 | a8083063 | Iustin Pop | |
475 | a8083063 | Iustin Pop | class OpQueryInstances(OpCode): |
476 | a8083063 | Iustin Pop | """Compute the list of instances."""
|
477 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_QUERY"
|
478 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["output_fields", "names", "use_locking"] |
479 | a8083063 | Iustin Pop | |
480 | a8083063 | Iustin Pop | |
481 | a8083063 | Iustin Pop | class OpQueryInstanceData(OpCode): |
482 | a8083063 | Iustin Pop | """Compute the run-time status of instances."""
|
483 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_QUERY_DATA"
|
484 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["instances", "static"] |
485 | a8083063 | Iustin Pop | |
486 | a8083063 | Iustin Pop | |
487 | 7767bbf5 | Manuel Franceschini | class OpSetInstanceParams(OpCode): |
488 | a8083063 | Iustin Pop | """Change the parameters of an instance."""
|
489 | 7767bbf5 | Manuel Franceschini | OP_ID = "OP_INSTANCE_SET_PARAMS"
|
490 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
491 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [ |
492 | 24991749 | Iustin Pop | "instance_name",
|
493 | 338e51e8 | Iustin Pop | "hvparams", "beparams", "force", |
494 | 24991749 | Iustin Pop | "nics", "disks", |
495 | 973d7867 | Iustin Pop | ] |
496 | a8083063 | Iustin Pop | |
497 | a8083063 | Iustin Pop | |
498 | 8729e0d7 | Iustin Pop | class OpGrowDisk(OpCode): |
499 | 8729e0d7 | Iustin Pop | """Grow a disk of an instance."""
|
500 | 8729e0d7 | Iustin Pop | OP_ID = "OP_INSTANCE_GROW_DISK"
|
501 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
502 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [ |
503 | 4f05fd3b | Iustin Pop | "instance_name", "disk", "amount", "wait_for_sync", |
504 | 4f05fd3b | Iustin Pop | ] |
505 | 8729e0d7 | Iustin Pop | |
506 | 8729e0d7 | Iustin Pop | |
507 | a8083063 | Iustin Pop | # OS opcodes
|
508 | a8083063 | Iustin Pop | class OpDiagnoseOS(OpCode): |
509 | a8083063 | Iustin Pop | """Compute the list of guest operating systems."""
|
510 | a8083063 | Iustin Pop | OP_ID = "OP_OS_DIAGNOSE"
|
511 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["output_fields", "names"] |
512 | a8083063 | Iustin Pop | |
513 | 7c0d6283 | Michael Hanselmann | |
514 | a8083063 | Iustin Pop | # Exports opcodes
|
515 | a8083063 | Iustin Pop | class OpQueryExports(OpCode): |
516 | a8083063 | Iustin Pop | """Compute the list of exported images."""
|
517 | a8083063 | Iustin Pop | OP_ID = "OP_BACKUP_QUERY"
|
518 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["nodes", "use_locking"] |
519 | a8083063 | Iustin Pop | |
520 | 7c0d6283 | Michael Hanselmann | |
521 | a8083063 | Iustin Pop | class OpExportInstance(OpCode): |
522 | a8083063 | Iustin Pop | """Export an instance."""
|
523 | a8083063 | Iustin Pop | OP_ID = "OP_BACKUP_EXPORT"
|
524 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
525 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["instance_name", "target_node", "shutdown"] |
526 | 5c947f38 | Iustin Pop | |
527 | 0a7bed64 | Michael Hanselmann | |
528 | 9ac99fda | Guido Trotter | class OpRemoveExport(OpCode): |
529 | 9ac99fda | Guido Trotter | """Remove an instance's export."""
|
530 | 9ac99fda | Guido Trotter | OP_ID = "OP_BACKUP_REMOVE"
|
531 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
532 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["instance_name"]
|
533 | 5c947f38 | Iustin Pop | |
534 | 0a7bed64 | Michael Hanselmann | |
535 | 5c947f38 | Iustin Pop | # Tags opcodes
|
536 | 5c947f38 | Iustin Pop | class OpGetTags(OpCode): |
537 | 5c947f38 | Iustin Pop | """Returns the tags of the given object."""
|
538 | 5c947f38 | Iustin Pop | OP_ID = "OP_TAGS_GET"
|
539 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "name"
|
540 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["kind", "name"] |
541 | 5c947f38 | Iustin Pop | |
542 | 5c947f38 | Iustin Pop | |
543 | 73415719 | Iustin Pop | class OpSearchTags(OpCode): |
544 | 73415719 | Iustin Pop | """Searches the tags in the cluster for a given pattern."""
|
545 | 73415719 | Iustin Pop | OP_ID = "OP_TAGS_SEARCH"
|
546 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "pattern"
|
547 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["pattern"]
|
548 | 73415719 | Iustin Pop | |
549 | 73415719 | Iustin Pop | |
550 | f27302fa | Iustin Pop | class OpAddTags(OpCode): |
551 | f27302fa | Iustin Pop | """Add a list of tags on a given object."""
|
552 | 5c947f38 | Iustin Pop | OP_ID = "OP_TAGS_SET"
|
553 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["kind", "name", "tags"] |
554 | 5c947f38 | Iustin Pop | |
555 | 5c947f38 | Iustin Pop | |
556 | f27302fa | Iustin Pop | class OpDelTags(OpCode): |
557 | f27302fa | Iustin Pop | """Remove a list of tags from a given object."""
|
558 | 5c947f38 | Iustin Pop | OP_ID = "OP_TAGS_DEL"
|
559 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["kind", "name", "tags"] |
560 | 06009e27 | Iustin Pop | |
561 | 06009e27 | Iustin Pop | |
562 | 06009e27 | Iustin Pop | # Test opcodes
|
563 | 06009e27 | Iustin Pop | class OpTestDelay(OpCode): |
564 | 06009e27 | Iustin Pop | """Sleeps for a configured amount of time.
|
565 | 06009e27 | Iustin Pop |
|
566 | 06009e27 | Iustin Pop | This is used just for debugging and testing.
|
567 | 06009e27 | Iustin Pop |
|
568 | 06009e27 | Iustin Pop | Parameters:
|
569 | 06009e27 | Iustin Pop | - duration: the time to sleep
|
570 | 06009e27 | Iustin Pop | - on_master: if true, sleep on the master
|
571 | 06009e27 | Iustin Pop | - on_nodes: list of nodes in which to sleep
|
572 | 06009e27 | Iustin Pop |
|
573 | 06009e27 | Iustin Pop | If the on_master parameter is true, it will execute a sleep on the
|
574 | 06009e27 | Iustin Pop | master (before any node sleep).
|
575 | 06009e27 | Iustin Pop |
|
576 | 06009e27 | Iustin Pop | If the on_nodes list is not empty, it will sleep on those nodes
|
577 | 06009e27 | Iustin Pop | (after the sleep on the master, if that is enabled).
|
578 | 06009e27 | Iustin Pop |
|
579 | 06009e27 | Iustin Pop | As an additional feature, the case of duration < 0 will be reported
|
580 | 06009e27 | Iustin Pop | as an execution error, so this opcode can be used as a failure
|
581 | 06009e27 | Iustin Pop | generator. The case of duration == 0 will not be treated specially.
|
582 | 06009e27 | Iustin Pop |
|
583 | 06009e27 | Iustin Pop | """
|
584 | 06009e27 | Iustin Pop | OP_ID = "OP_TEST_DELAY"
|
585 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "duration"
|
586 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + ["duration", "on_master", "on_nodes"] |
587 | d61df03e | Iustin Pop | |
588 | d61df03e | Iustin Pop | |
589 | d61df03e | Iustin Pop | class OpTestAllocator(OpCode): |
590 | d61df03e | Iustin Pop | """Allocator framework testing.
|
591 | d61df03e | Iustin Pop |
|
592 | d61df03e | Iustin Pop | This opcode has two modes:
|
593 | d61df03e | Iustin Pop | - gather and return allocator input for a given mode (allocate new
|
594 | d61df03e | Iustin Pop | or replace secondary) and a given instance definition (direction
|
595 | d61df03e | Iustin Pop | 'in')
|
596 | d61df03e | Iustin Pop | - run a selected allocator for a given operation (as above) and
|
597 | d61df03e | Iustin Pop | return the allocator output (direction 'out')
|
598 | d61df03e | Iustin Pop |
|
599 | d61df03e | Iustin Pop | """
|
600 | d61df03e | Iustin Pop | OP_ID = "OP_TEST_ALLOCATOR"
|
601 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "allocator"
|
602 | 4f05fd3b | Iustin Pop | __slots__ = OpCode.__slots__ + [ |
603 | d61df03e | Iustin Pop | "direction", "mode", "allocator", "name", |
604 | d61df03e | Iustin Pop | "mem_size", "disks", "disk_template", |
605 | 8cc7e742 | Guido Trotter | "os", "tags", "nics", "vcpus", "hypervisor", |
606 | d61df03e | Iustin Pop | ] |