root / lib / opcodes.py @ df458e0b
History | View | Annotate | Download (11.1 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 | df458e0b | Iustin Pop | """Job definition structure"""
|
78 | df458e0b | Iustin Pop | STATUS_PENDING = 1
|
79 | df458e0b | Iustin Pop | STATUS_RUNNING = 2
|
80 | df458e0b | Iustin Pop | STATUS_FINISHED = 3
|
81 | df458e0b | Iustin Pop | RESULT_OK = 1
|
82 | df458e0b | Iustin Pop | RESULT_FAIL = 2
|
83 | df458e0b | Iustin Pop | RESULT_ABORT = 3
|
84 | df458e0b | Iustin Pop | |
85 | df458e0b | Iustin Pop | __slots__ = ["job_id", "op_list", "status", "result"] |
86 | df458e0b | Iustin Pop | |
87 | df458e0b | Iustin Pop | def __getstate__(self): |
88 | df458e0b | Iustin Pop | """Specialized getstate for jobs
|
89 | df458e0b | Iustin Pop |
|
90 | df458e0b | Iustin Pop | """
|
91 | df458e0b | Iustin Pop | data = BaseJO.__getstate__(self)
|
92 | df458e0b | Iustin Pop | if "op_list" in data: |
93 | df458e0b | Iustin Pop | data["op_list"] = [op.__getstate__() for op in data["op_list"]] |
94 | df458e0b | Iustin Pop | return data
|
95 | df458e0b | Iustin Pop | |
96 | df458e0b | Iustin Pop | def __setstate__(self, state): |
97 | df458e0b | Iustin Pop | """Specialized setstate for jobs
|
98 | df458e0b | Iustin Pop |
|
99 | df458e0b | Iustin Pop | """
|
100 | df458e0b | Iustin Pop | BaseJO.__setstate__(self, state)
|
101 | df458e0b | Iustin Pop | if "op_list" in state: |
102 | df458e0b | Iustin Pop | self.op_list = [OpCode.LoadOpcode(op) for op in state["op_list"]] |
103 | df458e0b | Iustin Pop | |
104 | df458e0b | Iustin Pop | |
105 | df458e0b | Iustin Pop | class OpCode(BaseJO): |
106 | df458e0b | Iustin Pop | """Abstract OpCode"""
|
107 | df458e0b | Iustin Pop | OP_ID = "OP_ABSTRACT"
|
108 | df458e0b | Iustin Pop | __slots__ = [] |
109 | df458e0b | Iustin Pop | |
110 | df458e0b | Iustin Pop | def __getstate__(self): |
111 | df458e0b | Iustin Pop | """Specialized getstate for opcodes.
|
112 | df458e0b | Iustin Pop |
|
113 | df458e0b | Iustin Pop | """
|
114 | df458e0b | Iustin Pop | data = BaseJO.__getstate__(self)
|
115 | df458e0b | Iustin Pop | data["OP_ID"] = self.OP_ID |
116 | df458e0b | Iustin Pop | return data
|
117 | df458e0b | Iustin Pop | |
118 | df458e0b | Iustin Pop | @classmethod
|
119 | df458e0b | Iustin Pop | def LoadOpcode(cls, data): |
120 | df458e0b | Iustin Pop | """Generic load opcode method.
|
121 | df458e0b | Iustin Pop |
|
122 | df458e0b | Iustin Pop | """
|
123 | df458e0b | Iustin Pop | if not isinstance(data, dict): |
124 | df458e0b | Iustin Pop | raise ValueError("Invalid data to LoadOpCode (%s)" % type(data)) |
125 | df458e0b | Iustin Pop | if "OP_ID" not in data: |
126 | df458e0b | Iustin Pop | raise ValueError("Invalid data to LoadOpcode, missing OP_ID") |
127 | df458e0b | Iustin Pop | op_id = data["OP_ID"]
|
128 | df458e0b | Iustin Pop | op_class = None
|
129 | df458e0b | Iustin Pop | for item in globals().values(): |
130 | df458e0b | Iustin Pop | if (isinstance(item, type) and |
131 | df458e0b | Iustin Pop | issubclass(item, cls) and |
132 | df458e0b | Iustin Pop | hasattr(item, "OP_ID") and |
133 | df458e0b | Iustin Pop | getattr(item, "OP_ID") == op_id): |
134 | df458e0b | Iustin Pop | op_class = item |
135 | df458e0b | Iustin Pop | break
|
136 | df458e0b | Iustin Pop | if op_class is None: |
137 | df458e0b | Iustin Pop | raise ValueError("Invalid data to LoadOpCode: OP_ID %s unsupported" % |
138 | df458e0b | Iustin Pop | op_id) |
139 | df458e0b | Iustin Pop | op = op_class() |
140 | df458e0b | Iustin Pop | new_data = data.copy() |
141 | df458e0b | Iustin Pop | del new_data["OP_ID"] |
142 | df458e0b | Iustin Pop | op.__setstate__(new_data) |
143 | df458e0b | Iustin Pop | return op
|
144 | df458e0b | Iustin Pop | |
145 | a8083063 | Iustin Pop | |
146 | a8083063 | Iustin Pop | class OpInitCluster(OpCode): |
147 | a8083063 | Iustin Pop | """Initialise the cluster."""
|
148 | a8083063 | Iustin Pop | OP_ID = "OP_CLUSTER_INIT"
|
149 | a8083063 | Iustin Pop | __slots__ = ["cluster_name", "secondary_ip", "hypervisor_type", |
150 | 1322c697 | Manuel Franceschini | "vg_name", "mac_prefix", "def_bridge", "master_netdev", |
151 | 1322c697 | Manuel Franceschini | "file_storage_dir"]
|
152 | a8083063 | Iustin Pop | |
153 | a8083063 | Iustin Pop | |
154 | a8083063 | Iustin Pop | class OpDestroyCluster(OpCode): |
155 | a8083063 | Iustin Pop | """Destroy the cluster."""
|
156 | a8083063 | Iustin Pop | OP_ID = "OP_CLUSTER_DESTROY"
|
157 | a8083063 | Iustin Pop | __slots__ = [] |
158 | a8083063 | Iustin Pop | |
159 | a8083063 | Iustin Pop | |
160 | a8083063 | Iustin Pop | class OpQueryClusterInfo(OpCode): |
161 | fdc267f4 | Iustin Pop | """Query cluster information."""
|
162 | a8083063 | Iustin Pop | OP_ID = "OP_CLUSTER_QUERY"
|
163 | a8083063 | Iustin Pop | __slots__ = [] |
164 | a8083063 | Iustin Pop | |
165 | a8083063 | Iustin Pop | |
166 | a8083063 | Iustin Pop | class OpClusterCopyFile(OpCode): |
167 | fdc267f4 | Iustin Pop | """Copy a file to multiple nodes."""
|
168 | a8083063 | Iustin Pop | OP_ID = "OP_CLUSTER_COPYFILE"
|
169 | a8083063 | Iustin Pop | __slots__ = ["nodes", "filename"] |
170 | a8083063 | Iustin Pop | |
171 | a8083063 | Iustin Pop | |
172 | a8083063 | Iustin Pop | class OpRunClusterCommand(OpCode): |
173 | fdc267f4 | Iustin Pop | """Run a command on multiple nodes."""
|
174 | a8083063 | Iustin Pop | OP_ID = "OP_CLUSTER_RUNCOMMAND"
|
175 | a8083063 | Iustin Pop | __slots__ = ["nodes", "command"] |
176 | a8083063 | Iustin Pop | |
177 | a8083063 | Iustin Pop | |
178 | a8083063 | Iustin Pop | class OpVerifyCluster(OpCode): |
179 | fdc267f4 | Iustin Pop | """Verify the cluster state."""
|
180 | a8083063 | Iustin Pop | OP_ID = "OP_CLUSTER_VERIFY"
|
181 | a8083063 | Iustin Pop | __slots__ = [] |
182 | a8083063 | Iustin Pop | |
183 | a8083063 | Iustin Pop | |
184 | 150e978f | Iustin Pop | class OpVerifyDisks(OpCode): |
185 | 150e978f | Iustin Pop | """Verify the cluster disks.
|
186 | 150e978f | Iustin Pop |
|
187 | 150e978f | Iustin Pop | Parameters: none
|
188 | 150e978f | Iustin Pop |
|
189 | 150e978f | Iustin Pop | Result: two lists:
|
190 | 150e978f | Iustin Pop | - list of node names with bad data returned (unreachable, etc.)
|
191 | b63ed789 | Iustin Pop | - dist of node names with broken volume groups (values: error msg)
|
192 | 150e978f | Iustin Pop | - list of instances with degraded disks (that should be activated)
|
193 | b63ed789 | Iustin Pop | - dict of instances with missing logical volumes (values: (node, vol)
|
194 | b63ed789 | Iustin Pop | pairs with details about the missing volumes)
|
195 | 150e978f | Iustin Pop |
|
196 | b63ed789 | Iustin Pop | In normal operation, all lists should be empty. A non-empty instance
|
197 | b63ed789 | Iustin Pop | list (3rd element of the result) is still ok (errors were fixed) but
|
198 | b63ed789 | Iustin Pop | non-empty node list means some node is down, and probably there are
|
199 | b63ed789 | Iustin Pop | unfixable drbd errors.
|
200 | 150e978f | Iustin Pop |
|
201 | 150e978f | Iustin Pop | Note that only instances that are drbd-based are taken into
|
202 | 150e978f | Iustin Pop | consideration. This might need to be revisited in the future.
|
203 | 150e978f | Iustin Pop |
|
204 | 150e978f | Iustin Pop | """
|
205 | 150e978f | Iustin Pop | OP_ID = "OP_CLUSTER_VERIFY_DISKS"
|
206 | 150e978f | Iustin Pop | __slots__ = [] |
207 | 150e978f | Iustin Pop | |
208 | 150e978f | Iustin Pop | |
209 | a8083063 | Iustin Pop | class OpMasterFailover(OpCode): |
210 | fdc267f4 | Iustin Pop | """Do a master failover."""
|
211 | a8083063 | Iustin Pop | OP_ID = "OP_CLUSTER_MASTERFAILOVER"
|
212 | a8083063 | Iustin Pop | __slots__ = [] |
213 | a8083063 | Iustin Pop | |
214 | a8083063 | Iustin Pop | |
215 | a8083063 | Iustin Pop | class OpDumpClusterConfig(OpCode): |
216 | fdc267f4 | Iustin Pop | """Dump the cluster configuration."""
|
217 | a8083063 | Iustin Pop | OP_ID = "OP_CLUSTER_DUMPCONFIG"
|
218 | a8083063 | Iustin Pop | __slots__ = [] |
219 | a8083063 | Iustin Pop | |
220 | a8083063 | Iustin Pop | |
221 | 07bd8a51 | Iustin Pop | class OpRenameCluster(OpCode): |
222 | 07bd8a51 | Iustin Pop | """Rename the cluster."""
|
223 | 07bd8a51 | Iustin Pop | OP_ID = "OP_CLUSTER_RENAME"
|
224 | 07bd8a51 | Iustin Pop | __slots__ = ["name"]
|
225 | 07bd8a51 | Iustin Pop | |
226 | 07bd8a51 | Iustin Pop | |
227 | 07bd8a51 | Iustin Pop | # node opcodes
|
228 | 07bd8a51 | Iustin Pop | |
229 | a8083063 | Iustin Pop | class OpRemoveNode(OpCode): |
230 | a8083063 | Iustin Pop | """Remove a node."""
|
231 | a8083063 | Iustin Pop | OP_ID = "OP_NODE_REMOVE"
|
232 | a8083063 | Iustin Pop | __slots__ = ["node_name"]
|
233 | a8083063 | Iustin Pop | |
234 | a8083063 | Iustin Pop | |
235 | a8083063 | Iustin Pop | class OpAddNode(OpCode): |
236 | a8083063 | Iustin Pop | """Add a node."""
|
237 | a8083063 | Iustin Pop | OP_ID = "OP_NODE_ADD"
|
238 | a8083063 | Iustin Pop | __slots__ = ["node_name", "primary_ip", "secondary_ip"] |
239 | a8083063 | Iustin Pop | |
240 | a8083063 | Iustin Pop | |
241 | a8083063 | Iustin Pop | class OpQueryNodes(OpCode): |
242 | a8083063 | Iustin Pop | """Compute the list of nodes."""
|
243 | a8083063 | Iustin Pop | OP_ID = "OP_NODE_QUERY"
|
244 | 246e180a | Iustin Pop | __slots__ = ["output_fields", "names"] |
245 | a8083063 | Iustin Pop | |
246 | a8083063 | Iustin Pop | |
247 | dcb93971 | Michael Hanselmann | class OpQueryNodeVolumes(OpCode): |
248 | dcb93971 | Michael Hanselmann | """Get list of volumes on node."""
|
249 | dcb93971 | Michael Hanselmann | OP_ID = "OP_NODE_QUERYVOLS"
|
250 | dcb93971 | Michael Hanselmann | __slots__ = ["nodes", "output_fields"] |
251 | dcb93971 | Michael Hanselmann | |
252 | dcb93971 | Michael Hanselmann | |
253 | a8083063 | Iustin Pop | # instance opcodes
|
254 | a8083063 | Iustin Pop | |
255 | a8083063 | Iustin Pop | class OpCreateInstance(OpCode): |
256 | fdc267f4 | Iustin Pop | """Create an instance."""
|
257 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_CREATE"
|
258 | 3b6d8c9b | Iustin Pop | __slots__ = [ |
259 | 3b6d8c9b | Iustin Pop | "instance_name", "mem_size", "disk_size", "os_type", "pnode", |
260 | 3b6d8c9b | Iustin Pop | "disk_template", "snode", "swap_size", "mode", |
261 | 3b6d8c9b | Iustin Pop | "vcpus", "ip", "bridge", "src_node", "src_path", "start", |
262 | 3b6d8c9b | Iustin Pop | "wait_for_sync", "ip_check", "mac", |
263 | 25c5878d | Alexander Schreiber | "kernel_path", "initrd_path", "hvm_boot_order", |
264 | 3b6d8c9b | Iustin Pop | ] |
265 | a8083063 | Iustin Pop | |
266 | a8083063 | Iustin Pop | |
267 | fe7b0351 | Michael Hanselmann | class OpReinstallInstance(OpCode): |
268 | fdc267f4 | Iustin Pop | """Reinstall an instance's OS."""
|
269 | fe7b0351 | Michael Hanselmann | OP_ID = "OP_INSTANCE_REINSTALL"
|
270 | d0834de3 | Michael Hanselmann | __slots__ = ["instance_name", "os_type"] |
271 | fe7b0351 | Michael Hanselmann | |
272 | fe7b0351 | Michael Hanselmann | |
273 | a8083063 | Iustin Pop | class OpRemoveInstance(OpCode): |
274 | a8083063 | Iustin Pop | """Remove an instance."""
|
275 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_REMOVE"
|
276 | 1d67656e | Iustin Pop | __slots__ = ["instance_name", "ignore_failures"] |
277 | a8083063 | Iustin Pop | |
278 | a8083063 | Iustin Pop | |
279 | decd5f45 | Iustin Pop | class OpRenameInstance(OpCode): |
280 | decd5f45 | Iustin Pop | """Rename an instance."""
|
281 | decd5f45 | Iustin Pop | OP_ID = "OP_INSTANCE_RENAME"
|
282 | decd5f45 | Iustin Pop | __slots__ = ["instance_name", "ignore_ip", "new_name"] |
283 | decd5f45 | Iustin Pop | |
284 | decd5f45 | Iustin Pop | |
285 | a8083063 | Iustin Pop | class OpStartupInstance(OpCode): |
286 | fdc267f4 | Iustin Pop | """Startup an instance."""
|
287 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_STARTUP"
|
288 | a8083063 | Iustin Pop | __slots__ = ["instance_name", "force", "extra_args"] |
289 | a8083063 | Iustin Pop | |
290 | a8083063 | Iustin Pop | |
291 | a8083063 | Iustin Pop | class OpShutdownInstance(OpCode): |
292 | fdc267f4 | Iustin Pop | """Shutdown an instance."""
|
293 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_SHUTDOWN"
|
294 | a8083063 | Iustin Pop | __slots__ = ["instance_name"]
|
295 | a8083063 | Iustin Pop | |
296 | a8083063 | Iustin Pop | |
297 | bf6929a2 | Alexander Schreiber | class OpRebootInstance(OpCode): |
298 | bf6929a2 | Alexander Schreiber | """Reboot an instance."""
|
299 | eeb3a5f9 | Iustin Pop | OP_ID = "OP_INSTANCE_REBOOT"
|
300 | bf6929a2 | Alexander Schreiber | __slots__ = ["instance_name", "reboot_type", "extra_args", |
301 | bf6929a2 | Alexander Schreiber | "ignore_secondaries" ]
|
302 | bf6929a2 | Alexander Schreiber | |
303 | bf6929a2 | Alexander Schreiber | |
304 | a8083063 | Iustin Pop | class OpAddMDDRBDComponent(OpCode): |
305 | a8083063 | Iustin Pop | """Add a MD-DRBD component."""
|
306 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_ADD_MDDRBD"
|
307 | a8083063 | Iustin Pop | __slots__ = ["instance_name", "remote_node", "disk_name"] |
308 | a8083063 | Iustin Pop | |
309 | a8083063 | Iustin Pop | |
310 | a8083063 | Iustin Pop | class OpRemoveMDDRBDComponent(OpCode): |
311 | a8083063 | Iustin Pop | """Remove a MD-DRBD component."""
|
312 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_REMOVE_MDDRBD"
|
313 | a8083063 | Iustin Pop | __slots__ = ["instance_name", "disk_name", "disk_id"] |
314 | a8083063 | Iustin Pop | |
315 | a8083063 | Iustin Pop | |
316 | a8083063 | Iustin Pop | class OpReplaceDisks(OpCode): |
317 | fdc267f4 | Iustin Pop | """Replace the disks of an instance."""
|
318 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_REPLACE_DISKS"
|
319 | a9e0c397 | Iustin Pop | __slots__ = ["instance_name", "remote_node", "mode", "disks"] |
320 | a8083063 | Iustin Pop | |
321 | a8083063 | Iustin Pop | |
322 | a8083063 | Iustin Pop | class OpFailoverInstance(OpCode): |
323 | a8083063 | Iustin Pop | """Failover an instance."""
|
324 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_FAILOVER"
|
325 | a8083063 | Iustin Pop | __slots__ = ["instance_name", "ignore_consistency"] |
326 | a8083063 | Iustin Pop | |
327 | a8083063 | Iustin Pop | |
328 | a8083063 | Iustin Pop | class OpConnectConsole(OpCode): |
329 | fdc267f4 | Iustin Pop | """Connect to an instance's console."""
|
330 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_CONSOLE"
|
331 | a8083063 | Iustin Pop | __slots__ = ["instance_name"]
|
332 | a8083063 | Iustin Pop | |
333 | a8083063 | Iustin Pop | |
334 | a8083063 | Iustin Pop | class OpActivateInstanceDisks(OpCode): |
335 | fdc267f4 | Iustin Pop | """Activate an instance's disks."""
|
336 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_ACTIVATE_DISKS"
|
337 | a8083063 | Iustin Pop | __slots__ = ["instance_name"]
|
338 | a8083063 | Iustin Pop | |
339 | a8083063 | Iustin Pop | |
340 | a8083063 | Iustin Pop | class OpDeactivateInstanceDisks(OpCode): |
341 | fdc267f4 | Iustin Pop | """Deactivate an instance's disks."""
|
342 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_DEACTIVATE_DISKS"
|
343 | a8083063 | Iustin Pop | __slots__ = ["instance_name"]
|
344 | a8083063 | Iustin Pop | |
345 | a8083063 | Iustin Pop | |
346 | a8083063 | Iustin Pop | class OpQueryInstances(OpCode): |
347 | a8083063 | Iustin Pop | """Compute the list of instances."""
|
348 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_QUERY"
|
349 | 069dcc86 | Iustin Pop | __slots__ = ["output_fields", "names"] |
350 | a8083063 | Iustin Pop | |
351 | a8083063 | Iustin Pop | |
352 | a8083063 | Iustin Pop | class OpQueryInstanceData(OpCode): |
353 | a8083063 | Iustin Pop | """Compute the run-time status of instances."""
|
354 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_QUERY_DATA"
|
355 | a8083063 | Iustin Pop | __slots__ = ["instances"]
|
356 | a8083063 | Iustin Pop | |
357 | a8083063 | Iustin Pop | |
358 | a8083063 | Iustin Pop | class OpSetInstanceParms(OpCode): |
359 | a8083063 | Iustin Pop | """Change the parameters of an instance."""
|
360 | a8083063 | Iustin Pop | OP_ID = "OP_INSTANCE_SET_PARMS"
|
361 | 973d7867 | Iustin Pop | __slots__ = [ |
362 | 973d7867 | Iustin Pop | "instance_name", "mem", "vcpus", "ip", "bridge", "mac", |
363 | 25c5878d | Alexander Schreiber | "kernel_path", "initrd_path", "hvm_boot_order", |
364 | 973d7867 | Iustin Pop | ] |
365 | a8083063 | Iustin Pop | |
366 | a8083063 | 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 | a8083063 | Iustin Pop | __slots__ = [] |
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 | 5c947f38 | Iustin Pop | |
387 | 5c947f38 | Iustin Pop | # Tags opcodes
|
388 | 5c947f38 | Iustin Pop | class OpGetTags(OpCode): |
389 | 5c947f38 | Iustin Pop | """Returns the tags of the given object."""
|
390 | 5c947f38 | Iustin Pop | OP_ID = "OP_TAGS_GET"
|
391 | 5c947f38 | Iustin Pop | __slots__ = ["kind", "name"] |
392 | 5c947f38 | Iustin Pop | |
393 | 5c947f38 | Iustin Pop | |
394 | 73415719 | Iustin Pop | class OpSearchTags(OpCode): |
395 | 73415719 | Iustin Pop | """Searches the tags in the cluster for a given pattern."""
|
396 | 73415719 | Iustin Pop | OP_ID = "OP_TAGS_SEARCH"
|
397 | 73415719 | Iustin Pop | __slots__ = ["pattern"]
|
398 | 73415719 | Iustin Pop | |
399 | 73415719 | Iustin Pop | |
400 | f27302fa | Iustin Pop | class OpAddTags(OpCode): |
401 | f27302fa | Iustin Pop | """Add a list of tags on a given object."""
|
402 | 5c947f38 | Iustin Pop | OP_ID = "OP_TAGS_SET"
|
403 | f27302fa | Iustin Pop | __slots__ = ["kind", "name", "tags"] |
404 | 5c947f38 | Iustin Pop | |
405 | 5c947f38 | Iustin Pop | |
406 | f27302fa | Iustin Pop | class OpDelTags(OpCode): |
407 | f27302fa | Iustin Pop | """Remove a list of tags from a given object."""
|
408 | 5c947f38 | Iustin Pop | OP_ID = "OP_TAGS_DEL"
|
409 | f27302fa | Iustin Pop | __slots__ = ["kind", "name", "tags"] |
410 | 06009e27 | Iustin Pop | |
411 | 06009e27 | Iustin Pop | |
412 | 06009e27 | Iustin Pop | # Test opcodes
|
413 | 06009e27 | Iustin Pop | class OpTestDelay(OpCode): |
414 | 06009e27 | Iustin Pop | """Sleeps for a configured amount of time.
|
415 | 06009e27 | Iustin Pop |
|
416 | 06009e27 | Iustin Pop | This is used just for debugging and testing.
|
417 | 06009e27 | Iustin Pop |
|
418 | 06009e27 | Iustin Pop | Parameters:
|
419 | 06009e27 | Iustin Pop | - duration: the time to sleep
|
420 | 06009e27 | Iustin Pop | - on_master: if true, sleep on the master
|
421 | 06009e27 | Iustin Pop | - on_nodes: list of nodes in which to sleep
|
422 | 06009e27 | Iustin Pop |
|
423 | 06009e27 | Iustin Pop | If the on_master parameter is true, it will execute a sleep on the
|
424 | 06009e27 | Iustin Pop | master (before any node sleep).
|
425 | 06009e27 | Iustin Pop |
|
426 | 06009e27 | Iustin Pop | If the on_nodes list is not empty, it will sleep on those nodes
|
427 | 06009e27 | Iustin Pop | (after the sleep on the master, if that is enabled).
|
428 | 06009e27 | Iustin Pop |
|
429 | 06009e27 | Iustin Pop | As an additional feature, the case of duration < 0 will be reported
|
430 | 06009e27 | Iustin Pop | as an execution error, so this opcode can be used as a failure
|
431 | 06009e27 | Iustin Pop | generator. The case of duration == 0 will not be treated specially.
|
432 | 06009e27 | Iustin Pop |
|
433 | 06009e27 | Iustin Pop | """
|
434 | 06009e27 | Iustin Pop | OP_ID = "OP_TEST_DELAY"
|
435 | 06009e27 | Iustin Pop | __slots__ = ["duration", "on_master", "on_nodes"] |