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