4 # Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Google Inc.
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.
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.
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
21 """RPC definitions for communication between master and node daemons.
23 RPC definition fields:
26 - L{SINGLE} for single-node calls, L{MULTI} for multi-node
27 - Timeout (e.g. L{TMO_NORMAL})
28 - List of arguments as tuples
31 - Wrapper code ("%s" is replaced with argument name, see L{OBJECT_TO_DICT})
32 - Description for docstring (can be C{None})
34 - Return value wrapper (e.g. for deserializing into L{objects}-based objects)
35 - Short call description for docstring
40 # Various time constants for the timeout table
41 TMO_URGENT = 60 # one minute
42 TMO_FAST = 5 * 60 # five minutes
43 TMO_NORMAL = 15 * 60 # 15 minutes
44 TMO_SLOW = 3600 # one hour
48 SINGLE = "single-node"
51 OBJECT_TO_DICT = "%s.ToDict()"
52 OBJECT_LIST_TO_DICT = "map(lambda d: d.ToDict(), %s)"
53 INST_TO_DICT = "self._InstDict(%s)"
56 ("dict((name, %s) for name, disks in %%s.items())" %
57 (OBJECT_LIST_TO_DICT % "disks"))
59 _FILE_STORAGE_CALLS = [
60 ("file_storage_dir_create", SINGLE, TMO_FAST, [
61 ("file_storage_dir", None, "File storage directory"),
62 ], None, "Create the given file storage directory"),
63 ("file_storage_dir_remove", SINGLE, TMO_FAST, [
64 ("file_storage_dir", None, "File storage directory"),
65 ], None, "Remove the given file storage directory"),
66 ("file_storage_dir_rename", SINGLE, TMO_FAST, [
67 ("old_file_storage_dir", None, "Old name"),
68 ("new_file_storage_dir", None, "New name"),
69 ], None, "Rename file storage directory"),
73 ("storage_list", MULTI, TMO_NORMAL, [
74 ("su_name", None, None),
75 ("su_args", None, None),
77 ("fields", None, None),
78 ], None, "Get list of storage units"),
79 ("storage_modify", SINGLE, TMO_NORMAL, [
80 ("su_name", None, None),
81 ("su_args", None, None),
83 ("changes", None, None),
84 ], None, "Modify a storage unit"),
85 ("storage_execute", SINGLE, TMO_NORMAL, [
86 ("su_name", None, None),
87 ("su_args", None, None),
90 ], None, "Executes an operation on a storage unit"),
94 ("instance_info", SINGLE, TMO_URGENT, [
95 ("instance", None, "Instance name"),
96 ("hname", None, "Hypervisor type"),
97 ], None, "Returns information about a single instance"),
98 ("all_instances_info", MULTI, TMO_URGENT, [
99 ("hypervisor_list", None, "Hypervisors to query for instances"),
100 ], None, "Returns information about all instances on the given nodes"),
101 ("instance_list", MULTI, TMO_URGENT, [
102 ("hypervisor_list", None, "Hypervisors to query for instances"),
103 ], None, "Returns the list of running instances on the given nodes"),
104 ("instance_reboot", SINGLE, TMO_NORMAL, [
105 ("inst", INST_TO_DICT, "Instance object"),
106 ("reboot_type", None, None),
107 ("shutdown_timeout", None, None),
108 ], None, "Returns the list of running instances on the given nodes"),
109 ("instance_shutdown", SINGLE, TMO_NORMAL, [
110 ("instance", INST_TO_DICT, "Instance object"),
111 ("timeout", None, None),
112 ], None, "Stops an instance"),
113 ("instance_run_rename", SINGLE, TMO_SLOW, [
114 ("instance", INST_TO_DICT, "Instance object"),
115 ("old_name", None, None),
116 ("debug", None, None),
117 ], None, "Run the OS rename script for an instance"),
118 ("instance_migratable", SINGLE, TMO_NORMAL, [
119 ("instance", INST_TO_DICT, "Instance object"),
120 ], None, "Checks whether the given instance can be migrated"),
121 ("migration_info", SINGLE, TMO_NORMAL, [
122 ("instance", INST_TO_DICT, "Instance object"),
124 "Gather the information necessary to prepare an instance migration"),
125 ("accept_instance", SINGLE, TMO_NORMAL, [
126 ("instance", INST_TO_DICT, "Instance object"),
127 ("info", None, "Result for the call_migration_info call"),
128 ("target", None, "Target hostname (usually an IP address)"),
129 ], None, "Prepare a node to accept an instance"),
130 ("instance_finalize_migration_dst", SINGLE, TMO_NORMAL, [
131 ("instance", INST_TO_DICT, "Instance object"),
132 ("info", None, "Result for the call_migration_info call"),
133 ("success", None, "Whether the migration was a success or failure"),
134 ], None, "Finalize any target-node migration specific operation"),
135 ("instance_migrate", SINGLE, TMO_SLOW, [
136 ("instance", INST_TO_DICT, "Instance object"),
137 ("target", None, "Target node name"),
138 ("live", None, "Whether the migration should be done live or not"),
139 ], None, "Migrate an instance"),
140 ("instance_finalize_migration_src", SINGLE, TMO_SLOW, [
141 ("instance", INST_TO_DICT, "Instance object"),
142 ("success", None, "Whether the migration succeeded or not"),
143 ("live", None, "Whether the user requested a live migration or not"),
144 ], None, "Finalize the instance migration on the source node"),
148 ("impexp_status", SINGLE, TMO_FAST, [
149 ("names", None, "Import/export names"),
150 ], "self._ImpExpStatusPostProc", "Gets the status of an import or export"),
151 ("impexp_abort", SINGLE, TMO_NORMAL, [
152 ("name", None, "Import/export name"),
153 ], None, "Aborts an import or export"),
154 ("impexp_cleanup", SINGLE, TMO_NORMAL, [
155 ("name", None, "Import/export name"),
156 ], None, "Cleans up after an import or export"),
157 ("export_info", SINGLE, TMO_FAST, [
158 ("path", None, None),
159 ], None, "Queries the export information in a given path"),
160 ("finalize_export", SINGLE, TMO_NORMAL, [
161 ("instance", INST_TO_DICT, None),
162 ("snap_disks", "self._PrepareFinalizeExportDisks(%s)", None),
163 ], None, "Request the completion of an export operation"),
164 ("export_list", MULTI, TMO_FAST, [], None, "Gets the stored exports list"),
165 ("export_remove", SINGLE, TMO_FAST, [
166 ("export", None, None),
167 ], None, "Requests removal of a given export"),
171 ("x509_cert_create", SINGLE, TMO_NORMAL, [
172 ("validity", None, "Validity in seconds"),
173 ], None, "Creates a new X509 certificate for SSL/TLS"),
174 ("x509_cert_remove", SINGLE, TMO_NORMAL, [
175 ("name", None, "Certificate name"),
176 ], None, "Removes a X509 certificate"),
180 ("bdev_sizes", MULTI, TMO_URGENT, [
181 ("devices", None, None),
182 ], None, "Gets the sizes of requested block devices present on a node"),
183 ("blockdev_create", SINGLE, TMO_NORMAL, [
184 ("bdev", OBJECT_TO_DICT, None),
185 ("size", None, None),
186 ("owner", None, None),
187 ("on_primary", None, None),
188 ("info", None, None),
189 ], None, "Request creation of a given block device"),
190 ("blockdev_wipe", SINGLE, TMO_SLOW, [
191 ("bdev", OBJECT_TO_DICT, None),
192 ("offset", None, None),
193 ("size", None, None),
195 "Request wipe at given offset with given size of a block device"),
196 ("blockdev_remove", SINGLE, TMO_NORMAL, [
197 ("bdev", OBJECT_TO_DICT, None),
198 ], None, "Request removal of a given block device"),
199 ("blockdev_pause_resume_sync", SINGLE, TMO_NORMAL, [
200 ("disks", OBJECT_LIST_TO_DICT, None),
201 ("pause", None, None),
202 ], None, "Request a pause/resume of given block device"),
203 ("blockdev_assemble", SINGLE, TMO_NORMAL, [
204 ("disk", OBJECT_TO_DICT, None),
205 ("owner", None, None),
206 ("on_primary", None, None),
208 ], None, "Request assembling of a given block device"),
209 ("blockdev_shutdown", SINGLE, TMO_NORMAL, [
210 ("disk", OBJECT_TO_DICT, None),
211 ], None, "Request shutdown of a given block device"),
212 ("blockdev_addchildren", SINGLE, TMO_NORMAL, [
213 ("bdev", OBJECT_TO_DICT, None),
214 ("ndevs", OBJECT_LIST_TO_DICT, None),
215 ], None, "Request adding a list of children to a (mirroring) device"),
216 ("blockdev_removechildren", SINGLE, TMO_NORMAL, [
217 ("bdev", OBJECT_TO_DICT, None),
218 ("ndevs", OBJECT_LIST_TO_DICT, None),
219 ], None, "Request removing a list of children from a (mirroring) device"),
220 ("blockdev_close", SINGLE, TMO_NORMAL, [
221 ("instance_name", None, None),
222 ("disks", OBJECT_LIST_TO_DICT, None),
223 ], None, "Closes the given block devices"),
224 ("blockdev_getsize", SINGLE, TMO_NORMAL, [
225 ("disks", OBJECT_LIST_TO_DICT, None),
226 ], None, "Returns the size of the given disks"),
227 ("drbd_disconnect_net", MULTI, TMO_NORMAL, [
228 ("nodes_ip", None, None),
229 ("disks", OBJECT_LIST_TO_DICT, None),
230 ], None, "Disconnects the network of the given drbd devices"),
231 ("drbd_attach_net", MULTI, TMO_NORMAL, [
232 ("nodes_ip", None, None),
233 ("disks", OBJECT_LIST_TO_DICT, None),
234 ("instance_name", None, None),
235 ("multimaster", None, None),
236 ], None, "Connects the given DRBD devices"),
237 ("drbd_wait_sync", MULTI, TMO_SLOW, [
238 ("nodes_ip", None, None),
239 ("disks", OBJECT_LIST_TO_DICT, None),
240 ], None, "Waits for the synchronization of drbd devices is complete"),
241 ("blockdev_grow", SINGLE, TMO_NORMAL, [
242 ("cf_bdev", OBJECT_TO_DICT, None),
243 ("amount", None, None),
244 ("dryrun", None, None),
245 ], None, "Request a snapshot of the given block device"),
246 ("blockdev_export", SINGLE, TMO_1DAY, [
247 ("cf_bdev", OBJECT_TO_DICT, None),
248 ("dest_node", None, None),
249 ("dest_path", None, None),
250 ("cluster_name", None, None),
251 ], None, "Export a given disk to another node"),
252 ("blockdev_snapshot", SINGLE, TMO_NORMAL, [
253 ("cf_bdev", OBJECT_TO_DICT, None),
254 ], None, "Export a given disk to another node"),
255 ("blockdev_rename", SINGLE, TMO_NORMAL, [
256 ("devlist", "[(d.ToDict(), uid) for d, uid in %s]", None),
257 ], None, "Request rename of the given block devices"),
258 ("blockdev_find", SINGLE, TMO_NORMAL, [
259 ("disk", OBJECT_TO_DICT, None),
260 ], "self._BlockdevFindPostProc",
261 "Request identification of a given block device"),
262 ("blockdev_getmirrorstatus", SINGLE, TMO_NORMAL, [
263 ("disks", OBJECT_LIST_TO_DICT, None),
264 ], "self._BlockdevGetMirrorStatusPostProc",
265 "Request status of a (mirroring) device"),
266 ("blockdev_getmirrorstatus_multi", MULTI, TMO_NORMAL, [
267 ("node_disks", NODE_TO_DISK_DICT, None),
268 ], "self._BlockdevGetMirrorStatusMultiPostProc",
269 "Request status of (mirroring) devices from multiple nodes"),
273 ("os_diagnose", MULTI, TMO_FAST, [], None,
274 "Request a diagnose of OS definitions"),
275 ("os_validate", MULTI, TMO_FAST, [
276 ("required", None, None),
277 ("name", None, None),
278 ("checks", None, None),
279 ("params", None, None),
280 ], None, "Run a validation routine for a given OS"),
281 ("os_get", SINGLE, TMO_FAST, [
282 ("name", None, None),
283 ], "self._OsGetPostProc", "Returns an OS definition"),
287 ("node_has_ip_address", SINGLE, TMO_FAST, [
288 ("address", None, "IP address"),
289 ], None, "Checks if a node has the given IP address"),
290 ("node_info", MULTI, TMO_URGENT, [
292 "Name of the volume group to ask for disk space information"),
293 ("hypervisor_type", None,
294 "Name of the hypervisor to ask for memory information"),
295 ], None, "Return node information"),
296 ("node_verify", MULTI, TMO_NORMAL, [
297 ("checkdict", None, None),
298 ("cluster_name", None, None),
299 ], None, "Request verification of given parameters"),
300 ("node_volumes", MULTI, TMO_FAST, [], None, "Gets all volumes on node(s)"),
301 ("node_demote_from_mc", SINGLE, TMO_FAST, [], None,
302 "Demote a node from the master candidate role"),
303 ("node_powercycle", SINGLE, TMO_NORMAL, [
304 ("hypervisor", None, "Hypervisor type"),
305 ], None, "Tries to powercycle a node"),
309 ("lv_list", MULTI, TMO_URGENT, [
310 ("vg_name", None, None),
311 ], None, "Gets the logical volumes present in a given volume group"),
312 ("vg_list", MULTI, TMO_URGENT, [], None, "Gets the volume group list"),
313 ("bridges_exist", SINGLE, TMO_URGENT, [
314 ("bridges_list", None, "Bridges which must be present on remote node"),
315 ], None, "Checks if a node has all the bridges given"),
316 ("etc_hosts_modify", SINGLE, TMO_NORMAL, [
318 "Mode to operate; currently L{constants.ETC_HOSTS_ADD} or"
319 " L{constants.ETC_HOSTS_REMOVE}"),
320 ("name", None, "Hostname to be modified"),
321 ("ip", None, "IP address (L{constants.ETC_HOSTS_ADD} only)"),
322 ], None, "Modify hosts file with name"),
323 ("drbd_helper", MULTI, TMO_URGENT, [], None, "Gets DRBD helper"),
324 ("run_oob", SINGLE, TMO_NORMAL, [
325 ("oob_program", None, None),
326 ("command", None, None),
327 ("remote_node", None, None),
328 ("timeout", None, None),
329 ], None, "Runs out-of-band command"),
330 ("hooks_runner", MULTI, TMO_NORMAL, [
331 ("hpath", None, None),
332 ("phase", None, None),
334 ], None, "Call the hooks runner"),
335 ("iallocator_runner", SINGLE, TMO_NORMAL, [
336 ("name", None, "Iallocator name"),
337 ("idata", None, "JSON-encoded input string"),
338 ], None, "Call an iallocator on a remote node"),
339 ("test_delay", MULTI, None, [
340 ("duration", None, None),
341 ], None, "Sleep for a fixed time on given node(s)"),
345 "RpcClientDefault": (_IMPEXP_CALLS + _X509_CALLS),