root / lib / opcodes.py @ 3d1e7706
History | View | Annotate | Download (11.9 kB)
1 | 2f31098c | Iustin Pop | #
|
---|---|---|---|
2 | a8083063 | Iustin Pop | #
|
3 | a8083063 | Iustin Pop | |
4 | a8083063 | Iustin Pop | # Copyright (C) 2006, 2007 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 | a8083063 | Iustin Pop |
|
28 | a8083063 | Iustin Pop | This module implements the logic for doing operations in the cluster. There
|
29 | a8083063 | Iustin Pop | are two kinds of classes defined:
|
30 | a8083063 | Iustin Pop | - opcodes, which are small classes only holding data for the task at hand
|
31 | a8083063 | Iustin Pop | - logical units, which know how to deal with their specific opcode only
|
32 | a8083063 | Iustin Pop |
|
33 | a8083063 | Iustin Pop | """
|
34 | a8083063 | Iustin Pop | |
35 | a8083063 | Iustin Pop | # this are practically structures, so disable the message about too
|
36 | a8083063 | Iustin Pop | # few public methods:
|
37 | a8083063 | Iustin Pop | # pylint: disable-msg=R0903
|
38 | a8083063 | Iustin Pop | |
39 | df458e0b | Iustin Pop | |
40 | df458e0b | Iustin Pop | class BaseJO(object): |
41 | df458e0b | Iustin Pop | """A simple serializable object.
|
42 | df458e0b | Iustin Pop |
|
43 | df458e0b | Iustin Pop | This object serves as a parent class for both OpCode and Job since
|
44 | df458e0b | Iustin Pop | they are serialized in the same way.
|
45 | df458e0b | Iustin Pop |
|
46 | df458e0b | Iustin Pop | """
|
47 | a8083063 | Iustin Pop | __slots__ = [] |
48 | a8083063 | Iustin Pop | |
49 | a8083063 | Iustin Pop | def __init__(self, **kwargs): |
50 | a8083063 | Iustin Pop | for key in kwargs: |
51 | a8083063 | Iustin Pop | if key not in self.__slots__: |
52 | df458e0b | Iustin Pop | raise TypeError("Object %s doesn't support the parameter '%s'" % |
53 | 3ecf6786 | Iustin Pop | (self.__class__.__name__, key))
|
54 | a8083063 | Iustin Pop | setattr(self, key, kwargs[key]) |
55 | a8083063 | Iustin Pop | |
56 | df458e0b | Iustin Pop | def __getstate__(self): |
57 | df458e0b | Iustin Pop | state = {} |
58 | df458e0b | Iustin Pop | for name in self.__slots__: |
59 | df458e0b | Iustin Pop | if hasattr(self, name): |
60 | df458e0b | Iustin Pop | state[name] = getattr(self, name) |
61 | df458e0b | Iustin Pop | return state
|
62 | df458e0b | Iustin Pop | |
63 | df458e0b | Iustin Pop | def __setstate__(self, state): |
64 | df458e0b | Iustin Pop | if not isinstance(state, dict): |
65 | df458e0b | Iustin Pop | raise ValueError("Invalid data to __setstate__: expected dict, got %s" % |
66 | df458e0b | Iustin Pop | type(state))
|
67 | df458e0b | Iustin Pop | |
68 | df458e0b | Iustin Pop | for name in self.__slots__: |
69 | df458e0b | Iustin Pop | if name not in state: |
70 | df458e0b | Iustin Pop | delattr(self, name) |
71 | df458e0b | Iustin Pop | |
72 | df458e0b | Iustin Pop | for name in state: |
73 | df458e0b | Iustin Pop | setattr(self, name, state[name]) |
74 | df458e0b | Iustin Pop | |
75 | df458e0b | Iustin Pop | |
76 | df458e0b | Iustin Pop | class Job(BaseJO): |
77 | 35049ff2 | Iustin Pop | """Job definition structure
|
78 | 35049ff2 | Iustin Pop |
|
79 | 35049ff2 | Iustin Pop | The Job definitions has two sets of parameters:
|
80 | 35049ff2 | Iustin Pop | - the parameters of the job itself (all filled by server):
|
81 | 35049ff2 | Iustin Pop | - job_id,
|
82 | 35049ff2 | Iustin Pop | - status: pending, running, successfull, failed, aborted
|
83 | 35049ff2 | Iustin Pop | - opcode parameters:
|
84 | 35049ff2 | Iustin Pop | - op_list, list of opcodes, clients creates this
|
85 | 35049ff2 | Iustin Pop | - op_status, status for each opcode, server fills in
|
86 | 35049ff2 | Iustin Pop | - op_result, result for each opcode, server fills in
|
87 | 35049ff2 | Iustin Pop |
|
88 | 35049ff2 | Iustin Pop | """
|
89 | df458e0b | Iustin Pop | STATUS_PENDING = 1
|
90 | df458e0b | Iustin Pop | STATUS_RUNNING = 2
|
91 | 35049ff2 | Iustin Pop | STATUS_SUCCESS = 3
|
92 | 35049ff2 | Iustin Pop | STATUS_FAIL = 4
|
93 | 35049ff2 | Iustin Pop | STATUS_ABORT = 5
|
94 | 35049ff2 | Iustin Pop | |
95 | 35049ff2 | Iustin Pop | __slots__ = [ |
96 | 35049ff2 | Iustin Pop | "job_id",
|
97 | 35049ff2 | Iustin Pop | "status",
|
98 | 35049ff2 | Iustin Pop | "op_list",
|
99 | 35049ff2 | Iustin Pop | "op_status",
|
100 | 35049ff2 | Iustin Pop | "op_result",
|
101 | 35049ff2 | Iustin Pop | ] |
102 | df458e0b | Iustin Pop | |
103 | df458e0b | Iustin Pop | def __getstate__(self): |
104 | df458e0b | Iustin Pop | """Specialized getstate for jobs
|
105 | df458e0b | Iustin Pop |
|
106 | df458e0b | Iustin Pop | """
|
107 | df458e0b | Iustin Pop | data = BaseJO.__getstate__(self)
|
108 | df458e0b | Iustin Pop | if "op_list" in data: |
109 | df458e0b | Iustin Pop | data["op_list"] = [op.__getstate__() for op in data["op_list"]] |
110 | df458e0b | Iustin Pop | return data
|
111 | df458e0b | Iustin Pop | |
112 | df458e0b | Iustin Pop | def __setstate__(self, state): |
113 | df458e0b | Iustin Pop | """Specialized setstate for jobs
|
114 | df458e0b | Iustin Pop |
|
115 | df458e0b | Iustin Pop | """
|
116 | df458e0b | Iustin Pop | BaseJO.__setstate__(self, state)
|
117 | df458e0b | Iustin Pop | if "op_list" in state: |
118 | 00abdc96 | Iustin Pop | self.op_list = [OpCode.LoadOpCode(op) for op in state["op_list"]] |
119 | df458e0b | Iustin Pop | |
120 | df458e0b | Iustin Pop | |
121 | df458e0b | Iustin Pop | class OpCode(BaseJO): |
122 | df458e0b | Iustin Pop | """Abstract OpCode"""
|
123 | df458e0b | Iustin Pop | OP_ID = "OP_ABSTRACT"
|
124 | df458e0b | Iustin Pop | __slots__ = [] |
125 | df458e0b | Iustin Pop | |
126 | df458e0b | Iustin Pop | def __getstate__(self): |
127 | df458e0b | Iustin Pop | """Specialized getstate for opcodes.
|
128 | df458e0b | Iustin Pop |
|
129 | df458e0b | Iustin Pop | """
|
130 | df458e0b | Iustin Pop | data = BaseJO.__getstate__(self)
|
131 | df458e0b | Iustin Pop | data["OP_ID"] = self.OP_ID |
132 | df458e0b | Iustin Pop | return data
|
133 | df458e0b | Iustin Pop | |
134 | df458e0b | Iustin Pop | @classmethod
|
135 | 00abdc96 | Iustin Pop | def LoadOpCode(cls, data): |
136 | df458e0b | Iustin Pop | """Generic load opcode method.
|
137 | df458e0b | Iustin Pop |
|
138 | df458e0b | Iustin Pop | """
|
139 | df458e0b | Iustin Pop | if not isinstance(data, dict): |
140 | df458e0b | Iustin Pop | raise ValueError("Invalid data to LoadOpCode (%s)" % type(data)) |
141 | df458e0b | Iustin Pop | if "OP_ID" not in data: |
142 | df458e0b | Iustin Pop | raise ValueError("Invalid data to LoadOpcode, missing OP_ID") |
143 | df458e0b | Iustin Pop | op_id = data["OP_ID"]
|
144 | df458e0b | Iustin Pop | op_class = None
|
145 | df458e0b | Iustin Pop | for item in globals().values(): |
146 | df458e0b | Iustin Pop | if (isinstance(item, type) and |
147 | df458e0b | Iustin Pop | issubclass(item, cls) and |
148 | df458e0b | Iustin Pop | hasattr(item, "OP_ID") and |
149 | df458e0b | Iustin Pop | getattr(item, "OP_ID") == op_id): |
150 | df458e0b | Iustin Pop | op_class = item |
151 | df458e0b | Iustin Pop | break
|
152 | df458e0b | Iustin Pop | if op_class is None: |
153 | df458e0b | Iustin Pop | raise ValueError("Invalid data to LoadOpCode: OP_ID %s unsupported" % |
154 | df458e0b | Iustin Pop | op_id) |
155 | df458e0b | Iustin Pop | op = op_class() |
156 | df458e0b | Iustin Pop | new_data = data.copy() |
157 | df458e0b | Iustin Pop | del new_data["OP_ID"] |
158 | df458e0b | Iustin Pop | op.__setstate__(new_data) |
159 | df458e0b | Iustin Pop | return op
|
160 | df458e0b | Iustin Pop | |
161 | a8083063 | Iustin Pop | |
162 | a8083063 | Iustin Pop | class OpDestroyCluster(OpCode): |
163 | a8083063 | Iustin Pop | """Destroy the cluster."""
|
164 | a8083063 | Iustin Pop | OP_ID = "OP_CLUSTER_DESTROY"
|
165 | a8083063 | Iustin Pop | __slots__ = [] |
166 | a8083063 | Iustin Pop | |
167 | a8083063 | Iustin Pop | |
168 | a8083063 | Iustin Pop | class OpQueryClusterInfo(OpCode): |
169 | fdc267f4 | Iustin Pop | """Query cluster information."""
|
170 | a8083063 | Iustin Pop | OP_ID = "OP_CLUSTER_QUERY"
|
171 | a8083063 | Iustin Pop | __slots__ = [] |
172 | a8083063 | Iustin Pop | |
173 | a8083063 | Iustin Pop | |
174 | a8083063 | Iustin Pop | class OpVerifyCluster(OpCode): |
175 | fdc267f4 | Iustin Pop | """Verify the cluster state."""
|
176 | a8083063 | Iustin Pop | OP_ID = "OP_CLUSTER_VERIFY"
|
177 | e54c4c5e | Guido Trotter | __slots__ = ["skip_checks"]
|
178 | a8083063 | Iustin Pop | |
179 | a8083063 | Iustin Pop | |
180 | 150e978f | Iustin Pop | class OpVerifyDisks(OpCode): |
181 | 150e978f | Iustin Pop | """Verify the cluster disks.
|
182 | 150e978f | Iustin Pop |
|
183 | 150e978f | Iustin Pop | Parameters: none
|
184 | 150e978f | Iustin Pop |
|
185 | 150e978f | Iustin Pop | Result: two lists:
|
186 | 150e978f | Iustin Pop | - list of node names with bad data returned (unreachable, etc.)
|
187 | b63ed789 | Iustin Pop | - dist of node names with broken volume groups (values: error msg)
|
188 | 150e978f | Iustin Pop | - list of instances with degraded disks (that should be activated)
|
189 | b63ed789 | Iustin Pop | - dict of instances with missing logical volumes (values: (node, vol)
|
190 | b63ed789 | Iustin Pop | pairs with details about the missing volumes)
|
191 | 150e978f | Iustin Pop |
|
192 | b63ed789 | Iustin Pop | In normal operation, all lists should be empty. A non-empty instance
|
193 | b63ed789 | Iustin Pop | list (3rd element of the result) is still ok (errors were fixed) but
|
194 | b63ed789 | Iustin Pop | non-empty node list means some node is down, and probably there are
|
195 | b63ed789 | Iustin Pop | unfixable drbd errors.
|
196 | 150e978f | Iustin Pop |
|
197 | 150e978f | Iustin Pop | Note that only instances that are drbd-based are taken into
|
198 | 150e978f | Iustin Pop | consideration. This might need to be revisited in the future.
|
199 | 150e978f | Iustin Pop |
|
200 | 150e978f | Iustin Pop | """
|
201 | 150e978f | Iustin Pop | OP_ID = "OP_CLUSTER_VERIFY_DISKS"
|
202 | 150e978f | Iustin Pop | __slots__ = [] |
203 | 150e978f | Iustin Pop | |
204 | 150e978f | Iustin Pop | |
205 | a8083063 | Iustin Pop | class OpMasterFailover(OpCode): |
206 | fdc267f4 | Iustin Pop | """Do a master failover."""
|
207 | a8083063 | Iustin Pop | OP_ID = "OP_CLUSTER_MASTERFAILOVER"
|
208 | a8083063 | Iustin Pop | __slots__ = [] |
209 | a8083063 | Iustin Pop | |
210 | a8083063 | Iustin Pop | |
211 | a8083063 | Iustin Pop | class OpDumpClusterConfig(OpCode): |
212 | fdc267f4 | Iustin Pop | """Dump the cluster configuration."""
|
213 | a8083063 | Iustin Pop | OP_ID = "OP_CLUSTER_DUMPCONFIG"
|
214 | a8083063 | Iustin Pop | __slots__ = [] |
215 | a8083063 | Iustin Pop | |
216 | a8083063 | Iustin Pop | |
217 | 07bd8a51 | Iustin Pop | class OpRenameCluster(OpCode): |
218 | 07bd8a51 | Iustin Pop | """Rename the cluster."""
|
219 | 07bd8a51 | Iustin Pop | OP_ID = "OP_CLUSTER_RENAME"
|
220 | 07bd8a51 | Iustin Pop | __slots__ = ["name"]
|
221 | 07bd8a51 | Iustin Pop | |
222 | 07bd8a51 | Iustin Pop | |
223 | 12515db7 | Manuel Franceschini | class OpSetClusterParams(OpCode): |
224 | 12515db7 | Manuel Franceschini | """Change the parameters of the cluster."""
|
225 | 12515db7 | Manuel Franceschini | OP_ID = "OP_CLUSTER_SET_PARAMS"
|
226 | 12515db7 | Manuel Franceschini | __slots__ = ["vg_name"]
|
227 | 12515db7 | Manuel Franceschini | |
228 | 12515db7 | Manuel Franceschini | |
229 | 07bd8a51 | Iustin Pop | # node opcodes
|
230 | 07bd8a51 | Iustin Pop | |
231 | a8083063 | Iustin Pop | class OpRemoveNode(OpCode): |
232 | a8083063 | Iustin Pop | """Remove a node."""
|
233 | a8083063 | Iustin Pop | OP_ID = "OP_NODE_REMOVE"
|
234 | a8083063 | Iustin Pop | __slots__ = ["node_name"]
|
235 | a8083063 | Iustin Pop | |
236 | a8083063 | Iustin Pop | |
237 | a8083063 | Iustin Pop | class OpAddNode(OpCode): |
238 | a8083063 | Iustin Pop | """Add a node."""
|
239 | a8083063 | Iustin Pop | OP_ID = "OP_NODE_ADD"
|
240 | e7c6e02b | Michael Hanselmann | __slots__ = ["node_name", "primary_ip", "secondary_ip", "readd"] |
241 | a8083063 | Iustin Pop | |
242 | a8083063 | Iustin Pop | |
243 | a8083063 | Iustin Pop | class OpQueryNodes(OpCode): |
244 | a8083063 | Iustin Pop | """Compute the list of nodes."""
|
245 | a8083063 | Iustin Pop | OP_ID = "OP_NODE_QUERY"
|
246 | 246e180a | Iustin Pop | __slots__ = ["output_fields", "names"] |
247 | a8083063 | Iustin Pop | |
248 | a8083063 | Iustin Pop | |
249 | dcb93971 | Michael Hanselmann | class OpQueryNodeVolumes(OpCode): |
250 | dcb93971 | Michael Hanselmann | """Get list of volumes on node."""
|
251 | dcb93971 | Michael Hanselmann | OP_ID = "OP_NODE_QUERYVOLS"
|
252 | dcb93971 | Michael Hanselmann | __slots__ = ["nodes", "output_fields"] |
253 | dcb93971 | Michael Hanselmann | |
254 | dcb93971 | Michael Hanselmann | |
255 | a8083063 | Iustin Pop | # instance opcodes
|
256 | a8083063 | Iustin Pop | |
257 | a8083063 | Iustin Pop | class OpCreateInstance(OpCode): |
258 | fdc267f4 | Iustin Pop | """Create an instance."""
|
259 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_CREATE"
|
260 | 3b6d8c9b | Iustin Pop | __slots__ = [ |
261 | 3b6d8c9b | Iustin Pop | "instance_name", "mem_size", "disk_size", "os_type", "pnode", |
262 | 3b6d8c9b | Iustin Pop | "disk_template", "snode", "swap_size", "mode", |
263 | 3b6d8c9b | Iustin Pop | "vcpus", "ip", "bridge", "src_node", "src_path", "start", |
264 | 3b6d8c9b | Iustin Pop | "wait_for_sync", "ip_check", "mac", |
265 | 31a853d2 | Iustin Pop | "kernel_path", "initrd_path", "hvm_boot_order", "hvm_acpi", |
266 | 31a853d2 | Iustin Pop | "hvm_pae", "hvm_cdrom_image_path", "vnc_bind_address", |
267 | dc936b49 | Manuel Franceschini | "file_storage_dir", "file_driver", |
268 | 538475ca | Iustin Pop | "iallocator",
|
269 | 3b6d8c9b | Iustin Pop | ] |
270 | a8083063 | Iustin Pop | |
271 | a8083063 | Iustin Pop | |
272 | fe7b0351 | Michael Hanselmann | class OpReinstallInstance(OpCode): |
273 | fdc267f4 | Iustin Pop | """Reinstall an instance's OS."""
|
274 | fe7b0351 | Michael Hanselmann | OP_ID = "OP_INSTANCE_REINSTALL"
|
275 | d0834de3 | Michael Hanselmann | __slots__ = ["instance_name", "os_type"] |
276 | fe7b0351 | Michael Hanselmann | |
277 | fe7b0351 | Michael Hanselmann | |
278 | a8083063 | Iustin Pop | class OpRemoveInstance(OpCode): |
279 | a8083063 | Iustin Pop | """Remove an instance."""
|
280 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_REMOVE"
|
281 | 1d67656e | Iustin Pop | __slots__ = ["instance_name", "ignore_failures"] |
282 | a8083063 | Iustin Pop | |
283 | a8083063 | Iustin Pop | |
284 | decd5f45 | Iustin Pop | class OpRenameInstance(OpCode): |
285 | decd5f45 | Iustin Pop | """Rename an instance."""
|
286 | decd5f45 | Iustin Pop | OP_ID = "OP_INSTANCE_RENAME"
|
287 | decd5f45 | Iustin Pop | __slots__ = ["instance_name", "ignore_ip", "new_name"] |
288 | decd5f45 | Iustin Pop | |
289 | decd5f45 | Iustin Pop | |
290 | a8083063 | Iustin Pop | class OpStartupInstance(OpCode): |
291 | fdc267f4 | Iustin Pop | """Startup an instance."""
|
292 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_STARTUP"
|
293 | a8083063 | Iustin Pop | __slots__ = ["instance_name", "force", "extra_args"] |
294 | a8083063 | Iustin Pop | |
295 | a8083063 | Iustin Pop | |
296 | a8083063 | Iustin Pop | class OpShutdownInstance(OpCode): |
297 | fdc267f4 | Iustin Pop | """Shutdown an instance."""
|
298 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_SHUTDOWN"
|
299 | a8083063 | Iustin Pop | __slots__ = ["instance_name"]
|
300 | a8083063 | Iustin Pop | |
301 | a8083063 | Iustin Pop | |
302 | bf6929a2 | Alexander Schreiber | class OpRebootInstance(OpCode): |
303 | bf6929a2 | Alexander Schreiber | """Reboot an instance."""
|
304 | eeb3a5f9 | Iustin Pop | OP_ID = "OP_INSTANCE_REBOOT"
|
305 | bf6929a2 | Alexander Schreiber | __slots__ = ["instance_name", "reboot_type", "extra_args", |
306 | bf6929a2 | Alexander Schreiber | "ignore_secondaries" ]
|
307 | bf6929a2 | Alexander Schreiber | |
308 | bf6929a2 | Alexander Schreiber | |
309 | a8083063 | Iustin Pop | class OpReplaceDisks(OpCode): |
310 | fdc267f4 | Iustin Pop | """Replace the disks of an instance."""
|
311 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_REPLACE_DISKS"
|
312 | b6e82a65 | Iustin Pop | __slots__ = ["instance_name", "remote_node", "mode", "disks", "iallocator"] |
313 | a8083063 | Iustin Pop | |
314 | a8083063 | Iustin Pop | |
315 | a8083063 | Iustin Pop | class OpFailoverInstance(OpCode): |
316 | a8083063 | Iustin Pop | """Failover an instance."""
|
317 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_FAILOVER"
|
318 | a8083063 | Iustin Pop | __slots__ = ["instance_name", "ignore_consistency"] |
319 | a8083063 | Iustin Pop | |
320 | a8083063 | Iustin Pop | |
321 | a8083063 | Iustin Pop | class OpConnectConsole(OpCode): |
322 | fdc267f4 | Iustin Pop | """Connect to an instance's console."""
|
323 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_CONSOLE"
|
324 | a8083063 | Iustin Pop | __slots__ = ["instance_name"]
|
325 | a8083063 | Iustin Pop | |
326 | a8083063 | Iustin Pop | |
327 | a8083063 | Iustin Pop | class OpActivateInstanceDisks(OpCode): |
328 | fdc267f4 | Iustin Pop | """Activate an instance's disks."""
|
329 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_ACTIVATE_DISKS"
|
330 | a8083063 | Iustin Pop | __slots__ = ["instance_name"]
|
331 | a8083063 | Iustin Pop | |
332 | a8083063 | Iustin Pop | |
333 | a8083063 | Iustin Pop | class OpDeactivateInstanceDisks(OpCode): |
334 | fdc267f4 | Iustin Pop | """Deactivate an instance's disks."""
|
335 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_DEACTIVATE_DISKS"
|
336 | a8083063 | Iustin Pop | __slots__ = ["instance_name"]
|
337 | a8083063 | Iustin Pop | |
338 | a8083063 | Iustin Pop | |
339 | a8083063 | Iustin Pop | class OpQueryInstances(OpCode): |
340 | a8083063 | Iustin Pop | """Compute the list of instances."""
|
341 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_QUERY"
|
342 | 069dcc86 | Iustin Pop | __slots__ = ["output_fields", "names"] |
343 | a8083063 | Iustin Pop | |
344 | a8083063 | Iustin Pop | |
345 | a8083063 | Iustin Pop | class OpQueryInstanceData(OpCode): |
346 | a8083063 | Iustin Pop | """Compute the run-time status of instances."""
|
347 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_QUERY_DATA"
|
348 | a8083063 | Iustin Pop | __slots__ = ["instances"]
|
349 | a8083063 | Iustin Pop | |
350 | a8083063 | Iustin Pop | |
351 | 7767bbf5 | Manuel Franceschini | class OpSetInstanceParams(OpCode): |
352 | a8083063 | Iustin Pop | """Change the parameters of an instance."""
|
353 | 7767bbf5 | Manuel Franceschini | OP_ID = "OP_INSTANCE_SET_PARAMS"
|
354 | 973d7867 | Iustin Pop | __slots__ = [ |
355 | 973d7867 | Iustin Pop | "instance_name", "mem", "vcpus", "ip", "bridge", "mac", |
356 | 31a853d2 | Iustin Pop | "kernel_path", "initrd_path", "hvm_boot_order", "hvm_acpi", |
357 | 31a853d2 | Iustin Pop | "hvm_pae", "hvm_cdrom_image_path", "vnc_bind_address" |
358 | 973d7867 | Iustin Pop | ] |
359 | a8083063 | Iustin Pop | |
360 | a8083063 | Iustin Pop | |
361 | 8729e0d7 | Iustin Pop | class OpGrowDisk(OpCode): |
362 | 8729e0d7 | Iustin Pop | """Grow a disk of an instance."""
|
363 | 8729e0d7 | Iustin Pop | OP_ID = "OP_INSTANCE_GROW_DISK"
|
364 | 8729e0d7 | Iustin Pop | __slots__ = ["instance_name", "disk", "amount"] |
365 | 8729e0d7 | Iustin Pop | |
366 | 8729e0d7 | Iustin Pop | |
367 | a8083063 | Iustin Pop | # OS opcodes
|
368 | a8083063 | Iustin Pop | class OpDiagnoseOS(OpCode): |
369 | a8083063 | Iustin Pop | """Compute the list of guest operating systems."""
|
370 | a8083063 | Iustin Pop | OP_ID = "OP_OS_DIAGNOSE"
|
371 | 1f9430d6 | Iustin Pop | __slots__ = ["output_fields", "names"] |
372 | a8083063 | Iustin Pop | |
373 | 7c0d6283 | Michael Hanselmann | |
374 | a8083063 | Iustin Pop | # Exports opcodes
|
375 | a8083063 | Iustin Pop | class OpQueryExports(OpCode): |
376 | a8083063 | Iustin Pop | """Compute the list of exported images."""
|
377 | a8083063 | Iustin Pop | OP_ID = "OP_BACKUP_QUERY"
|
378 | a8083063 | Iustin Pop | __slots__ = ["nodes"]
|
379 | a8083063 | Iustin Pop | |
380 | 7c0d6283 | Michael Hanselmann | |
381 | a8083063 | Iustin Pop | class OpExportInstance(OpCode): |
382 | a8083063 | Iustin Pop | """Export an instance."""
|
383 | a8083063 | Iustin Pop | OP_ID = "OP_BACKUP_EXPORT"
|
384 | a8083063 | Iustin Pop | __slots__ = ["instance_name", "target_node", "shutdown"] |
385 | 5c947f38 | Iustin Pop | |
386 | 9ac99fda | Guido Trotter | class OpRemoveExport(OpCode): |
387 | 9ac99fda | Guido Trotter | """Remove an instance's export."""
|
388 | 9ac99fda | Guido Trotter | OP_ID = "OP_BACKUP_REMOVE"
|
389 | 9ac99fda | Guido Trotter | __slots__ = ["instance_name"]
|
390 | 5c947f38 | Iustin Pop | |
391 | 5c947f38 | Iustin Pop | # Tags opcodes
|
392 | 5c947f38 | Iustin Pop | class OpGetTags(OpCode): |
393 | 5c947f38 | Iustin Pop | """Returns the tags of the given object."""
|
394 | 5c947f38 | Iustin Pop | OP_ID = "OP_TAGS_GET"
|
395 | 5c947f38 | Iustin Pop | __slots__ = ["kind", "name"] |
396 | 5c947f38 | Iustin Pop | |
397 | 5c947f38 | Iustin Pop | |
398 | 73415719 | Iustin Pop | class OpSearchTags(OpCode): |
399 | 73415719 | Iustin Pop | """Searches the tags in the cluster for a given pattern."""
|
400 | 73415719 | Iustin Pop | OP_ID = "OP_TAGS_SEARCH"
|
401 | 73415719 | Iustin Pop | __slots__ = ["pattern"]
|
402 | 73415719 | Iustin Pop | |
403 | 73415719 | Iustin Pop | |
404 | f27302fa | Iustin Pop | class OpAddTags(OpCode): |
405 | f27302fa | Iustin Pop | """Add a list of tags on a given object."""
|
406 | 5c947f38 | Iustin Pop | OP_ID = "OP_TAGS_SET"
|
407 | f27302fa | Iustin Pop | __slots__ = ["kind", "name", "tags"] |
408 | 5c947f38 | Iustin Pop | |
409 | 5c947f38 | Iustin Pop | |
410 | f27302fa | Iustin Pop | class OpDelTags(OpCode): |
411 | f27302fa | Iustin Pop | """Remove a list of tags from a given object."""
|
412 | 5c947f38 | Iustin Pop | OP_ID = "OP_TAGS_DEL"
|
413 | f27302fa | Iustin Pop | __slots__ = ["kind", "name", "tags"] |
414 | 06009e27 | Iustin Pop | |
415 | 06009e27 | Iustin Pop | |
416 | 06009e27 | Iustin Pop | # Test opcodes
|
417 | 06009e27 | Iustin Pop | class OpTestDelay(OpCode): |
418 | 06009e27 | Iustin Pop | """Sleeps for a configured amount of time.
|
419 | 06009e27 | Iustin Pop |
|
420 | 06009e27 | Iustin Pop | This is used just for debugging and testing.
|
421 | 06009e27 | Iustin Pop |
|
422 | 06009e27 | Iustin Pop | Parameters:
|
423 | 06009e27 | Iustin Pop | - duration: the time to sleep
|
424 | 06009e27 | Iustin Pop | - on_master: if true, sleep on the master
|
425 | 06009e27 | Iustin Pop | - on_nodes: list of nodes in which to sleep
|
426 | 06009e27 | Iustin Pop |
|
427 | 06009e27 | Iustin Pop | If the on_master parameter is true, it will execute a sleep on the
|
428 | 06009e27 | Iustin Pop | master (before any node sleep).
|
429 | 06009e27 | Iustin Pop |
|
430 | 06009e27 | Iustin Pop | If the on_nodes list is not empty, it will sleep on those nodes
|
431 | 06009e27 | Iustin Pop | (after the sleep on the master, if that is enabled).
|
432 | 06009e27 | Iustin Pop |
|
433 | 06009e27 | Iustin Pop | As an additional feature, the case of duration < 0 will be reported
|
434 | 06009e27 | Iustin Pop | as an execution error, so this opcode can be used as a failure
|
435 | 06009e27 | Iustin Pop | generator. The case of duration == 0 will not be treated specially.
|
436 | 06009e27 | Iustin Pop |
|
437 | 06009e27 | Iustin Pop | """
|
438 | 06009e27 | Iustin Pop | OP_ID = "OP_TEST_DELAY"
|
439 | 06009e27 | Iustin Pop | __slots__ = ["duration", "on_master", "on_nodes"] |
440 | d61df03e | Iustin Pop | |
441 | d61df03e | Iustin Pop | |
442 | d61df03e | Iustin Pop | class OpTestAllocator(OpCode): |
443 | d61df03e | Iustin Pop | """Allocator framework testing.
|
444 | d61df03e | Iustin Pop |
|
445 | d61df03e | Iustin Pop | This opcode has two modes:
|
446 | d61df03e | Iustin Pop | - gather and return allocator input for a given mode (allocate new
|
447 | d61df03e | Iustin Pop | or replace secondary) and a given instance definition (direction
|
448 | d61df03e | Iustin Pop | 'in')
|
449 | d61df03e | Iustin Pop | - run a selected allocator for a given operation (as above) and
|
450 | d61df03e | Iustin Pop | return the allocator output (direction 'out')
|
451 | d61df03e | Iustin Pop |
|
452 | d61df03e | Iustin Pop | """
|
453 | d61df03e | Iustin Pop | OP_ID = "OP_TEST_ALLOCATOR"
|
454 | d61df03e | Iustin Pop | __slots__ = [ |
455 | d61df03e | Iustin Pop | "direction", "mode", "allocator", "name", |
456 | d61df03e | Iustin Pop | "mem_size", "disks", "disk_template", |
457 | d61df03e | Iustin Pop | "os", "tags", "nics", "vcpus", |
458 | d61df03e | Iustin Pop | ] |