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