root / lib / opcodes.py @ 1ff7bbd9
History | View | Annotate | Download (62.6 kB)
1 | 2f31098c | Iustin Pop | #
|
---|---|---|---|
2 | a8083063 | Iustin Pop | #
|
3 | a8083063 | Iustin Pop | |
4 | fa47242b | Iustin Pop | # Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 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 | b459a848 | Andrea Spadaccini | # pylint: disable=R0903
|
35 | a8083063 | Iustin Pop | |
36 | 1cbef6d8 | Michael Hanselmann | import logging |
37 | ff0d18e6 | Iustin Pop | import re |
38 | 176b0ee2 | Dimitris Aragiorgis | import ipaddr |
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 | 415feb2e | René Nussbaumer | from ganeti import objects |
44 | 65e183af | Michael Hanselmann | |
45 | 65e183af | Michael Hanselmann | |
46 | 65e183af | Michael Hanselmann | # Common opcode attributes
|
47 | 65e183af | Michael Hanselmann | |
48 | 65e183af | Michael Hanselmann | #: output fields for a query operation
|
49 | 197b323b | Michael Hanselmann | _POutputFields = ("output_fields", ht.NoDefault, ht.TListOf(ht.TNonEmptyString),
|
50 | 45d4c81c | Michael Hanselmann | "Selected output fields")
|
51 | 65e183af | Michael Hanselmann | |
52 | 65e183af | Michael Hanselmann | #: the shutdown timeout
|
53 | 45d4c81c | Michael Hanselmann | _PShutdownTimeout = \ |
54 | 45d4c81c | Michael Hanselmann | ("shutdown_timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT, ht.TPositiveInt,
|
55 | 45d4c81c | Michael Hanselmann | "How long to wait for instance to shut down")
|
56 | 65e183af | Michael Hanselmann | |
57 | 65e183af | Michael Hanselmann | #: the force parameter
|
58 | 45d4c81c | Michael Hanselmann | _PForce = ("force", False, ht.TBool, "Whether to force the operation") |
59 | 65e183af | Michael Hanselmann | |
60 | 65e183af | Michael Hanselmann | #: a required instance name (for single-instance LUs)
|
61 | 45d4c81c | Michael Hanselmann | _PInstanceName = ("instance_name", ht.NoDefault, ht.TNonEmptyString,
|
62 | 45d4c81c | Michael Hanselmann | "Instance name")
|
63 | 65e183af | Michael Hanselmann | |
64 | 65e183af | Michael Hanselmann | #: Whether to ignore offline nodes
|
65 | 45d4c81c | Michael Hanselmann | _PIgnoreOfflineNodes = ("ignore_offline_nodes", False, ht.TBool, |
66 | 45d4c81c | Michael Hanselmann | "Whether to ignore offline nodes")
|
67 | 65e183af | Michael Hanselmann | |
68 | 65e183af | Michael Hanselmann | #: a required node name (for single-node LUs)
|
69 | 45d4c81c | Michael Hanselmann | _PNodeName = ("node_name", ht.NoDefault, ht.TNonEmptyString, "Node name") |
70 | 65e183af | Michael Hanselmann | |
71 | 65e183af | Michael Hanselmann | #: a required node group name (for single-group LUs)
|
72 | 45d4c81c | Michael Hanselmann | _PGroupName = ("group_name", ht.NoDefault, ht.TNonEmptyString, "Group name") |
73 | 65e183af | Michael Hanselmann | |
74 | 65e183af | Michael Hanselmann | #: Migration type (live/non-live)
|
75 | 65e183af | Michael Hanselmann | _PMigrationMode = ("mode", None, |
76 | 197b323b | Michael Hanselmann | ht.TOr(ht.TNone, ht.TElemOf(constants.HT_MIGRATION_MODES)), |
77 | 45d4c81c | Michael Hanselmann | "Migration mode")
|
78 | 65e183af | Michael Hanselmann | |
79 | 65e183af | Michael Hanselmann | #: Obsolete 'live' migration mode (boolean)
|
80 | 45d4c81c | Michael Hanselmann | _PMigrationLive = ("live", None, ht.TMaybeBool, |
81 | 45d4c81c | Michael Hanselmann | "Legacy setting for live migration, do not use")
|
82 | 65e183af | Michael Hanselmann | |
83 | 65e183af | Michael Hanselmann | #: Tag type
|
84 | 971b3a98 | Michael Hanselmann | _PTagKind = ("kind", ht.NoDefault, ht.TElemOf(constants.VALID_TAG_TYPES),
|
85 | 971b3a98 | Michael Hanselmann | "Tag kind")
|
86 | 65e183af | Michael Hanselmann | |
87 | 65e183af | Michael Hanselmann | #: List of tag strings
|
88 | 971b3a98 | Michael Hanselmann | _PTags = ("tags", ht.NoDefault, ht.TListOf(ht.TNonEmptyString),
|
89 | 971b3a98 | Michael Hanselmann | "List of tag names")
|
90 | 65e183af | Michael Hanselmann | |
91 | 45d4c81c | Michael Hanselmann | _PForceVariant = ("force_variant", False, ht.TBool, |
92 | 45d4c81c | Michael Hanselmann | "Whether to force an unknown OS variant")
|
93 | 45d4c81c | Michael Hanselmann | |
94 | 45d4c81c | Michael Hanselmann | _PWaitForSync = ("wait_for_sync", True, ht.TBool, |
95 | 45d4c81c | Michael Hanselmann | "Whether to wait for the disk to synchronize")
|
96 | 45d4c81c | Michael Hanselmann | |
97 | b69437c5 | Iustin Pop | _PWaitForSyncFalse = ("wait_for_sync", False, ht.TBool, |
98 | b69437c5 | Iustin Pop | "Whether to wait for the disk to synchronize"
|
99 | b69437c5 | Iustin Pop | " (defaults to false)")
|
100 | b69437c5 | Iustin Pop | |
101 | 45d4c81c | Michael Hanselmann | _PIgnoreConsistency = ("ignore_consistency", False, ht.TBool, |
102 | 45d4c81c | Michael Hanselmann | "Whether to ignore disk consistency")
|
103 | 45d4c81c | Michael Hanselmann | |
104 | 45d4c81c | Michael Hanselmann | _PStorageName = ("name", ht.NoDefault, ht.TMaybeString, "Storage name") |
105 | 45d4c81c | Michael Hanselmann | |
106 | 45d4c81c | Michael Hanselmann | _PUseLocking = ("use_locking", False, ht.TBool, |
107 | 45d4c81c | Michael Hanselmann | "Whether to use synchronization")
|
108 | 45d4c81c | Michael Hanselmann | |
109 | 45d4c81c | Michael Hanselmann | _PNameCheck = ("name_check", True, ht.TBool, "Whether to check name") |
110 | 45d4c81c | Michael Hanselmann | |
111 | 45d4c81c | Michael Hanselmann | _PNodeGroupAllocPolicy = \ |
112 | 45d4c81c | Michael Hanselmann | ("alloc_policy", None, |
113 | 45d4c81c | Michael Hanselmann | ht.TOr(ht.TNone, ht.TElemOf(constants.VALID_ALLOC_POLICIES)), |
114 | 45d4c81c | Michael Hanselmann | "Instance allocation policy")
|
115 | 45d4c81c | Michael Hanselmann | |
116 | 45d4c81c | Michael Hanselmann | _PGroupNodeParams = ("ndparams", None, ht.TMaybeDict, |
117 | 45d4c81c | Michael Hanselmann | "Default node parameters for group")
|
118 | 45d4c81c | Michael Hanselmann | |
119 | abd66bf8 | Michael Hanselmann | _PQueryWhat = ("what", ht.NoDefault, ht.TElemOf(constants.QR_VIA_OP),
|
120 | 8e7078e0 | Michael Hanselmann | "Resource(s) to query for")
|
121 | 8e7078e0 | Michael Hanselmann | |
122 | e1f23243 | Michael Hanselmann | _PEarlyRelease = ("early_release", False, ht.TBool, |
123 | e1f23243 | Michael Hanselmann | "Whether to release locks as soon as possible")
|
124 | e1f23243 | Michael Hanselmann | |
125 | 45d4c81c | Michael Hanselmann | _PIpCheckDoc = "Whether to ensure instance's IP address is inactive"
|
126 | 45d4c81c | Michael Hanselmann | |
127 | 9b64e486 | Iustin Pop | #: Do not remember instance state changes
|
128 | 6aac5aef | Iustin Pop | _PNoRemember = ("no_remember", False, ht.TBool, |
129 | 6aac5aef | Iustin Pop | "Do not remember the state change")
|
130 | 9b64e486 | Iustin Pop | |
131 | f8fa4175 | Michael Hanselmann | #: Target node for instance migration/failover
|
132 | f8fa4175 | Michael Hanselmann | _PMigrationTargetNode = ("target_node", None, ht.TMaybeString, |
133 | f8fa4175 | Michael Hanselmann | "Target node for shared-storage instances")
|
134 | f8fa4175 | Michael Hanselmann | |
135 | 323f9095 | Stephen Shirley | _PStartupPaused = ("startup_paused", False, ht.TBool, |
136 | 323f9095 | Stephen Shirley | "Pause instance at startup")
|
137 | 323f9095 | Stephen Shirley | |
138 | 57106b74 | Michael Hanselmann | _PVerbose = ("verbose", False, ht.TBool, "Verbose mode") |
139 | 57106b74 | Michael Hanselmann | |
140 | 57106b74 | Michael Hanselmann | # Parameters for cluster verification
|
141 | 57106b74 | Michael Hanselmann | _PDebugSimulateErrors = ("debug_simulate_errors", False, ht.TBool, |
142 | 57106b74 | Michael Hanselmann | "Whether to simulate errors (useful for debugging)")
|
143 | 57106b74 | Michael Hanselmann | _PErrorCodes = ("error_codes", False, ht.TBool, "Error codes") |
144 | 57106b74 | Michael Hanselmann | _PSkipChecks = ("skip_checks", ht.EmptyList,
|
145 | 57106b74 | Michael Hanselmann | ht.TListOf(ht.TElemOf(constants.VERIFY_OPTIONAL_CHECKS)), |
146 | 57106b74 | Michael Hanselmann | "Which checks to skip")
|
147 | 93f2399e | Andrea Spadaccini | _PIgnoreErrors = ("ignore_errors", ht.EmptyList,
|
148 | 93f2399e | Andrea Spadaccini | ht.TListOf(ht.TElemOf(constants.CV_ALL_ECODES_STRINGS)), |
149 | 93f2399e | Andrea Spadaccini | "List of error codes that should be treated as warnings")
|
150 | 323f9095 | Stephen Shirley | |
151 | bc5d0215 | Andrea Spadaccini | # Disk parameters
|
152 | bc5d0215 | Andrea Spadaccini | _PDiskParams = ("diskparams", None, |
153 | bc5d0215 | Andrea Spadaccini | ht.TOr( |
154 | bc5d0215 | Andrea Spadaccini | ht.TDictOf(ht.TElemOf(constants.DISK_TEMPLATES), ht.TDict), |
155 | bc5d0215 | Andrea Spadaccini | ht.TNone), |
156 | bc5d0215 | Andrea Spadaccini | "Disk templates' parameter defaults")
|
157 | bc5d0215 | Andrea Spadaccini | |
158 | 0ec2ce46 | René Nussbaumer | # Parameters for node resource model
|
159 | 0ec2ce46 | René Nussbaumer | _PHvState = ("hv_state", None, ht.TMaybeDict, "Set hypervisor states") |
160 | 0ec2ce46 | René Nussbaumer | _PDiskState = ("disk_state", None, ht.TMaybeDict, "Set disk states") |
161 | 0ec2ce46 | René Nussbaumer | |
162 | b6aaf437 | René Nussbaumer | |
163 | b6aaf437 | René Nussbaumer | _PIgnoreIpolicy = ("ignore_ipolicy", False, ht.TBool, |
164 | b6aaf437 | René Nussbaumer | "Whether to ignore ipolicy violations")
|
165 | b6aaf437 | René Nussbaumer | |
166 | 8c0b16f6 | Guido Trotter | # Allow runtime changes while migrating
|
167 | 8c0b16f6 | Guido Trotter | _PAllowRuntimeChgs = ("allow_runtime_changes", True, ht.TBool, |
168 | 8c0b16f6 | Guido Trotter | "Allow runtime changes (eg. memory ballooning)")
|
169 | 8c0b16f6 | Guido Trotter | |
170 | 176b0ee2 | Dimitris Aragiorgis | #: a required network name
|
171 | 176b0ee2 | Dimitris Aragiorgis | _PNetworkName = ("network_name", ht.NoDefault, ht.TNonEmptyString,
|
172 | 176b0ee2 | Dimitris Aragiorgis | "Set network name")
|
173 | 8c0b16f6 | Guido Trotter | |
174 | ff0d18e6 | Iustin Pop | #: OP_ID conversion regular expression
|
175 | ff0d18e6 | Iustin Pop | _OPID_RE = re.compile("([a-z])([A-Z])")
|
176 | ff0d18e6 | Iustin Pop | |
177 | 8c9ee749 | Michael Hanselmann | #: Utility function for L{OpClusterSetParams}
|
178 | 8f227489 | Michael Hanselmann | _TestClusterOsListItem = \ |
179 | 8f227489 | Michael Hanselmann | ht.TAnd(ht.TIsLength(2), ht.TItems([
|
180 | 8f227489 | Michael Hanselmann | ht.TElemOf(constants.DDMS_VALUES), |
181 | 8f227489 | Michael Hanselmann | ht.TNonEmptyString, |
182 | 8f227489 | Michael Hanselmann | ])) |
183 | 8c9ee749 | Michael Hanselmann | |
184 | ff8067cf | Michael Hanselmann | _TestClusterOsList = ht.TMaybeListOf(_TestClusterOsListItem) |
185 | ff0d18e6 | Iustin Pop | |
186 | 526a662a | Michael Hanselmann | # TODO: Generate check from constants.INIC_PARAMS_TYPES
|
187 | 526a662a | Michael Hanselmann | #: Utility function for testing NIC definitions
|
188 | 20a32e74 | Michael Hanselmann | _TestNicDef = \ |
189 | 20a32e74 | Michael Hanselmann | ht.Comment("NIC parameters")(ht.TDictOf(ht.TElemOf(constants.INIC_PARAMS),
|
190 | 20a32e74 | Michael Hanselmann | ht.TOr(ht.TNone, ht.TNonEmptyString))) |
191 | 526a662a | Michael Hanselmann | |
192 | 1456df62 | Michael Hanselmann | _TSetParamsResultItemItems = [ |
193 | 1456df62 | Michael Hanselmann | ht.Comment("name of changed parameter")(ht.TNonEmptyString),
|
194 | b3d2ee31 | Michael Hanselmann | ht.Comment("new value")(ht.TAny),
|
195 | 1456df62 | Michael Hanselmann | ] |
196 | 1456df62 | Michael Hanselmann | |
197 | 1456df62 | Michael Hanselmann | _TSetParamsResult = \ |
198 | 1456df62 | Michael Hanselmann | ht.TListOf(ht.TAnd(ht.TIsLength(len(_TSetParamsResultItemItems)),
|
199 | 1456df62 | Michael Hanselmann | ht.TItems(_TSetParamsResultItemItems))) |
200 | 1456df62 | Michael Hanselmann | |
201 | 735e1318 | Michael Hanselmann | # TODO: Generate check from constants.IDISK_PARAMS_TYPES (however, not all users
|
202 | 735e1318 | Michael Hanselmann | # of this check support all parameters)
|
203 | 20a32e74 | Michael Hanselmann | _TDiskParams = \ |
204 | 20a32e74 | Michael Hanselmann | ht.Comment("Disk parameters")(ht.TDictOf(ht.TElemOf(constants.IDISK_PARAMS),
|
205 | 20a32e74 | Michael Hanselmann | ht.TOr(ht.TNonEmptyString, ht.TInt))) |
206 | 735e1318 | Michael Hanselmann | |
207 | aa12a891 | René Nussbaumer | _TQueryRow = \ |
208 | aa12a891 | René Nussbaumer | ht.TListOf(ht.TAnd(ht.TIsLength(2),
|
209 | aa12a891 | René Nussbaumer | ht.TItems([ht.TElemOf(constants.RS_ALL), |
210 | aa12a891 | René Nussbaumer | ht.TAny]))) |
211 | aa12a891 | René Nussbaumer | |
212 | 415feb2e | René Nussbaumer | _TQueryResult = ht.TListOf(_TQueryRow) |
213 | 415feb2e | René Nussbaumer | |
214 | 415feb2e | René Nussbaumer | _TOldQueryRow = ht.TListOf(ht.TAny) |
215 | 415feb2e | René Nussbaumer | |
216 | 415feb2e | René Nussbaumer | _TOldQueryResult = ht.TListOf(_TOldQueryRow) |
217 | 415feb2e | René Nussbaumer | |
218 | 415feb2e | René Nussbaumer | |
219 | 3ce9a5e7 | Michael Hanselmann | _SUMMARY_PREFIX = { |
220 | 3ce9a5e7 | Michael Hanselmann | "CLUSTER_": "C_", |
221 | 3ce9a5e7 | Michael Hanselmann | "GROUP_": "G_", |
222 | 3ce9a5e7 | Michael Hanselmann | "NODE_": "N_", |
223 | 3ce9a5e7 | Michael Hanselmann | "INSTANCE_": "I_", |
224 | 3ce9a5e7 | Michael Hanselmann | } |
225 | 3ce9a5e7 | Michael Hanselmann | |
226 | b95479a5 | Michael Hanselmann | #: Attribute name for dependencies
|
227 | b95479a5 | Michael Hanselmann | DEPEND_ATTR = "depends"
|
228 | b95479a5 | Michael Hanselmann | |
229 | 018ae30b | Michael Hanselmann | #: Attribute name for comment
|
230 | 018ae30b | Michael Hanselmann | COMMENT_ATTR = "comment"
|
231 | 018ae30b | Michael Hanselmann | |
232 | 526a662a | Michael Hanselmann | |
233 | ff0d18e6 | Iustin Pop | def _NameToId(name): |
234 | ff0d18e6 | Iustin Pop | """Convert an opcode class name to an OP_ID.
|
235 | ff0d18e6 | Iustin Pop |
|
236 | ff0d18e6 | Iustin Pop | @type name: string
|
237 | ff0d18e6 | Iustin Pop | @param name: the class name, as OpXxxYyy
|
238 | ff0d18e6 | Iustin Pop | @rtype: string
|
239 | ff0d18e6 | Iustin Pop | @return: the name in the OP_XXXX_YYYY format
|
240 | ff0d18e6 | Iustin Pop |
|
241 | ff0d18e6 | Iustin Pop | """
|
242 | ff0d18e6 | Iustin Pop | if not name.startswith("Op"): |
243 | ff0d18e6 | Iustin Pop | return None |
244 | ff0d18e6 | Iustin Pop | # Note: (?<=[a-z])(?=[A-Z]) would be ideal, since it wouldn't
|
245 | ff0d18e6 | Iustin Pop | # consume any input, and hence we would just have all the elements
|
246 | ff0d18e6 | Iustin Pop | # in the list, one by one; but it seems that split doesn't work on
|
247 | ff0d18e6 | Iustin Pop | # non-consuming input, hence we have to process the input string a
|
248 | ff0d18e6 | Iustin Pop | # bit
|
249 | ff0d18e6 | Iustin Pop | name = _OPID_RE.sub(r"\1,\2", name)
|
250 | ff0d18e6 | Iustin Pop | elems = name.split(",")
|
251 | ff0d18e6 | Iustin Pop | return "_".join(n.upper() for n in elems) |
252 | ff0d18e6 | Iustin Pop | |
253 | 65e183af | Michael Hanselmann | |
254 | 415feb2e | René Nussbaumer | def _GenerateObjectTypeCheck(obj, fields_types): |
255 | 415feb2e | René Nussbaumer | """Helper to generate type checks for objects.
|
256 | 415feb2e | René Nussbaumer |
|
257 | 415feb2e | René Nussbaumer | @param obj: The object to generate type checks
|
258 | 415feb2e | René Nussbaumer | @param fields_types: The fields and their types as a dict
|
259 | 415feb2e | René Nussbaumer | @return: A ht type check function
|
260 | 415feb2e | René Nussbaumer |
|
261 | 415feb2e | René Nussbaumer | """
|
262 | 415feb2e | René Nussbaumer | assert set(obj.GetAllSlots()) == set(fields_types.keys()), \ |
263 | 415feb2e | René Nussbaumer | "%s != %s" % (set(obj.GetAllSlots()), set(fields_types.keys())) |
264 | 415feb2e | René Nussbaumer | return ht.TStrictDict(True, True, fields_types) |
265 | 415feb2e | René Nussbaumer | |
266 | 415feb2e | René Nussbaumer | |
267 | b02c6bdf | Michael Hanselmann | _TQueryFieldDef = \ |
268 | b02c6bdf | Michael Hanselmann | _GenerateObjectTypeCheck(objects.QueryFieldDefinition, { |
269 | b02c6bdf | Michael Hanselmann | "name": ht.TNonEmptyString,
|
270 | b02c6bdf | Michael Hanselmann | "title": ht.TNonEmptyString,
|
271 | b02c6bdf | Michael Hanselmann | "kind": ht.TElemOf(constants.QFT_ALL),
|
272 | b02c6bdf | Michael Hanselmann | "doc": ht.TNonEmptyString,
|
273 | b02c6bdf | Michael Hanselmann | }) |
274 | 415feb2e | René Nussbaumer | |
275 | 415feb2e | René Nussbaumer | |
276 | 65e183af | Michael Hanselmann | def RequireFileStorage(): |
277 | 65e183af | Michael Hanselmann | """Checks that file storage is enabled.
|
278 | 65e183af | Michael Hanselmann |
|
279 | 65e183af | Michael Hanselmann | While it doesn't really fit into this module, L{utils} was deemed too large
|
280 | 65e183af | Michael Hanselmann | of a dependency to be imported for just one or two functions.
|
281 | 65e183af | Michael Hanselmann |
|
282 | 65e183af | Michael Hanselmann | @raise errors.OpPrereqError: when file storage is disabled
|
283 | 65e183af | Michael Hanselmann |
|
284 | 65e183af | Michael Hanselmann | """
|
285 | 65e183af | Michael Hanselmann | if not constants.ENABLE_FILE_STORAGE: |
286 | 65e183af | Michael Hanselmann | raise errors.OpPrereqError("File storage disabled at configure time", |
287 | 65e183af | Michael Hanselmann | errors.ECODE_INVAL) |
288 | 65e183af | Michael Hanselmann | |
289 | 65e183af | Michael Hanselmann | |
290 | 4b97f902 | Apollon Oikonomopoulos | def RequireSharedFileStorage(): |
291 | 4b97f902 | Apollon Oikonomopoulos | """Checks that shared file storage is enabled.
|
292 | 4b97f902 | Apollon Oikonomopoulos |
|
293 | 4b97f902 | Apollon Oikonomopoulos | While it doesn't really fit into this module, L{utils} was deemed too large
|
294 | 4b97f902 | Apollon Oikonomopoulos | of a dependency to be imported for just one or two functions.
|
295 | 4b97f902 | Apollon Oikonomopoulos |
|
296 | 4b97f902 | Apollon Oikonomopoulos | @raise errors.OpPrereqError: when shared file storage is disabled
|
297 | 4b97f902 | Apollon Oikonomopoulos |
|
298 | 4b97f902 | Apollon Oikonomopoulos | """
|
299 | 4b97f902 | Apollon Oikonomopoulos | if not constants.ENABLE_SHARED_FILE_STORAGE: |
300 | 4b97f902 | Apollon Oikonomopoulos | raise errors.OpPrereqError("Shared file storage disabled at" |
301 | 4b97f902 | Apollon Oikonomopoulos | " configure time", errors.ECODE_INVAL)
|
302 | 4b97f902 | Apollon Oikonomopoulos | |
303 | 4b97f902 | Apollon Oikonomopoulos | |
304 | 8c9ee749 | Michael Hanselmann | @ht.WithDesc("CheckFileStorage") |
305 | 8c9ee749 | Michael Hanselmann | def _CheckFileStorage(value): |
306 | 8c9ee749 | Michael Hanselmann | """Ensures file storage is enabled if used.
|
307 | 65e183af | Michael Hanselmann |
|
308 | 65e183af | Michael Hanselmann | """
|
309 | 8c9ee749 | Michael Hanselmann | if value == constants.DT_FILE:
|
310 | 65e183af | Michael Hanselmann | RequireFileStorage() |
311 | 4b97f902 | Apollon Oikonomopoulos | elif value == constants.DT_SHARED_FILE:
|
312 | 4b97f902 | Apollon Oikonomopoulos | RequireSharedFileStorage() |
313 | 65e183af | Michael Hanselmann | return True |
314 | 65e183af | Michael Hanselmann | |
315 | 65e183af | Michael Hanselmann | |
316 | 45fe090b | Michael Hanselmann | def _BuildDiskTemplateCheck(accept_none): |
317 | 45fe090b | Michael Hanselmann | """Builds check for disk template.
|
318 | 45fe090b | Michael Hanselmann |
|
319 | 45fe090b | Michael Hanselmann | @type accept_none: bool
|
320 | 45fe090b | Michael Hanselmann | @param accept_none: whether to accept None as a correct value
|
321 | 45fe090b | Michael Hanselmann | @rtype: callable
|
322 | 45fe090b | Michael Hanselmann |
|
323 | 45fe090b | Michael Hanselmann | """
|
324 | 45fe090b | Michael Hanselmann | template_check = ht.TElemOf(constants.DISK_TEMPLATES) |
325 | 45fe090b | Michael Hanselmann | |
326 | 45fe090b | Michael Hanselmann | if accept_none:
|
327 | 45fe090b | Michael Hanselmann | template_check = ht.TOr(template_check, ht.TNone) |
328 | 45fe090b | Michael Hanselmann | |
329 | 45fe090b | Michael Hanselmann | return ht.TAnd(template_check, _CheckFileStorage)
|
330 | 8c9ee749 | Michael Hanselmann | |
331 | 8c9ee749 | Michael Hanselmann | |
332 | 65e183af | Michael Hanselmann | def _CheckStorageType(storage_type): |
333 | 65e183af | Michael Hanselmann | """Ensure a given storage type is valid.
|
334 | 65e183af | Michael Hanselmann |
|
335 | 65e183af | Michael Hanselmann | """
|
336 | 65e183af | Michael Hanselmann | if storage_type not in constants.VALID_STORAGE_TYPES: |
337 | 65e183af | Michael Hanselmann | raise errors.OpPrereqError("Unknown storage type: %s" % storage_type, |
338 | 65e183af | Michael Hanselmann | errors.ECODE_INVAL) |
339 | 65e183af | Michael Hanselmann | if storage_type == constants.ST_FILE:
|
340 | 65e183af | Michael Hanselmann | RequireFileStorage() |
341 | 65e183af | Michael Hanselmann | return True |
342 | 65e183af | Michael Hanselmann | |
343 | 65e183af | Michael Hanselmann | |
344 | 65e183af | Michael Hanselmann | #: Storage type parameter
|
345 | 45d4c81c | Michael Hanselmann | _PStorageType = ("storage_type", ht.NoDefault, _CheckStorageType,
|
346 | 45d4c81c | Michael Hanselmann | "Storage type")
|
347 | 65e183af | Michael Hanselmann | |
348 | 176b0ee2 | Dimitris Aragiorgis | _CheckNetworkType = ht.TElemOf(constants.NETWORK_VALID_TYPES) |
349 | 176b0ee2 | Dimitris Aragiorgis | |
350 | 176b0ee2 | Dimitris Aragiorgis | #: Network type parameter
|
351 | 176b0ee2 | Dimitris Aragiorgis | _PNetworkType = ("network_type", None, ht.TOr(ht.TNone, _CheckNetworkType), |
352 | 176b0ee2 | Dimitris Aragiorgis | "Network type")
|
353 | 176b0ee2 | Dimitris Aragiorgis | |
354 | 176b0ee2 | Dimitris Aragiorgis | def _CheckCIDRNetNotation(value): |
355 | 176b0ee2 | Dimitris Aragiorgis | """Ensure a given cidr notation type is valid.
|
356 | 176b0ee2 | Dimitris Aragiorgis |
|
357 | 176b0ee2 | Dimitris Aragiorgis | """
|
358 | 176b0ee2 | Dimitris Aragiorgis | try:
|
359 | 176b0ee2 | Dimitris Aragiorgis | ipaddr.IPv4Network(value) |
360 | 176b0ee2 | Dimitris Aragiorgis | except ipaddr.AddressValueError:
|
361 | 176b0ee2 | Dimitris Aragiorgis | return False |
362 | 176b0ee2 | Dimitris Aragiorgis | return True |
363 | 176b0ee2 | Dimitris Aragiorgis | |
364 | 176b0ee2 | Dimitris Aragiorgis | def _CheckCIDRAddrNotation(value): |
365 | 176b0ee2 | Dimitris Aragiorgis | """Ensure a given cidr notation type is valid.
|
366 | 176b0ee2 | Dimitris Aragiorgis |
|
367 | 176b0ee2 | Dimitris Aragiorgis | """
|
368 | 176b0ee2 | Dimitris Aragiorgis | try:
|
369 | 176b0ee2 | Dimitris Aragiorgis | ipaddr.IPv4Address(value) |
370 | 176b0ee2 | Dimitris Aragiorgis | except ipaddr.AddressValueError:
|
371 | 176b0ee2 | Dimitris Aragiorgis | return False |
372 | 176b0ee2 | Dimitris Aragiorgis | return True |
373 | 176b0ee2 | Dimitris Aragiorgis | |
374 | 176b0ee2 | Dimitris Aragiorgis | def _CheckCIDR6AddrNotation(value): |
375 | 176b0ee2 | Dimitris Aragiorgis | """Ensure a given cidr notation type is valid.
|
376 | 176b0ee2 | Dimitris Aragiorgis |
|
377 | 176b0ee2 | Dimitris Aragiorgis | """
|
378 | 176b0ee2 | Dimitris Aragiorgis | try:
|
379 | 176b0ee2 | Dimitris Aragiorgis | ipaddr.IPv6Address(value) |
380 | 176b0ee2 | Dimitris Aragiorgis | except ipaddr.AddressValueError:
|
381 | 176b0ee2 | Dimitris Aragiorgis | return False |
382 | 176b0ee2 | Dimitris Aragiorgis | return True |
383 | 176b0ee2 | Dimitris Aragiorgis | |
384 | 176b0ee2 | Dimitris Aragiorgis | def _CheckCIDR6NetNotation(value): |
385 | 176b0ee2 | Dimitris Aragiorgis | """Ensure a given cidr notation type is valid.
|
386 | 176b0ee2 | Dimitris Aragiorgis |
|
387 | 176b0ee2 | Dimitris Aragiorgis | """
|
388 | 176b0ee2 | Dimitris Aragiorgis | try:
|
389 | 176b0ee2 | Dimitris Aragiorgis | ipaddr.IPv6Network(value) |
390 | 176b0ee2 | Dimitris Aragiorgis | except ipaddr.AddressValueError:
|
391 | 176b0ee2 | Dimitris Aragiorgis | return False |
392 | 176b0ee2 | Dimitris Aragiorgis | return True |
393 | 65e183af | Michael Hanselmann | |
394 | 65e183af | Michael Hanselmann | class _AutoOpParamSlots(type): |
395 | 65e183af | Michael Hanselmann | """Meta class for opcode definitions.
|
396 | 65e183af | Michael Hanselmann |
|
397 | 65e183af | Michael Hanselmann | """
|
398 | 65e183af | Michael Hanselmann | def __new__(mcs, name, bases, attrs): |
399 | 65e183af | Michael Hanselmann | """Called when a class should be created.
|
400 | 65e183af | Michael Hanselmann |
|
401 | 65e183af | Michael Hanselmann | @param mcs: The meta class
|
402 | 65e183af | Michael Hanselmann | @param name: Name of created class
|
403 | 65e183af | Michael Hanselmann | @param bases: Base classes
|
404 | 65e183af | Michael Hanselmann | @type attrs: dict
|
405 | 65e183af | Michael Hanselmann | @param attrs: Class attributes
|
406 | 65e183af | Michael Hanselmann |
|
407 | 65e183af | Michael Hanselmann | """
|
408 | 65e183af | Michael Hanselmann | assert "__slots__" not in attrs, \ |
409 | 65e183af | Michael Hanselmann | "Class '%s' defines __slots__ when it should use OP_PARAMS" % name
|
410 | e89a9021 | Iustin Pop | assert "OP_ID" not in attrs, "Class '%s' defining OP_ID" % name |
411 | ff0d18e6 | Iustin Pop | |
412 | e89a9021 | Iustin Pop | attrs["OP_ID"] = _NameToId(name)
|
413 | 65e183af | Michael Hanselmann | |
414 | 65e183af | Michael Hanselmann | # Always set OP_PARAMS to avoid duplicates in BaseOpCode.GetAllParams
|
415 | 65e183af | Michael Hanselmann | params = attrs.setdefault("OP_PARAMS", [])
|
416 | 65e183af | Michael Hanselmann | |
417 | 65e183af | Michael Hanselmann | # Use parameter names as slots
|
418 | 197b323b | Michael Hanselmann | slots = [pname for (pname, _, _, _) in params] |
419 | 65e183af | Michael Hanselmann | |
420 | 65e183af | Michael Hanselmann | assert "OP_DSC_FIELD" not in attrs or attrs["OP_DSC_FIELD"] in slots, \ |
421 | 65e183af | Michael Hanselmann | "Class '%s' uses unknown field in OP_DSC_FIELD" % name
|
422 | 65e183af | Michael Hanselmann | |
423 | 65e183af | Michael Hanselmann | attrs["__slots__"] = slots
|
424 | 65e183af | Michael Hanselmann | |
425 | 65e183af | Michael Hanselmann | return type.__new__(mcs, name, bases, attrs) |
426 | 65e183af | Michael Hanselmann | |
427 | df458e0b | Iustin Pop | |
428 | 0e46916d | Iustin Pop | class BaseOpCode(object): |
429 | df458e0b | Iustin Pop | """A simple serializable object.
|
430 | df458e0b | Iustin Pop |
|
431 | 0e46916d | Iustin Pop | This object serves as a parent class for OpCode without any custom
|
432 | 0e46916d | Iustin Pop | field handling.
|
433 | 0e46916d | Iustin Pop |
|
434 | df458e0b | Iustin Pop | """
|
435 | b459a848 | Andrea Spadaccini | # pylint: disable=E1101
|
436 | e89a9021 | Iustin Pop | # as OP_ID is dynamically defined
|
437 | 65e183af | Michael Hanselmann | __metaclass__ = _AutoOpParamSlots |
438 | 65e183af | Michael Hanselmann | |
439 | a8083063 | Iustin Pop | def __init__(self, **kwargs): |
440 | a7399f66 | Iustin Pop | """Constructor for BaseOpCode.
|
441 | a7399f66 | Iustin Pop |
|
442 | a7399f66 | Iustin Pop | The constructor takes only keyword arguments and will set
|
443 | a7399f66 | Iustin Pop | attributes on this object based on the passed arguments. As such,
|
444 | a7399f66 | Iustin Pop | it means that you should not pass arguments which are not in the
|
445 | a7399f66 | Iustin Pop | __slots__ attribute for this class.
|
446 | a7399f66 | Iustin Pop |
|
447 | a7399f66 | Iustin Pop | """
|
448 | adf385c7 | Iustin Pop | slots = self._all_slots()
|
449 | a8083063 | Iustin Pop | for key in kwargs: |
450 | adf385c7 | Iustin Pop | if key not in slots: |
451 | df458e0b | Iustin Pop | raise TypeError("Object %s doesn't support the parameter '%s'" % |
452 | 3ecf6786 | Iustin Pop | (self.__class__.__name__, key))
|
453 | a8083063 | Iustin Pop | setattr(self, key, kwargs[key]) |
454 | a8083063 | Iustin Pop | |
455 | df458e0b | Iustin Pop | def __getstate__(self): |
456 | a7399f66 | Iustin Pop | """Generic serializer.
|
457 | a7399f66 | Iustin Pop |
|
458 | a7399f66 | Iustin Pop | This method just returns the contents of the instance as a
|
459 | a7399f66 | Iustin Pop | dictionary.
|
460 | a7399f66 | Iustin Pop |
|
461 | a7399f66 | Iustin Pop | @rtype: C{dict}
|
462 | a7399f66 | Iustin Pop | @return: the instance attributes and their values
|
463 | a7399f66 | Iustin Pop |
|
464 | a7399f66 | Iustin Pop | """
|
465 | df458e0b | Iustin Pop | state = {} |
466 | adf385c7 | Iustin Pop | for name in self._all_slots(): |
467 | df458e0b | Iustin Pop | if hasattr(self, name): |
468 | df458e0b | Iustin Pop | state[name] = getattr(self, name) |
469 | df458e0b | Iustin Pop | return state
|
470 | df458e0b | Iustin Pop | |
471 | df458e0b | Iustin Pop | def __setstate__(self, state): |
472 | a7399f66 | Iustin Pop | """Generic unserializer.
|
473 | a7399f66 | Iustin Pop |
|
474 | a7399f66 | Iustin Pop | This method just restores from the serialized state the attributes
|
475 | a7399f66 | Iustin Pop | of the current instance.
|
476 | a7399f66 | Iustin Pop |
|
477 | a7399f66 | Iustin Pop | @param state: the serialized opcode data
|
478 | a7399f66 | Iustin Pop | @type state: C{dict}
|
479 | a7399f66 | Iustin Pop |
|
480 | a7399f66 | Iustin Pop | """
|
481 | df458e0b | Iustin Pop | if not isinstance(state, dict): |
482 | df458e0b | Iustin Pop | raise ValueError("Invalid data to __setstate__: expected dict, got %s" % |
483 | df458e0b | Iustin Pop | type(state))
|
484 | df458e0b | Iustin Pop | |
485 | adf385c7 | Iustin Pop | for name in self._all_slots(): |
486 | 44db3a6f | Iustin Pop | if name not in state and hasattr(self, name): |
487 | df458e0b | Iustin Pop | delattr(self, name) |
488 | df458e0b | Iustin Pop | |
489 | df458e0b | Iustin Pop | for name in state: |
490 | df458e0b | Iustin Pop | setattr(self, name, state[name]) |
491 | df458e0b | Iustin Pop | |
492 | adf385c7 | Iustin Pop | @classmethod
|
493 | adf385c7 | Iustin Pop | def _all_slots(cls): |
494 | adf385c7 | Iustin Pop | """Compute the list of all declared slots for a class.
|
495 | adf385c7 | Iustin Pop |
|
496 | adf385c7 | Iustin Pop | """
|
497 | adf385c7 | Iustin Pop | slots = [] |
498 | adf385c7 | Iustin Pop | for parent in cls.__mro__: |
499 | adf385c7 | Iustin Pop | slots.extend(getattr(parent, "__slots__", [])) |
500 | adf385c7 | Iustin Pop | return slots
|
501 | adf385c7 | Iustin Pop | |
502 | 65e183af | Michael Hanselmann | @classmethod
|
503 | 65e183af | Michael Hanselmann | def GetAllParams(cls): |
504 | 65e183af | Michael Hanselmann | """Compute list of all parameters for an opcode.
|
505 | 65e183af | Michael Hanselmann |
|
506 | 65e183af | Michael Hanselmann | """
|
507 | 65e183af | Michael Hanselmann | slots = [] |
508 | 65e183af | Michael Hanselmann | for parent in cls.__mro__: |
509 | 65e183af | Michael Hanselmann | slots.extend(getattr(parent, "OP_PARAMS", [])) |
510 | 65e183af | Michael Hanselmann | return slots
|
511 | 65e183af | Michael Hanselmann | |
512 | 1cbef6d8 | Michael Hanselmann | def Validate(self, set_defaults): |
513 | 1cbef6d8 | Michael Hanselmann | """Validate opcode parameters, optionally setting default values.
|
514 | 1cbef6d8 | Michael Hanselmann |
|
515 | 1cbef6d8 | Michael Hanselmann | @type set_defaults: bool
|
516 | 1cbef6d8 | Michael Hanselmann | @param set_defaults: Whether to set default values
|
517 | 1cbef6d8 | Michael Hanselmann | @raise errors.OpPrereqError: When a parameter value doesn't match
|
518 | 1cbef6d8 | Michael Hanselmann | requirements
|
519 | 1cbef6d8 | Michael Hanselmann |
|
520 | 1cbef6d8 | Michael Hanselmann | """
|
521 | 197b323b | Michael Hanselmann | for (attr_name, default, test, _) in self.GetAllParams(): |
522 | 1cbef6d8 | Michael Hanselmann | assert test == ht.NoType or callable(test) |
523 | 1cbef6d8 | Michael Hanselmann | |
524 | 1cbef6d8 | Michael Hanselmann | if not hasattr(self, attr_name): |
525 | 1cbef6d8 | Michael Hanselmann | if default == ht.NoDefault:
|
526 | 1cbef6d8 | Michael Hanselmann | raise errors.OpPrereqError("Required parameter '%s.%s' missing" % |
527 | 1cbef6d8 | Michael Hanselmann | (self.OP_ID, attr_name),
|
528 | 1cbef6d8 | Michael Hanselmann | errors.ECODE_INVAL) |
529 | 1cbef6d8 | Michael Hanselmann | elif set_defaults:
|
530 | 1cbef6d8 | Michael Hanselmann | if callable(default): |
531 | 1cbef6d8 | Michael Hanselmann | dval = default() |
532 | 1cbef6d8 | Michael Hanselmann | else:
|
533 | 1cbef6d8 | Michael Hanselmann | dval = default |
534 | 1cbef6d8 | Michael Hanselmann | setattr(self, attr_name, dval) |
535 | 1cbef6d8 | Michael Hanselmann | |
536 | 1cbef6d8 | Michael Hanselmann | if test == ht.NoType:
|
537 | 1cbef6d8 | Michael Hanselmann | # no tests here
|
538 | 1cbef6d8 | Michael Hanselmann | continue
|
539 | 1cbef6d8 | Michael Hanselmann | |
540 | 1cbef6d8 | Michael Hanselmann | if set_defaults or hasattr(self, attr_name): |
541 | 1cbef6d8 | Michael Hanselmann | attr_val = getattr(self, attr_name) |
542 | 1cbef6d8 | Michael Hanselmann | if not test(attr_val): |
543 | 1cbef6d8 | Michael Hanselmann | logging.error("OpCode %s, parameter %s, has invalid type %s/value %s",
|
544 | 1cbef6d8 | Michael Hanselmann | self.OP_ID, attr_name, type(attr_val), attr_val) |
545 | 1cbef6d8 | Michael Hanselmann | raise errors.OpPrereqError("Parameter '%s.%s' fails validation" % |
546 | 1cbef6d8 | Michael Hanselmann | (self.OP_ID, attr_name),
|
547 | 1cbef6d8 | Michael Hanselmann | errors.ECODE_INVAL) |
548 | 1cbef6d8 | Michael Hanselmann | |
549 | df458e0b | Iustin Pop | |
550 | b247c6fc | Michael Hanselmann | def _BuildJobDepCheck(relative): |
551 | b247c6fc | Michael Hanselmann | """Builds check for job dependencies (L{DEPEND_ATTR}).
|
552 | b247c6fc | Michael Hanselmann |
|
553 | b247c6fc | Michael Hanselmann | @type relative: bool
|
554 | b247c6fc | Michael Hanselmann | @param relative: Whether to accept relative job IDs (negative)
|
555 | b247c6fc | Michael Hanselmann | @rtype: callable
|
556 | b247c6fc | Michael Hanselmann |
|
557 | b247c6fc | Michael Hanselmann | """
|
558 | b247c6fc | Michael Hanselmann | if relative:
|
559 | b247c6fc | Michael Hanselmann | job_id = ht.TOr(ht.TJobId, ht.TRelativeJobId) |
560 | b247c6fc | Michael Hanselmann | else:
|
561 | b247c6fc | Michael Hanselmann | job_id = ht.TJobId |
562 | b247c6fc | Michael Hanselmann | |
563 | b247c6fc | Michael Hanselmann | job_dep = \ |
564 | b247c6fc | Michael Hanselmann | ht.TAnd(ht.TIsLength(2),
|
565 | b247c6fc | Michael Hanselmann | ht.TItems([job_id, |
566 | b247c6fc | Michael Hanselmann | ht.TListOf(ht.TElemOf(constants.JOBS_FINALIZED))])) |
567 | b247c6fc | Michael Hanselmann | |
568 | ff8067cf | Michael Hanselmann | return ht.TMaybeListOf(job_dep)
|
569 | b247c6fc | Michael Hanselmann | |
570 | b247c6fc | Michael Hanselmann | |
571 | b247c6fc | Michael Hanselmann | TNoRelativeJobDependencies = _BuildJobDepCheck(False)
|
572 | b247c6fc | Michael Hanselmann | |
573 | 1ce03fb1 | Michael Hanselmann | #: List of submission status and job ID as returned by C{SubmitManyJobs}
|
574 | 1456df62 | Michael Hanselmann | _TJobIdListItem = \ |
575 | 1456df62 | Michael Hanselmann | ht.TAnd(ht.TIsLength(2),
|
576 | 1456df62 | Michael Hanselmann | ht.TItems([ht.Comment("success")(ht.TBool),
|
577 | 1456df62 | Michael Hanselmann | ht.Comment("Job ID if successful, error message"
|
578 | 1456df62 | Michael Hanselmann | " otherwise")(ht.TOr(ht.TString,
|
579 | 1456df62 | Michael Hanselmann | ht.TJobId))])) |
580 | 1456df62 | Michael Hanselmann | TJobIdList = ht.TListOf(_TJobIdListItem) |
581 | 1ce03fb1 | Michael Hanselmann | |
582 | f7686867 | Michael Hanselmann | #: Result containing only list of submitted jobs
|
583 | f7686867 | Michael Hanselmann | TJobIdListOnly = ht.TStrictDict(True, True, { |
584 | 1456df62 | Michael Hanselmann | constants.JOB_IDS_KEY: ht.Comment("List of submitted jobs")(TJobIdList),
|
585 | f7686867 | Michael Hanselmann | }) |
586 | f7686867 | Michael Hanselmann | |
587 | b247c6fc | Michael Hanselmann | |
588 | 0e46916d | Iustin Pop | class OpCode(BaseOpCode): |
589 | a7399f66 | Iustin Pop | """Abstract OpCode.
|
590 | a7399f66 | Iustin Pop |
|
591 | a7399f66 | Iustin Pop | This is the root of the actual OpCode hierarchy. All clases derived
|
592 | a7399f66 | Iustin Pop | from this class should override OP_ID.
|
593 | a7399f66 | Iustin Pop |
|
594 | a7399f66 | Iustin Pop | @cvar OP_ID: The ID of this opcode. This should be unique amongst all
|
595 | 20777413 | Iustin Pop | children of this class.
|
596 | bde8f481 | Adeodato Simo | @cvar OP_DSC_FIELD: The name of a field whose value will be included in the
|
597 | bde8f481 | Adeodato Simo | string returned by Summary(); see the docstring of that
|
598 | bde8f481 | Adeodato Simo | method for details).
|
599 | 65e183af | Michael Hanselmann | @cvar OP_PARAMS: List of opcode attributes, the default values they should
|
600 | 65e183af | Michael Hanselmann | get if not already defined, and types they must match.
|
601 | 1ce03fb1 | Michael Hanselmann | @cvar OP_RESULT: Callable to verify opcode result
|
602 | 687c10d9 | Iustin Pop | @cvar WITH_LU: Boolean that specifies whether this should be included in
|
603 | 687c10d9 | Iustin Pop | mcpu's dispatch table
|
604 | 20777413 | Iustin Pop | @ivar dry_run: Whether the LU should be run in dry-run mode, i.e. just
|
605 | 20777413 | Iustin Pop | the check steps
|
606 | 8f5c488d | Michael Hanselmann | @ivar priority: Opcode priority for queue
|
607 | a7399f66 | Iustin Pop |
|
608 | a7399f66 | Iustin Pop | """
|
609 | b459a848 | Andrea Spadaccini | # pylint: disable=E1101
|
610 | e89a9021 | Iustin Pop | # as OP_ID is dynamically defined
|
611 | 687c10d9 | Iustin Pop | WITH_LU = True
|
612 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
613 | 45d4c81c | Michael Hanselmann | ("dry_run", None, ht.TMaybeBool, "Run checks only, don't execute"), |
614 | 45d4c81c | Michael Hanselmann | ("debug_level", None, ht.TOr(ht.TNone, ht.TPositiveInt), "Debug level"), |
615 | 65e183af | Michael Hanselmann | ("priority", constants.OP_PRIO_DEFAULT,
|
616 | 45d4c81c | Michael Hanselmann | ht.TElemOf(constants.OP_PRIO_SUBMIT_VALID), "Opcode priority"),
|
617 | b247c6fc | Michael Hanselmann | (DEPEND_ATTR, None, _BuildJobDepCheck(True), |
618 | b247c6fc | Michael Hanselmann | "Job dependencies; if used through ``SubmitManyJobs`` relative (negative)"
|
619 | 822a50c4 | Michael Hanselmann | " job IDs can be used; see :doc:`design document <design-chained-jobs>`"
|
620 | 822a50c4 | Michael Hanselmann | " for details"),
|
621 | 018ae30b | Michael Hanselmann | (COMMENT_ATTR, None, ht.TMaybeString,
|
622 | 018ae30b | Michael Hanselmann | "Comment describing the purpose of the opcode"),
|
623 | 65e183af | Michael Hanselmann | ] |
624 | 1ce03fb1 | Michael Hanselmann | OP_RESULT = None
|
625 | df458e0b | Iustin Pop | |
626 | df458e0b | Iustin Pop | def __getstate__(self): |
627 | df458e0b | Iustin Pop | """Specialized getstate for opcodes.
|
628 | df458e0b | Iustin Pop |
|
629 | a7399f66 | Iustin Pop | This method adds to the state dictionary the OP_ID of the class,
|
630 | a7399f66 | Iustin Pop | so that on unload we can identify the correct class for
|
631 | a7399f66 | Iustin Pop | instantiating the opcode.
|
632 | a7399f66 | Iustin Pop |
|
633 | a7399f66 | Iustin Pop | @rtype: C{dict}
|
634 | a7399f66 | Iustin Pop | @return: the state as a dictionary
|
635 | a7399f66 | Iustin Pop |
|
636 | df458e0b | Iustin Pop | """
|
637 | 0e46916d | Iustin Pop | data = BaseOpCode.__getstate__(self)
|
638 | df458e0b | Iustin Pop | data["OP_ID"] = self.OP_ID |
639 | df458e0b | Iustin Pop | return data
|
640 | df458e0b | Iustin Pop | |
641 | df458e0b | Iustin Pop | @classmethod
|
642 | 00abdc96 | Iustin Pop | def LoadOpCode(cls, data): |
643 | df458e0b | Iustin Pop | """Generic load opcode method.
|
644 | df458e0b | Iustin Pop |
|
645 | a7399f66 | Iustin Pop | The method identifies the correct opcode class from the dict-form
|
646 | a7399f66 | Iustin Pop | by looking for a OP_ID key, if this is not found, or its value is
|
647 | a7399f66 | Iustin Pop | not available in this module as a child of this class, we fail.
|
648 | a7399f66 | Iustin Pop |
|
649 | a7399f66 | Iustin Pop | @type data: C{dict}
|
650 | a7399f66 | Iustin Pop | @param data: the serialized opcode
|
651 | a7399f66 | Iustin Pop |
|
652 | df458e0b | Iustin Pop | """
|
653 | df458e0b | Iustin Pop | if not isinstance(data, dict): |
654 | df458e0b | Iustin Pop | raise ValueError("Invalid data to LoadOpCode (%s)" % type(data)) |
655 | df458e0b | Iustin Pop | if "OP_ID" not in data: |
656 | df458e0b | Iustin Pop | raise ValueError("Invalid data to LoadOpcode, missing OP_ID") |
657 | df458e0b | Iustin Pop | op_id = data["OP_ID"]
|
658 | df458e0b | Iustin Pop | op_class = None
|
659 | 363acb1e | Iustin Pop | if op_id in OP_MAPPING: |
660 | 363acb1e | Iustin Pop | op_class = OP_MAPPING[op_id] |
661 | 363acb1e | Iustin Pop | else:
|
662 | df458e0b | Iustin Pop | raise ValueError("Invalid data to LoadOpCode: OP_ID %s unsupported" % |
663 | df458e0b | Iustin Pop | op_id) |
664 | df458e0b | Iustin Pop | op = op_class() |
665 | df458e0b | Iustin Pop | new_data = data.copy() |
666 | df458e0b | Iustin Pop | del new_data["OP_ID"] |
667 | df458e0b | Iustin Pop | op.__setstate__(new_data) |
668 | df458e0b | Iustin Pop | return op
|
669 | df458e0b | Iustin Pop | |
670 | 60dd1473 | Iustin Pop | def Summary(self): |
671 | 60dd1473 | Iustin Pop | """Generates a summary description of this opcode.
|
672 | 60dd1473 | Iustin Pop |
|
673 | ff0d18e6 | Iustin Pop | The summary is the value of the OP_ID attribute (without the "OP_"
|
674 | ff0d18e6 | Iustin Pop | prefix), plus the value of the OP_DSC_FIELD attribute, if one was
|
675 | ff0d18e6 | Iustin Pop | defined; this field should allow to easily identify the operation
|
676 | ff0d18e6 | Iustin Pop | (for an instance creation job, e.g., it would be the instance
|
677 | ff0d18e6 | Iustin Pop | name).
|
678 | bde8f481 | Adeodato Simo |
|
679 | 60dd1473 | Iustin Pop | """
|
680 | ff0d18e6 | Iustin Pop | assert self.OP_ID is not None and len(self.OP_ID) > 3 |
681 | 60dd1473 | Iustin Pop | # all OP_ID start with OP_, we remove that
|
682 | 60dd1473 | Iustin Pop | txt = self.OP_ID[3:] |
683 | 60dd1473 | Iustin Pop | field_name = getattr(self, "OP_DSC_FIELD", None) |
684 | 60dd1473 | Iustin Pop | if field_name:
|
685 | 60dd1473 | Iustin Pop | field_value = getattr(self, field_name, None) |
686 | bc8bbda1 | Iustin Pop | if isinstance(field_value, (list, tuple)): |
687 | bc8bbda1 | Iustin Pop | field_value = ",".join(str(i) for i in field_value) |
688 | 60dd1473 | Iustin Pop | txt = "%s(%s)" % (txt, field_value)
|
689 | 60dd1473 | Iustin Pop | return txt
|
690 | 60dd1473 | Iustin Pop | |
691 | 3ce9a5e7 | Michael Hanselmann | def TinySummary(self): |
692 | 3ce9a5e7 | Michael Hanselmann | """Generates a compact summary description of the opcode.
|
693 | 3ce9a5e7 | Michael Hanselmann |
|
694 | 3ce9a5e7 | Michael Hanselmann | """
|
695 | 3ce9a5e7 | Michael Hanselmann | assert self.OP_ID.startswith("OP_") |
696 | 3ce9a5e7 | Michael Hanselmann | |
697 | 3ce9a5e7 | Michael Hanselmann | text = self.OP_ID[3:] |
698 | 3ce9a5e7 | Michael Hanselmann | |
699 | 3ce9a5e7 | Michael Hanselmann | for (prefix, supplement) in _SUMMARY_PREFIX.items(): |
700 | 3ce9a5e7 | Michael Hanselmann | if text.startswith(prefix):
|
701 | 3ce9a5e7 | Michael Hanselmann | return supplement + text[len(prefix):] |
702 | 3ce9a5e7 | Michael Hanselmann | |
703 | 3ce9a5e7 | Michael Hanselmann | return text
|
704 | 3ce9a5e7 | Michael Hanselmann | |
705 | a8083063 | Iustin Pop | |
706 | afee0879 | Iustin Pop | # cluster opcodes
|
707 | afee0879 | Iustin Pop | |
708 | bc84ffa7 | Iustin Pop | class OpClusterPostInit(OpCode): |
709 | b5f5fae9 | Luca Bigliardi | """Post cluster initialization.
|
710 | b5f5fae9 | Luca Bigliardi |
|
711 | b5f5fae9 | Luca Bigliardi | This opcode does not touch the cluster at all. Its purpose is to run hooks
|
712 | b5f5fae9 | Luca Bigliardi | after the cluster has been initialized.
|
713 | b5f5fae9 | Luca Bigliardi |
|
714 | b5f5fae9 | Luca Bigliardi | """
|
715 | c363310d | René Nussbaumer | OP_RESULT = ht.TBool |
716 | b5f5fae9 | Luca Bigliardi | |
717 | b5f5fae9 | Luca Bigliardi | |
718 | c6d43e9e | Iustin Pop | class OpClusterDestroy(OpCode): |
719 | a7399f66 | Iustin Pop | """Destroy the cluster.
|
720 | a7399f66 | Iustin Pop |
|
721 | a7399f66 | Iustin Pop | This opcode has no other parameters. All the state is irreversibly
|
722 | a7399f66 | Iustin Pop | lost after the execution of this opcode.
|
723 | a7399f66 | Iustin Pop |
|
724 | a7399f66 | Iustin Pop | """
|
725 | c363310d | René Nussbaumer | OP_RESULT = ht.TNonEmptyString |
726 | a8083063 | Iustin Pop | |
727 | a8083063 | Iustin Pop | |
728 | a2f7ab92 | Iustin Pop | class OpClusterQuery(OpCode): |
729 | fdc267f4 | Iustin Pop | """Query cluster information."""
|
730 | 415feb2e | René Nussbaumer | OP_RESULT = ht.TDictOf(ht.TNonEmptyString, ht.TAny) |
731 | a8083063 | Iustin Pop | |
732 | a8083063 | Iustin Pop | |
733 | fcad7225 | Michael Hanselmann | class OpClusterVerify(OpCode): |
734 | fcad7225 | Michael Hanselmann | """Submits all jobs necessary to verify the cluster.
|
735 | fcad7225 | Michael Hanselmann |
|
736 | fcad7225 | Michael Hanselmann | """
|
737 | fcad7225 | Michael Hanselmann | OP_PARAMS = [ |
738 | fcad7225 | Michael Hanselmann | _PDebugSimulateErrors, |
739 | fcad7225 | Michael Hanselmann | _PErrorCodes, |
740 | fcad7225 | Michael Hanselmann | _PSkipChecks, |
741 | 93f2399e | Andrea Spadaccini | _PIgnoreErrors, |
742 | fcad7225 | Michael Hanselmann | _PVerbose, |
743 | fcad7225 | Michael Hanselmann | ("group_name", None, ht.TMaybeString, "Group to verify") |
744 | fcad7225 | Michael Hanselmann | ] |
745 | f7686867 | Michael Hanselmann | OP_RESULT = TJobIdListOnly |
746 | fcad7225 | Michael Hanselmann | |
747 | fcad7225 | Michael Hanselmann | |
748 | bf93ae69 | Adeodato Simo | class OpClusterVerifyConfig(OpCode): |
749 | bf93ae69 | Adeodato Simo | """Verify the cluster config.
|
750 | bf93ae69 | Adeodato Simo |
|
751 | bf93ae69 | Adeodato Simo | """
|
752 | bf93ae69 | Adeodato Simo | OP_PARAMS = [ |
753 | 57106b74 | Michael Hanselmann | _PDebugSimulateErrors, |
754 | 57106b74 | Michael Hanselmann | _PErrorCodes, |
755 | 93f2399e | Andrea Spadaccini | _PIgnoreErrors, |
756 | 57106b74 | Michael Hanselmann | _PVerbose, |
757 | bf93ae69 | Adeodato Simo | ] |
758 | f7686867 | Michael Hanselmann | OP_RESULT = ht.TBool |
759 | bf93ae69 | Adeodato Simo | |
760 | bf93ae69 | Adeodato Simo | |
761 | bf93ae69 | Adeodato Simo | class OpClusterVerifyGroup(OpCode): |
762 | bf93ae69 | Adeodato Simo | """Run verify on a node group from the cluster.
|
763 | a7399f66 | Iustin Pop |
|
764 | a7399f66 | Iustin Pop | @type skip_checks: C{list}
|
765 | a7399f66 | Iustin Pop | @ivar skip_checks: steps to be skipped from the verify process; this
|
766 | a7399f66 | Iustin Pop | needs to be a subset of
|
767 | a7399f66 | Iustin Pop | L{constants.VERIFY_OPTIONAL_CHECKS}; currently
|
768 | a7399f66 | Iustin Pop | only L{constants.VERIFY_NPLUSONE_MEM} can be passed
|
769 | a7399f66 | Iustin Pop |
|
770 | a7399f66 | Iustin Pop | """
|
771 | bf93ae69 | Adeodato Simo | OP_DSC_FIELD = "group_name"
|
772 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
773 | 57106b74 | Michael Hanselmann | _PGroupName, |
774 | 57106b74 | Michael Hanselmann | _PDebugSimulateErrors, |
775 | 57106b74 | Michael Hanselmann | _PErrorCodes, |
776 | 57106b74 | Michael Hanselmann | _PSkipChecks, |
777 | 93f2399e | Andrea Spadaccini | _PIgnoreErrors, |
778 | 57106b74 | Michael Hanselmann | _PVerbose, |
779 | 65e183af | Michael Hanselmann | ] |
780 | f7686867 | Michael Hanselmann | OP_RESULT = ht.TBool |
781 | a8083063 | Iustin Pop | |
782 | a8083063 | Iustin Pop | |
783 | bd8210a7 | Iustin Pop | class OpClusterVerifyDisks(OpCode): |
784 | 150e978f | Iustin Pop | """Verify the cluster disks.
|
785 | 150e978f | Iustin Pop |
|
786 | ae1a845c | Michael Hanselmann | """
|
787 | f7686867 | Michael Hanselmann | OP_RESULT = TJobIdListOnly |
788 | ae1a845c | Michael Hanselmann | |
789 | ae1a845c | Michael Hanselmann | |
790 | ae1a845c | Michael Hanselmann | class OpGroupVerifyDisks(OpCode): |
791 | ae1a845c | Michael Hanselmann | """Verifies the status of all disks in a node group.
|
792 | 150e978f | Iustin Pop |
|
793 | ae1a845c | Michael Hanselmann | Result: a tuple of three elements:
|
794 | ae1a845c | Michael Hanselmann | - dict of node names with issues (values: error msg)
|
795 | 150e978f | Iustin Pop | - list of instances with degraded disks (that should be activated)
|
796 | b63ed789 | Iustin Pop | - dict of instances with missing logical volumes (values: (node, vol)
|
797 | b63ed789 | Iustin Pop | pairs with details about the missing volumes)
|
798 | 150e978f | Iustin Pop |
|
799 | b63ed789 | Iustin Pop | In normal operation, all lists should be empty. A non-empty instance
|
800 | b63ed789 | Iustin Pop | list (3rd element of the result) is still ok (errors were fixed) but
|
801 | b63ed789 | Iustin Pop | non-empty node list means some node is down, and probably there are
|
802 | b63ed789 | Iustin Pop | unfixable drbd errors.
|
803 | 150e978f | Iustin Pop |
|
804 | 150e978f | Iustin Pop | Note that only instances that are drbd-based are taken into
|
805 | 150e978f | Iustin Pop | consideration. This might need to be revisited in the future.
|
806 | 150e978f | Iustin Pop |
|
807 | 150e978f | Iustin Pop | """
|
808 | ae1a845c | Michael Hanselmann | OP_DSC_FIELD = "group_name"
|
809 | ae1a845c | Michael Hanselmann | OP_PARAMS = [ |
810 | ae1a845c | Michael Hanselmann | _PGroupName, |
811 | ae1a845c | Michael Hanselmann | ] |
812 | 1ce03fb1 | Michael Hanselmann | OP_RESULT = \ |
813 | 1ce03fb1 | Michael Hanselmann | ht.TAnd(ht.TIsLength(3),
|
814 | 1ce03fb1 | Michael Hanselmann | ht.TItems([ht.TDictOf(ht.TString, ht.TString), |
815 | 1ce03fb1 | Michael Hanselmann | ht.TListOf(ht.TString), |
816 | 6973587f | Michael Hanselmann | ht.TDictOf(ht.TString, |
817 | 6973587f | Michael Hanselmann | ht.TListOf(ht.TListOf(ht.TString)))])) |
818 | 150e978f | Iustin Pop | |
819 | 150e978f | Iustin Pop | |
820 | 5d01aca3 | Iustin Pop | class OpClusterRepairDiskSizes(OpCode): |
821 | 60975797 | Iustin Pop | """Verify the disk sizes of the instances and fixes configuration
|
822 | 60975797 | Iustin Pop | mimatches.
|
823 | 60975797 | Iustin Pop |
|
824 | 60975797 | Iustin Pop | Parameters: optional instances list, in case we want to restrict the
|
825 | 60975797 | Iustin Pop | checks to only a subset of the instances.
|
826 | 60975797 | Iustin Pop |
|
827 | 60975797 | Iustin Pop | Result: a list of tuples, (instance, disk, new-size) for changed
|
828 | 60975797 | Iustin Pop | configurations.
|
829 | 60975797 | Iustin Pop |
|
830 | 60975797 | Iustin Pop | In normal operation, the list should be empty.
|
831 | 60975797 | Iustin Pop |
|
832 | 60975797 | Iustin Pop | @type instances: list
|
833 | 60975797 | Iustin Pop | @ivar instances: the list of instances to check, or empty for all instances
|
834 | 60975797 | Iustin Pop |
|
835 | 60975797 | Iustin Pop | """
|
836 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
837 | 197b323b | Michael Hanselmann | ("instances", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), None), |
838 | 65e183af | Michael Hanselmann | ] |
839 | c363310d | René Nussbaumer | OP_RESULT = ht.TListOf(ht.TAnd(ht.TIsLength(3),
|
840 | c363310d | René Nussbaumer | ht.TItems([ht.TNonEmptyString, |
841 | c363310d | René Nussbaumer | ht.TPositiveInt, |
842 | c363310d | René Nussbaumer | ht.TPositiveInt]))) |
843 | 60975797 | Iustin Pop | |
844 | 60975797 | Iustin Pop | |
845 | 2f093ea0 | Iustin Pop | class OpClusterConfigQuery(OpCode): |
846 | ae5849b5 | Michael Hanselmann | """Query cluster configuration values."""
|
847 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
848 | 65e183af | Michael Hanselmann | _POutputFields |
849 | 65e183af | Michael Hanselmann | ] |
850 | c363310d | René Nussbaumer | OP_RESULT = ht.TListOf(ht.TAny) |
851 | a8083063 | Iustin Pop | |
852 | a8083063 | Iustin Pop | |
853 | e126df25 | Iustin Pop | class OpClusterRename(OpCode): |
854 | a7399f66 | Iustin Pop | """Rename the cluster.
|
855 | a7399f66 | Iustin Pop |
|
856 | a7399f66 | Iustin Pop | @type name: C{str}
|
857 | a7399f66 | Iustin Pop | @ivar name: The new name of the cluster. The name and/or the master IP
|
858 | a7399f66 | Iustin Pop | address will be changed to match the new name and its IP
|
859 | a7399f66 | Iustin Pop | address.
|
860 | a7399f66 | Iustin Pop |
|
861 | a7399f66 | Iustin Pop | """
|
862 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "name"
|
863 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
864 | 197b323b | Michael Hanselmann | ("name", ht.NoDefault, ht.TNonEmptyString, None), |
865 | 65e183af | Michael Hanselmann | ] |
866 | c363310d | René Nussbaumer | OP_RESULT = ht.TNonEmptyString |
867 | 07bd8a51 | Iustin Pop | |
868 | 07bd8a51 | Iustin Pop | |
869 | a6682fdc | Iustin Pop | class OpClusterSetParams(OpCode): |
870 | a7399f66 | Iustin Pop | """Change the parameters of the cluster.
|
871 | a7399f66 | Iustin Pop |
|
872 | a7399f66 | Iustin Pop | @type vg_name: C{str} or C{None}
|
873 | a7399f66 | Iustin Pop | @ivar vg_name: The new volume group name or None to disable LVM usage.
|
874 | a7399f66 | Iustin Pop |
|
875 | a7399f66 | Iustin Pop | """
|
876 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
877 | 2da9f556 | René Nussbaumer | _PHvState, |
878 | 2da9f556 | René Nussbaumer | _PDiskState, |
879 | 45d4c81c | Michael Hanselmann | ("vg_name", None, ht.TMaybeString, "Volume group name"), |
880 | 65e183af | Michael Hanselmann | ("enabled_hypervisors", None, |
881 | 65e183af | Michael Hanselmann | ht.TOr(ht.TAnd(ht.TListOf(ht.TElemOf(constants.HYPER_TYPES)), ht.TTrue), |
882 | 45d4c81c | Michael Hanselmann | ht.TNone), |
883 | 45d4c81c | Michael Hanselmann | "List of enabled hypervisors"),
|
884 | 65e183af | Michael Hanselmann | ("hvparams", None, ht.TOr(ht.TDictOf(ht.TNonEmptyString, ht.TDict), |
885 | 45d4c81c | Michael Hanselmann | ht.TNone), |
886 | 45d4c81c | Michael Hanselmann | "Cluster-wide hypervisor parameter defaults, hypervisor-dependent"),
|
887 | 45d4c81c | Michael Hanselmann | ("beparams", None, ht.TOr(ht.TDict, ht.TNone), |
888 | 45d4c81c | Michael Hanselmann | "Cluster-wide backend parameter defaults"),
|
889 | 65e183af | Michael Hanselmann | ("os_hvp", None, ht.TOr(ht.TDictOf(ht.TNonEmptyString, ht.TDict), |
890 | 45d4c81c | Michael Hanselmann | ht.TNone), |
891 | 45d4c81c | Michael Hanselmann | "Cluster-wide per-OS hypervisor parameter defaults"),
|
892 | 65e183af | Michael Hanselmann | ("osparams", None, ht.TOr(ht.TDictOf(ht.TNonEmptyString, ht.TDict), |
893 | 45d4c81c | Michael Hanselmann | ht.TNone), |
894 | 45d4c81c | Michael Hanselmann | "Cluster-wide OS parameter defaults"),
|
895 | bc5d0215 | Andrea Spadaccini | _PDiskParams, |
896 | 197b323b | Michael Hanselmann | ("candidate_pool_size", None, ht.TOr(ht.TStrictPositiveInt, ht.TNone), |
897 | 45d4c81c | Michael Hanselmann | "Master candidate pool size"),
|
898 | 45d4c81c | Michael Hanselmann | ("uid_pool", None, ht.NoType, |
899 | 45d4c81c | Michael Hanselmann | "Set UID pool, must be list of lists describing UID ranges (two items,"
|
900 | 45d4c81c | Michael Hanselmann | " start and end inclusive)"),
|
901 | 45d4c81c | Michael Hanselmann | ("add_uids", None, ht.NoType, |
902 | 45d4c81c | Michael Hanselmann | "Extend UID pool, must be list of lists describing UID ranges (two"
|
903 | 45d4c81c | Michael Hanselmann | " items, start and end inclusive) to be added"),
|
904 | 45d4c81c | Michael Hanselmann | ("remove_uids", None, ht.NoType, |
905 | 45d4c81c | Michael Hanselmann | "Shrink UID pool, must be list of lists describing UID ranges (two"
|
906 | 45d4c81c | Michael Hanselmann | " items, start and end inclusive) to be removed"),
|
907 | 45d4c81c | Michael Hanselmann | ("maintain_node_health", None, ht.TMaybeBool, |
908 | 45d4c81c | Michael Hanselmann | "Whether to automatically maintain node health"),
|
909 | 45d4c81c | Michael Hanselmann | ("prealloc_wipe_disks", None, ht.TMaybeBool, |
910 | 45d4c81c | Michael Hanselmann | "Whether to wipe disks before allocating them to instances"),
|
911 | 45d4c81c | Michael Hanselmann | ("nicparams", None, ht.TMaybeDict, "Cluster-wide NIC parameter defaults"), |
912 | 45d4c81c | Michael Hanselmann | ("ndparams", None, ht.TMaybeDict, "Cluster-wide node parameter defaults"), |
913 | 1b01390b | René Nussbaumer | ("ipolicy", None, ht.TMaybeDict, |
914 | 1b01390b | René Nussbaumer | "Cluster-wide :ref:`instance policy <rapi-ipolicy>` specs"),
|
915 | 45d4c81c | Michael Hanselmann | ("drbd_helper", None, ht.TOr(ht.TString, ht.TNone), "DRBD helper program"), |
916 | 45d4c81c | Michael Hanselmann | ("default_iallocator", None, ht.TOr(ht.TString, ht.TNone), |
917 | 45d4c81c | Michael Hanselmann | "Default iallocator for cluster"),
|
918 | 45d4c81c | Michael Hanselmann | ("master_netdev", None, ht.TOr(ht.TString, ht.TNone), |
919 | 45d4c81c | Michael Hanselmann | "Master network device"),
|
920 | 5a8648eb | Andrea Spadaccini | ("master_netmask", None, ht.TOr(ht.TInt, ht.TNone), |
921 | 5a8648eb | Andrea Spadaccini | "Netmask of the master IP"),
|
922 | ff8067cf | Michael Hanselmann | ("reserved_lvs", None, ht.TMaybeListOf(ht.TNonEmptyString), |
923 | 45d4c81c | Michael Hanselmann | "List of reserved LVs"),
|
924 | 45d4c81c | Michael Hanselmann | ("hidden_os", None, _TestClusterOsList, |
925 | 0fb66bb1 | Iustin Pop | "Modify list of hidden operating systems: each modification must have"
|
926 | 0fb66bb1 | Iustin Pop | " two items, the operation and the OS name; the operation can be"
|
927 | 0fb66bb1 | Iustin Pop | " ``%s`` or ``%s``" % (constants.DDM_ADD, constants.DDM_REMOVE)),
|
928 | 45d4c81c | Michael Hanselmann | ("blacklisted_os", None, _TestClusterOsList, |
929 | 0fb66bb1 | Iustin Pop | "Modify list of blacklisted operating systems: each modification must"
|
930 | 0fb66bb1 | Iustin Pop | " have two items, the operation and the OS name; the operation can be"
|
931 | 0fb66bb1 | Iustin Pop | " ``%s`` or ``%s``" % (constants.DDM_ADD, constants.DDM_REMOVE)),
|
932 | bf689b7a | Andrea Spadaccini | ("use_external_mip_script", None, ht.TMaybeBool, |
933 | bf689b7a | Andrea Spadaccini | "Whether to use an external master IP address setup script"),
|
934 | 4b7735f9 | Iustin Pop | ] |
935 | c363310d | René Nussbaumer | OP_RESULT = ht.TNone |
936 | 12515db7 | Manuel Franceschini | |
937 | 12515db7 | Manuel Franceschini | |
938 | d1240007 | Iustin Pop | class OpClusterRedistConf(OpCode): |
939 | afee0879 | Iustin Pop | """Force a full push of the cluster configuration.
|
940 | afee0879 | Iustin Pop |
|
941 | afee0879 | Iustin Pop | """
|
942 | c363310d | René Nussbaumer | OP_RESULT = ht.TNone |
943 | afee0879 | Iustin Pop | |
944 | 83f72637 | Michael Hanselmann | |
945 | fb926117 | Andrea Spadaccini | class OpClusterActivateMasterIp(OpCode): |
946 | fb926117 | Andrea Spadaccini | """Activate the master IP on the master node.
|
947 | fb926117 | Andrea Spadaccini |
|
948 | fb926117 | Andrea Spadaccini | """
|
949 | c363310d | René Nussbaumer | OP_RESULT = ht.TNone |
950 | fb926117 | Andrea Spadaccini | |
951 | fb926117 | Andrea Spadaccini | |
952 | fb926117 | Andrea Spadaccini | class OpClusterDeactivateMasterIp(OpCode): |
953 | fb926117 | Andrea Spadaccini | """Deactivate the master IP on the master node.
|
954 | fb926117 | Andrea Spadaccini |
|
955 | fb926117 | Andrea Spadaccini | """
|
956 | c363310d | René Nussbaumer | OP_RESULT = ht.TNone |
957 | fb926117 | Andrea Spadaccini | |
958 | fb926117 | Andrea Spadaccini | |
959 | 83f72637 | Michael Hanselmann | class OpQuery(OpCode): |
960 | 83f72637 | Michael Hanselmann | """Query for resources/items.
|
961 | 83f72637 | Michael Hanselmann |
|
962 | abd66bf8 | Michael Hanselmann | @ivar what: Resources to query for, must be one of L{constants.QR_VIA_OP}
|
963 | 83f72637 | Michael Hanselmann | @ivar fields: List of fields to retrieve
|
964 | 2e5c33db | Iustin Pop | @ivar qfilter: Query filter
|
965 | 83f72637 | Michael Hanselmann |
|
966 | 83f72637 | Michael Hanselmann | """
|
967 | e50d8412 | Michael Hanselmann | OP_DSC_FIELD = "what"
|
968 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
969 | 8e7078e0 | Michael Hanselmann | _PQueryWhat, |
970 | ee13764f | Michael Hanselmann | _PUseLocking, |
971 | 45d4c81c | Michael Hanselmann | ("fields", ht.NoDefault, ht.TListOf(ht.TNonEmptyString),
|
972 | 45d4c81c | Michael Hanselmann | "Requested fields"),
|
973 | 7bfb3367 | Iustin Pop | ("qfilter", None, ht.TOr(ht.TNone, ht.TList), |
974 | 45d4c81c | Michael Hanselmann | "Query filter"),
|
975 | 83f72637 | Michael Hanselmann | ] |
976 | 415feb2e | René Nussbaumer | OP_RESULT = \ |
977 | b02c6bdf | Michael Hanselmann | _GenerateObjectTypeCheck(objects.QueryResponse, { |
978 | b02c6bdf | Michael Hanselmann | "fields": ht.TListOf(_TQueryFieldDef),
|
979 | b02c6bdf | Michael Hanselmann | "data": _TQueryResult,
|
980 | b02c6bdf | Michael Hanselmann | }) |
981 | 83f72637 | Michael Hanselmann | |
982 | 83f72637 | Michael Hanselmann | |
983 | 83f72637 | Michael Hanselmann | class OpQueryFields(OpCode): |
984 | 83f72637 | Michael Hanselmann | """Query for available resource/item fields.
|
985 | 83f72637 | Michael Hanselmann |
|
986 | abd66bf8 | Michael Hanselmann | @ivar what: Resources to query for, must be one of L{constants.QR_VIA_OP}
|
987 | 83f72637 | Michael Hanselmann | @ivar fields: List of fields to retrieve
|
988 | 83f72637 | Michael Hanselmann |
|
989 | 83f72637 | Michael Hanselmann | """
|
990 | e50d8412 | Michael Hanselmann | OP_DSC_FIELD = "what"
|
991 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
992 | 8e7078e0 | Michael Hanselmann | _PQueryWhat, |
993 | ff8067cf | Michael Hanselmann | ("fields", None, ht.TMaybeListOf(ht.TNonEmptyString), |
994 | 8e7078e0 | Michael Hanselmann | "Requested fields; if not given, all are returned"),
|
995 | 83f72637 | Michael Hanselmann | ] |
996 | 415feb2e | René Nussbaumer | OP_RESULT = \ |
997 | b02c6bdf | Michael Hanselmann | _GenerateObjectTypeCheck(objects.QueryFieldsResponse, { |
998 | b02c6bdf | Michael Hanselmann | "fields": ht.TListOf(_TQueryFieldDef),
|
999 | b02c6bdf | Michael Hanselmann | }) |
1000 | 83f72637 | Michael Hanselmann | |
1001 | 83f72637 | Michael Hanselmann | |
1002 | 792af3ad | René Nussbaumer | class OpOobCommand(OpCode): |
1003 | eb64da59 | René Nussbaumer | """Interact with OOB."""
|
1004 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1005 | c4ec0755 | René Nussbaumer | ("node_names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString),
|
1006 | c4ec0755 | René Nussbaumer | "List of nodes to run the OOB command against"),
|
1007 | c4ec0755 | René Nussbaumer | ("command", None, ht.TElemOf(constants.OOB_COMMANDS), |
1008 | c4ec0755 | René Nussbaumer | "OOB command to be run"),
|
1009 | c4ec0755 | René Nussbaumer | ("timeout", constants.OOB_TIMEOUT, ht.TInt,
|
1010 | c4ec0755 | René Nussbaumer | "Timeout before the OOB helper will be terminated"),
|
1011 | c4ec0755 | René Nussbaumer | ("ignore_status", False, ht.TBool, |
1012 | c4ec0755 | René Nussbaumer | "Ignores the node offline status for power off"),
|
1013 | beff3779 | René Nussbaumer | ("power_delay", constants.OOB_POWER_DELAY, ht.TPositiveFloat,
|
1014 | beff3779 | René Nussbaumer | "Time in seconds to wait between powering on nodes"),
|
1015 | eb64da59 | René Nussbaumer | ] |
1016 | c363310d | René Nussbaumer | # Fixme: Make it more specific with all the special cases in LUOobCommand
|
1017 | 415feb2e | René Nussbaumer | OP_RESULT = _TQueryResult |
1018 | eb64da59 | René Nussbaumer | |
1019 | eb64da59 | René Nussbaumer | |
1020 | 07bd8a51 | Iustin Pop | # node opcodes
|
1021 | 07bd8a51 | Iustin Pop | |
1022 | 73d565a3 | Iustin Pop | class OpNodeRemove(OpCode): |
1023 | a7399f66 | Iustin Pop | """Remove a node.
|
1024 | a7399f66 | Iustin Pop |
|
1025 | a7399f66 | Iustin Pop | @type node_name: C{str}
|
1026 | a7399f66 | Iustin Pop | @ivar node_name: The name of the node to remove. If the node still has
|
1027 | a7399f66 | Iustin Pop | instances on it, the operation will fail.
|
1028 | a7399f66 | Iustin Pop |
|
1029 | a7399f66 | Iustin Pop | """
|
1030 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "node_name"
|
1031 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1032 | 65e183af | Michael Hanselmann | _PNodeName, |
1033 | 65e183af | Michael Hanselmann | ] |
1034 | c363310d | René Nussbaumer | OP_RESULT = ht.TNone |
1035 | a8083063 | Iustin Pop | |
1036 | a8083063 | Iustin Pop | |
1037 | d817d49f | Iustin Pop | class OpNodeAdd(OpCode): |
1038 | a7399f66 | Iustin Pop | """Add a node to the cluster.
|
1039 | a7399f66 | Iustin Pop |
|
1040 | a7399f66 | Iustin Pop | @type node_name: C{str}
|
1041 | a7399f66 | Iustin Pop | @ivar node_name: The name of the node to add. This can be a short name,
|
1042 | a7399f66 | Iustin Pop | but it will be expanded to the FQDN.
|
1043 | a7399f66 | Iustin Pop | @type primary_ip: IP address
|
1044 | a7399f66 | Iustin Pop | @ivar primary_ip: The primary IP of the node. This will be ignored when the
|
1045 | a7399f66 | Iustin Pop | opcode is submitted, but will be filled during the node
|
1046 | a7399f66 | Iustin Pop | add (so it will be visible in the job query).
|
1047 | a7399f66 | Iustin Pop | @type secondary_ip: IP address
|
1048 | a7399f66 | Iustin Pop | @ivar secondary_ip: The secondary IP of the node. This needs to be passed
|
1049 | a7399f66 | Iustin Pop | if the cluster has been initialized in 'dual-network'
|
1050 | a7399f66 | Iustin Pop | mode, otherwise it must not be given.
|
1051 | a7399f66 | Iustin Pop | @type readd: C{bool}
|
1052 | a7399f66 | Iustin Pop | @ivar readd: Whether to re-add an existing node to the cluster. If
|
1053 | a7399f66 | Iustin Pop | this is not passed, then the operation will abort if the node
|
1054 | a7399f66 | Iustin Pop | name is already in the cluster; use this parameter to 'repair'
|
1055 | a7399f66 | Iustin Pop | a node that had its configuration broken, or was reinstalled
|
1056 | a7399f66 | Iustin Pop | without removal from the cluster.
|
1057 | f936c153 | Iustin Pop | @type group: C{str}
|
1058 | f936c153 | Iustin Pop | @ivar group: The node group to which this node will belong.
|
1059 | fd3d37b6 | Iustin Pop | @type vm_capable: C{bool}
|
1060 | fd3d37b6 | Iustin Pop | @ivar vm_capable: The vm_capable node attribute
|
1061 | fd3d37b6 | Iustin Pop | @type master_capable: C{bool}
|
1062 | fd3d37b6 | Iustin Pop | @ivar master_capable: The master_capable node attribute
|
1063 | a7399f66 | Iustin Pop |
|
1064 | a7399f66 | Iustin Pop | """
|
1065 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "node_name"
|
1066 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1067 | 65e183af | Michael Hanselmann | _PNodeName, |
1068 | 085e0d9f | René Nussbaumer | _PHvState, |
1069 | 085e0d9f | René Nussbaumer | _PDiskState, |
1070 | 45d4c81c | Michael Hanselmann | ("primary_ip", None, ht.NoType, "Primary IP address"), |
1071 | 45d4c81c | Michael Hanselmann | ("secondary_ip", None, ht.TMaybeString, "Secondary IP address"), |
1072 | 45d4c81c | Michael Hanselmann | ("readd", False, ht.TBool, "Whether node is re-added to cluster"), |
1073 | 45d4c81c | Michael Hanselmann | ("group", None, ht.TMaybeString, "Initial node group"), |
1074 | 45d4c81c | Michael Hanselmann | ("master_capable", None, ht.TMaybeBool, |
1075 | 45d4c81c | Michael Hanselmann | "Whether node can become master or master candidate"),
|
1076 | 45d4c81c | Michael Hanselmann | ("vm_capable", None, ht.TMaybeBool, |
1077 | 45d4c81c | Michael Hanselmann | "Whether node can host instances"),
|
1078 | 45d4c81c | Michael Hanselmann | ("ndparams", None, ht.TMaybeDict, "Node parameters"), |
1079 | 65e183af | Michael Hanselmann | ] |
1080 | c363310d | René Nussbaumer | OP_RESULT = ht.TNone |
1081 | a8083063 | Iustin Pop | |
1082 | a8083063 | Iustin Pop | |
1083 | 2237687b | Iustin Pop | class OpNodeQuery(OpCode): |
1084 | a8083063 | Iustin Pop | """Compute the list of nodes."""
|
1085 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1086 | 65e183af | Michael Hanselmann | _POutputFields, |
1087 | 45d4c81c | Michael Hanselmann | _PUseLocking, |
1088 | 45d4c81c | Michael Hanselmann | ("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString),
|
1089 | 45d4c81c | Michael Hanselmann | "Empty list to query all nodes, node names otherwise"),
|
1090 | 65e183af | Michael Hanselmann | ] |
1091 | 415feb2e | René Nussbaumer | OP_RESULT = _TOldQueryResult |
1092 | a8083063 | Iustin Pop | |
1093 | a8083063 | Iustin Pop | |
1094 | 8ed55bfd | Iustin Pop | class OpNodeQueryvols(OpCode): |
1095 | dcb93971 | Michael Hanselmann | """Get list of volumes on node."""
|
1096 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1097 | 65e183af | Michael Hanselmann | _POutputFields, |
1098 | 45d4c81c | Michael Hanselmann | ("nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString),
|
1099 | 45d4c81c | Michael Hanselmann | "Empty list to query all nodes, node names otherwise"),
|
1100 | 65e183af | Michael Hanselmann | ] |
1101 | c363310d | René Nussbaumer | OP_RESULT = ht.TListOf(ht.TAny) |
1102 | dcb93971 | Michael Hanselmann | |
1103 | dcb93971 | Michael Hanselmann | |
1104 | ad8d0595 | Iustin Pop | class OpNodeQueryStorage(OpCode): |
1105 | 9e5442ce | Michael Hanselmann | """Get information on storage for node(s)."""
|
1106 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1107 | 65e183af | Michael Hanselmann | _POutputFields, |
1108 | 65e183af | Michael Hanselmann | _PStorageType, |
1109 | 45d4c81c | Michael Hanselmann | ("nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), "List of nodes"), |
1110 | 45d4c81c | Michael Hanselmann | ("name", None, ht.TMaybeString, "Storage name"), |
1111 | 9e5442ce | Michael Hanselmann | ] |
1112 | 415feb2e | René Nussbaumer | OP_RESULT = _TOldQueryResult |
1113 | 9e5442ce | Michael Hanselmann | |
1114 | 9e5442ce | Michael Hanselmann | |
1115 | 2cee4077 | Iustin Pop | class OpNodeModifyStorage(OpCode): |
1116 | 099c52ad | Iustin Pop | """Modifies the properies of a storage unit"""
|
1117 | 32708d0a | Iustin Pop | OP_DSC_FIELD = "node_name"
|
1118 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1119 | 65e183af | Michael Hanselmann | _PNodeName, |
1120 | 65e183af | Michael Hanselmann | _PStorageType, |
1121 | 45d4c81c | Michael Hanselmann | _PStorageName, |
1122 | 45d4c81c | Michael Hanselmann | ("changes", ht.NoDefault, ht.TDict, "Requested changes"), |
1123 | efb8da02 | Michael Hanselmann | ] |
1124 | c363310d | René Nussbaumer | OP_RESULT = ht.TNone |
1125 | efb8da02 | Michael Hanselmann | |
1126 | efb8da02 | Michael Hanselmann | |
1127 | 76aef8fc | Michael Hanselmann | class OpRepairNodeStorage(OpCode): |
1128 | 76aef8fc | Michael Hanselmann | """Repairs the volume group on a node."""
|
1129 | 76aef8fc | Michael Hanselmann | OP_DSC_FIELD = "node_name"
|
1130 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1131 | 65e183af | Michael Hanselmann | _PNodeName, |
1132 | 65e183af | Michael Hanselmann | _PStorageType, |
1133 | 45d4c81c | Michael Hanselmann | _PStorageName, |
1134 | 45d4c81c | Michael Hanselmann | _PIgnoreConsistency, |
1135 | 76aef8fc | Michael Hanselmann | ] |
1136 | c363310d | René Nussbaumer | OP_RESULT = ht.TNone |
1137 | 76aef8fc | Michael Hanselmann | |
1138 | 76aef8fc | Michael Hanselmann | |
1139 | f13973c4 | Iustin Pop | class OpNodeSetParams(OpCode): |
1140 | b31c8676 | Iustin Pop | """Change the parameters of a node."""
|
1141 | b31c8676 | Iustin Pop | OP_DSC_FIELD = "node_name"
|
1142 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1143 | 65e183af | Michael Hanselmann | _PNodeName, |
1144 | 65e183af | Michael Hanselmann | _PForce, |
1145 | 0ec2ce46 | René Nussbaumer | _PHvState, |
1146 | 0ec2ce46 | René Nussbaumer | _PDiskState, |
1147 | 45d4c81c | Michael Hanselmann | ("master_candidate", None, ht.TMaybeBool, |
1148 | 45d4c81c | Michael Hanselmann | "Whether the node should become a master candidate"),
|
1149 | 45d4c81c | Michael Hanselmann | ("offline", None, ht.TMaybeBool, |
1150 | 45d4c81c | Michael Hanselmann | "Whether the node should be marked as offline"),
|
1151 | 45d4c81c | Michael Hanselmann | ("drained", None, ht.TMaybeBool, |
1152 | 45d4c81c | Michael Hanselmann | "Whether the node should be marked as drained"),
|
1153 | 45d4c81c | Michael Hanselmann | ("auto_promote", False, ht.TBool, |
1154 | 45d4c81c | Michael Hanselmann | "Whether node(s) should be promoted to master candidate if necessary"),
|
1155 | 45d4c81c | Michael Hanselmann | ("master_capable", None, ht.TMaybeBool, |
1156 | 45d4c81c | Michael Hanselmann | "Denote whether node can become master or master candidate"),
|
1157 | 45d4c81c | Michael Hanselmann | ("vm_capable", None, ht.TMaybeBool, |
1158 | 45d4c81c | Michael Hanselmann | "Denote whether node can host instances"),
|
1159 | 45d4c81c | Michael Hanselmann | ("secondary_ip", None, ht.TMaybeString, |
1160 | 45d4c81c | Michael Hanselmann | "Change node's secondary IP address"),
|
1161 | 45d4c81c | Michael Hanselmann | ("ndparams", None, ht.TMaybeDict, "Set node parameters"), |
1162 | 45d4c81c | Michael Hanselmann | ("powered", None, ht.TMaybeBool, |
1163 | 45d4c81c | Michael Hanselmann | "Whether the node should be marked as powered"),
|
1164 | b31c8676 | Iustin Pop | ] |
1165 | 1456df62 | Michael Hanselmann | OP_RESULT = _TSetParamsResult |
1166 | b31c8676 | Iustin Pop | |
1167 | f5118ade | Iustin Pop | |
1168 | e0d4735f | Iustin Pop | class OpNodePowercycle(OpCode): |
1169 | f5118ade | Iustin Pop | """Tries to powercycle a node."""
|
1170 | f5118ade | Iustin Pop | OP_DSC_FIELD = "node_name"
|
1171 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1172 | 65e183af | Michael Hanselmann | _PNodeName, |
1173 | 65e183af | Michael Hanselmann | _PForce, |
1174 | f5118ade | Iustin Pop | ] |
1175 | c363310d | René Nussbaumer | OP_RESULT = ht.TMaybeString |
1176 | f5118ade | Iustin Pop | |
1177 | 7ffc5a86 | Michael Hanselmann | |
1178 | 5b14a488 | Iustin Pop | class OpNodeMigrate(OpCode): |
1179 | 80cb875c | Michael Hanselmann | """Migrate all instances from a node."""
|
1180 | 80cb875c | Michael Hanselmann | OP_DSC_FIELD = "node_name"
|
1181 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1182 | 65e183af | Michael Hanselmann | _PNodeName, |
1183 | 65e183af | Michael Hanselmann | _PMigrationMode, |
1184 | 65e183af | Michael Hanselmann | _PMigrationLive, |
1185 | f8fa4175 | Michael Hanselmann | _PMigrationTargetNode, |
1186 | 8c0b16f6 | Guido Trotter | _PAllowRuntimeChgs, |
1187 | 9fa567b3 | René Nussbaumer | _PIgnoreIpolicy, |
1188 | 8eb34306 | Apollon Oikonomopoulos | ("iallocator", None, ht.TMaybeString, |
1189 | 8eb34306 | Apollon Oikonomopoulos | "Iallocator for deciding the target node for shared-storage instances"),
|
1190 | 80cb875c | Michael Hanselmann | ] |
1191 | 65c9591c | Michael Hanselmann | OP_RESULT = TJobIdListOnly |
1192 | 80cb875c | Michael Hanselmann | |
1193 | 80cb875c | Michael Hanselmann | |
1194 | e1f23243 | Michael Hanselmann | class OpNodeEvacuate(OpCode): |
1195 | e1f23243 | Michael Hanselmann | """Evacuate instances off a number of nodes."""
|
1196 | e1f23243 | Michael Hanselmann | OP_DSC_FIELD = "node_name"
|
1197 | e1f23243 | Michael Hanselmann | OP_PARAMS = [ |
1198 | e1f23243 | Michael Hanselmann | _PEarlyRelease, |
1199 | e1f23243 | Michael Hanselmann | _PNodeName, |
1200 | e1f23243 | Michael Hanselmann | ("remote_node", None, ht.TMaybeString, "New secondary node"), |
1201 | e1f23243 | Michael Hanselmann | ("iallocator", None, ht.TMaybeString, "Iallocator for computing solution"), |
1202 | cb92e7a1 | Michael Hanselmann | ("mode", ht.NoDefault, ht.TElemOf(constants.NODE_EVAC_MODES),
|
1203 | e1f23243 | Michael Hanselmann | "Node evacuation mode"),
|
1204 | e1f23243 | Michael Hanselmann | ] |
1205 | 1456df62 | Michael Hanselmann | OP_RESULT = TJobIdListOnly |
1206 | e1f23243 | Michael Hanselmann | |
1207 | e1f23243 | Michael Hanselmann | |
1208 | a8083063 | Iustin Pop | # instance opcodes
|
1209 | a8083063 | Iustin Pop | |
1210 | e1530b10 | Iustin Pop | class OpInstanceCreate(OpCode): |
1211 | 9bf56d77 | Michael Hanselmann | """Create an instance.
|
1212 | 9bf56d77 | Michael Hanselmann |
|
1213 | 9bf56d77 | Michael Hanselmann | @ivar instance_name: Instance name
|
1214 | 9bf56d77 | Michael Hanselmann | @ivar mode: Instance creation mode (one of L{constants.INSTANCE_CREATE_MODES})
|
1215 | 9bf56d77 | Michael Hanselmann | @ivar source_handshake: Signed handshake from source (remote import only)
|
1216 | 9bf56d77 | Michael Hanselmann | @ivar source_x509_ca: Source X509 CA in PEM format (remote import only)
|
1217 | 9bf56d77 | Michael Hanselmann | @ivar source_instance_name: Previous name of instance (remote import only)
|
1218 | dae91d02 | Michael Hanselmann | @ivar source_shutdown_timeout: Shutdown timeout used for source instance
|
1219 | dae91d02 | Michael Hanselmann | (remote import only)
|
1220 | 9bf56d77 | Michael Hanselmann |
|
1221 | 9bf56d77 | Michael Hanselmann | """
|
1222 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
1223 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1224 | 65e183af | Michael Hanselmann | _PInstanceName, |
1225 | 45d4c81c | Michael Hanselmann | _PForceVariant, |
1226 | 45d4c81c | Michael Hanselmann | _PWaitForSync, |
1227 | 45d4c81c | Michael Hanselmann | _PNameCheck, |
1228 | 10889e0c | René Nussbaumer | _PIgnoreIpolicy, |
1229 | 45d4c81c | Michael Hanselmann | ("beparams", ht.EmptyDict, ht.TDict, "Backend parameters for instance"), |
1230 | 735e1318 | Michael Hanselmann | ("disks", ht.NoDefault, ht.TListOf(_TDiskParams),
|
1231 | 526a662a | Michael Hanselmann | "Disk descriptions, for example ``[{\"%s\": 100}, {\"%s\": 5}]``;"
|
1232 | 526a662a | Michael Hanselmann | " each disk definition must contain a ``%s`` value and"
|
1233 | 526a662a | Michael Hanselmann | " can contain an optional ``%s`` value denoting the disk access mode"
|
1234 | 526a662a | Michael Hanselmann | " (%s)" %
|
1235 | 526a662a | Michael Hanselmann | (constants.IDISK_SIZE, constants.IDISK_SIZE, constants.IDISK_SIZE, |
1236 | 526a662a | Michael Hanselmann | constants.IDISK_MODE, |
1237 | 526a662a | Michael Hanselmann | " or ".join("``%s``" % i for i in sorted(constants.DISK_ACCESS_SET)))), |
1238 | 45fe090b | Michael Hanselmann | ("disk_template", ht.NoDefault, _BuildDiskTemplateCheck(True), |
1239 | 45fe090b | Michael Hanselmann | "Disk template"),
|
1240 | 45d4c81c | Michael Hanselmann | ("file_driver", None, ht.TOr(ht.TNone, ht.TElemOf(constants.FILE_DRIVER)), |
1241 | 45d4c81c | Michael Hanselmann | "Driver for file-backed disks"),
|
1242 | 45d4c81c | Michael Hanselmann | ("file_storage_dir", None, ht.TMaybeString, |
1243 | 45d4c81c | Michael Hanselmann | "Directory for storing file-backed disks"),
|
1244 | 45d4c81c | Michael Hanselmann | ("hvparams", ht.EmptyDict, ht.TDict,
|
1245 | 45d4c81c | Michael Hanselmann | "Hypervisor parameters for instance, hypervisor-dependent"),
|
1246 | 45d4c81c | Michael Hanselmann | ("hypervisor", None, ht.TMaybeString, "Hypervisor"), |
1247 | 45d4c81c | Michael Hanselmann | ("iallocator", None, ht.TMaybeString, |
1248 | 45d4c81c | Michael Hanselmann | "Iallocator for deciding which node(s) to use"),
|
1249 | 45d4c81c | Michael Hanselmann | ("identify_defaults", False, ht.TBool, |
1250 | 45d4c81c | Michael Hanselmann | "Reset instance parameters to default if equal"),
|
1251 | 45d4c81c | Michael Hanselmann | ("ip_check", True, ht.TBool, _PIpCheckDoc), |
1252 | 176b0ee2 | Dimitris Aragiorgis | ("conflicts_check", True, ht.TBool, "Check for conflicting IPs"), |
1253 | 45d4c81c | Michael Hanselmann | ("mode", ht.NoDefault, ht.TElemOf(constants.INSTANCE_CREATE_MODES),
|
1254 | 45d4c81c | Michael Hanselmann | "Instance creation mode"),
|
1255 | 526a662a | Michael Hanselmann | ("nics", ht.NoDefault, ht.TListOf(_TestNicDef),
|
1256 | 526a662a | Michael Hanselmann | "List of NIC (network interface) definitions, for example"
|
1257 | 526a662a | Michael Hanselmann | " ``[{}, {}, {\"%s\": \"198.51.100.4\"}]``; each NIC definition can"
|
1258 | 526a662a | Michael Hanselmann | " contain the optional values %s" %
|
1259 | 526a662a | Michael Hanselmann | (constants.INIC_IP, |
1260 | 526a662a | Michael Hanselmann | ", ".join("``%s``" % i for i in sorted(constants.INIC_PARAMS)))), |
1261 | 45d4c81c | Michael Hanselmann | ("no_install", None, ht.TMaybeBool, |
1262 | 45d4c81c | Michael Hanselmann | "Do not install the OS (will disable automatic start)"),
|
1263 | 45d4c81c | Michael Hanselmann | ("osparams", ht.EmptyDict, ht.TDict, "OS parameters for instance"), |
1264 | 45d4c81c | Michael Hanselmann | ("os_type", None, ht.TMaybeString, "Operating system"), |
1265 | 45d4c81c | Michael Hanselmann | ("pnode", None, ht.TMaybeString, "Primary node"), |
1266 | 45d4c81c | Michael Hanselmann | ("snode", None, ht.TMaybeString, "Secondary node"), |
1267 | 45d4c81c | Michael Hanselmann | ("source_handshake", None, ht.TOr(ht.TList, ht.TNone), |
1268 | 45d4c81c | Michael Hanselmann | "Signed handshake from source (remote import only)"),
|
1269 | 45d4c81c | Michael Hanselmann | ("source_instance_name", None, ht.TMaybeString, |
1270 | 45d4c81c | Michael Hanselmann | "Source instance name (remote import only)"),
|
1271 | 65e183af | Michael Hanselmann | ("source_shutdown_timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT,
|
1272 | 526a662a | Michael Hanselmann | ht.TPositiveInt, |
1273 | 526a662a | Michael Hanselmann | "How long source instance was given to shut down (remote import only)"),
|
1274 | 45d4c81c | Michael Hanselmann | ("source_x509_ca", None, ht.TMaybeString, |
1275 | 45d4c81c | Michael Hanselmann | "Source X509 CA in PEM format (remote import only)"),
|
1276 | 45d4c81c | Michael Hanselmann | ("src_node", None, ht.TMaybeString, "Source node for import"), |
1277 | 45d4c81c | Michael Hanselmann | ("src_path", None, ht.TMaybeString, "Source directory for import"), |
1278 | 45d4c81c | Michael Hanselmann | ("start", True, ht.TBool, "Whether to start instance after creation"), |
1279 | 720f56c8 | Apollon Oikonomopoulos | ("tags", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), "Instance tags"), |
1280 | 3b6d8c9b | Iustin Pop | ] |
1281 | 1456df62 | Michael Hanselmann | OP_RESULT = ht.Comment("instance nodes")(ht.TListOf(ht.TNonEmptyString))
|
1282 | a8083063 | Iustin Pop | |
1283 | a8083063 | Iustin Pop | |
1284 | 5073fd8f | Iustin Pop | class OpInstanceReinstall(OpCode): |
1285 | fdc267f4 | Iustin Pop | """Reinstall an instance's OS."""
|
1286 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
1287 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1288 | 65e183af | Michael Hanselmann | _PInstanceName, |
1289 | 45d4c81c | Michael Hanselmann | _PForceVariant, |
1290 | 45d4c81c | Michael Hanselmann | ("os_type", None, ht.TMaybeString, "Instance operating system"), |
1291 | 45d4c81c | Michael Hanselmann | ("osparams", None, ht.TMaybeDict, "Temporary OS parameters"), |
1292 | 65e183af | Michael Hanselmann | ] |
1293 | c363310d | René Nussbaumer | OP_RESULT = ht.TNone |
1294 | fe7b0351 | Michael Hanselmann | |
1295 | fe7b0351 | Michael Hanselmann | |
1296 | 3cd2d4b1 | Iustin Pop | class OpInstanceRemove(OpCode): |
1297 | a8083063 | Iustin Pop | """Remove an instance."""
|
1298 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
1299 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1300 | 65e183af | Michael Hanselmann | _PInstanceName, |
1301 | 65e183af | Michael Hanselmann | _PShutdownTimeout, |
1302 | 45d4c81c | Michael Hanselmann | ("ignore_failures", False, ht.TBool, |
1303 | 45d4c81c | Michael Hanselmann | "Whether to ignore failures during removal"),
|
1304 | fc1baca9 | Michael Hanselmann | ] |
1305 | c363310d | René Nussbaumer | OP_RESULT = ht.TNone |
1306 | a8083063 | Iustin Pop | |
1307 | a8083063 | Iustin Pop | |
1308 | 5659e2e2 | Iustin Pop | class OpInstanceRename(OpCode): |
1309 | decd5f45 | Iustin Pop | """Rename an instance."""
|
1310 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1311 | 65e183af | Michael Hanselmann | _PInstanceName, |
1312 | 45d4c81c | Michael Hanselmann | _PNameCheck, |
1313 | 45d4c81c | Michael Hanselmann | ("new_name", ht.NoDefault, ht.TNonEmptyString, "New instance name"), |
1314 | 45d4c81c | Michael Hanselmann | ("ip_check", False, ht.TBool, _PIpCheckDoc), |
1315 | 4f05fd3b | Iustin Pop | ] |
1316 | 1456df62 | Michael Hanselmann | OP_RESULT = ht.Comment("New instance name")(ht.TNonEmptyString)
|
1317 | decd5f45 | Iustin Pop | |
1318 | decd5f45 | Iustin Pop | |
1319 | c873d91c | Iustin Pop | class OpInstanceStartup(OpCode): |
1320 | fdc267f4 | Iustin Pop | """Startup an instance."""
|
1321 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
1322 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1323 | 65e183af | Michael Hanselmann | _PInstanceName, |
1324 | 65e183af | Michael Hanselmann | _PForce, |
1325 | 65e183af | Michael Hanselmann | _PIgnoreOfflineNodes, |
1326 | 45d4c81c | Michael Hanselmann | ("hvparams", ht.EmptyDict, ht.TDict,
|
1327 | 45d4c81c | Michael Hanselmann | "Temporary hypervisor parameters, hypervisor-dependent"),
|
1328 | 45d4c81c | Michael Hanselmann | ("beparams", ht.EmptyDict, ht.TDict, "Temporary backend parameters"), |
1329 | 9b64e486 | Iustin Pop | _PNoRemember, |
1330 | 323f9095 | Stephen Shirley | _PStartupPaused, |
1331 | 4f05fd3b | Iustin Pop | ] |
1332 | c363310d | René Nussbaumer | OP_RESULT = ht.TNone |
1333 | a8083063 | Iustin Pop | |
1334 | a8083063 | Iustin Pop | |
1335 | ee3e37a7 | Iustin Pop | class OpInstanceShutdown(OpCode): |
1336 | fdc267f4 | Iustin Pop | """Shutdown an instance."""
|
1337 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
1338 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1339 | 65e183af | Michael Hanselmann | _PInstanceName, |
1340 | 65e183af | Michael Hanselmann | _PIgnoreOfflineNodes, |
1341 | 45d4c81c | Michael Hanselmann | ("timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT, ht.TPositiveInt,
|
1342 | 45d4c81c | Michael Hanselmann | "How long to wait for instance to shut down"),
|
1343 | 9b64e486 | Iustin Pop | _PNoRemember, |
1344 | b44bd844 | Michael Hanselmann | ] |
1345 | c363310d | René Nussbaumer | OP_RESULT = ht.TNone |
1346 | a8083063 | Iustin Pop | |
1347 | a8083063 | Iustin Pop | |
1348 | 90ab1a95 | Iustin Pop | class OpInstanceReboot(OpCode): |
1349 | bf6929a2 | Alexander Schreiber | """Reboot an instance."""
|
1350 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
1351 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1352 | 65e183af | Michael Hanselmann | _PInstanceName, |
1353 | 65e183af | Michael Hanselmann | _PShutdownTimeout, |
1354 | 45d4c81c | Michael Hanselmann | ("ignore_secondaries", False, ht.TBool, |
1355 | 45d4c81c | Michael Hanselmann | "Whether to start the instance even if secondary disks are failing"),
|
1356 | 45d4c81c | Michael Hanselmann | ("reboot_type", ht.NoDefault, ht.TElemOf(constants.REBOOT_TYPES),
|
1357 | 45d4c81c | Michael Hanselmann | "How to reboot instance"),
|
1358 | 4f05fd3b | Iustin Pop | ] |
1359 | c363310d | René Nussbaumer | OP_RESULT = ht.TNone |
1360 | bf6929a2 | Alexander Schreiber | |
1361 | bf6929a2 | Alexander Schreiber | |
1362 | 668f755d | Iustin Pop | class OpInstanceReplaceDisks(OpCode): |
1363 | fdc267f4 | Iustin Pop | """Replace the disks of an instance."""
|
1364 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
1365 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1366 | 65e183af | Michael Hanselmann | _PInstanceName, |
1367 | e1f23243 | Michael Hanselmann | _PEarlyRelease, |
1368 | d2fe2bfb | René Nussbaumer | _PIgnoreIpolicy, |
1369 | 45d4c81c | Michael Hanselmann | ("mode", ht.NoDefault, ht.TElemOf(constants.REPLACE_MODES),
|
1370 | 45d4c81c | Michael Hanselmann | "Replacement mode"),
|
1371 | 45d4c81c | Michael Hanselmann | ("disks", ht.EmptyList, ht.TListOf(ht.TPositiveInt),
|
1372 | 45d4c81c | Michael Hanselmann | "Disk indexes"),
|
1373 | 45d4c81c | Michael Hanselmann | ("remote_node", None, ht.TMaybeString, "New secondary node"), |
1374 | 45d4c81c | Michael Hanselmann | ("iallocator", None, ht.TMaybeString, |
1375 | 45d4c81c | Michael Hanselmann | "Iallocator for deciding new secondary node"),
|
1376 | 4f05fd3b | Iustin Pop | ] |
1377 | c363310d | René Nussbaumer | OP_RESULT = ht.TNone |
1378 | a8083063 | Iustin Pop | |
1379 | a8083063 | Iustin Pop | |
1380 | 019dbee1 | Iustin Pop | class OpInstanceFailover(OpCode): |
1381 | a8083063 | Iustin Pop | """Failover an instance."""
|
1382 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
1383 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1384 | 65e183af | Michael Hanselmann | _PInstanceName, |
1385 | 65e183af | Michael Hanselmann | _PShutdownTimeout, |
1386 | 45d4c81c | Michael Hanselmann | _PIgnoreConsistency, |
1387 | f8fa4175 | Michael Hanselmann | _PMigrationTargetNode, |
1388 | b6aaf437 | René Nussbaumer | _PIgnoreIpolicy, |
1389 | 8eb34306 | Apollon Oikonomopoulos | ("iallocator", None, ht.TMaybeString, |
1390 | 8eb34306 | Apollon Oikonomopoulos | "Iallocator for deciding the target node for shared-storage instances"),
|
1391 | 17c3f802 | Guido Trotter | ] |
1392 | c363310d | René Nussbaumer | OP_RESULT = ht.TNone |
1393 | a8083063 | Iustin Pop | |
1394 | a8083063 | Iustin Pop | |
1395 | 75c866c2 | Iustin Pop | class OpInstanceMigrate(OpCode): |
1396 | 53c776b5 | Iustin Pop | """Migrate an instance.
|
1397 | 53c776b5 | Iustin Pop |
|
1398 | 53c776b5 | Iustin Pop | This migrates (without shutting down an instance) to its secondary
|
1399 | 53c776b5 | Iustin Pop | node.
|
1400 | 53c776b5 | Iustin Pop |
|
1401 | 2f907a8c | Iustin Pop | @ivar instance_name: the name of the instance
|
1402 | 8c35561f | Iustin Pop | @ivar mode: the migration mode (live, non-live or None for auto)
|
1403 | 53c776b5 | Iustin Pop |
|
1404 | 53c776b5 | Iustin Pop | """
|
1405 | ee69c97f | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
1406 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1407 | 65e183af | Michael Hanselmann | _PInstanceName, |
1408 | 65e183af | Michael Hanselmann | _PMigrationMode, |
1409 | 65e183af | Michael Hanselmann | _PMigrationLive, |
1410 | f8fa4175 | Michael Hanselmann | _PMigrationTargetNode, |
1411 | 8c0b16f6 | Guido Trotter | _PAllowRuntimeChgs, |
1412 | 3ed23330 | René Nussbaumer | _PIgnoreIpolicy, |
1413 | 45d4c81c | Michael Hanselmann | ("cleanup", False, ht.TBool, |
1414 | 45d4c81c | Michael Hanselmann | "Whether a previously failed migration should be cleaned up"),
|
1415 | 8eb34306 | Apollon Oikonomopoulos | ("iallocator", None, ht.TMaybeString, |
1416 | 8eb34306 | Apollon Oikonomopoulos | "Iallocator for deciding the target node for shared-storage instances"),
|
1417 | d5cafd31 | René Nussbaumer | ("allow_failover", False, ht.TBool, |
1418 | d5cafd31 | René Nussbaumer | "Whether we can fallback to failover if migration is not possible"),
|
1419 | 65e183af | Michael Hanselmann | ] |
1420 | c363310d | René Nussbaumer | OP_RESULT = ht.TNone |
1421 | 53c776b5 | Iustin Pop | |
1422 | 53c776b5 | Iustin Pop | |
1423 | 0091b480 | Iustin Pop | class OpInstanceMove(OpCode): |
1424 | 313bcead | Iustin Pop | """Move an instance.
|
1425 | 313bcead | Iustin Pop |
|
1426 | 313bcead | Iustin Pop | This move (with shutting down an instance and data copying) to an
|
1427 | 313bcead | Iustin Pop | arbitrary node.
|
1428 | 313bcead | Iustin Pop |
|
1429 | 313bcead | Iustin Pop | @ivar instance_name: the name of the instance
|
1430 | 313bcead | Iustin Pop | @ivar target_node: the destination node
|
1431 | 313bcead | Iustin Pop |
|
1432 | 313bcead | Iustin Pop | """
|
1433 | 313bcead | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
1434 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1435 | 65e183af | Michael Hanselmann | _PInstanceName, |
1436 | 65e183af | Michael Hanselmann | _PShutdownTimeout, |
1437 | 92cf62e3 | René Nussbaumer | _PIgnoreIpolicy, |
1438 | 45d4c81c | Michael Hanselmann | ("target_node", ht.NoDefault, ht.TNonEmptyString, "Target node"), |
1439 | bb851c63 | Iustin Pop | _PIgnoreConsistency, |
1440 | 154b9580 | Balazs Lecz | ] |
1441 | c363310d | René Nussbaumer | OP_RESULT = ht.TNone |
1442 | 313bcead | Iustin Pop | |
1443 | 313bcead | Iustin Pop | |
1444 | cc0dec7b | Iustin Pop | class OpInstanceConsole(OpCode): |
1445 | fdc267f4 | Iustin Pop | """Connect to an instance's console."""
|
1446 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
1447 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1448 | 65e183af | Michael Hanselmann | _PInstanceName |
1449 | 65e183af | Michael Hanselmann | ] |
1450 | c363310d | René Nussbaumer | OP_RESULT = ht.TDict |
1451 | a8083063 | Iustin Pop | |
1452 | a8083063 | Iustin Pop | |
1453 | 83f5d475 | Iustin Pop | class OpInstanceActivateDisks(OpCode): |
1454 | fdc267f4 | Iustin Pop | """Activate an instance's disks."""
|
1455 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
1456 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1457 | 65e183af | Michael Hanselmann | _PInstanceName, |
1458 | 45d4c81c | Michael Hanselmann | ("ignore_size", False, ht.TBool, "Whether to ignore recorded size"), |
1459 | b69437c5 | Iustin Pop | _PWaitForSyncFalse, |
1460 | 65e183af | Michael Hanselmann | ] |
1461 | c363310d | René Nussbaumer | OP_RESULT = ht.TListOf(ht.TAnd(ht.TIsLength(3),
|
1462 | c363310d | René Nussbaumer | ht.TItems([ht.TNonEmptyString, |
1463 | c363310d | René Nussbaumer | ht.TNonEmptyString, |
1464 | c363310d | René Nussbaumer | ht.TNonEmptyString]))) |
1465 | a8083063 | Iustin Pop | |
1466 | a8083063 | Iustin Pop | |
1467 | e176281f | Iustin Pop | class OpInstanceDeactivateDisks(OpCode): |
1468 | fdc267f4 | Iustin Pop | """Deactivate an instance's disks."""
|
1469 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
1470 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1471 | c9c41373 | Iustin Pop | _PInstanceName, |
1472 | c9c41373 | Iustin Pop | _PForce, |
1473 | 65e183af | Michael Hanselmann | ] |
1474 | c363310d | René Nussbaumer | OP_RESULT = ht.TNone |
1475 | a8083063 | Iustin Pop | |
1476 | a8083063 | Iustin Pop | |
1477 | 6b273e78 | Iustin Pop | class OpInstanceRecreateDisks(OpCode): |
1478 | a52978c7 | Michael Hanselmann | """Recreate an instance's disks."""
|
1479 | 735e1318 | Michael Hanselmann | _TDiskChanges = \ |
1480 | 735e1318 | Michael Hanselmann | ht.TAnd(ht.TIsLength(2),
|
1481 | 735e1318 | Michael Hanselmann | ht.TItems([ht.Comment("Disk index")(ht.TPositiveInt),
|
1482 | 735e1318 | Michael Hanselmann | ht.Comment("Parameters")(_TDiskParams)]))
|
1483 | 735e1318 | Michael Hanselmann | |
1484 | bd315bfa | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
1485 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1486 | 65e183af | Michael Hanselmann | _PInstanceName, |
1487 | 735e1318 | Michael Hanselmann | ("disks", ht.EmptyList,
|
1488 | 735e1318 | Michael Hanselmann | ht.TOr(ht.TListOf(ht.TPositiveInt), ht.TListOf(_TDiskChanges)), |
1489 | 735e1318 | Michael Hanselmann | "List of disk indexes (deprecated) or a list of tuples containing a disk"
|
1490 | 735e1318 | Michael Hanselmann | " index and a possibly empty dictionary with disk parameter changes"),
|
1491 | 93384b8c | Guido Trotter | ("nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString),
|
1492 | 93384b8c | Guido Trotter | "New instance nodes, if relocation is desired"),
|
1493 | 65e183af | Michael Hanselmann | ] |
1494 | c363310d | René Nussbaumer | OP_RESULT = ht.TNone |
1495 | bd315bfa | Iustin Pop | |
1496 | bd315bfa | Iustin Pop | |
1497 | f2af0bec | Iustin Pop | class OpInstanceQuery(OpCode): |
1498 | a8083063 | Iustin Pop | """Compute the list of instances."""
|
1499 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1500 | 65e183af | Michael Hanselmann | _POutputFields, |
1501 | 45d4c81c | Michael Hanselmann | _PUseLocking, |
1502 | 45d4c81c | Michael Hanselmann | ("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString),
|
1503 | 45d4c81c | Michael Hanselmann | "Empty list to query all instances, instance names otherwise"),
|
1504 | 65e183af | Michael Hanselmann | ] |
1505 | 415feb2e | René Nussbaumer | OP_RESULT = _TOldQueryResult |
1506 | a8083063 | Iustin Pop | |
1507 | a8083063 | Iustin Pop | |
1508 | dc28c4e4 | Iustin Pop | class OpInstanceQueryData(OpCode): |
1509 | a8083063 | Iustin Pop | """Compute the run-time status of instances."""
|
1510 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1511 | af7b6689 | Michael Hanselmann | _PUseLocking, |
1512 | af7b6689 | Michael Hanselmann | ("instances", ht.EmptyList, ht.TListOf(ht.TNonEmptyString),
|
1513 | af7b6689 | Michael Hanselmann | "Instance names"),
|
1514 | af7b6689 | Michael Hanselmann | ("static", False, ht.TBool, |
1515 | af7b6689 | Michael Hanselmann | "Whether to only return configuration data without querying"
|
1516 | af7b6689 | Michael Hanselmann | " nodes"),
|
1517 | 65e183af | Michael Hanselmann | ] |
1518 | 415feb2e | René Nussbaumer | OP_RESULT = ht.TDictOf(ht.TNonEmptyString, ht.TDict) |
1519 | a8083063 | Iustin Pop | |
1520 | a8083063 | Iustin Pop | |
1521 | ddc1de7c | Michael Hanselmann | def _TestInstSetParamsModList(fn): |
1522 | ddc1de7c | Michael Hanselmann | """Generates a check for modification lists.
|
1523 | ddc1de7c | Michael Hanselmann |
|
1524 | ddc1de7c | Michael Hanselmann | """
|
1525 | e9c3d864 | Michael Hanselmann | # Old format
|
1526 | e9c3d864 | Michael Hanselmann | # TODO: Remove in version 2.8 including support in LUInstanceSetParams
|
1527 | e9c3d864 | Michael Hanselmann | old_mod_item_fn = \ |
1528 | ddc1de7c | Michael Hanselmann | ht.TAnd(ht.TIsLength(2), ht.TItems([
|
1529 | ddc1de7c | Michael Hanselmann | ht.TOr(ht.TElemOf(constants.DDMS_VALUES), ht.TPositiveInt), |
1530 | ddc1de7c | Michael Hanselmann | fn, |
1531 | ddc1de7c | Michael Hanselmann | ])) |
1532 | ddc1de7c | Michael Hanselmann | |
1533 | e9c3d864 | Michael Hanselmann | # New format, supporting adding/removing disks/NICs at arbitrary indices
|
1534 | e9c3d864 | Michael Hanselmann | mod_item_fn = \ |
1535 | e9c3d864 | Michael Hanselmann | ht.TAnd(ht.TIsLength(3), ht.TItems([
|
1536 | e9c3d864 | Michael Hanselmann | ht.TElemOf(constants.DDMS_VALUES_WITH_MODIFY), |
1537 | e9c3d864 | Michael Hanselmann | ht.Comment("Disk index, can be negative, e.g. -1 for last disk")(ht.TInt),
|
1538 | e9c3d864 | Michael Hanselmann | fn, |
1539 | e9c3d864 | Michael Hanselmann | ])) |
1540 | e9c3d864 | Michael Hanselmann | |
1541 | e9c3d864 | Michael Hanselmann | return ht.TOr(ht.Comment("Recommended")(ht.TListOf(mod_item_fn)), |
1542 | e9c3d864 | Michael Hanselmann | ht.Comment("Deprecated")(ht.TListOf(old_mod_item_fn)))
|
1543 | ddc1de7c | Michael Hanselmann | |
1544 | ddc1de7c | Michael Hanselmann | |
1545 | 9a3cc7ae | Iustin Pop | class OpInstanceSetParams(OpCode): |
1546 | ddc1de7c | Michael Hanselmann | """Change the parameters of an instance.
|
1547 | ddc1de7c | Michael Hanselmann |
|
1548 | ddc1de7c | Michael Hanselmann | """
|
1549 | a2aadb34 | Michael Hanselmann | TestNicModifications = _TestInstSetParamsModList(_TestNicDef) |
1550 | a2aadb34 | Michael Hanselmann | TestDiskModifications = _TestInstSetParamsModList(_TDiskParams) |
1551 | ddc1de7c | Michael Hanselmann | |
1552 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
1553 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1554 | 65e183af | Michael Hanselmann | _PInstanceName, |
1555 | 65e183af | Michael Hanselmann | _PForce, |
1556 | 45d4c81c | Michael Hanselmann | _PForceVariant, |
1557 | 1559e1e7 | René Nussbaumer | _PIgnoreIpolicy, |
1558 | a2aadb34 | Michael Hanselmann | ("nics", ht.EmptyList, TestNicModifications,
|
1559 | 0fb66bb1 | Iustin Pop | "List of NIC changes: each item is of the form ``(op, index, settings)``,"
|
1560 | 0fb66bb1 | Iustin Pop | " ``op`` is one of ``%s``, ``%s`` or ``%s``, ``index`` can be either -1"
|
1561 | 0fb66bb1 | Iustin Pop | " to refer to the last position, or a zero-based index number; a"
|
1562 | 0fb66bb1 | Iustin Pop | " deprecated version of this parameter used the form ``(op, settings)``,"
|
1563 | 0fb66bb1 | Iustin Pop | " where ``op`` can be ``%s`` to add a new NIC with the specified"
|
1564 | 0fb66bb1 | Iustin Pop | " settings, ``%s`` to remove the last NIC or a number to modify the"
|
1565 | 0fb66bb1 | Iustin Pop | " settings of the NIC with that index" %
|
1566 | e9c3d864 | Michael Hanselmann | (constants.DDM_ADD, constants.DDM_MODIFY, constants.DDM_REMOVE, |
1567 | e9c3d864 | Michael Hanselmann | constants.DDM_ADD, constants.DDM_REMOVE)), |
1568 | a2aadb34 | Michael Hanselmann | ("disks", ht.EmptyList, TestDiskModifications,
|
1569 | 0fb66bb1 | Iustin Pop | "List of disk changes; see ``nics``"),
|
1570 | 45d4c81c | Michael Hanselmann | ("beparams", ht.EmptyDict, ht.TDict, "Per-instance backend parameters"), |
1571 | 2c0af7da | Guido Trotter | ("runtime_mem", None, ht.TMaybeStrictPositiveInt, "New runtime memory"), |
1572 | 45d4c81c | Michael Hanselmann | ("hvparams", ht.EmptyDict, ht.TDict,
|
1573 | 45d4c81c | Michael Hanselmann | "Per-instance hypervisor parameters, hypervisor-dependent"),
|
1574 | 45fe090b | Michael Hanselmann | ("disk_template", None, ht.TOr(ht.TNone, _BuildDiskTemplateCheck(False)), |
1575 | 45d4c81c | Michael Hanselmann | "Disk template for instance"),
|
1576 | 45d4c81c | Michael Hanselmann | ("remote_node", None, ht.TMaybeString, |
1577 | 45d4c81c | Michael Hanselmann | "Secondary node (used when changing disk template)"),
|
1578 | 45d4c81c | Michael Hanselmann | ("os_name", None, ht.TMaybeString, |
1579 | 0fb66bb1 | Iustin Pop | "Change the instance's OS without reinstalling the instance"),
|
1580 | 45d4c81c | Michael Hanselmann | ("osparams", None, ht.TMaybeDict, "Per-instance OS parameters"), |
1581 | 93384b8c | Guido Trotter | ("wait_for_sync", True, ht.TBool, |
1582 | 93384b8c | Guido Trotter | "Whether to wait for the disk to synchronize, when changing template"),
|
1583 | 3016bc1f | Michael Hanselmann | ("offline", None, ht.TMaybeBool, "Whether to mark instance as offline"), |
1584 | 176b0ee2 | Dimitris Aragiorgis | ("conflicts_check", True, ht.TBool, "Check for conflicting IPs"), |
1585 | 973d7867 | Iustin Pop | ] |
1586 | 1456df62 | Michael Hanselmann | OP_RESULT = _TSetParamsResult |
1587 | a8083063 | Iustin Pop | |
1588 | a8083063 | Iustin Pop | |
1589 | 60472d29 | Iustin Pop | class OpInstanceGrowDisk(OpCode): |
1590 | 8729e0d7 | Iustin Pop | """Grow a disk of an instance."""
|
1591 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
1592 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1593 | 65e183af | Michael Hanselmann | _PInstanceName, |
1594 | 45d4c81c | Michael Hanselmann | _PWaitForSync, |
1595 | 45d4c81c | Michael Hanselmann | ("disk", ht.NoDefault, ht.TInt, "Disk index"), |
1596 | fa47242b | Iustin Pop | ("amount", ht.NoDefault, ht.TPositiveInt,
|
1597 | 45d4c81c | Michael Hanselmann | "Amount of disk space to add (megabytes)"),
|
1598 | e7f99087 | Iustin Pop | ("absolute", False, ht.TBool, |
1599 | e7f99087 | Iustin Pop | "Whether the amount parameter is an absolute target or a relative one"),
|
1600 | 4f05fd3b | Iustin Pop | ] |
1601 | c363310d | René Nussbaumer | OP_RESULT = ht.TNone |
1602 | 8729e0d7 | Iustin Pop | |
1603 | 8729e0d7 | Iustin Pop | |
1604 | 1aef3df8 | Michael Hanselmann | class OpInstanceChangeGroup(OpCode): |
1605 | 1aef3df8 | Michael Hanselmann | """Moves an instance to another node group."""
|
1606 | 1aef3df8 | Michael Hanselmann | OP_DSC_FIELD = "instance_name"
|
1607 | 1aef3df8 | Michael Hanselmann | OP_PARAMS = [ |
1608 | 1aef3df8 | Michael Hanselmann | _PInstanceName, |
1609 | 1aef3df8 | Michael Hanselmann | _PEarlyRelease, |
1610 | 1aef3df8 | Michael Hanselmann | ("iallocator", None, ht.TMaybeString, "Iallocator for computing solution"), |
1611 | ff8067cf | Michael Hanselmann | ("target_groups", None, ht.TMaybeListOf(ht.TNonEmptyString), |
1612 | 1aef3df8 | Michael Hanselmann | "Destination group names or UUIDs (defaults to \"all but current group\""),
|
1613 | 1aef3df8 | Michael Hanselmann | ] |
1614 | 1456df62 | Michael Hanselmann | OP_RESULT = TJobIdListOnly |
1615 | 1aef3df8 | Michael Hanselmann | |
1616 | 1aef3df8 | Michael Hanselmann | |
1617 | 70a6a926 | Adeodato Simo | # Node group opcodes
|
1618 | 70a6a926 | Adeodato Simo | |
1619 | fabf1731 | Iustin Pop | class OpGroupAdd(OpCode): |
1620 | b1ee5610 | Adeodato Simo | """Add a node group to the cluster."""
|
1621 | b1ee5610 | Adeodato Simo | OP_DSC_FIELD = "group_name"
|
1622 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1623 | 65e183af | Michael Hanselmann | _PGroupName, |
1624 | 45d4c81c | Michael Hanselmann | _PNodeGroupAllocPolicy, |
1625 | 45d4c81c | Michael Hanselmann | _PGroupNodeParams, |
1626 | bc5d0215 | Andrea Spadaccini | _PDiskParams, |
1627 | e4c03256 | René Nussbaumer | _PHvState, |
1628 | e4c03256 | René Nussbaumer | _PDiskState, |
1629 | 1b01390b | René Nussbaumer | ("ipolicy", None, ht.TMaybeDict, |
1630 | 1b01390b | René Nussbaumer | "Group-wide :ref:`instance policy <rapi-ipolicy>` specs"),
|
1631 | 483be60d | Adeodato Simo | ] |
1632 | c363310d | René Nussbaumer | OP_RESULT = ht.TNone |
1633 | b1ee5610 | Adeodato Simo | |
1634 | b1ee5610 | Adeodato Simo | |
1635 | 934704ae | Iustin Pop | class OpGroupAssignNodes(OpCode): |
1636 | 96276ae7 | Adeodato Simo | """Assign nodes to a node group."""
|
1637 | 96276ae7 | Adeodato Simo | OP_DSC_FIELD = "group_name"
|
1638 | 96276ae7 | Adeodato Simo | OP_PARAMS = [ |
1639 | 96276ae7 | Adeodato Simo | _PGroupName, |
1640 | 96276ae7 | Adeodato Simo | _PForce, |
1641 | 45d4c81c | Michael Hanselmann | ("nodes", ht.NoDefault, ht.TListOf(ht.TNonEmptyString),
|
1642 | 45d4c81c | Michael Hanselmann | "List of nodes to assign"),
|
1643 | 96276ae7 | Adeodato Simo | ] |
1644 | c363310d | René Nussbaumer | OP_RESULT = ht.TNone |
1645 | 96276ae7 | Adeodato Simo | |
1646 | 96276ae7 | Adeodato Simo | |
1647 | d4d654bd | Iustin Pop | class OpGroupQuery(OpCode): |
1648 | 70a6a926 | Adeodato Simo | """Compute the list of node groups."""
|
1649 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1650 | 65e183af | Michael Hanselmann | _POutputFields, |
1651 | 45d4c81c | Michael Hanselmann | ("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString),
|
1652 | 45d4c81c | Michael Hanselmann | "Empty list to query all groups, group names otherwise"),
|
1653 | 65e183af | Michael Hanselmann | ] |
1654 | 415feb2e | René Nussbaumer | OP_RESULT = _TOldQueryResult |
1655 | 70a6a926 | Adeodato Simo | |
1656 | 70a6a926 | Adeodato Simo | |
1657 | 7cbf74f0 | Iustin Pop | class OpGroupSetParams(OpCode): |
1658 | 4da7909a | Adeodato Simo | """Change the parameters of a node group."""
|
1659 | 4da7909a | Adeodato Simo | OP_DSC_FIELD = "group_name"
|
1660 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1661 | 65e183af | Michael Hanselmann | _PGroupName, |
1662 | 45d4c81c | Michael Hanselmann | _PNodeGroupAllocPolicy, |
1663 | 45d4c81c | Michael Hanselmann | _PGroupNodeParams, |
1664 | bc5d0215 | Andrea Spadaccini | _PDiskParams, |
1665 | a8282327 | René Nussbaumer | _PHvState, |
1666 | a8282327 | René Nussbaumer | _PDiskState, |
1667 | fb644e77 | Agata Murawska | ("ipolicy", None, ht.TMaybeDict, "Group-wide instance policy specs"), |
1668 | 4da7909a | Adeodato Simo | ] |
1669 | 1456df62 | Michael Hanselmann | OP_RESULT = _TSetParamsResult |
1670 | 4da7909a | Adeodato Simo | |
1671 | 4da7909a | Adeodato Simo | |
1672 | 4d1baa51 | Iustin Pop | class OpGroupRemove(OpCode): |
1673 | 94bd652a | Adeodato Simo | """Remove a node group from the cluster."""
|
1674 | 94bd652a | Adeodato Simo | OP_DSC_FIELD = "group_name"
|
1675 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1676 | 65e183af | Michael Hanselmann | _PGroupName, |
1677 | 65e183af | Michael Hanselmann | ] |
1678 | c363310d | René Nussbaumer | OP_RESULT = ht.TNone |
1679 | 94bd652a | Adeodato Simo | |
1680 | 94bd652a | Adeodato Simo | |
1681 | a8173e82 | Iustin Pop | class OpGroupRename(OpCode): |
1682 | 4fe5cf90 | Adeodato Simo | """Rename a node group in the cluster."""
|
1683 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1684 | 12da663a | Michael Hanselmann | _PGroupName, |
1685 | 12da663a | Michael Hanselmann | ("new_name", ht.NoDefault, ht.TNonEmptyString, "New group name"), |
1686 | 65e183af | Michael Hanselmann | ] |
1687 | 1456df62 | Michael Hanselmann | OP_RESULT = ht.Comment("New group name")(ht.TNonEmptyString)
|
1688 | 4fe5cf90 | Adeodato Simo | |
1689 | 4fe5cf90 | Adeodato Simo | |
1690 | 08f8c82c | Michael Hanselmann | class OpGroupEvacuate(OpCode): |
1691 | 08f8c82c | Michael Hanselmann | """Evacuate a node group in the cluster."""
|
1692 | 08f8c82c | Michael Hanselmann | OP_DSC_FIELD = "group_name"
|
1693 | 08f8c82c | Michael Hanselmann | OP_PARAMS = [ |
1694 | 08f8c82c | Michael Hanselmann | _PGroupName, |
1695 | 08f8c82c | Michael Hanselmann | _PEarlyRelease, |
1696 | 08f8c82c | Michael Hanselmann | ("iallocator", None, ht.TMaybeString, "Iallocator for computing solution"), |
1697 | ff8067cf | Michael Hanselmann | ("target_groups", None, ht.TMaybeListOf(ht.TNonEmptyString), |
1698 | 08f8c82c | Michael Hanselmann | "Destination group names or UUIDs"),
|
1699 | 08f8c82c | Michael Hanselmann | ] |
1700 | 1456df62 | Michael Hanselmann | OP_RESULT = TJobIdListOnly |
1701 | 08f8c82c | Michael Hanselmann | |
1702 | 08f8c82c | Michael Hanselmann | |
1703 | a8083063 | Iustin Pop | # OS opcodes
|
1704 | da2d02e7 | Iustin Pop | class OpOsDiagnose(OpCode): |
1705 | a8083063 | Iustin Pop | """Compute the list of guest operating systems."""
|
1706 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1707 | 65e183af | Michael Hanselmann | _POutputFields, |
1708 | 45d4c81c | Michael Hanselmann | ("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString),
|
1709 | 45d4c81c | Michael Hanselmann | "Which operating systems to diagnose"),
|
1710 | 65e183af | Michael Hanselmann | ] |
1711 | 415feb2e | René Nussbaumer | OP_RESULT = _TOldQueryResult |
1712 | a8083063 | Iustin Pop | |
1713 | 7c0d6283 | Michael Hanselmann | |
1714 | a8083063 | Iustin Pop | # Exports opcodes
|
1715 | 7ca2d4d8 | Iustin Pop | class OpBackupQuery(OpCode): |
1716 | a8083063 | Iustin Pop | """Compute the list of exported images."""
|
1717 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1718 | 45d4c81c | Michael Hanselmann | _PUseLocking, |
1719 | 45d4c81c | Michael Hanselmann | ("nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString),
|
1720 | 45d4c81c | Michael Hanselmann | "Empty list to query all nodes, node names otherwise"),
|
1721 | 65e183af | Michael Hanselmann | ] |
1722 | 202fb4e0 | Michael Hanselmann | OP_RESULT = ht.TDictOf(ht.TNonEmptyString, |
1723 | 202fb4e0 | Michael Hanselmann | ht.TOr(ht.Comment("False on error")(ht.TBool),
|
1724 | 202fb4e0 | Michael Hanselmann | ht.TListOf(ht.TNonEmptyString))) |
1725 | a8083063 | Iustin Pop | |
1726 | 7c0d6283 | Michael Hanselmann | |
1727 | 71910715 | Iustin Pop | class OpBackupPrepare(OpCode): |
1728 | 1410fa8d | Michael Hanselmann | """Prepares an instance export.
|
1729 | 1410fa8d | Michael Hanselmann |
|
1730 | 1410fa8d | Michael Hanselmann | @ivar instance_name: Instance name
|
1731 | 1410fa8d | Michael Hanselmann | @ivar mode: Export mode (one of L{constants.EXPORT_MODES})
|
1732 | 1410fa8d | Michael Hanselmann |
|
1733 | 1410fa8d | Michael Hanselmann | """
|
1734 | 1410fa8d | Michael Hanselmann | OP_DSC_FIELD = "instance_name"
|
1735 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1736 | 65e183af | Michael Hanselmann | _PInstanceName, |
1737 | 45d4c81c | Michael Hanselmann | ("mode", ht.NoDefault, ht.TElemOf(constants.EXPORT_MODES),
|
1738 | 45d4c81c | Michael Hanselmann | "Export mode"),
|
1739 | 1410fa8d | Michael Hanselmann | ] |
1740 | c363310d | René Nussbaumer | OP_RESULT = ht.TOr(ht.TNone, ht.TDict) |
1741 | 1410fa8d | Michael Hanselmann | |
1742 | 1410fa8d | Michael Hanselmann | |
1743 | 4ff922a2 | Iustin Pop | class OpBackupExport(OpCode): |
1744 | 4a96f1d1 | Michael Hanselmann | """Export an instance.
|
1745 | 4a96f1d1 | Michael Hanselmann |
|
1746 | 4a96f1d1 | Michael Hanselmann | For local exports, the export destination is the node name. For remote
|
1747 | 4a96f1d1 | Michael Hanselmann | exports, the export destination is a list of tuples, each consisting of
|
1748 | 4a96f1d1 | Michael Hanselmann | hostname/IP address, port, HMAC and HMAC salt. The HMAC is calculated using
|
1749 | 4a96f1d1 | Michael Hanselmann | the cluster domain secret over the value "${index}:${hostname}:${port}". The
|
1750 | 4a96f1d1 | Michael Hanselmann | destination X509 CA must be a signed certificate.
|
1751 | 4a96f1d1 | Michael Hanselmann |
|
1752 | 4a96f1d1 | Michael Hanselmann | @ivar mode: Export mode (one of L{constants.EXPORT_MODES})
|
1753 | 4a96f1d1 | Michael Hanselmann | @ivar target_node: Export destination
|
1754 | 4a96f1d1 | Michael Hanselmann | @ivar x509_key_name: X509 key to use (remote export only)
|
1755 | 4a96f1d1 | Michael Hanselmann | @ivar destination_x509_ca: Destination X509 CA in PEM format (remote export
|
1756 | 4a96f1d1 | Michael Hanselmann | only)
|
1757 | 4a96f1d1 | Michael Hanselmann |
|
1758 | 4a96f1d1 | Michael Hanselmann | """
|
1759 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
1760 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1761 | 65e183af | Michael Hanselmann | _PInstanceName, |
1762 | 65e183af | Michael Hanselmann | _PShutdownTimeout, |
1763 | 4a96f1d1 | Michael Hanselmann | # TODO: Rename target_node as it changes meaning for different export modes
|
1764 | 4a96f1d1 | Michael Hanselmann | # (e.g. "destination")
|
1765 | 45d4c81c | Michael Hanselmann | ("target_node", ht.NoDefault, ht.TOr(ht.TNonEmptyString, ht.TList),
|
1766 | 45d4c81c | Michael Hanselmann | "Destination information, depends on export mode"),
|
1767 | 45d4c81c | Michael Hanselmann | ("shutdown", True, ht.TBool, "Whether to shutdown instance before export"), |
1768 | 45d4c81c | Michael Hanselmann | ("remove_instance", False, ht.TBool, |
1769 | 45d4c81c | Michael Hanselmann | "Whether to remove instance after export"),
|
1770 | 45d4c81c | Michael Hanselmann | ("ignore_remove_failures", False, ht.TBool, |
1771 | 45d4c81c | Michael Hanselmann | "Whether to ignore failures while removing instances"),
|
1772 | 45d4c81c | Michael Hanselmann | ("mode", constants.EXPORT_MODE_LOCAL, ht.TElemOf(constants.EXPORT_MODES),
|
1773 | 45d4c81c | Michael Hanselmann | "Export mode"),
|
1774 | 45d4c81c | Michael Hanselmann | ("x509_key_name", None, ht.TOr(ht.TList, ht.TNone), |
1775 | 45d4c81c | Michael Hanselmann | "Name of X509 key (remote export only)"),
|
1776 | 45d4c81c | Michael Hanselmann | ("destination_x509_ca", None, ht.TMaybeString, |
1777 | 45d4c81c | Michael Hanselmann | "Destination X509 CA (remote export only)"),
|
1778 | 17c3f802 | Guido Trotter | ] |
1779 | 202fb4e0 | Michael Hanselmann | OP_RESULT = \ |
1780 | 202fb4e0 | Michael Hanselmann | ht.TAnd(ht.TIsLength(2), ht.TItems([
|
1781 | 202fb4e0 | Michael Hanselmann | ht.Comment("Finalizing status")(ht.TBool),
|
1782 | 202fb4e0 | Michael Hanselmann | ht.Comment("Status for every exported disk")(ht.TListOf(ht.TBool)),
|
1783 | 202fb4e0 | Michael Hanselmann | ])) |
1784 | 5c947f38 | Iustin Pop | |
1785 | 0a7bed64 | Michael Hanselmann | |
1786 | ca5890ad | Iustin Pop | class OpBackupRemove(OpCode): |
1787 | 9ac99fda | Guido Trotter | """Remove an instance's export."""
|
1788 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "instance_name"
|
1789 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1790 | 65e183af | Michael Hanselmann | _PInstanceName, |
1791 | 65e183af | Michael Hanselmann | ] |
1792 | 202fb4e0 | Michael Hanselmann | OP_RESULT = ht.TNone |
1793 | 5c947f38 | Iustin Pop | |
1794 | 0a7bed64 | Michael Hanselmann | |
1795 | 5c947f38 | Iustin Pop | # Tags opcodes
|
1796 | c6afb1ca | Iustin Pop | class OpTagsGet(OpCode): |
1797 | 5c947f38 | Iustin Pop | """Returns the tags of the given object."""
|
1798 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "name"
|
1799 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1800 | 65e183af | Michael Hanselmann | _PTagKind, |
1801 | cfdf561d | Michael Hanselmann | # Not using _PUseLocking as the default is different for historical reasons
|
1802 | cfdf561d | Michael Hanselmann | ("use_locking", True, ht.TBool, "Whether to use synchronization"), |
1803 | 65e183af | Michael Hanselmann | # Name is only meaningful for nodes and instances
|
1804 | 971b3a98 | Michael Hanselmann | ("name", ht.NoDefault, ht.TMaybeString,
|
1805 | 971b3a98 | Michael Hanselmann | "Name of object to retrieve tags from"),
|
1806 | 65e183af | Michael Hanselmann | ] |
1807 | 48796673 | Michael Hanselmann | OP_RESULT = ht.TListOf(ht.TNonEmptyString) |
1808 | 5c947f38 | Iustin Pop | |
1809 | 5c947f38 | Iustin Pop | |
1810 | 715462e7 | Iustin Pop | class OpTagsSearch(OpCode): |
1811 | 73415719 | Iustin Pop | """Searches the tags in the cluster for a given pattern."""
|
1812 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "pattern"
|
1813 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1814 | 971b3a98 | Michael Hanselmann | ("pattern", ht.NoDefault, ht.TNonEmptyString,
|
1815 | 971b3a98 | Michael Hanselmann | "Search pattern (regular expression)"),
|
1816 | 65e183af | Michael Hanselmann | ] |
1817 | 48796673 | Michael Hanselmann | OP_RESULT = ht.TListOf(ht.TAnd(ht.TIsLength(2), ht.TItems([
|
1818 | 48796673 | Michael Hanselmann | ht.TNonEmptyString, |
1819 | 48796673 | Michael Hanselmann | ht.TNonEmptyString, |
1820 | 48796673 | Michael Hanselmann | ]))) |
1821 | 73415719 | Iustin Pop | |
1822 | 73415719 | Iustin Pop | |
1823 | d1602edc | Iustin Pop | class OpTagsSet(OpCode): |
1824 | f27302fa | Iustin Pop | """Add a list of tags on a given object."""
|
1825 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1826 | 65e183af | Michael Hanselmann | _PTagKind, |
1827 | 65e183af | Michael Hanselmann | _PTags, |
1828 | 65e183af | Michael Hanselmann | # Name is only meaningful for nodes and instances
|
1829 | 971b3a98 | Michael Hanselmann | ("name", ht.NoDefault, ht.TMaybeString,
|
1830 | 971b3a98 | Michael Hanselmann | "Name of object where tag(s) should be added"),
|
1831 | 65e183af | Michael Hanselmann | ] |
1832 | 48796673 | Michael Hanselmann | OP_RESULT = ht.TNone |
1833 | 5c947f38 | Iustin Pop | |
1834 | 5c947f38 | Iustin Pop | |
1835 | 3f0ab95f | Iustin Pop | class OpTagsDel(OpCode): |
1836 | f27302fa | Iustin Pop | """Remove a list of tags from a given object."""
|
1837 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1838 | 65e183af | Michael Hanselmann | _PTagKind, |
1839 | 65e183af | Michael Hanselmann | _PTags, |
1840 | 65e183af | Michael Hanselmann | # Name is only meaningful for nodes and instances
|
1841 | 971b3a98 | Michael Hanselmann | ("name", ht.NoDefault, ht.TMaybeString,
|
1842 | 971b3a98 | Michael Hanselmann | "Name of object where tag(s) should be deleted"),
|
1843 | 65e183af | Michael Hanselmann | ] |
1844 | 48796673 | Michael Hanselmann | OP_RESULT = ht.TNone |
1845 | 06009e27 | Iustin Pop | |
1846 | e687ec01 | Michael Hanselmann | |
1847 | 06009e27 | Iustin Pop | # Test opcodes
|
1848 | 06009e27 | Iustin Pop | class OpTestDelay(OpCode): |
1849 | 06009e27 | Iustin Pop | """Sleeps for a configured amount of time.
|
1850 | 06009e27 | Iustin Pop |
|
1851 | 06009e27 | Iustin Pop | This is used just for debugging and testing.
|
1852 | 06009e27 | Iustin Pop |
|
1853 | 06009e27 | Iustin Pop | Parameters:
|
1854 | 06009e27 | Iustin Pop | - duration: the time to sleep
|
1855 | 06009e27 | Iustin Pop | - on_master: if true, sleep on the master
|
1856 | 06009e27 | Iustin Pop | - on_nodes: list of nodes in which to sleep
|
1857 | 06009e27 | Iustin Pop |
|
1858 | 06009e27 | Iustin Pop | If the on_master parameter is true, it will execute a sleep on the
|
1859 | 06009e27 | Iustin Pop | master (before any node sleep).
|
1860 | 06009e27 | Iustin Pop |
|
1861 | 06009e27 | Iustin Pop | If the on_nodes list is not empty, it will sleep on those nodes
|
1862 | 06009e27 | Iustin Pop | (after the sleep on the master, if that is enabled).
|
1863 | 06009e27 | Iustin Pop |
|
1864 | 06009e27 | Iustin Pop | As an additional feature, the case of duration < 0 will be reported
|
1865 | 06009e27 | Iustin Pop | as an execution error, so this opcode can be used as a failure
|
1866 | 06009e27 | Iustin Pop | generator. The case of duration == 0 will not be treated specially.
|
1867 | 06009e27 | Iustin Pop |
|
1868 | 06009e27 | Iustin Pop | """
|
1869 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "duration"
|
1870 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1871 | b795a775 | Michael Hanselmann | ("duration", ht.NoDefault, ht.TNumber, None), |
1872 | 197b323b | Michael Hanselmann | ("on_master", True, ht.TBool, None), |
1873 | 197b323b | Michael Hanselmann | ("on_nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), None), |
1874 | 197b323b | Michael Hanselmann | ("repeat", 0, ht.TPositiveInt, None), |
1875 | 65e183af | Michael Hanselmann | ] |
1876 | d61df03e | Iustin Pop | |
1877 | d61df03e | Iustin Pop | |
1878 | d61df03e | Iustin Pop | class OpTestAllocator(OpCode): |
1879 | d61df03e | Iustin Pop | """Allocator framework testing.
|
1880 | d61df03e | Iustin Pop |
|
1881 | d61df03e | Iustin Pop | This opcode has two modes:
|
1882 | d61df03e | Iustin Pop | - gather and return allocator input for a given mode (allocate new
|
1883 | d61df03e | Iustin Pop | or replace secondary) and a given instance definition (direction
|
1884 | d61df03e | Iustin Pop | 'in')
|
1885 | d61df03e | Iustin Pop | - run a selected allocator for a given operation (as above) and
|
1886 | d61df03e | Iustin Pop | return the allocator output (direction 'out')
|
1887 | d61df03e | Iustin Pop |
|
1888 | d61df03e | Iustin Pop | """
|
1889 | 60dd1473 | Iustin Pop | OP_DSC_FIELD = "allocator"
|
1890 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1891 | 65e183af | Michael Hanselmann | ("direction", ht.NoDefault,
|
1892 | 197b323b | Michael Hanselmann | ht.TElemOf(constants.VALID_IALLOCATOR_DIRECTIONS), None),
|
1893 | 197b323b | Michael Hanselmann | ("mode", ht.NoDefault, ht.TElemOf(constants.VALID_IALLOCATOR_MODES), None), |
1894 | 197b323b | Michael Hanselmann | ("name", ht.NoDefault, ht.TNonEmptyString, None), |
1895 | ff8067cf | Michael Hanselmann | ("nics", ht.NoDefault,
|
1896 | ff8067cf | Michael Hanselmann | ht.TMaybeListOf(ht.TDictOf(ht.TElemOf([constants.INIC_MAC, |
1897 | ff8067cf | Michael Hanselmann | constants.INIC_IP, |
1898 | ff8067cf | Michael Hanselmann | "bridge"]),
|
1899 | ff8067cf | Michael Hanselmann | ht.TOr(ht.TNone, ht.TNonEmptyString))), |
1900 | ff8067cf | Michael Hanselmann | None),
|
1901 | 197b323b | Michael Hanselmann | ("disks", ht.NoDefault, ht.TOr(ht.TNone, ht.TList), None), |
1902 | 197b323b | Michael Hanselmann | ("hypervisor", None, ht.TMaybeString, None), |
1903 | 197b323b | Michael Hanselmann | ("allocator", None, ht.TMaybeString, None), |
1904 | 197b323b | Michael Hanselmann | ("tags", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), None), |
1905 | dd47a0f0 | Iustin Pop | ("memory", None, ht.TOr(ht.TNone, ht.TPositiveInt), None), |
1906 | 197b323b | Michael Hanselmann | ("vcpus", None, ht.TOr(ht.TNone, ht.TPositiveInt), None), |
1907 | 197b323b | Michael Hanselmann | ("os", None, ht.TMaybeString, None), |
1908 | 197b323b | Michael Hanselmann | ("disk_template", None, ht.TMaybeString, None), |
1909 | ff8067cf | Michael Hanselmann | ("instances", None, ht.TMaybeListOf(ht.TNonEmptyString), None), |
1910 | 60152bbe | Michael Hanselmann | ("evac_mode", None, |
1911 | 60152bbe | Michael Hanselmann | ht.TOr(ht.TNone, ht.TElemOf(constants.IALLOCATOR_NEVAC_MODES)), None),
|
1912 | ff8067cf | Michael Hanselmann | ("target_groups", None, ht.TMaybeListOf(ht.TNonEmptyString), None), |
1913 | d61df03e | Iustin Pop | ] |
1914 | 363acb1e | Iustin Pop | |
1915 | 76aef8fc | Michael Hanselmann | |
1916 | b469eb4d | Iustin Pop | class OpTestJqueue(OpCode): |
1917 | e58f87a9 | Michael Hanselmann | """Utility opcode to test some aspects of the job queue.
|
1918 | e58f87a9 | Michael Hanselmann |
|
1919 | e58f87a9 | Michael Hanselmann | """
|
1920 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1921 | 197b323b | Michael Hanselmann | ("notify_waitlock", False, ht.TBool, None), |
1922 | 197b323b | Michael Hanselmann | ("notify_exec", False, ht.TBool, None), |
1923 | 197b323b | Michael Hanselmann | ("log_messages", ht.EmptyList, ht.TListOf(ht.TString), None), |
1924 | 197b323b | Michael Hanselmann | ("fail", False, ht.TBool, None), |
1925 | e58f87a9 | Michael Hanselmann | ] |
1926 | e58f87a9 | Michael Hanselmann | |
1927 | e58f87a9 | Michael Hanselmann | |
1928 | be760ba8 | Michael Hanselmann | class OpTestDummy(OpCode): |
1929 | be760ba8 | Michael Hanselmann | """Utility opcode used by unittests.
|
1930 | be760ba8 | Michael Hanselmann |
|
1931 | be760ba8 | Michael Hanselmann | """
|
1932 | 65e183af | Michael Hanselmann | OP_PARAMS = [ |
1933 | 197b323b | Michael Hanselmann | ("result", ht.NoDefault, ht.NoType, None), |
1934 | 197b323b | Michael Hanselmann | ("messages", ht.NoDefault, ht.NoType, None), |
1935 | 197b323b | Michael Hanselmann | ("fail", ht.NoDefault, ht.NoType, None), |
1936 | 6a373640 | Michael Hanselmann | ("submit_jobs", None, ht.NoType, None), |
1937 | be760ba8 | Michael Hanselmann | ] |
1938 | 687c10d9 | Iustin Pop | WITH_LU = False
|
1939 | be760ba8 | Michael Hanselmann | |
1940 | be760ba8 | Michael Hanselmann | |
1941 | 176b0ee2 | Dimitris Aragiorgis | # Network opcodes
|
1942 | 176b0ee2 | Dimitris Aragiorgis | # Add a new network in the cluster
|
1943 | 176b0ee2 | Dimitris Aragiorgis | class OpNetworkAdd(OpCode): |
1944 | 176b0ee2 | Dimitris Aragiorgis | """Add an IP network to the cluster."""
|
1945 | 176b0ee2 | Dimitris Aragiorgis | OP_DSC_FIELD = "network_name"
|
1946 | 176b0ee2 | Dimitris Aragiorgis | OP_PARAMS = [ |
1947 | 176b0ee2 | Dimitris Aragiorgis | _PNetworkName, |
1948 | 176b0ee2 | Dimitris Aragiorgis | _PNetworkType, |
1949 | 176b0ee2 | Dimitris Aragiorgis | ("network", None, ht.TAnd(ht.TString ,_CheckCIDRNetNotation), None), |
1950 | 176b0ee2 | Dimitris Aragiorgis | ("gateway", None, ht.TOr(ht.TNone, _CheckCIDRAddrNotation), None), |
1951 | 176b0ee2 | Dimitris Aragiorgis | ("network6", None, ht.TOr(ht.TNone, _CheckCIDR6NetNotation), None), |
1952 | 176b0ee2 | Dimitris Aragiorgis | ("gateway6", None, ht.TOr(ht.TNone, _CheckCIDR6AddrNotation), None), |
1953 | 176b0ee2 | Dimitris Aragiorgis | ("mac_prefix", None, ht.TMaybeString, None), |
1954 | 176b0ee2 | Dimitris Aragiorgis | ("add_reserved_ips", None, |
1955 | 176b0ee2 | Dimitris Aragiorgis | ht.TOr(ht.TNone, ht.TListOf(_CheckCIDRAddrNotation)), None),
|
1956 | 176b0ee2 | Dimitris Aragiorgis | ] |
1957 | 176b0ee2 | Dimitris Aragiorgis | |
1958 | 176b0ee2 | Dimitris Aragiorgis | class OpNetworkRemove(OpCode): |
1959 | 176b0ee2 | Dimitris Aragiorgis | """Remove an existing network from the cluster.
|
1960 | 176b0ee2 | Dimitris Aragiorgis | Must not be connected to any nodegroup.
|
1961 | 176b0ee2 | Dimitris Aragiorgis |
|
1962 | 176b0ee2 | Dimitris Aragiorgis | """
|
1963 | 176b0ee2 | Dimitris Aragiorgis | OP_DSC_FIELD = "network_name"
|
1964 | 176b0ee2 | Dimitris Aragiorgis | OP_PARAMS = [ |
1965 | 176b0ee2 | Dimitris Aragiorgis | _PNetworkName, |
1966 | 176b0ee2 | Dimitris Aragiorgis | _PForce, |
1967 | 176b0ee2 | Dimitris Aragiorgis | ] |
1968 | 176b0ee2 | Dimitris Aragiorgis | |
1969 | 176b0ee2 | Dimitris Aragiorgis | class OpNetworkSetParams(OpCode): |
1970 | 176b0ee2 | Dimitris Aragiorgis | """Modify Network's parameters except for IPv4 subnet"""
|
1971 | 176b0ee2 | Dimitris Aragiorgis | OP_DSC_FIELD = "network_name"
|
1972 | 176b0ee2 | Dimitris Aragiorgis | OP_PARAMS = [ |
1973 | 176b0ee2 | Dimitris Aragiorgis | _PNetworkName, |
1974 | 176b0ee2 | Dimitris Aragiorgis | _PNetworkType, |
1975 | 176b0ee2 | Dimitris Aragiorgis | ("gateway", None, ht.TOr(ht.TNone, _CheckCIDRAddrNotation), None), |
1976 | 176b0ee2 | Dimitris Aragiorgis | ("network6", None, ht.TOr(ht.TNone, _CheckCIDR6NetNotation), None), |
1977 | 176b0ee2 | Dimitris Aragiorgis | ("gateway6", None, ht.TOr(ht.TNone, _CheckCIDR6AddrNotation), None), |
1978 | 176b0ee2 | Dimitris Aragiorgis | ("mac_prefix", None, ht.TMaybeString, None), |
1979 | 176b0ee2 | Dimitris Aragiorgis | ("add_reserved_ips", None, |
1980 | 176b0ee2 | Dimitris Aragiorgis | ht.TOr(ht.TNone, ht.TListOf(_CheckCIDRAddrNotation)), None),
|
1981 | 176b0ee2 | Dimitris Aragiorgis | ("remove_reserved_ips", None, |
1982 | 176b0ee2 | Dimitris Aragiorgis | ht.TOr(ht.TNone, ht.TListOf(_CheckCIDRAddrNotation)), None),
|
1983 | 176b0ee2 | Dimitris Aragiorgis | ] |
1984 | 176b0ee2 | Dimitris Aragiorgis | |
1985 | 176b0ee2 | Dimitris Aragiorgis | class OpNetworkConnect(OpCode): |
1986 | 176b0ee2 | Dimitris Aragiorgis | """Connect a Network to a specific Nodegroup with the defined netparams
|
1987 | 176b0ee2 | Dimitris Aragiorgis | (mode, link). Nics in this Network will inherit those params.
|
1988 | 176b0ee2 | Dimitris Aragiorgis | Produce errors if a NIC (that its not already assigned to a network)
|
1989 | 176b0ee2 | Dimitris Aragiorgis | has an IP that is contained in the Network this will produce error unless
|
1990 | 176b0ee2 | Dimitris Aragiorgis | --no-conflicts-check is passed.
|
1991 | 176b0ee2 | Dimitris Aragiorgis |
|
1992 | 176b0ee2 | Dimitris Aragiorgis | """
|
1993 | 176b0ee2 | Dimitris Aragiorgis | OP_DSC_FIELD = "network_name"
|
1994 | 176b0ee2 | Dimitris Aragiorgis | OP_PARAMS = [ |
1995 | 176b0ee2 | Dimitris Aragiorgis | _PGroupName, |
1996 | 176b0ee2 | Dimitris Aragiorgis | _PNetworkName, |
1997 | 176b0ee2 | Dimitris Aragiorgis | ("network_mode", None, ht.TString, None), |
1998 | 176b0ee2 | Dimitris Aragiorgis | ("network_link", None, ht.TString, None), |
1999 | 176b0ee2 | Dimitris Aragiorgis | ("conflicts_check", True, ht.TBool, "Check for conflicting IPs"), |
2000 | 176b0ee2 | Dimitris Aragiorgis | ] |
2001 | 176b0ee2 | Dimitris Aragiorgis | |
2002 | 176b0ee2 | Dimitris Aragiorgis | class OpNetworkDisconnect(OpCode): |
2003 | 176b0ee2 | Dimitris Aragiorgis | """Disconnect a Network from a Nodegroup. Produce errors if NICs are
|
2004 | 176b0ee2 | Dimitris Aragiorgis | present in the Network unless --no-conficts-check option is passed.
|
2005 | 176b0ee2 | Dimitris Aragiorgis |
|
2006 | 176b0ee2 | Dimitris Aragiorgis | """
|
2007 | 176b0ee2 | Dimitris Aragiorgis | OP_DSC_FIELD = "network_name"
|
2008 | 176b0ee2 | Dimitris Aragiorgis | OP_PARAMS = [ |
2009 | 176b0ee2 | Dimitris Aragiorgis | _PGroupName, |
2010 | 176b0ee2 | Dimitris Aragiorgis | _PNetworkName, |
2011 | 176b0ee2 | Dimitris Aragiorgis | ("conflicts_check", True, ht.TBool, "Check for conflicting IPs"), |
2012 | 176b0ee2 | Dimitris Aragiorgis | ] |
2013 | 176b0ee2 | Dimitris Aragiorgis | |
2014 | 176b0ee2 | Dimitris Aragiorgis | class OpNetworkQuery(OpCode): |
2015 | 176b0ee2 | Dimitris Aragiorgis | """Compute the list of networks."""
|
2016 | 176b0ee2 | Dimitris Aragiorgis | OP_PARAMS = [ |
2017 | 176b0ee2 | Dimitris Aragiorgis | _POutputFields, |
2018 | 176b0ee2 | Dimitris Aragiorgis | ("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString),
|
2019 | 176b0ee2 | Dimitris Aragiorgis | "Empty list to query all groups, group names otherwise"),
|
2020 | 176b0ee2 | Dimitris Aragiorgis | ] |
2021 | 176b0ee2 | Dimitris Aragiorgis | |
2022 | 176b0ee2 | Dimitris Aragiorgis | |
2023 | dbc96028 | Michael Hanselmann | def _GetOpList(): |
2024 | dbc96028 | Michael Hanselmann | """Returns list of all defined opcodes.
|
2025 | dbc96028 | Michael Hanselmann |
|
2026 | dbc96028 | Michael Hanselmann | Does not eliminate duplicates by C{OP_ID}.
|
2027 | dbc96028 | Michael Hanselmann |
|
2028 | dbc96028 | Michael Hanselmann | """
|
2029 | dbc96028 | Michael Hanselmann | return [v for v in globals().values() |
2030 | dbc96028 | Michael Hanselmann | if (isinstance(v, type) and issubclass(v, OpCode) and |
2031 | 687c10d9 | Iustin Pop | hasattr(v, "OP_ID") and v is not OpCode)] |
2032 | dbc96028 | Michael Hanselmann | |
2033 | dbc96028 | Michael Hanselmann | |
2034 | dbc96028 | Michael Hanselmann | OP_MAPPING = dict((v.OP_ID, v) for v in _GetOpList()) |