Remove OpQueryNodeData and LUQueryNodeData
[ganeti-local] / lib / opcodes.py
1 #!/usr/bin/python
2 #
3
4 # Copyright (C) 2006, 2007 Google Inc.
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 # 02110-1301, USA.
20
21
22 """OpCodes module
23
24 This module implements the data structures which define the cluster
25 operations - the so-called opcodes.
26
27
28 This module implements the logic for doing operations in the cluster. There
29 are two kinds of classes defined:
30   - opcodes, which are small classes only holding data for the task at hand
31   - logical units, which know how to deal with their specific opcode only
32
33 """
34
35 # this are practically structures, so disable the message about too
36 # few public methods:
37 # pylint: disable-msg=R0903
38
39 class OpCode(object):
40   """Abstract OpCode"""
41   OP_ID = "OP_ABSTRACT"
42   __slots__ = []
43
44   def __init__(self, **kwargs):
45     for key in kwargs:
46       if key not in self.__slots__:
47         raise TypeError("OpCode %s doesn't support the parameter '%s'" %
48                         (self.__class__.__name__, key))
49       setattr(self, key, kwargs[key])
50
51
52 class OpInitCluster(OpCode):
53   """Initialise the cluster."""
54   OP_ID = "OP_CLUSTER_INIT"
55   __slots__ = ["cluster_name", "secondary_ip", "hypervisor_type",
56                "vg_name", "mac_prefix", "def_bridge", "master_netdev"]
57
58
59 class OpDestroyCluster(OpCode):
60   """Destroy the cluster."""
61   OP_ID = "OP_CLUSTER_DESTROY"
62   __slots__ = []
63
64
65 class OpQueryClusterInfo(OpCode):
66   """Query cluster information."""
67   OP_ID = "OP_CLUSTER_QUERY"
68   __slots__ = []
69
70
71 class OpClusterCopyFile(OpCode):
72   """Copy a file to multiple nodes."""
73   OP_ID = "OP_CLUSTER_COPYFILE"
74   __slots__ = ["nodes", "filename"]
75
76
77 class OpRunClusterCommand(OpCode):
78   """Run a command on multiple nodes."""
79   OP_ID = "OP_CLUSTER_RUNCOMMAND"
80   __slots__ = ["nodes", "command"]
81
82
83 class OpVerifyCluster(OpCode):
84   """Verify the cluster state."""
85   OP_ID = "OP_CLUSTER_VERIFY"
86   __slots__ = []
87
88
89 class OpMasterFailover(OpCode):
90   """Do a master failover."""
91   OP_ID = "OP_CLUSTER_MASTERFAILOVER"
92   __slots__ = []
93
94
95 class OpDumpClusterConfig(OpCode):
96   """Dump the cluster configuration."""
97   OP_ID = "OP_CLUSTER_DUMPCONFIG"
98   __slots__ = []
99
100
101 class OpRemoveNode(OpCode):
102   """Remove a node."""
103   OP_ID = "OP_NODE_REMOVE"
104   __slots__ = ["node_name"]
105
106
107 class OpAddNode(OpCode):
108   """Add a node."""
109   OP_ID = "OP_NODE_ADD"
110   __slots__ = ["node_name", "primary_ip", "secondary_ip"]
111
112
113 class OpQueryNodes(OpCode):
114   """Compute the list of nodes."""
115   OP_ID = "OP_NODE_QUERY"
116   __slots__ = ["output_fields", "nodes"]
117
118
119 class OpQueryNodeVolumes(OpCode):
120   """Get list of volumes on node."""
121   OP_ID = "OP_NODE_QUERYVOLS"
122   __slots__ = ["nodes", "output_fields"]
123
124
125 # instance opcodes
126
127 class OpCreateInstance(OpCode):
128   """Create an instance."""
129   OP_ID = "OP_INSTANCE_CREATE"
130   __slots__ = ["instance_name", "mem_size", "disk_size", "os_type", "pnode",
131                "disk_template", "snode", "swap_size", "mode",
132                "vcpus", "ip", "bridge", "src_node", "src_path", "start",
133                "wait_for_sync"]
134
135
136 class OpReinstallInstance(OpCode):
137   """Reinstall an instance's OS."""
138   OP_ID = "OP_INSTANCE_REINSTALL"
139   __slots__ = ["instance_name", "os_type"]
140
141
142 class OpRemoveInstance(OpCode):
143   """Remove an instance."""
144   OP_ID = "OP_INSTANCE_REMOVE"
145   __slots__ = ["instance_name"]
146
147
148 class OpStartupInstance(OpCode):
149   """Startup an instance."""
150   OP_ID = "OP_INSTANCE_STARTUP"
151   __slots__ = ["instance_name", "force", "extra_args"]
152
153
154 class OpShutdownInstance(OpCode):
155   """Shutdown an instance."""
156   OP_ID = "OP_INSTANCE_SHUTDOWN"
157   __slots__ = ["instance_name"]
158
159
160 class OpAddMDDRBDComponent(OpCode):
161   """Add a MD-DRBD component."""
162   OP_ID = "OP_INSTANCE_ADD_MDDRBD"
163   __slots__ = ["instance_name", "remote_node", "disk_name"]
164
165
166 class OpRemoveMDDRBDComponent(OpCode):
167   """Remove a MD-DRBD component."""
168   OP_ID = "OP_INSTANCE_REMOVE_MDDRBD"
169   __slots__ = ["instance_name", "disk_name", "disk_id"]
170
171
172 class OpReplaceDisks(OpCode):
173   """Replace the disks of an instance."""
174   OP_ID = "OP_INSTANCE_REPLACE_DISKS"
175   __slots__ = ["instance_name", "remote_node"]
176
177
178 class OpFailoverInstance(OpCode):
179   """Failover an instance."""
180   OP_ID = "OP_INSTANCE_FAILOVER"
181   __slots__ = ["instance_name", "ignore_consistency"]
182
183
184 class OpConnectConsole(OpCode):
185   """Connect to an instance's console."""
186   OP_ID = "OP_INSTANCE_CONSOLE"
187   __slots__ = ["instance_name"]
188
189
190 class OpActivateInstanceDisks(OpCode):
191   """Activate an instance's disks."""
192   OP_ID = "OP_INSTANCE_ACTIVATE_DISKS"
193   __slots__ = ["instance_name"]
194
195
196 class OpDeactivateInstanceDisks(OpCode):
197   """Deactivate an instance's disks."""
198   OP_ID = "OP_INSTANCE_DEACTIVATE_DISKS"
199   __slots__ = ["instance_name"]
200
201
202 class OpQueryInstances(OpCode):
203   """Compute the list of instances."""
204   OP_ID = "OP_INSTANCE_QUERY"
205   __slots__ = ["output_fields"]
206
207
208 class OpQueryInstanceData(OpCode):
209   """Compute the run-time status of instances."""
210   OP_ID = "OP_INSTANCE_QUERY_DATA"
211   __slots__ = ["instances"]
212
213
214 class OpSetInstanceParms(OpCode):
215   """Change the parameters of an instance."""
216   OP_ID = "OP_INSTANCE_SET_PARMS"
217   __slots__ = ["instance_name", "mem", "vcpus", "ip", "bridge"]
218
219
220 # OS opcodes
221 class OpDiagnoseOS(OpCode):
222   """Compute the list of guest operating systems."""
223   OP_ID = "OP_OS_DIAGNOSE"
224   __slots__ = []
225
226 # Exports opcodes
227 class OpQueryExports(OpCode):
228   """Compute the list of exported images."""
229   OP_ID = "OP_BACKUP_QUERY"
230   __slots__ = ["nodes"]
231
232 class OpExportInstance(OpCode):
233   """Export an instance."""
234   OP_ID = "OP_BACKUP_EXPORT"
235   __slots__ = ["instance_name", "target_node", "shutdown"]
236
237
238 # Tags opcodes
239 class OpGetTags(OpCode):
240   """Returns the tags of the given object."""
241   OP_ID = "OP_TAGS_GET"
242   __slots__ = ["kind", "name"]
243
244
245 class OpSetTag(OpCode):
246   """Sets the value of a tag on a given object."""
247   OP_ID = "OP_TAGS_SET"
248   __slots__ = ["kind", "name", "tag"]
249
250
251 class OpDelTag(OpCode):
252   """Remove a tag from a given object."""
253   OP_ID = "OP_TAGS_DEL"
254   __slots__ = ["kind", "name", "tag"]