root / lib / opcodes.py @ 82599b3e
History | View | Annotate | Download (36 kB)
1 | 2f31098c | Iustin Pop | #
|
---|---|---|---|
2 | a8083063 | Iustin Pop | #
|
3 | a8083063 | Iustin Pop | |
4 | 687c10d9 | Iustin Pop | # Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 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 | 1cbef6d8 | Michael Hanselmann | import logging |
37 | ff0d18e6 | Iustin Pop | import re |
38 | 1cbef6d8 | Michael Hanselmann | |
39 | 65e183af | Michael Hanselmann | from ganeti import constants |
40 | 65e183af | Michael Hanselmann | from ganeti import errors |
41 | 65e183af | Michael Hanselmann | from ganeti import ht |
42 | 65e183af | Michael Hanselmann | |
43 | 65e183af | Michael Hanselmann | |
44 | 65e183af | Michael Hanselmann | # Common opcode attributes
|
45 | 65e183af | Michael Hanselmann | |
46 | 65e183af | Michael Hanselmann | #: output fields for a query operation
|
47 | 65e183af | Michael Hanselmann | _POutputFields = ("output_fields", ht.NoDefault, ht.TListOf(ht.TNonEmptyString))
|
48 | 65e183af | Michael Hanselmann | |
49 | 65e183af | Michael Hanselmann | #: the shutdown timeout
|
50 | 65e183af | Michael Hanselmann | _PShutdownTimeout = ("shutdown_timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT,
|
51 | 65e183af | Michael Hanselmann | ht.TPositiveInt) |
52 | 65e183af | Michael Hanselmann | |
53 | 65e183af | Michael Hanselmann | #: the force parameter
|
54 | 65e183af | Michael Hanselmann | _PForce = ("force", False, ht.TBool) |
55 | 65e183af | Michael Hanselmann | |
56 | 65e183af | Michael Hanselmann | #: a required instance name (for single-instance LUs)
|
57 | 65e183af | Michael Hanselmann | _PInstanceName = ("instance_name", ht.NoDefault, ht.TNonEmptyString)
|
58 | 65e183af | Michael Hanselmann | |
59 | 65e183af | Michael Hanselmann | #: Whether to ignore offline nodes
|
60 | 65e183af | Michael Hanselmann | _PIgnoreOfflineNodes = ("ignore_offline_nodes", False, ht.TBool) |
61 | 65e183af | Michael Hanselmann | |
62 | 65e183af | Michael Hanselmann | #: a required node name (for single-node LUs)
|
63 | 65e183af | Michael Hanselmann | _PNodeName = ("node_name", ht.NoDefault, ht.TNonEmptyString)
|
64 | 65e183af | Michael Hanselmann | |
65 | 65e183af | Michael Hanselmann | #: a required node group name (for single-group LUs)
|
66 | 65e183af | Michael Hanselmann | _PGroupName = ("group_name", ht.NoDefault, ht.TNonEmptyString)
|
67 | 65e183af | Michael Hanselmann | |
68 | 65e183af | Michael Hanselmann | #: Migration type (live/non-live)
|
69 | 65e183af | Michael Hanselmann | _PMigrationMode = ("mode", None, |
70 | 65e183af | Michael Hanselmann | ht.TOr(ht.TNone, ht.TElemOf(constants.HT_MIGRATION_MODES))) |
71 | 65e183af | Michael Hanselmann | |
72 | 65e183af | Michael Hanselmann | #: Obsolete 'live' migration mode (boolean)
|
73 | 65e183af | Michael Hanselmann | _PMigrationLive = ("live", None, ht.TMaybeBool) |
74 | 65e183af | Michael Hanselmann | |
75 | 65e183af | Michael Hanselmann | #: Tag type
|
76 | 65e183af | Michael Hanselmann | _PTagKind = ("kind", ht.NoDefault, ht.TElemOf(constants.VALID_TAG_TYPES))
|
77 | 65e183af | Michael Hanselmann | |
78 | 65e183af | Michael Hanselmann | #: List of tag strings
|
79 | 65e183af | Michael Hanselmann | _PTags = ("tags", ht.NoDefault, ht.TListOf(ht.TNonEmptyString))
|
80 | 65e183af | Michael Hanselmann | |
81 | ff0d18e6 | Iustin Pop | #: OP_ID conversion regular expression
|
82 | ff0d18e6 | Iustin Pop | _OPID_RE = re.compile("([a-z])([A-Z])")
|
83 | ff0d18e6 | Iustin Pop | |
84 | ff0d18e6 | Iustin Pop | |
85 | ff0d18e6 | Iustin Pop | def _NameToId(name): |
86 | ff0d18e6 | Iustin Pop | """Convert an opcode class name to an OP_ID.
|
87 | ff0d18e6 | Iustin Pop |
|
88 | ff0d18e6 | Iustin Pop | @type name: string
|
89 | ff0d18e6 | Iustin Pop | @param name: the class name, as OpXxxYyy
|
90 | ff0d18e6 | Iustin Pop | @rtype: string
|
91 | ff0d18e6 | Iustin Pop | @return: the name in the OP_XXXX_YYYY format
|
92 | ff0d18e6 | Iustin Pop |
|
93 | ff0d18e6 | Iustin Pop | """
|
94 | ff0d18e6 | Iustin Pop | if not name.startswith("Op"): |
95 | ff0d18e6 | Iustin Pop | return None |
96 | ff0d18e6 | Iustin Pop | # Note: (?<=[a-z])(?=[A-Z]) would be ideal, since it wouldn't
|
97 | ff0d18e6 | Iustin Pop | # consume any input, and hence we would just have all the elements
|
98 | ff0d18e6 | Iustin Pop | # in the list, one by one; but it seems that split doesn't work on
|
99 | ff0d18e6 | Iustin Pop | # non-consuming input, hence we have to process the input string a
|
100 | ff0d18e6 | Iustin Pop | # bit
|
101 | ff0d18e6 | Iustin Pop | name = _OPID_RE.sub(r"\1,\2", name)
|
102 | ff0d18e6 | Iustin Pop | elems = name.split(",")
|
103 | ff0d18e6 | Iustin Pop | return "_".join(n.upper() for n in elems) |
104 | ff0d18e6 | Iustin Pop | |
105 | 65e183af | Michael Hanselmann | |
106 | 65e183af | Michael Hanselmann | def RequireFileStorage(): |
107 | 65e183af | Michael Hanselmann | """Checks that file storage is enabled.
|
108 | 65e183af | Michael Hanselmann |
|
109 | 65e183af | Michael Hanselmann | While it doesn't really fit into this module, L{utils} was deemed too large
|
110 | 65e183af | Michael Hanselmann | of a dependency to be imported for just one or two functions.
|
111 | 65e183af | Michael Hanselmann |
|
112 | 65e183af | Michael Hanselmann | @raise errors.OpPrereqError: when file storage is disabled
|
113 | 65e183af | Michael Hanselmann |
|
114 | 65e183af | Michael Hanselmann | """
|
115 | 65e183af | Michael Hanselmann | if not constants.ENABLE_FILE_STORAGE: |
116 | 65e183af | Michael Hanselmann | raise errors.OpPrereqError("File storage disabled at configure time", |
117 | 65e183af | Michael Hanselmann | errors.ECODE_INVAL) |
118 | 65e183af | Michael Hanselmann | |
119 | 65e183af | Michael Hanselmann | |
120 | 65e183af | Michael Hanselmann | def _CheckDiskTemplate(template): |
121 | 65e183af | Michael Hanselmann | """Ensure a given disk template is valid.
|
122 | 65e183af | Michael Hanselmann |
|
123 | 65e183af | Michael Hanselmann | """
|
124 | 65e183af | Michael Hanselmann | if template not in constants.DISK_TEMPLATES: |
125 | 65e183af | Michael Hanselmann | # Using str.join directly to avoid importing utils for CommaJoin
|
126 | 65e183af | Michael Hanselmann | msg = ("Invalid disk template name '%s', valid templates are: %s" %
|
127 | 65e183af | Michael Hanselmann | (template, ", ".join(constants.DISK_TEMPLATES)))
|
128 | 65e183af | Michael Hanselmann | raise errors.OpPrereqError(msg, errors.ECODE_INVAL)
|
129 | 65e183af | Michael Hanselmann | if template == constants.DT_FILE:
|
130 | 65e183af | Michael Hanselmann | RequireFileStorage() |
131 | 65e183af | Michael Hanselmann | return True |
132 | 65e183af | Michael Hanselmann | |
133 | 65e183af | Michael Hanselmann | |
134 | 65e183af | Michael Hanselmann | def _CheckStorageType(storage_type): |
135 | 65e183af | Michael Hanselmann | """Ensure a given storage type is valid.
|
136 | 65e183af | Michael Hanselmann |
|
137 | 65e183af | Michael Hanselmann | """
|
138 | 65e183af | Michael Hanselmann | if storage_type not in constants.VALID_STORAGE_TYPES: |
139 | 65e183af | Michael Hanselmann | raise errors.OpPrereqError("Unknown storage type: %s" % storage_type, |
140 | 65e183af | Michael Hanselmann | errors.ECODE_INVAL) |
141 | 65e183af | Michael Hanselmann | if storage_type == constants.ST_FILE:
|
142 | 65e183af | Michael Hanselmann | RequireFileStorage() |
143 | 65e183af | Michael Hanselmann | return True |
144 | 65e183af | Michael Hanselmann | |
145 | 65e183af | Michael Hanselmann | |
146 | 65e183af | Michael Hanselmann | #: Storage type parameter
|
147 | 65e183af | Michael Hanselmann | _PStorageType = ("storage_type", ht.NoDefault, _CheckStorageType)
|
148 | 65e183af | Michael Hanselmann | |
149 | 65e183af | Michael Hanselmann | |
150 | 65e183af | Michael Hanselmann | class _AutoOpParamSlots(type): |
151 | 65e183af | Michael Hanselmann | """Meta class for opcode definitions.
|
152 | 65e183af | Michael Hanselmann |
|
153 | 65e183af | Michael Hanselmann | """
|
154 | 65e183af | Michael Hanselmann | def __new__(mcs, name, bases, attrs): |
155 | 65e183af | Michael Hanselmann | """Called when a class should be created.
|
156 | 65e183af | Michael Hanselmann |
|
157 | 65e183af | Michael Hanselmann | @param mcs: The meta class
|
158 | 65e183af | Michael Hanselmann | @param name: Name of created class
|
159 | 65e183af | Michael Hanselmann | @param bases: Base classes
|
160 | 65e183af | Michael Hanselmann | @type attrs: dict
|
161 | 65e183af | Michael Hanselmann | @param attrs: Class attributes
|
162 | 65e183af | Michael Hanselmann |
|
163 | 65e183af | Michael Hanselmann | """
|
164 | 65e183af | Michael Hanselmann | assert "__slots__" not in attrs, \ |
165 | 65e183af | Michael Hanselmann | "Class '%s' defines __slots__ when it should use OP_PARAMS" % name
|
166 | e89a9021 | Iustin Pop | assert "OP_ID" not in attrs, "Class '%s' defining OP_ID" % name |
167 | ff0d18e6 | Iustin Pop | |
168 | e89a9021 | Iustin Pop | attrs["OP_ID"] = _NameToId(name)
|
169 | 65e183af | Michael Hanselmann | |
170 | 65e183af | Michael Hanselmann | # Always set OP_PARAMS to avoid duplicates in BaseOpCode.GetAllParams
|
171 | 65e183af | Michael Hanselmann | params = attrs.setdefault("OP_PARAMS", [])
|
172 | 65e183af | Michael Hanselmann | |
173 | 65e183af | Michael Hanselmann | # Use parameter names as slots
|
174 | 65e183af | Michael Hanselmann | slots = [pname for (pname, _, _) in params] |
175 | 65e183af | Michael Hanselmann | |
176 | 65e183af | Michael Hanselmann | assert "OP_DSC_FIELD" not in attrs or attrs["OP_DSC_FIELD"] in slots, \ |
177 | 65e183af | Michael Hanselmann | "Class '%s' uses unknown field in OP_DSC_FIELD" % name
|
178 | 65e183af | Michael Hanselmann | |
179 | 65e183af | Michael Hanselmann | attrs["__slots__"] = slots
|
180 | 65e183af | Michael Hanselmann | |
181 | 65e183af | Michael Hanselmann | return type.__new__(mcs, name, bases, attrs) |
182 | 65e183af | Michael Hanselmann | |
183 | df458e0b | Iustin Pop | |
184 | 0e46916d | Iustin Pop | class BaseOpCode(object): |
185 | df458e0b | Iustin Pop | """A simple serializable object.
|
186 | df458e0b | Iustin Pop |
|
187 | 0e46916d | Iustin Pop | This object serves as a parent class for OpCode without any custom
|
188 | 0e46916d | Iustin Pop | field handling.
|
189 | 0e46916d | Iustin Pop |
|
190 | df458e0b | Iustin Pop | """
|
191 | e89a9021 | Iustin Pop | # pylint: disable-msg=E1101
|
192 | e89a9021 | Iustin Pop | # as OP_ID is dynamically defined
|
193 | 65e183af | Michael Hanselmann | __metaclass__ = _AutoOpParamSlots |
194 | 65e183af | Michael Hanselmann | |
195 | a8083063 | Iustin Pop | def __init__(self, **kwargs): |
196 | a7399f66 | Iustin Pop | """Constructor for BaseOpCode.
|
197 | a7399f66 | Iustin Pop |
|
198 | a7399f66 | Iustin Pop | The constructor takes only keyword arguments and will set
|
199 | a7399f66 | Iustin Pop | attributes on this object based on the passed arguments. As such,
|
200 | a7399f66 | Iustin Pop | it means that you should not pass arguments which are not in the
|
201 | a7399f66 | Iustin Pop | __slots__ attribute for this class.
|
202 | a7399f66 | Iustin Pop |
|
203 | a7399f66 | Iustin Pop | """
|
204 | adf385c7 | Iustin Pop | slots = self._all_slots()
|
205 | a8083063 | Iustin Pop | for key in kwargs: |
206 | adf385c7 | Iustin Pop | if key not in slots: |
207 | df458e0b | Iustin Pop | raise TypeError("Object %s doesn't support the parameter '%s'" % |
208 | 3ecf6786 | Iustin Pop | (self.__class__.__name__, key))
|
209 | a8083063 | Iustin Pop | setattr(self, key, kwargs[key]) |
210 | a8083063 | Iustin Pop | |
211 | df458e0b | Iustin Pop | def __getstate__(self): |
212 | a7399f66 | Iustin Pop | """Generic serializer.
|
213 | a7399f66 | Iustin Pop |
|
214 | a7399f66 | Iustin Pop | This method just returns the contents of the instance as a
|
215 | a7399f66 | Iustin Pop | dictionary.
|
216 | a7399f66 | Iustin Pop |
|
217 | a7399f66 | Iustin Pop | @rtype: C{dict}
|
218 | a7399f66 | Iustin Pop | @return: the instance attributes and their values
|
219 | a7399f66 | Iustin Pop |
|
220 | a7399f66 | Iustin Pop | """
|
221 | df458e0b | Iustin Pop | state = {} |
222 | adf385c7 | Iustin Pop | for name in self._all_slots(): |
223 | df458e0b | Iustin Pop | if hasattr(self, name): |
224 | df458e0b | Iustin Pop | state[name] = getattr(self, name) |
225 | df458e0b | Iustin Pop | return state
|
226 | df458e0b | Iustin Pop | |
227 | df458e0b | Iustin Pop | def __setstate__(self, state): |
228 | a7399f66 | Iustin Pop | """Generic unserializer.
|
229 | a7399f66 | Iustin Pop |
|
230 | a7399f66 | Iustin Pop | This method just restores from the serialized state the attributes
|
231 | a7399f66 | Iustin Pop | of the current instance.
|
232 | a7399f66 | Iustin Pop |
|
233 | a7399f66 | Iustin Pop | @param state: the serialized opcode data
|
234 | a7399f66 | Iustin Pop | @type state: C{dict}
|
235 | a7399f66 | Iustin Pop |
|
236 | a7399f66 | Iustin Pop | """
|
237 | df458e0b | Iustin Pop | if not isinstance(state, dict): |
238 | df458e0b | Iustin Pop | raise ValueError("Invalid data to __setstate__: expected dict, got %s" % |
239 | df458e0b | Iustin Pop | type(state))
|
240 | df458e0b | Iustin Pop | |
241 | adf385c7 | Iustin Pop | for name in self._all_slots(): |
242 | 44db3a6f | Iustin Pop | if name not in state and hasattr(self, name): |
243 | df458e0b | Iustin Pop | delattr(self, name) |
244 | df458e0b | Iustin Pop | |
245 | df458e0b | Iustin Pop | for name in state: |
246 | df458e0b | Iustin Pop | setattr(self, name, state[name]) |
247 | df458e0b | Iustin Pop | |
248 | adf385c7 | Iustin Pop | @classmethod
|
249 | adf385c7 | Iustin Pop | def _all_slots(cls): |
250 | adf385c7 | Iustin Pop | """Compute the list of all declared slots for a class.
|
251 | adf385c7 | Iustin Pop |
|
252 | adf385c7 | Iustin Pop | """
|
253 | adf385c7 | Iustin Pop | slots = [] |
254 | adf385c7 | Iustin Pop | for parent in cls.__mro__: |
255 | adf385c7 | Iustin Pop | slots.extend(getattr(parent, "__slots__", [])) |
256 | adf385c7 | Iustin Pop | return slots
|
257 | adf385c7 | Iustin Pop | |
258 | 65e183af | Michael Hanselmann | @classmethod
|
259 | 65e183af | Michael Hanselmann | def GetAllParams(cls): |
260 | 65e183af | Michael Hanselmann | """Compute list of all parameters for an opcode.
|
261 | 65e183af | Michael Hanselmann |
|
262 | 65e183af | Michael Hanselmann | """
|
263 | 65e183af | Michael Hanselmann | slots = [] |
264 | 65e183af | Michael Hanselmann | for parent in cls.__mro__: |
265 | 65e183af | Michael Hanselmann | slots.extend(getattr(parent, "OP_PARAMS", [])) |
266 | 65e183af | Michael Hanselmann | return slots
|
267 | 65e183af | Michael Hanselmann | |
268 | 1cbef6d8 | Michael Hanselmann | def Validate(self, set_defaults): |
269 | 1cbef6d8 | Michael Hanselmann | """Validate opcode parameters, optionally setting default values.
|
270 | 1cbef6d8 | Michael Hanselmann |
|
271 | 1cbef6d8 | Michael Hanselmann | @type set_defaults: bool
|
272 | 1cbef6d8 | Michael Hanselmann | @param set_defaults: Whether to set default values
|
273 | 1cbef6d8 | Michael Hanselmann | @raise errors.OpPrereqError: When a parameter value doesn't match
|
274 | 1cbef6d8 | Michael Hanselmann | requirements
|
275 | 1cbef6d8 | Michael Hanselmann |
|
276 | 1cbef6d8 | Michael Hanselmann | """
|
277 | 1cbef6d8 | Michael Hanselmann | for (attr_name, default, test) in self.GetAllParams(): |
278 | 1cbef6d8 | Michael Hanselmann | assert test == ht.NoType or callable(test) |
279 | 1cbef6d8 | Michael Hanselmann | |
280 | 1cbef6d8 | Michael Hanselmann | if not hasattr(self, attr_name): |
281 | 1cbef6d8 | Michael Hanselmann | if default == ht.NoDefault:
|
282 | 1cbef6d8 | Michael Hanselmann | raise errors.OpPrereqError("Required parameter '%s.%s' missing" % |
283 | 1cbef6d8 | Michael Hanselmann | (self.OP_ID, attr_name),
|
284 | 1cbef6d8 | Michael Hanselmann | errors.ECODE_INVAL) |
285 | 1cbef6d8 | Michael Hanselmann | elif set_defaults:
|
286 | 1cbef6d8 | Michael Hanselmann | if callable(default): |
287 | 1cbef6d8 | Michael Hanselmann | dval = default() |
288 | 1cbef6d8 | Michael Hanselmann | else:
|
289 | 1cbef6d8 | Michael Hanselmann | dval = default |
290 | 1cbef6d8 | Michael Hanselmann | setattr(self, attr_name, dval) |
291 | 1cbef6d8 | Michael Hanselmann | |
292 | 1cbef6d8 | Michael Hanselmann | if test == ht.NoType:
|
293 | 1cbef6d8 | Michael Hanselmann | # no tests here
|
294 | 1cbef6d8 | Michael Hanselmann | continue
|
295 | 1cbef6d8 | Michael Hanselmann | |
296 | 1cbef6d8 | Michael Hanselmann | if set_defaults or hasattr(self, attr_name): |
297 | 1cbef6d8 | Michael Hanselmann | attr_val = getattr(self, attr_name) |
298 | 1cbef6d8 | Michael Hanselmann | if not test(attr_val): |
299 | 1cbef6d8 | Michael Hanselmann | logging.error("OpCode %s, parameter %s, has invalid type %s/value %s",
|
300 | 1cbef6d8 | Michael Hanselmann | self.OP_ID, attr_name, type(attr_val), attr_val) |
301 | 1cbef6d8 | Michael Hanselmann | raise errors.OpPrereqError("Parameter '%s.%s' fails validation" % |
302 | 1cbef6d8 | Michael Hanselmann | (self.OP_ID, attr_name),
|
303 | 1cbef6d8 | Michael Hanselmann | errors.ECODE_INVAL) |
304 | 1cbef6d8 | Michael Hanselmann | |
305 | df458e0b | Iustin Pop | |
306 | 0e46916d | Iustin Pop | class OpCode(BaseOpCode): |
307 | a7399f66 | Iustin Pop | """Abstract OpCode.
|
308 | a7399f66 | Iustin Pop |
|
309 | a7399f66 | Iustin Pop | This is the root of the actual OpCode hierarchy. All clases derived
|
310 | a7399f66 | Iustin Pop | from this class should override OP_ID.
|
311 | a7399f66 | Iustin Pop |
|
312 | a7399f66 | Iustin Pop | @cvar OP_ID: The ID of this opcode. This should be unique amongst all
|
313 | 20777413 | Iustin Pop | children of this class.
|
314 | bde8f481 | Adeodato Simo | @cvar OP_DSC_FIELD: The name of a field whose value will be included in the
|
315 | bde8f481 | Adeodato Simo | string returned by Summary(); see the docstring of that
|
316 | bde8f481 | Adeodato Simo | method for details).
|
317 | 65e183af | Michael Hanselmann | @cvar OP_PARAMS: List of opcode attributes, the default values they should
|
318 | 65e183af | Michael Hanselmann | get if not already defined, and types they must match.
|
319 | 687c10d9 | Iustin Pop | @cvar WITH_LU: Boolean that specifies whether this should be included in
|
320 | 687c10d9 | Iustin Pop | mcpu's dispatch table
|
321 | 20777413 | Iustin Pop | @ivar dry_run: Whether the LU should be run in dry-run mode, i.e. just
|
322 | 20777413 | Iustin Pop | the check steps
|
323 | 8f5c488d | Michael Hanselmann | @ivar priority: Opcode priority for queue
|
324 | a7399f66 | Iustin Pop |
|
325 | a7399f66 | Iustin Pop | """
|
326 | e89a9021 | Iustin Pop | # pylint: disable-msg=E1101
|
327 | e89a9021 | Iustin Pop | # as OP_ID is dynamically defined
|
328 | 687c10d9 | Iustin Pop | WITH_LU = True
|
329 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
330 | 65e183af | Michael Hanselmann | ("dry_run", None, ht.TMaybeBool), |
331 | 65e183af | Michael Hanselmann | ("debug_level", None, ht.TOr(ht.TNone, ht.TPositiveInt)), |
332 | 65e183af | Michael Hanselmann | ("priority", constants.OP_PRIO_DEFAULT,
|
333 | 65e183af | Michael Hanselmann | ht.TElemOf(constants.OP_PRIO_SUBMIT_VALID)), |
334 | 65e183af | Michael Hanselmann | ] |
335 | df458e0b | Iustin Pop | |
336 | df458e0b | Iustin Pop | def __getstate__(self): |
337 | df458e0b | Iustin Pop | """Specialized getstate for opcodes.
|
338 | df458e0b | Iustin Pop |
|
339 | a7399f66 | Iustin Pop | This method adds to the state dictionary the OP_ID of the class,
|
340 | a7399f66 | Iustin Pop | so that on unload we can identify the correct class for
|
341 | a7399f66 | Iustin Pop | instantiating the opcode.
|
342 | a7399f66 | Iustin Pop |
|
343 | a7399f66 | Iustin Pop | @rtype: C{dict}
|
344 | a7399f66 | Iustin Pop | @return: the state as a dictionary
|
345 | a7399f66 | Iustin Pop |
|
346 | df458e0b | Iustin Pop | """
|
347 | 0e46916d | Iustin Pop | data = BaseOpCode.__getstate__(self)
|
348 | df458e0b | Iustin Pop | data["OP_ID"] = self.OP_ID |
349 | df458e0b | Iustin Pop | return data
|
350 | df458e0b | Iustin Pop | |
351 | df458e0b | Iustin Pop | @classmethod
|
352 | 00abdc96 | Iustin Pop | def LoadOpCode(cls, data): |
353 | df458e0b | Iustin Pop | """Generic load opcode method.
|
354 | df458e0b | Iustin Pop |
|
355 | a7399f66 | Iustin Pop | The method identifies the correct opcode class from the dict-form
|
356 | a7399f66 | Iustin Pop | by looking for a OP_ID key, if this is not found, or its value is
|
357 | a7399f66 | Iustin Pop | not available in this module as a child of this class, we fail.
|
358 | a7399f66 | Iustin Pop |
|
359 | a7399f66 | Iustin Pop | @type data: C{dict}
|
360 | a7399f66 | Iustin Pop | @param data: the serialized opcode
|
361 | a7399f66 | Iustin Pop |
|
362 | df458e0b | Iustin Pop | """
|
363 | df458e0b | Iustin Pop | if not isinstance(data, dict): |
364 | df458e0b | Iustin Pop | raise ValueError("Invalid data to LoadOpCode (%s)" % type(data)) |
365 | df458e0b | Iustin Pop | if "OP_ID" not in data: |
366 | df458e0b | Iustin Pop | raise ValueError("Invalid data to LoadOpcode, missing OP_ID") |
367 | df458e0b | Iustin Pop | op_id = data["OP_ID"]
|
368 | df458e0b | Iustin Pop | op_class = None
|
369 | 363acb1e | Iustin Pop | if op_id in OP_MAPPING: |
370 | 363acb1e | Iustin Pop | op_class = OP_MAPPING[op_id] |
371 | 363acb1e | Iustin Pop | else:
|
372 | df458e0b | Iustin Pop | raise ValueError("Invalid data to LoadOpCode: OP_ID %s unsupported" % |
373 | df458e0b | Iustin Pop | op_id) |
374 | df458e0b | Iustin Pop | op = op_class() |
375 | df458e0b | Iustin Pop | new_data = data.copy() |
376 | df458e0b | Iustin Pop | del new_data["OP_ID"] |
377 | df458e0b | Iustin Pop | op.__setstate__(new_data) |
378 | df458e0b | Iustin Pop | return op
|
379 | df458e0b | Iustin Pop | |
380 | 60dd1473 | Iustin Pop | def Summary(self): |
381 | 60dd1473 | Iustin Pop | """Generates a summary description of this opcode.
|
382 | 60dd1473 | Iustin Pop |
|
383 | ff0d18e6 | Iustin Pop | The summary is the value of the OP_ID attribute (without the "OP_"
|
384 | ff0d18e6 | Iustin Pop | prefix), plus the value of the OP_DSC_FIELD attribute, if one was
|
385 | ff0d18e6 | Iustin Pop | defined; this field should allow to easily identify the operation
|
386 | ff0d18e6 | Iustin Pop | (for an instance creation job, e.g., it would be the instance
|
387 | ff0d18e6 | Iustin Pop | name).
|
388 | bde8f481 | Adeodato Simo |
|
389 | 60dd1473 | Iustin Pop | """
|
390 | ff0d18e6 | Iustin Pop | assert self.OP_ID is not None and len(self.OP_ID) > 3 |
391 | 60dd1473 | Iustin Pop | # all OP_ID start with OP_, we remove that
|
392 | 60dd1473 | Iustin Pop | txt = self.OP_ID[3:] |
393 | 60dd1473 | Iustin Pop | field_name = getattr(self, "OP_DSC_FIELD", None) |
394 | 60dd1473 | Iustin Pop | if field_name:
|
395 | 60dd1473 | Iustin Pop | field_value = getattr(self, field_name, None) |
396 | bc8bbda1 | Iustin Pop | if isinstance(field_value, (list, tuple)): |
397 | bc8bbda1 | Iustin Pop | field_value = ",".join(str(i) for i in field_value) |
398 | 60dd1473 | Iustin Pop | txt = "%s(%s)" % (txt, field_value)
|
399 | 60dd1473 | Iustin Pop | return txt
|
400 | 60dd1473 | Iustin Pop | |
401 | a8083063 | Iustin Pop | |
402 | afee0879 | Iustin Pop | # cluster opcodes
|
403 | afee0879 | Iustin Pop | |
404 | bc84ffa7 | Iustin Pop | class OpClusterPostInit(OpCode): |
405 | b5f5fae9 | Luca Bigliardi | """Post cluster initialization.
|
406 | b5f5fae9 | Luca Bigliardi |
|
407 | b5f5fae9 | Luca Bigliardi | This opcode does not touch the cluster at all. Its purpose is to run hooks
|
408 | b5f5fae9 | Luca Bigliardi | after the cluster has been initialized.
|
409 | b5f5fae9 | Luca Bigliardi |
|
410 | b5f5fae9 | Luca Bigliardi | """
|
411 | b5f5fae9 | Luca Bigliardi | |
412 | b5f5fae9 | Luca Bigliardi | |
413 | c6d43e9e | Iustin Pop | class OpClusterDestroy(OpCode): |
414 | a7399f66 | Iustin Pop | """Destroy the cluster.
|
415 | a7399f66 | Iustin Pop |
|
416 | a7399f66 | Iustin Pop | This opcode has no other parameters. All the state is irreversibly
|
417 | a7399f66 | Iustin Pop | lost after the execution of this opcode.
|
418 | a7399f66 | Iustin Pop |
|
419 | a7399f66 | Iustin Pop | """
|
420 | a8083063 | Iustin Pop | |
421 | a8083063 | Iustin Pop | |
422 | a2f7ab92 | Iustin Pop | class OpClusterQuery(OpCode): |
423 | fdc267f4 | Iustin Pop | """Query cluster information."""
|
424 | a8083063 | Iustin Pop | |
425 | a8083063 | Iustin Pop | |
426 | a3d32770 | Iustin Pop | class OpClusterVerify(OpCode): |
427 | a7399f66 | Iustin Pop | """Verify the cluster state.
|
428 | a7399f66 | Iustin Pop |
|
429 | a7399f66 | Iustin Pop | @type skip_checks: C{list}
|
430 | a7399f66 | Iustin Pop | @ivar skip_checks: steps to be skipped from the verify process; this
|
431 | a7399f66 | Iustin Pop | needs to be a subset of
|
432 | a7399f66 | Iustin Pop | L{constants.VERIFY_OPTIONAL_CHECKS}; currently
|
433 | a7399f66 | Iustin Pop | only L{constants.VERIFY_NPLUSONE_MEM} can be passed
|
434 | a7399f66 | Iustin Pop |
|
435 | a7399f66 | Iustin Pop | """
|
436 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
437 | 65e183af | Michael Hanselmann | ("skip_checks", ht.EmptyList,
|
438 | 65e183af | Michael Hanselmann | ht.TListOf(ht.TElemOf(constants.VERIFY_OPTIONAL_CHECKS))), |
439 | 65e183af | Michael Hanselmann | ("verbose", False, ht.TBool), |
440 | 65e183af | Michael Hanselmann | ("error_codes", False, ht.TBool), |
441 | 65e183af | Michael Hanselmann | ("debug_simulate_errors", False, ht.TBool), |
442 | 65e183af | Michael Hanselmann | ] |
443 | a8083063 | Iustin Pop | |
444 | a8083063 | Iustin Pop | |
445 | bd8210a7 | Iustin Pop | class OpClusterVerifyDisks(OpCode): |
446 | 150e978f | Iustin Pop | """Verify the cluster disks.
|
447 | 150e978f | Iustin Pop |
|
448 | 150e978f | Iustin Pop | Parameters: none
|
449 | 150e978f | Iustin Pop |
|
450 | 5188ab37 | Iustin Pop | Result: a tuple of four elements:
|
451 | 150e978f | Iustin Pop | - list of node names with bad data returned (unreachable, etc.)
|
452 | a7399f66 | Iustin Pop | - dict of node names with broken volume groups (values: error msg)
|
453 | 150e978f | Iustin Pop | - list of instances with degraded disks (that should be activated)
|
454 | b63ed789 | Iustin Pop | - dict of instances with missing logical volumes (values: (node, vol)
|
455 | b63ed789 | Iustin Pop | pairs with details about the missing volumes)
|
456 | 150e978f | Iustin Pop |
|
457 | b63ed789 | Iustin Pop | In normal operation, all lists should be empty. A non-empty instance
|
458 | b63ed789 | Iustin Pop | list (3rd element of the result) is still ok (errors were fixed) but
|
459 | b63ed789 | Iustin Pop | non-empty node list means some node is down, and probably there are
|
460 | b63ed789 | Iustin Pop | unfixable drbd errors.
|
461 | 150e978f | Iustin Pop |
|
462 | 150e978f | Iustin Pop | Note that only instances that are drbd-based are taken into
|
463 | 150e978f | Iustin Pop | consideration. This might need to be revisited in the future.
|
464 | 150e978f | Iustin Pop |
|
465 | 150e978f | Iustin Pop | """
|
466 | 150e978f | Iustin Pop | |
467 | 150e978f | Iustin Pop | |
468 | 5d01aca3 | Iustin Pop | class OpClusterRepairDiskSizes(OpCode): |
469 | 60975797 | Iustin Pop | """Verify the disk sizes of the instances and fixes configuration
|
470 | 60975797 | Iustin Pop | mimatches.
|
471 | 60975797 | Iustin Pop |
|
472 | 60975797 | Iustin Pop | Parameters: optional instances list, in case we want to restrict the
|
473 | 60975797 | Iustin Pop | checks to only a subset of the instances.
|
474 | 60975797 | Iustin Pop |
|
475 | 60975797 | Iustin Pop | Result: a list of tuples, (instance, disk, new-size) for changed
|
476 | 60975797 | Iustin Pop | configurations.
|
477 | 60975797 | Iustin Pop |
|
478 | 60975797 | Iustin Pop | In normal operation, the list should be empty.
|
479 | 60975797 | Iustin Pop |
|
480 | 60975797 | Iustin Pop | @type instances: list
|
481 | 60975797 | Iustin Pop | @ivar instances: the list of instances to check, or empty for all instances
|
482 | 60975797 | Iustin Pop |
|
483 | 60975797 | Iustin Pop | """
|
484 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
485 | 65e183af | Michael Hanselmann | ("instances", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)),
|
486 | 65e183af | Michael Hanselmann | ] |
487 | 60975797 | Iustin Pop | |
488 | 60975797 | Iustin Pop | |
489 | 2f093ea0 | Iustin Pop | class OpClusterConfigQuery(OpCode): |
490 | ae5849b5 | Michael Hanselmann | """Query cluster configuration values."""
|
491 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
492 | 65e183af | Michael Hanselmann | _POutputFields |
493 | 65e183af | Michael Hanselmann | ] |
494 | a8083063 | Iustin Pop | |
495 | a8083063 | Iustin Pop | |
496 | e126df25 | Iustin Pop | class OpClusterRename(OpCode): |
497 | a7399f66 | Iustin Pop | """Rename the cluster.
|
498 | a7399f66 | Iustin Pop |
|
499 | a7399f66 | Iustin Pop | @type name: C{str}
|
500 | a7399f66 | Iustin Pop | @ivar name: The new name of the cluster. The name and/or the master IP
|
501 | a7399f66 | Iustin Pop | address will be changed to match the new name and its IP
|
502 | a7399f66 | Iustin Pop | address.
|
503 | a7399f66 | Iustin Pop |
|
504 | a7399f66 | Iustin Pop | """
|
505 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "name"
|
506 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
507 | 65e183af | Michael Hanselmann | ("name", ht.NoDefault, ht.TNonEmptyString),
|
508 | 65e183af | Michael Hanselmann | ] |
509 | 07bd8a51 | Iustin Pop | |
510 | 07bd8a51 | Iustin Pop | |
511 | a6682fdc | Iustin Pop | class OpClusterSetParams(OpCode): |
512 | a7399f66 | Iustin Pop | """Change the parameters of the cluster.
|
513 | a7399f66 | Iustin Pop |
|
514 | a7399f66 | Iustin Pop | @type vg_name: C{str} or C{None}
|
515 | a7399f66 | Iustin Pop | @ivar vg_name: The new volume group name or None to disable LVM usage.
|
516 | a7399f66 | Iustin Pop |
|
517 | a7399f66 | Iustin Pop | """
|
518 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
519 | 65e183af | Michael Hanselmann | ("vg_name", None, ht.TMaybeString), |
520 | 65e183af | Michael Hanselmann | ("enabled_hypervisors", None, |
521 | 65e183af | Michael Hanselmann | ht.TOr(ht.TAnd(ht.TListOf(ht.TElemOf(constants.HYPER_TYPES)), ht.TTrue), |
522 | 65e183af | Michael Hanselmann | ht.TNone)), |
523 | 65e183af | Michael Hanselmann | ("hvparams", None, ht.TOr(ht.TDictOf(ht.TNonEmptyString, ht.TDict), |
524 | 65e183af | Michael Hanselmann | ht.TNone)), |
525 | 65e183af | Michael Hanselmann | ("beparams", None, ht.TOr(ht.TDict, ht.TNone)), |
526 | 65e183af | Michael Hanselmann | ("os_hvp", None, ht.TOr(ht.TDictOf(ht.TNonEmptyString, ht.TDict), |
527 | 65e183af | Michael Hanselmann | ht.TNone)), |
528 | 65e183af | Michael Hanselmann | ("osparams", None, ht.TOr(ht.TDictOf(ht.TNonEmptyString, ht.TDict), |
529 | 65e183af | Michael Hanselmann | ht.TNone)), |
530 | 65e183af | Michael Hanselmann | ("candidate_pool_size", None, ht.TOr(ht.TStrictPositiveInt, ht.TNone)), |
531 | 65e183af | Michael Hanselmann | ("uid_pool", None, ht.NoType), |
532 | 65e183af | Michael Hanselmann | ("add_uids", None, ht.NoType), |
533 | 65e183af | Michael Hanselmann | ("remove_uids", None, ht.NoType), |
534 | 65e183af | Michael Hanselmann | ("maintain_node_health", None, ht.TMaybeBool), |
535 | 65e183af | Michael Hanselmann | ("prealloc_wipe_disks", None, ht.TMaybeBool), |
536 | 65e183af | Michael Hanselmann | ("nicparams", None, ht.TOr(ht.TDict, ht.TNone)), |
537 | 65e183af | Michael Hanselmann | ("ndparams", None, ht.TOr(ht.TDict, ht.TNone)), |
538 | 65e183af | Michael Hanselmann | ("drbd_helper", None, ht.TOr(ht.TString, ht.TNone)), |
539 | 65e183af | Michael Hanselmann | ("default_iallocator", None, ht.TOr(ht.TString, ht.TNone)), |
540 | 65e183af | Michael Hanselmann | ("master_netdev", None, ht.TOr(ht.TString, ht.TNone)), |
541 | 65e183af | Michael Hanselmann | ("reserved_lvs", None, ht.TOr(ht.TListOf(ht.TNonEmptyString), ht.TNone)), |
542 | 65e183af | Michael Hanselmann | ("hidden_os", None, ht.TOr(ht.TListOf( |
543 | 65e183af | Michael Hanselmann | ht.TAnd(ht.TList, |
544 | 65e183af | Michael Hanselmann | ht.TIsLength(2),
|
545 | 65e183af | Michael Hanselmann | ht.TMap(lambda v: v[0], ht.TElemOf(constants.DDMS_VALUES)))), |
546 | 65e183af | Michael Hanselmann | ht.TNone)), |
547 | 65e183af | Michael Hanselmann | ("blacklisted_os", None, ht.TOr(ht.TListOf( |
548 | 65e183af | Michael Hanselmann | ht.TAnd(ht.TList, |
549 | 65e183af | Michael Hanselmann | ht.TIsLength(2),
|
550 | 65e183af | Michael Hanselmann | ht.TMap(lambda v: v[0], ht.TElemOf(constants.DDMS_VALUES)))), |
551 | 65e183af | Michael Hanselmann | ht.TNone)), |
552 | 4b7735f9 | Iustin Pop | ] |
553 | 12515db7 | Manuel Franceschini | |
554 | 12515db7 | Manuel Franceschini | |
555 | d1240007 | Iustin Pop | class OpClusterRedistConf(OpCode): |
556 | afee0879 | Iustin Pop | """Force a full push of the cluster configuration.
|
557 | afee0879 | Iustin Pop |
|
558 | afee0879 | Iustin Pop | """
|
559 | afee0879 | Iustin Pop | |
560 | 83f72637 | Michael Hanselmann | |
561 | 83f72637 | Michael Hanselmann | class OpQuery(OpCode): |
562 | 83f72637 | Michael Hanselmann | """Query for resources/items.
|
563 | 83f72637 | Michael Hanselmann |
|
564 | 83f72637 | Michael Hanselmann | @ivar what: Resources to query for, must be one of L{constants.QR_OP_QUERY}
|
565 | 83f72637 | Michael Hanselmann | @ivar fields: List of fields to retrieve
|
566 | 83f72637 | Michael Hanselmann | @ivar filter: Query filter
|
567 | 83f72637 | Michael Hanselmann |
|
568 | 83f72637 | Michael Hanselmann | """
|
569 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
570 | 65e183af | Michael Hanselmann | ("what", ht.NoDefault, ht.TElemOf(constants.QR_OP_QUERY)),
|
571 | 65e183af | Michael Hanselmann | ("fields", ht.NoDefault, ht.TListOf(ht.TNonEmptyString)),
|
572 | 65e183af | Michael Hanselmann | ("filter", None, ht.TOr(ht.TNone, |
573 | 65e183af | Michael Hanselmann | ht.TListOf(ht.TOr(ht.TNonEmptyString, ht.TList)))), |
574 | 83f72637 | Michael Hanselmann | ] |
575 | 83f72637 | Michael Hanselmann | |
576 | 83f72637 | Michael Hanselmann | |
577 | 83f72637 | Michael Hanselmann | class OpQueryFields(OpCode): |
578 | 83f72637 | Michael Hanselmann | """Query for available resource/item fields.
|
579 | 83f72637 | Michael Hanselmann |
|
580 | 83f72637 | Michael Hanselmann | @ivar what: Resources to query for, must be one of L{constants.QR_OP_QUERY}
|
581 | 83f72637 | Michael Hanselmann | @ivar fields: List of fields to retrieve
|
582 | 83f72637 | Michael Hanselmann |
|
583 | 83f72637 | Michael Hanselmann | """
|
584 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
585 | 65e183af | Michael Hanselmann | ("what", ht.NoDefault, ht.TElemOf(constants.QR_OP_QUERY)),
|
586 | 65e183af | Michael Hanselmann | ("fields", None, ht.TOr(ht.TNone, ht.TListOf(ht.TNonEmptyString))), |
587 | 83f72637 | Michael Hanselmann | ] |
588 | 83f72637 | Michael Hanselmann | |
589 | 83f72637 | Michael Hanselmann | |
590 | 792af3ad | Renรฉ Nussbaumer | class OpOobCommand(OpCode): |
591 | eb64da59 | Renรฉ Nussbaumer | """Interact with OOB."""
|
592 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
593 | 65e183af | Michael Hanselmann | _PNodeName, |
594 | 65e183af | Michael Hanselmann | ("command", None, ht.TElemOf(constants.OOB_COMMANDS)), |
595 | 65e183af | Michael Hanselmann | ("timeout", constants.OOB_TIMEOUT, ht.TInt),
|
596 | eb64da59 | Renรฉ Nussbaumer | ] |
597 | eb64da59 | Renรฉ Nussbaumer | |
598 | eb64da59 | Renรฉ Nussbaumer | |
599 | 07bd8a51 | Iustin Pop | # node opcodes
|
600 | 07bd8a51 | Iustin Pop | |
601 | 73d565a3 | Iustin Pop | class OpNodeRemove(OpCode): |
602 | a7399f66 | Iustin Pop | """Remove a node.
|
603 | a7399f66 | Iustin Pop |
|
604 | a7399f66 | Iustin Pop | @type node_name: C{str}
|
605 | a7399f66 | Iustin Pop | @ivar node_name: The name of the node to remove. If the node still has
|
606 | a7399f66 | Iustin Pop | instances on it, the operation will fail.
|
607 | a7399f66 | Iustin Pop |
|
608 | a7399f66 | Iustin Pop | """
|
609 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "node_name"
|
610 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
611 | 65e183af | Michael Hanselmann | _PNodeName, |
612 | 65e183af | Michael Hanselmann | ] |
613 | a8083063 | Iustin Pop | |
614 | a8083063 | Iustin Pop | |
615 | d817d49f | Iustin Pop | class OpNodeAdd(OpCode): |
616 | a7399f66 | Iustin Pop | """Add a node to the cluster.
|
617 | a7399f66 | Iustin Pop |
|
618 | a7399f66 | Iustin Pop | @type node_name: C{str}
|
619 | a7399f66 | Iustin Pop | @ivar node_name: The name of the node to add. This can be a short name,
|
620 | a7399f66 | Iustin Pop | but it will be expanded to the FQDN.
|
621 | a7399f66 | Iustin Pop | @type primary_ip: IP address
|
622 | a7399f66 | Iustin Pop | @ivar primary_ip: The primary IP of the node. This will be ignored when the
|
623 | a7399f66 | Iustin Pop | opcode is submitted, but will be filled during the node
|
624 | a7399f66 | Iustin Pop | add (so it will be visible in the job query).
|
625 | a7399f66 | Iustin Pop | @type secondary_ip: IP address
|
626 | a7399f66 | Iustin Pop | @ivar secondary_ip: The secondary IP of the node. This needs to be passed
|
627 | a7399f66 | Iustin Pop | if the cluster has been initialized in 'dual-network'
|
628 | a7399f66 | Iustin Pop | mode, otherwise it must not be given.
|
629 | a7399f66 | Iustin Pop | @type readd: C{bool}
|
630 | a7399f66 | Iustin Pop | @ivar readd: Whether to re-add an existing node to the cluster. If
|
631 | a7399f66 | Iustin Pop | this is not passed, then the operation will abort if the node
|
632 | a7399f66 | Iustin Pop | name is already in the cluster; use this parameter to 'repair'
|
633 | a7399f66 | Iustin Pop | a node that had its configuration broken, or was reinstalled
|
634 | a7399f66 | Iustin Pop | without removal from the cluster.
|
635 | f936c153 | Iustin Pop | @type group: C{str}
|
636 | f936c153 | Iustin Pop | @ivar group: The node group to which this node will belong.
|
637 | fd3d37b6 | Iustin Pop | @type vm_capable: C{bool}
|
638 | fd3d37b6 | Iustin Pop | @ivar vm_capable: The vm_capable node attribute
|
639 | fd3d37b6 | Iustin Pop | @type master_capable: C{bool}
|
640 | fd3d37b6 | Iustin Pop | @ivar master_capable: The master_capable node attribute
|
641 | a7399f66 | Iustin Pop |
|
642 | a7399f66 | Iustin Pop | """
|
643 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "node_name"
|
644 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
645 | 65e183af | Michael Hanselmann | _PNodeName, |
646 | 65e183af | Michael Hanselmann | ("primary_ip", None, ht.NoType), |
647 | 65e183af | Michael Hanselmann | ("secondary_ip", None, ht.TMaybeString), |
648 | 65e183af | Michael Hanselmann | ("readd", False, ht.TBool), |
649 | 65e183af | Michael Hanselmann | ("group", None, ht.TMaybeString), |
650 | 65e183af | Michael Hanselmann | ("master_capable", None, ht.TMaybeBool), |
651 | 65e183af | Michael Hanselmann | ("vm_capable", None, ht.TMaybeBool), |
652 | 65e183af | Michael Hanselmann | ("ndparams", None, ht.TOr(ht.TDict, ht.TNone)), |
653 | 65e183af | Michael Hanselmann | ] |
654 | a8083063 | Iustin Pop | |
655 | a8083063 | Iustin Pop | |
656 | 2237687b | Iustin Pop | class OpNodeQuery(OpCode): |
657 | a8083063 | Iustin Pop | """Compute the list of nodes."""
|
658 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
659 | 65e183af | Michael Hanselmann | _POutputFields, |
660 | 65e183af | Michael Hanselmann | ("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)),
|
661 | 65e183af | Michael Hanselmann | ("use_locking", False, ht.TBool), |
662 | 65e183af | Michael Hanselmann | ] |
663 | a8083063 | Iustin Pop | |
664 | a8083063 | Iustin Pop | |
665 | 8ed55bfd | Iustin Pop | class OpNodeQueryvols(OpCode): |
666 | dcb93971 | Michael Hanselmann | """Get list of volumes on node."""
|
667 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
668 | 65e183af | Michael Hanselmann | _POutputFields, |
669 | 65e183af | Michael Hanselmann | ("nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)),
|
670 | 65e183af | Michael Hanselmann | ] |
671 | dcb93971 | Michael Hanselmann | |
672 | dcb93971 | Michael Hanselmann | |
673 | ad8d0595 | Iustin Pop | class OpNodeQueryStorage(OpCode): |
674 | 9e5442ce | Michael Hanselmann | """Get information on storage for node(s)."""
|
675 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
676 | 65e183af | Michael Hanselmann | _POutputFields, |
677 | 65e183af | Michael Hanselmann | _PStorageType, |
678 | 65e183af | Michael Hanselmann | ("nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)),
|
679 | 65e183af | Michael Hanselmann | ("name", None, ht.TMaybeString), |
680 | 9e5442ce | Michael Hanselmann | ] |
681 | 9e5442ce | Michael Hanselmann | |
682 | 9e5442ce | Michael Hanselmann | |
683 | 2cee4077 | Iustin Pop | class OpNodeModifyStorage(OpCode): |
684 | 099c52ad | Iustin Pop | """Modifies the properies of a storage unit"""
|
685 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
686 | 65e183af | Michael Hanselmann | _PNodeName, |
687 | 65e183af | Michael Hanselmann | _PStorageType, |
688 | 65e183af | Michael Hanselmann | ("name", ht.NoDefault, ht.TNonEmptyString),
|
689 | 65e183af | Michael Hanselmann | ("changes", ht.NoDefault, ht.TDict),
|
690 | efb8da02 | Michael Hanselmann | ] |
691 | efb8da02 | Michael Hanselmann | |
692 | efb8da02 | Michael Hanselmann | |
693 | 76aef8fc | Michael Hanselmann | class OpRepairNodeStorage(OpCode): |
694 | 76aef8fc | Michael Hanselmann | """Repairs the volume group on a node."""
|
695 | 76aef8fc | Michael Hanselmann | OP_DSC_FIELD = "node_name"
|
696 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
697 | 65e183af | Michael Hanselmann | _PNodeName, |
698 | 65e183af | Michael Hanselmann | _PStorageType, |
699 | 65e183af | Michael Hanselmann | ("name", ht.NoDefault, ht.TNonEmptyString),
|
700 | 65e183af | Michael Hanselmann | ("ignore_consistency", False, ht.TBool), |
701 | 76aef8fc | Michael Hanselmann | ] |
702 | 76aef8fc | Michael Hanselmann | |
703 | 76aef8fc | Michael Hanselmann | |
704 | f13973c4 | Iustin Pop | class OpNodeSetParams(OpCode): |
705 | b31c8676 | Iustin Pop | """Change the parameters of a node."""
|
706 | b31c8676 | Iustin Pop | OP_DSC_FIELD = "node_name"
|
707 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
708 | 65e183af | Michael Hanselmann | _PNodeName, |
709 | 65e183af | Michael Hanselmann | _PForce, |
710 | 65e183af | Michael Hanselmann | ("master_candidate", None, ht.TMaybeBool), |
711 | 65e183af | Michael Hanselmann | ("offline", None, ht.TMaybeBool), |
712 | 65e183af | Michael Hanselmann | ("drained", None, ht.TMaybeBool), |
713 | 65e183af | Michael Hanselmann | ("auto_promote", False, ht.TBool), |
714 | 65e183af | Michael Hanselmann | ("master_capable", None, ht.TMaybeBool), |
715 | 65e183af | Michael Hanselmann | ("vm_capable", None, ht.TMaybeBool), |
716 | 65e183af | Michael Hanselmann | ("secondary_ip", None, ht.TMaybeString), |
717 | 65e183af | Michael Hanselmann | ("ndparams", None, ht.TOr(ht.TDict, ht.TNone)), |
718 | 65e183af | Michael Hanselmann | ("powered", None, ht.TMaybeBool), |
719 | b31c8676 | Iustin Pop | ] |
720 | b31c8676 | Iustin Pop | |
721 | f5118ade | Iustin Pop | |
722 | e0d4735f | Iustin Pop | class OpNodePowercycle(OpCode): |
723 | f5118ade | Iustin Pop | """Tries to powercycle a node."""
|
724 | f5118ade | Iustin Pop | OP_DSC_FIELD = "node_name"
|
725 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
726 | 65e183af | Michael Hanselmann | _PNodeName, |
727 | 65e183af | Michael Hanselmann | _PForce, |
728 | f5118ade | Iustin Pop | ] |
729 | f5118ade | Iustin Pop | |
730 | 7ffc5a86 | Michael Hanselmann | |
731 | 5b14a488 | Iustin Pop | class OpNodeMigrate(OpCode): |
732 | 80cb875c | Michael Hanselmann | """Migrate all instances from a node."""
|
733 | 80cb875c | Michael Hanselmann | OP_DSC_FIELD = "node_name"
|
734 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
735 | 65e183af | Michael Hanselmann | _PNodeName, |
736 | 65e183af | Michael Hanselmann | _PMigrationMode, |
737 | 65e183af | Michael Hanselmann | _PMigrationLive, |
738 | 80cb875c | Michael Hanselmann | ] |
739 | 80cb875c | Michael Hanselmann | |
740 | 80cb875c | Michael Hanselmann | |
741 | 0ae89533 | Iustin Pop | class OpNodeEvacStrategy(OpCode): |
742 | d6aaa598 | Iustin Pop | """Compute the evacuation strategy for a list of nodes."""
|
743 | d6aaa598 | Iustin Pop | OP_DSC_FIELD = "nodes"
|
744 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
745 | 65e183af | Michael Hanselmann | ("nodes", ht.NoDefault, ht.TListOf(ht.TNonEmptyString)),
|
746 | 65e183af | Michael Hanselmann | ("remote_node", None, ht.TMaybeString), |
747 | 65e183af | Michael Hanselmann | ("iallocator", None, ht.TMaybeString), |
748 | 65e183af | Michael Hanselmann | ] |
749 | d6aaa598 | Iustin Pop | |
750 | d6aaa598 | Iustin Pop | |
751 | a8083063 | Iustin Pop | # instance opcodes
|
752 | a8083063 | Iustin Pop | |
753 | e1530b10 | Iustin Pop | class OpInstanceCreate(OpCode): |
754 | 9bf56d77 | Michael Hanselmann | """Create an instance.
|
755 | 9bf56d77 | Michael Hanselmann |
|
756 | 9bf56d77 | Michael Hanselmann | @ivar instance_name: Instance name
|
757 | 9bf56d77 | Michael Hanselmann | @ivar mode: Instance creation mode (one of L{constants.INSTANCE_CREATE_MODES})
|
758 | 9bf56d77 | Michael Hanselmann | @ivar source_handshake: Signed handshake from source (remote import only)
|
759 | 9bf56d77 | Michael Hanselmann | @ivar source_x509_ca: Source X509 CA in PEM format (remote import only)
|
760 | 9bf56d77 | Michael Hanselmann | @ivar source_instance_name: Previous name of instance (remote import only)
|
761 | dae91d02 | Michael Hanselmann | @ivar source_shutdown_timeout: Shutdown timeout used for source instance
|
762 | dae91d02 | Michael Hanselmann | (remote import only)
|
763 | 9bf56d77 | Michael Hanselmann |
|
764 | 9bf56d77 | Michael Hanselmann | """
|
765 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
766 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
767 | 65e183af | Michael Hanselmann | _PInstanceName, |
768 | 65e183af | Michael Hanselmann | ("beparams", ht.EmptyDict, ht.TDict),
|
769 | 65e183af | Michael Hanselmann | ("disks", ht.NoDefault, ht.TListOf(ht.TDict)),
|
770 | 65e183af | Michael Hanselmann | ("disk_template", ht.NoDefault, _CheckDiskTemplate),
|
771 | 65e183af | Michael Hanselmann | ("file_driver", None, ht.TOr(ht.TNone, ht.TElemOf(constants.FILE_DRIVER))), |
772 | 65e183af | Michael Hanselmann | ("file_storage_dir", None, ht.TMaybeString), |
773 | 65e183af | Michael Hanselmann | ("force_variant", False, ht.TBool), |
774 | 65e183af | Michael Hanselmann | ("hvparams", ht.EmptyDict, ht.TDict),
|
775 | 65e183af | Michael Hanselmann | ("hypervisor", None, ht.TMaybeString), |
776 | 65e183af | Michael Hanselmann | ("iallocator", None, ht.TMaybeString), |
777 | 65e183af | Michael Hanselmann | ("identify_defaults", False, ht.TBool), |
778 | 65e183af | Michael Hanselmann | ("ip_check", True, ht.TBool), |
779 | 65e183af | Michael Hanselmann | ("mode", ht.NoDefault, ht.TElemOf(constants.INSTANCE_CREATE_MODES)),
|
780 | 65e183af | Michael Hanselmann | ("name_check", True, ht.TBool), |
781 | 65e183af | Michael Hanselmann | ("nics", ht.NoDefault, ht.TListOf(ht.TDict)),
|
782 | 65e183af | Michael Hanselmann | ("no_install", None, ht.TMaybeBool), |
783 | 65e183af | Michael Hanselmann | ("osparams", ht.EmptyDict, ht.TDict),
|
784 | 65e183af | Michael Hanselmann | ("os_type", None, ht.TMaybeString), |
785 | 65e183af | Michael Hanselmann | ("pnode", None, ht.TMaybeString), |
786 | 65e183af | Michael Hanselmann | ("snode", None, ht.TMaybeString), |
787 | 65e183af | Michael Hanselmann | ("source_handshake", None, ht.TOr(ht.TList, ht.TNone)), |
788 | 65e183af | Michael Hanselmann | ("source_instance_name", None, ht.TMaybeString), |
789 | 65e183af | Michael Hanselmann | ("source_shutdown_timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT,
|
790 | 65e183af | Michael Hanselmann | ht.TPositiveInt), |
791 | 65e183af | Michael Hanselmann | ("source_x509_ca", None, ht.TMaybeString), |
792 | 65e183af | Michael Hanselmann | ("src_node", None, ht.TMaybeString), |
793 | 65e183af | Michael Hanselmann | ("src_path", None, ht.TMaybeString), |
794 | 65e183af | Michael Hanselmann | ("start", True, ht.TBool), |
795 | 65e183af | Michael Hanselmann | ("wait_for_sync", True, ht.TBool), |
796 | 3b6d8c9b | Iustin Pop | ] |
797 | a8083063 | Iustin Pop | |
798 | a8083063 | Iustin Pop | |
799 | 5073fd8f | Iustin Pop | class OpInstanceReinstall(OpCode): |
800 | fdc267f4 | Iustin Pop | """Reinstall an instance's OS."""
|
801 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
802 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
803 | 65e183af | Michael Hanselmann | _PInstanceName, |
804 | 65e183af | Michael Hanselmann | ("os_type", None, ht.TMaybeString), |
805 | 65e183af | Michael Hanselmann | ("force_variant", False, ht.TBool), |
806 | 65e183af | Michael Hanselmann | ("osparams", None, ht.TOr(ht.TDict, ht.TNone)), |
807 | 65e183af | Michael Hanselmann | ] |
808 | fe7b0351 | Michael Hanselmann | |
809 | fe7b0351 | Michael Hanselmann | |
810 | 3cd2d4b1 | Iustin Pop | class OpInstanceRemove(OpCode): |
811 | a8083063 | Iustin Pop | """Remove an instance."""
|
812 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
813 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
814 | 65e183af | Michael Hanselmann | _PInstanceName, |
815 | 65e183af | Michael Hanselmann | _PShutdownTimeout, |
816 | 65e183af | Michael Hanselmann | ("ignore_failures", False, ht.TBool), |
817 | fc1baca9 | Michael Hanselmann | ] |
818 | a8083063 | Iustin Pop | |
819 | a8083063 | Iustin Pop | |
820 | 5659e2e2 | Iustin Pop | class OpInstanceRename(OpCode): |
821 | decd5f45 | Iustin Pop | """Rename an instance."""
|
822 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
823 | 65e183af | Michael Hanselmann | _PInstanceName, |
824 | 65e183af | Michael Hanselmann | ("new_name", ht.NoDefault, ht.TNonEmptyString),
|
825 | 65e183af | Michael Hanselmann | ("ip_check", False, ht.TBool), |
826 | 65e183af | Michael Hanselmann | ("name_check", True, ht.TBool), |
827 | 4f05fd3b | Iustin Pop | ] |
828 | decd5f45 | Iustin Pop | |
829 | decd5f45 | Iustin Pop | |
830 | c873d91c | Iustin Pop | class OpInstanceStartup(OpCode): |
831 | fdc267f4 | Iustin Pop | """Startup an instance."""
|
832 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
833 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
834 | 65e183af | Michael Hanselmann | _PInstanceName, |
835 | 65e183af | Michael Hanselmann | _PForce, |
836 | 65e183af | Michael Hanselmann | _PIgnoreOfflineNodes, |
837 | 65e183af | Michael Hanselmann | ("hvparams", ht.EmptyDict, ht.TDict),
|
838 | 65e183af | Michael Hanselmann | ("beparams", ht.EmptyDict, ht.TDict),
|
839 | 4f05fd3b | Iustin Pop | ] |
840 | a8083063 | Iustin Pop | |
841 | a8083063 | Iustin Pop | |
842 | ee3e37a7 | Iustin Pop | class OpInstanceShutdown(OpCode): |
843 | fdc267f4 | Iustin Pop | """Shutdown an instance."""
|
844 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
845 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
846 | 65e183af | Michael Hanselmann | _PInstanceName, |
847 | 65e183af | Michael Hanselmann | _PIgnoreOfflineNodes, |
848 | 65e183af | Michael Hanselmann | ("timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT, ht.TPositiveInt),
|
849 | b44bd844 | Michael Hanselmann | ] |
850 | a8083063 | Iustin Pop | |
851 | a8083063 | Iustin Pop | |
852 | 90ab1a95 | Iustin Pop | class OpInstanceReboot(OpCode): |
853 | bf6929a2 | Alexander Schreiber | """Reboot an instance."""
|
854 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
855 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
856 | 65e183af | Michael Hanselmann | _PInstanceName, |
857 | 65e183af | Michael Hanselmann | _PShutdownTimeout, |
858 | 65e183af | Michael Hanselmann | ("ignore_secondaries", False, ht.TBool), |
859 | 65e183af | Michael Hanselmann | ("reboot_type", ht.NoDefault, ht.TElemOf(constants.REBOOT_TYPES)),
|
860 | 4f05fd3b | Iustin Pop | ] |
861 | bf6929a2 | Alexander Schreiber | |
862 | bf6929a2 | Alexander Schreiber | |
863 | 668f755d | Iustin Pop | class OpInstanceReplaceDisks(OpCode): |
864 | fdc267f4 | Iustin Pop | """Replace the disks of an instance."""
|
865 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
866 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
867 | 65e183af | Michael Hanselmann | _PInstanceName, |
868 | 65e183af | Michael Hanselmann | ("mode", ht.NoDefault, ht.TElemOf(constants.REPLACE_MODES)),
|
869 | 65e183af | Michael Hanselmann | ("disks", ht.EmptyList, ht.TListOf(ht.TPositiveInt)),
|
870 | 65e183af | Michael Hanselmann | ("remote_node", None, ht.TMaybeString), |
871 | 65e183af | Michael Hanselmann | ("iallocator", None, ht.TMaybeString), |
872 | 65e183af | Michael Hanselmann | ("early_release", False, ht.TBool), |
873 | 4f05fd3b | Iustin Pop | ] |
874 | a8083063 | Iustin Pop | |
875 | a8083063 | Iustin Pop | |
876 | 019dbee1 | Iustin Pop | class OpInstanceFailover(OpCode): |
877 | a8083063 | Iustin Pop | """Failover an instance."""
|
878 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
879 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
880 | 65e183af | Michael Hanselmann | _PInstanceName, |
881 | 65e183af | Michael Hanselmann | _PShutdownTimeout, |
882 | 65e183af | Michael Hanselmann | ("ignore_consistency", False, ht.TBool), |
883 | 17c3f802 | Guido Trotter | ] |
884 | a8083063 | Iustin Pop | |
885 | a8083063 | Iustin Pop | |
886 | 75c866c2 | Iustin Pop | class OpInstanceMigrate(OpCode): |
887 | 53c776b5 | Iustin Pop | """Migrate an instance.
|
888 | 53c776b5 | Iustin Pop |
|
889 | 53c776b5 | Iustin Pop | This migrates (without shutting down an instance) to its secondary
|
890 | 53c776b5 | Iustin Pop | node.
|
891 | 53c776b5 | Iustin Pop |
|
892 | 2f907a8c | Iustin Pop | @ivar instance_name: the name of the instance
|
893 | 8c35561f | Iustin Pop | @ivar mode: the migration mode (live, non-live or None for auto)
|
894 | 53c776b5 | Iustin Pop |
|
895 | 53c776b5 | Iustin Pop | """
|
896 | ee69c97f | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
897 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
898 | 65e183af | Michael Hanselmann | _PInstanceName, |
899 | 65e183af | Michael Hanselmann | _PMigrationMode, |
900 | 65e183af | Michael Hanselmann | _PMigrationLive, |
901 | 65e183af | Michael Hanselmann | ("cleanup", False, ht.TBool), |
902 | 65e183af | Michael Hanselmann | ] |
903 | 53c776b5 | Iustin Pop | |
904 | 53c776b5 | Iustin Pop | |
905 | 0091b480 | Iustin Pop | class OpInstanceMove(OpCode): |
906 | 313bcead | Iustin Pop | """Move an instance.
|
907 | 313bcead | Iustin Pop |
|
908 | 313bcead | Iustin Pop | This move (with shutting down an instance and data copying) to an
|
909 | 313bcead | Iustin Pop | arbitrary node.
|
910 | 313bcead | Iustin Pop |
|
911 | 313bcead | Iustin Pop | @ivar instance_name: the name of the instance
|
912 | 313bcead | Iustin Pop | @ivar target_node: the destination node
|
913 | 313bcead | Iustin Pop |
|
914 | 313bcead | Iustin Pop | """
|
915 | 313bcead | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
916 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
917 | 65e183af | Michael Hanselmann | _PInstanceName, |
918 | 65e183af | Michael Hanselmann | _PShutdownTimeout, |
919 | 65e183af | Michael Hanselmann | ("target_node", ht.NoDefault, ht.TNonEmptyString),
|
920 | 154b9580 | Balazs Lecz | ] |
921 | 313bcead | Iustin Pop | |
922 | 313bcead | Iustin Pop | |
923 | cc0dec7b | Iustin Pop | class OpInstanceConsole(OpCode): |
924 | fdc267f4 | Iustin Pop | """Connect to an instance's console."""
|
925 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
926 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
927 | 65e183af | Michael Hanselmann | _PInstanceName |
928 | 65e183af | Michael Hanselmann | ] |
929 | a8083063 | Iustin Pop | |
930 | a8083063 | Iustin Pop | |
931 | 83f5d475 | Iustin Pop | class OpInstanceActivateDisks(OpCode): |
932 | fdc267f4 | Iustin Pop | """Activate an instance's disks."""
|
933 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
934 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
935 | 65e183af | Michael Hanselmann | _PInstanceName, |
936 | 65e183af | Michael Hanselmann | ("ignore_size", False, ht.TBool), |
937 | 65e183af | Michael Hanselmann | ] |
938 | a8083063 | Iustin Pop | |
939 | a8083063 | Iustin Pop | |
940 | e176281f | Iustin Pop | class OpInstanceDeactivateDisks(OpCode): |
941 | fdc267f4 | Iustin Pop | """Deactivate an instance's disks."""
|
942 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
943 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
944 | 65e183af | Michael Hanselmann | _PInstanceName |
945 | 65e183af | Michael Hanselmann | ] |
946 | a8083063 | Iustin Pop | |
947 | a8083063 | Iustin Pop | |
948 | 6b273e78 | Iustin Pop | class OpInstanceRecreateDisks(OpCode): |
949 | bd315bfa | Iustin Pop | """Deactivate an instance's disks."""
|
950 | bd315bfa | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
951 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
952 | 65e183af | Michael Hanselmann | _PInstanceName, |
953 | 65e183af | Michael Hanselmann | ("disks", ht.EmptyList, ht.TListOf(ht.TPositiveInt)),
|
954 | 65e183af | Michael Hanselmann | ] |
955 | bd315bfa | Iustin Pop | |
956 | bd315bfa | Iustin Pop | |
957 | f2af0bec | Iustin Pop | class OpInstanceQuery(OpCode): |
958 | a8083063 | Iustin Pop | """Compute the list of instances."""
|
959 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
960 | 65e183af | Michael Hanselmann | _POutputFields, |
961 | 65e183af | Michael Hanselmann | ("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)),
|
962 | 65e183af | Michael Hanselmann | ("use_locking", False, ht.TBool), |
963 | 65e183af | Michael Hanselmann | ] |
964 | a8083063 | Iustin Pop | |
965 | a8083063 | Iustin Pop | |
966 | dc28c4e4 | Iustin Pop | class OpInstanceQueryData(OpCode): |
967 | a8083063 | Iustin Pop | """Compute the run-time status of instances."""
|
968 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
969 | 65e183af | Michael Hanselmann | ("instances", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)),
|
970 | 65e183af | Michael Hanselmann | ("static", False, ht.TBool), |
971 | 65e183af | Michael Hanselmann | ] |
972 | a8083063 | Iustin Pop | |
973 | a8083063 | Iustin Pop | |
974 | 9a3cc7ae | Iustin Pop | class OpInstanceSetParams(OpCode): |
975 | a8083063 | Iustin Pop | """Change the parameters of an instance."""
|
976 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
977 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
978 | 65e183af | Michael Hanselmann | _PInstanceName, |
979 | 65e183af | Michael Hanselmann | _PForce, |
980 | 65e183af | Michael Hanselmann | ("nics", ht.EmptyList, ht.TList),
|
981 | 65e183af | Michael Hanselmann | ("disks", ht.EmptyList, ht.TList),
|
982 | 65e183af | Michael Hanselmann | ("beparams", ht.EmptyDict, ht.TDict),
|
983 | 65e183af | Michael Hanselmann | ("hvparams", ht.EmptyDict, ht.TDict),
|
984 | f7c8f153 | Michael Hanselmann | ("disk_template", None, ht.TOr(ht.TNone, _CheckDiskTemplate)), |
985 | 65e183af | Michael Hanselmann | ("remote_node", None, ht.TMaybeString), |
986 | 65e183af | Michael Hanselmann | ("os_name", None, ht.TMaybeString), |
987 | 65e183af | Michael Hanselmann | ("force_variant", False, ht.TBool), |
988 | 65e183af | Michael Hanselmann | ("osparams", None, ht.TOr(ht.TDict, ht.TNone)), |
989 | 973d7867 | Iustin Pop | ] |
990 | a8083063 | Iustin Pop | |
991 | a8083063 | Iustin Pop | |
992 | 60472d29 | Iustin Pop | class OpInstanceGrowDisk(OpCode): |
993 | 8729e0d7 | Iustin Pop | """Grow a disk of an instance."""
|
994 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
995 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
996 | 65e183af | Michael Hanselmann | _PInstanceName, |
997 | 65e183af | Michael Hanselmann | ("disk", ht.NoDefault, ht.TInt),
|
998 | 65e183af | Michael Hanselmann | ("amount", ht.NoDefault, ht.TInt),
|
999 | 65e183af | Michael Hanselmann | ("wait_for_sync", True, ht.TBool), |
1000 | 4f05fd3b | Iustin Pop | ] |
1001 | 8729e0d7 | Iustin Pop | |
1002 | 8729e0d7 | Iustin Pop | |
1003 | 70a6a926 | Adeodato Simo | # Node group opcodes
|
1004 | 70a6a926 | Adeodato Simo | |
1005 | fabf1731 | Iustin Pop | class OpGroupAdd(OpCode): |
1006 | b1ee5610 | Adeodato Simo | """Add a node group to the cluster."""
|
1007 | b1ee5610 | Adeodato Simo | OP_DSC_FIELD = "group_name"
|
1008 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1009 | 65e183af | Michael Hanselmann | _PGroupName, |
1010 | 65e183af | Michael Hanselmann | ("ndparams", None, ht.TOr(ht.TDict, ht.TNone)), |
1011 | 65e183af | Michael Hanselmann | ("alloc_policy", None, |
1012 | 65e183af | Michael Hanselmann | ht.TOr(ht.TNone, ht.TElemOf(constants.VALID_ALLOC_POLICIES))), |
1013 | 483be60d | Adeodato Simo | ] |
1014 | b1ee5610 | Adeodato Simo | |
1015 | b1ee5610 | Adeodato Simo | |
1016 | 934704ae | Iustin Pop | class OpGroupAssignNodes(OpCode): |
1017 | 96276ae7 | Adeodato Simo | """Assign nodes to a node group."""
|
1018 | 96276ae7 | Adeodato Simo | OP_DSC_FIELD = "group_name"
|
1019 | 96276ae7 | Adeodato Simo | OP_PARAMS = [ |
1020 | 96276ae7 | Adeodato Simo | _PGroupName, |
1021 | 96276ae7 | Adeodato Simo | _PForce, |
1022 | 96276ae7 | Adeodato Simo | ("nodes", ht.NoDefault, ht.TListOf(ht.TNonEmptyString)),
|
1023 | 96276ae7 | Adeodato Simo | ] |
1024 | 96276ae7 | Adeodato Simo | |
1025 | 96276ae7 | Adeodato Simo | |
1026 | d4d654bd | Iustin Pop | class OpGroupQuery(OpCode): |
1027 | 70a6a926 | Adeodato Simo | """Compute the list of node groups."""
|
1028 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1029 | 65e183af | Michael Hanselmann | _POutputFields, |
1030 | 65e183af | Michael Hanselmann | ("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)),
|
1031 | 65e183af | Michael Hanselmann | ] |
1032 | 70a6a926 | Adeodato Simo | |
1033 | 70a6a926 | Adeodato Simo | |
1034 | 7cbf74f0 | Iustin Pop | class OpGroupSetParams(OpCode): |
1035 | 4da7909a | Adeodato Simo | """Change the parameters of a node group."""
|
1036 | 4da7909a | Adeodato Simo | OP_DSC_FIELD = "group_name"
|
1037 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1038 | 65e183af | Michael Hanselmann | _PGroupName, |
1039 | 65e183af | Michael Hanselmann | ("ndparams", None, ht.TOr(ht.TDict, ht.TNone)), |
1040 | 65e183af | Michael Hanselmann | ("alloc_policy", None, ht.TOr(ht.TNone, |
1041 | 65e183af | Michael Hanselmann | ht.TElemOf(constants.VALID_ALLOC_POLICIES))), |
1042 | 4da7909a | Adeodato Simo | ] |
1043 | 4da7909a | Adeodato Simo | |
1044 | 4da7909a | Adeodato Simo | |
1045 | 4d1baa51 | Iustin Pop | class OpGroupRemove(OpCode): |
1046 | 94bd652a | Adeodato Simo | """Remove a node group from the cluster."""
|
1047 | 94bd652a | Adeodato Simo | OP_DSC_FIELD = "group_name"
|
1048 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1049 | 65e183af | Michael Hanselmann | _PGroupName, |
1050 | 65e183af | Michael Hanselmann | ] |
1051 | 94bd652a | Adeodato Simo | |
1052 | 94bd652a | Adeodato Simo | |
1053 | a8173e82 | Iustin Pop | class OpGroupRename(OpCode): |
1054 | 4fe5cf90 | Adeodato Simo | """Rename a node group in the cluster."""
|
1055 | 4fe5cf90 | Adeodato Simo | OP_DSC_FIELD = "old_name"
|
1056 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1057 | 65e183af | Michael Hanselmann | ("old_name", ht.NoDefault, ht.TNonEmptyString),
|
1058 | 65e183af | Michael Hanselmann | ("new_name", ht.NoDefault, ht.TNonEmptyString),
|
1059 | 65e183af | Michael Hanselmann | ] |
1060 | 4fe5cf90 | Adeodato Simo | |
1061 | 4fe5cf90 | Adeodato Simo | |
1062 | a8083063 | Iustin Pop | # OS opcodes
|
1063 | da2d02e7 | Iustin Pop | class OpOsDiagnose(OpCode): |
1064 | a8083063 | Iustin Pop | """Compute the list of guest operating systems."""
|
1065 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1066 | 65e183af | Michael Hanselmann | _POutputFields, |
1067 | 65e183af | Michael Hanselmann | ("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)),
|
1068 | 65e183af | Michael Hanselmann | ] |
1069 | a8083063 | Iustin Pop | |
1070 | 7c0d6283 | Michael Hanselmann | |
1071 | a8083063 | Iustin Pop | # Exports opcodes
|
1072 | 7ca2d4d8 | Iustin Pop | class OpBackupQuery(OpCode): |
1073 | a8083063 | Iustin Pop | """Compute the list of exported images."""
|
1074 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1075 | 65e183af | Michael Hanselmann | ("nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)),
|
1076 | 65e183af | Michael Hanselmann | ("use_locking", False, ht.TBool), |
1077 | 65e183af | Michael Hanselmann | ] |
1078 | a8083063 | Iustin Pop | |
1079 | 7c0d6283 | Michael Hanselmann | |
1080 | 71910715 | Iustin Pop | class OpBackupPrepare(OpCode): |
1081 | 1410fa8d | Michael Hanselmann | """Prepares an instance export.
|
1082 | 1410fa8d | Michael Hanselmann |
|
1083 | 1410fa8d | Michael Hanselmann | @ivar instance_name: Instance name
|
1084 | 1410fa8d | Michael Hanselmann | @ivar mode: Export mode (one of L{constants.EXPORT_MODES})
|
1085 | 1410fa8d | Michael Hanselmann |
|
1086 | 1410fa8d | Michael Hanselmann | """
|
1087 | 1410fa8d | Michael Hanselmann | OP_DSC_FIELD = "instance_name"
|
1088 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1089 | 65e183af | Michael Hanselmann | _PInstanceName, |
1090 | 65e183af | Michael Hanselmann | ("mode", ht.NoDefault, ht.TElemOf(constants.EXPORT_MODES)),
|
1091 | 1410fa8d | Michael Hanselmann | ] |
1092 | 1410fa8d | Michael Hanselmann | |
1093 | 1410fa8d | Michael Hanselmann | |
1094 | 4ff922a2 | Iustin Pop | class OpBackupExport(OpCode): |
1095 | 4a96f1d1 | Michael Hanselmann | """Export an instance.
|
1096 | 4a96f1d1 | Michael Hanselmann |
|
1097 | 4a96f1d1 | Michael Hanselmann | For local exports, the export destination is the node name. For remote
|
1098 | 4a96f1d1 | Michael Hanselmann | exports, the export destination is a list of tuples, each consisting of
|
1099 | 4a96f1d1 | Michael Hanselmann | hostname/IP address, port, HMAC and HMAC salt. The HMAC is calculated using
|
1100 | 4a96f1d1 | Michael Hanselmann | the cluster domain secret over the value "${index}:${hostname}:${port}". The
|
1101 | 4a96f1d1 | Michael Hanselmann | destination X509 CA must be a signed certificate.
|
1102 | 4a96f1d1 | Michael Hanselmann |
|
1103 | 4a96f1d1 | Michael Hanselmann | @ivar mode: Export mode (one of L{constants.EXPORT_MODES})
|
1104 | 4a96f1d1 | Michael Hanselmann | @ivar target_node: Export destination
|
1105 | 4a96f1d1 | Michael Hanselmann | @ivar x509_key_name: X509 key to use (remote export only)
|
1106 | 4a96f1d1 | Michael Hanselmann | @ivar destination_x509_ca: Destination X509 CA in PEM format (remote export
|
1107 | 4a96f1d1 | Michael Hanselmann | only)
|
1108 | 4a96f1d1 | Michael Hanselmann |
|
1109 | 4a96f1d1 | Michael Hanselmann | """
|
1110 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
1111 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1112 | 65e183af | Michael Hanselmann | _PInstanceName, |
1113 | 65e183af | Michael Hanselmann | _PShutdownTimeout, |
1114 | 4a96f1d1 | Michael Hanselmann | # TODO: Rename target_node as it changes meaning for different export modes
|
1115 | 4a96f1d1 | Michael Hanselmann | # (e.g. "destination")
|
1116 | 65e183af | Michael Hanselmann | ("target_node", ht.NoDefault, ht.TOr(ht.TNonEmptyString, ht.TList)),
|
1117 | 65e183af | Michael Hanselmann | ("shutdown", True, ht.TBool), |
1118 | 65e183af | Michael Hanselmann | ("remove_instance", False, ht.TBool), |
1119 | 65e183af | Michael Hanselmann | ("ignore_remove_failures", False, ht.TBool), |
1120 | 65e183af | Michael Hanselmann | ("mode", constants.EXPORT_MODE_LOCAL, ht.TElemOf(constants.EXPORT_MODES)),
|
1121 | 65e183af | Michael Hanselmann | ("x509_key_name", None, ht.TOr(ht.TList, ht.TNone)), |
1122 | 65e183af | Michael Hanselmann | ("destination_x509_ca", None, ht.TMaybeString), |
1123 | 17c3f802 | Guido Trotter | ] |
1124 | 5c947f38 | Iustin Pop | |
1125 | 0a7bed64 | Michael Hanselmann | |
1126 | ca5890ad | Iustin Pop | class OpBackupRemove(OpCode): |
1127 | 9ac99fda | Guido Trotter | """Remove an instance's export."""
|
1128 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
1129 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1130 | 65e183af | Michael Hanselmann | _PInstanceName, |
1131 | 65e183af | Michael Hanselmann | ] |
1132 | 5c947f38 | Iustin Pop | |
1133 | 0a7bed64 | Michael Hanselmann | |
1134 | 5c947f38 | Iustin Pop | # Tags opcodes
|
1135 | c6afb1ca | Iustin Pop | class OpTagsGet(OpCode): |
1136 | 5c947f38 | Iustin Pop | """Returns the tags of the given object."""
|
1137 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "name"
|
1138 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1139 | 65e183af | Michael Hanselmann | _PTagKind, |
1140 | 65e183af | Michael Hanselmann | # Name is only meaningful for nodes and instances
|
1141 | 65e183af | Michael Hanselmann | ("name", ht.NoDefault, ht.TMaybeString),
|
1142 | 65e183af | Michael Hanselmann | ] |
1143 | 5c947f38 | Iustin Pop | |
1144 | 5c947f38 | Iustin Pop | |
1145 | 715462e7 | Iustin Pop | class OpTagsSearch(OpCode): |
1146 | 73415719 | Iustin Pop | """Searches the tags in the cluster for a given pattern."""
|
1147 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "pattern"
|
1148 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1149 | 65e183af | Michael Hanselmann | ("pattern", ht.NoDefault, ht.TNonEmptyString),
|
1150 | 65e183af | Michael Hanselmann | ] |
1151 | 73415719 | Iustin Pop | |
1152 | 73415719 | Iustin Pop | |
1153 | d1602edc | Iustin Pop | class OpTagsSet(OpCode): |
1154 | f27302fa | Iustin Pop | """Add a list of tags on a given object."""
|
1155 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1156 | 65e183af | Michael Hanselmann | _PTagKind, |
1157 | 65e183af | Michael Hanselmann | _PTags, |
1158 | 65e183af | Michael Hanselmann | # Name is only meaningful for nodes and instances
|
1159 | 65e183af | Michael Hanselmann | ("name", ht.NoDefault, ht.TMaybeString),
|
1160 | 65e183af | Michael Hanselmann | ] |
1161 | 5c947f38 | Iustin Pop | |
1162 | 5c947f38 | Iustin Pop | |
1163 | 3f0ab95f | Iustin Pop | class OpTagsDel(OpCode): |
1164 | f27302fa | Iustin Pop | """Remove a list of tags from a given object."""
|
1165 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1166 | 65e183af | Michael Hanselmann | _PTagKind, |
1167 | 65e183af | Michael Hanselmann | _PTags, |
1168 | 65e183af | Michael Hanselmann | # Name is only meaningful for nodes and instances
|
1169 | 65e183af | Michael Hanselmann | ("name", ht.NoDefault, ht.TMaybeString),
|
1170 | 65e183af | Michael Hanselmann | ] |
1171 | 06009e27 | Iustin Pop | |
1172 | 06009e27 | Iustin Pop | # Test opcodes
|
1173 | 06009e27 | Iustin Pop | class OpTestDelay(OpCode): |
1174 | 06009e27 | Iustin Pop | """Sleeps for a configured amount of time.
|
1175 | 06009e27 | Iustin Pop |
|
1176 | 06009e27 | Iustin Pop | This is used just for debugging and testing.
|
1177 | 06009e27 | Iustin Pop |
|
1178 | 06009e27 | Iustin Pop | Parameters:
|
1179 | 06009e27 | Iustin Pop | - duration: the time to sleep
|
1180 | 06009e27 | Iustin Pop | - on_master: if true, sleep on the master
|
1181 | 06009e27 | Iustin Pop | - on_nodes: list of nodes in which to sleep
|
1182 | 06009e27 | Iustin Pop |
|
1183 | 06009e27 | Iustin Pop | If the on_master parameter is true, it will execute a sleep on the
|
1184 | 06009e27 | Iustin Pop | master (before any node sleep).
|
1185 | 06009e27 | Iustin Pop |
|
1186 | 06009e27 | Iustin Pop | If the on_nodes list is not empty, it will sleep on those nodes
|
1187 | 06009e27 | Iustin Pop | (after the sleep on the master, if that is enabled).
|
1188 | 06009e27 | Iustin Pop |
|
1189 | 06009e27 | Iustin Pop | As an additional feature, the case of duration < 0 will be reported
|
1190 | 06009e27 | Iustin Pop | as an execution error, so this opcode can be used as a failure
|
1191 | 06009e27 | Iustin Pop | generator. The case of duration == 0 will not be treated specially.
|
1192 | 06009e27 | Iustin Pop |
|
1193 | 06009e27 | Iustin Pop | """
|
1194 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "duration"
|
1195 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1196 | 65e183af | Michael Hanselmann | ("duration", ht.NoDefault, ht.TFloat),
|
1197 | 65e183af | Michael Hanselmann | ("on_master", True, ht.TBool), |
1198 | 65e183af | Michael Hanselmann | ("on_nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)),
|
1199 | 65e183af | Michael Hanselmann | ("repeat", 0, ht.TPositiveInt) |
1200 | 65e183af | Michael Hanselmann | ] |
1201 | d61df03e | Iustin Pop | |
1202 | d61df03e | Iustin Pop | |
1203 | d61df03e | Iustin Pop | class OpTestAllocator(OpCode): |
1204 | d61df03e | Iustin Pop | """Allocator framework testing.
|
1205 | d61df03e | Iustin Pop |
|
1206 | d61df03e | Iustin Pop | This opcode has two modes:
|
1207 | d61df03e | Iustin Pop | - gather and return allocator input for a given mode (allocate new
|
1208 | d61df03e | Iustin Pop | or replace secondary) and a given instance definition (direction
|
1209 | d61df03e | Iustin Pop | 'in')
|
1210 | d61df03e | Iustin Pop | - run a selected allocator for a given operation (as above) and
|
1211 | d61df03e | Iustin Pop | return the allocator output (direction 'out')
|
1212 | d61df03e | Iustin Pop |
|
1213 | d61df03e | Iustin Pop | """
|
1214 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "allocator"
|
1215 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1216 | 65e183af | Michael Hanselmann | ("direction", ht.NoDefault,
|
1217 | 65e183af | Michael Hanselmann | ht.TElemOf(constants.VALID_IALLOCATOR_DIRECTIONS)), |
1218 | 65e183af | Michael Hanselmann | ("mode", ht.NoDefault, ht.TElemOf(constants.VALID_IALLOCATOR_MODES)),
|
1219 | 65e183af | Michael Hanselmann | ("name", ht.NoDefault, ht.TNonEmptyString),
|
1220 | 65e183af | Michael Hanselmann | ("nics", ht.NoDefault, ht.TOr(ht.TNone, ht.TListOf(
|
1221 | 65e183af | Michael Hanselmann | ht.TDictOf(ht.TElemOf(["mac", "ip", "bridge"]), |
1222 | 65e183af | Michael Hanselmann | ht.TOr(ht.TNone, ht.TNonEmptyString))))), |
1223 | 65e183af | Michael Hanselmann | ("disks", ht.NoDefault, ht.TOr(ht.TNone, ht.TList)),
|
1224 | 65e183af | Michael Hanselmann | ("hypervisor", None, ht.TMaybeString), |
1225 | 65e183af | Michael Hanselmann | ("allocator", None, ht.TMaybeString), |
1226 | 65e183af | Michael Hanselmann | ("tags", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)),
|
1227 | 65e183af | Michael Hanselmann | ("mem_size", None, ht.TOr(ht.TNone, ht.TPositiveInt)), |
1228 | 65e183af | Michael Hanselmann | ("vcpus", None, ht.TOr(ht.TNone, ht.TPositiveInt)), |
1229 | 65e183af | Michael Hanselmann | ("os", None, ht.TMaybeString), |
1230 | 65e183af | Michael Hanselmann | ("disk_template", None, ht.TMaybeString), |
1231 | 65e183af | Michael Hanselmann | ("evac_nodes", None, ht.TOr(ht.TNone, ht.TListOf(ht.TNonEmptyString))), |
1232 | d61df03e | Iustin Pop | ] |
1233 | 363acb1e | Iustin Pop | |
1234 | 76aef8fc | Michael Hanselmann | |
1235 | b469eb4d | Iustin Pop | class OpTestJqueue(OpCode): |
1236 | e58f87a9 | Michael Hanselmann | """Utility opcode to test some aspects of the job queue.
|
1237 | e58f87a9 | Michael Hanselmann |
|
1238 | e58f87a9 | Michael Hanselmann | """
|
1239 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1240 | 65e183af | Michael Hanselmann | ("notify_waitlock", False, ht.TBool), |
1241 | 65e183af | Michael Hanselmann | ("notify_exec", False, ht.TBool), |
1242 | 65e183af | Michael Hanselmann | ("log_messages", ht.EmptyList, ht.TListOf(ht.TString)),
|
1243 | 65e183af | Michael Hanselmann | ("fail", False, ht.TBool), |
1244 | e58f87a9 | Michael Hanselmann | ] |
1245 | e58f87a9 | Michael Hanselmann | |
1246 | e58f87a9 | Michael Hanselmann | |
1247 | be760ba8 | Michael Hanselmann | class OpTestDummy(OpCode): |
1248 | be760ba8 | Michael Hanselmann | """Utility opcode used by unittests.
|
1249 | be760ba8 | Michael Hanselmann |
|
1250 | be760ba8 | Michael Hanselmann | """
|
1251 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1252 | 65e183af | Michael Hanselmann | ("result", ht.NoDefault, ht.NoType),
|
1253 | 65e183af | Michael Hanselmann | ("messages", ht.NoDefault, ht.NoType),
|
1254 | 65e183af | Michael Hanselmann | ("fail", ht.NoDefault, ht.NoType),
|
1255 | be760ba8 | Michael Hanselmann | ] |
1256 | 687c10d9 | Iustin Pop | WITH_LU = False
|
1257 | be760ba8 | Michael Hanselmann | |
1258 | be760ba8 | Michael Hanselmann | |
1259 | dbc96028 | Michael Hanselmann | def _GetOpList(): |
1260 | dbc96028 | Michael Hanselmann | """Returns list of all defined opcodes.
|
1261 | dbc96028 | Michael Hanselmann |
|
1262 | dbc96028 | Michael Hanselmann | Does not eliminate duplicates by C{OP_ID}.
|
1263 | dbc96028 | Michael Hanselmann |
|
1264 | dbc96028 | Michael Hanselmann | """
|
1265 | dbc96028 | Michael Hanselmann | return [v for v in globals().values() |
1266 | dbc96028 | Michael Hanselmann | if (isinstance(v, type) and issubclass(v, OpCode) and |
1267 | 687c10d9 | Iustin Pop | hasattr(v, "OP_ID") and v is not OpCode)] |
1268 | dbc96028 | Michael Hanselmann | |
1269 | dbc96028 | Michael Hanselmann | |
1270 | dbc96028 | Michael Hanselmann | OP_MAPPING = dict((v.OP_ID, v) for v in _GetOpList()) |