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