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