Revision cd40dc53 lib/rpc_defs.py
b/lib/rpc_defs.py | ||
---|---|---|
28 | 28 |
- List of arguments as tuples |
29 | 29 |
|
30 | 30 |
- Name as string |
31 |
- Wrapper code ("%s" is replaced with argument name, see L{OBJECT_TO_DICT})
|
|
31 |
- Argument kind used for encoding/decoding
|
|
32 | 32 |
- Description for docstring (can be C{None}) |
33 | 33 |
|
34 | 34 |
- Return value wrapper (e.g. for deserializing into L{objects}-based objects) |
... | ... | |
52 | 52 |
SINGLE = "single-node" |
53 | 53 |
MULTI = "multi-node" |
54 | 54 |
|
55 |
OBJECT_TO_DICT = "%s.ToDict()" |
|
56 |
OBJECT_LIST_TO_DICT = "map(lambda d: d.ToDict(), %s)" |
|
57 |
INST_TO_DICT = "self._InstDict(%s)" |
|
58 |
|
|
59 |
NODE_TO_DISK_DICT = \ |
|
60 |
("dict((name, %s) for name, disks in %%s.items())" % |
|
61 |
(OBJECT_LIST_TO_DICT % "disks")) |
|
55 |
# Constants for encoding/decoding |
|
56 |
(ED_OBJECT_DICT, |
|
57 |
ED_OBJECT_DICT_LIST, |
|
58 |
ED_INST_DICT, |
|
59 |
ED_INST_DICT_HVP_BEP, |
|
60 |
ED_NODE_TO_DISK_DICT, |
|
61 |
ED_INST_DICT_OSP, |
|
62 |
ED_IMPEXP_IO, |
|
63 |
ED_FILE_DETAILS, |
|
64 |
ED_FINALIZE_EXPORT_DISKS, |
|
65 |
ED_COMPRESS, |
|
66 |
ED_BLOCKDEV_RENAME) = range(1, 12) |
|
62 | 67 |
|
63 | 68 |
_FILE_STORAGE_CALLS = [ |
64 | 69 |
("file_storage_dir_create", SINGLE, TMO_FAST, [ |
... | ... | |
106 | 111 |
("hypervisor_list", None, "Hypervisors to query for instances"), |
107 | 112 |
], None, "Returns the list of running instances on the given nodes"), |
108 | 113 |
("instance_reboot", SINGLE, TMO_NORMAL, [ |
109 |
("inst", INST_TO_DICT, "Instance object"),
|
|
114 |
("inst", ED_INST_DICT, "Instance object"),
|
|
110 | 115 |
("reboot_type", None, None), |
111 | 116 |
("shutdown_timeout", None, None), |
112 | 117 |
], None, "Returns the list of running instances on the given nodes"), |
113 | 118 |
("instance_shutdown", SINGLE, TMO_NORMAL, [ |
114 |
("instance", INST_TO_DICT, "Instance object"),
|
|
119 |
("instance", ED_INST_DICT, "Instance object"),
|
|
115 | 120 |
("timeout", None, None), |
116 | 121 |
], None, "Stops an instance"), |
117 | 122 |
("instance_run_rename", SINGLE, TMO_SLOW, [ |
118 |
("instance", INST_TO_DICT, "Instance object"),
|
|
123 |
("instance", ED_INST_DICT, "Instance object"),
|
|
119 | 124 |
("old_name", None, None), |
120 | 125 |
("debug", None, None), |
121 | 126 |
], None, "Run the OS rename script for an instance"), |
122 | 127 |
("instance_migratable", SINGLE, TMO_NORMAL, [ |
123 |
("instance", INST_TO_DICT, "Instance object"),
|
|
128 |
("instance", ED_INST_DICT, "Instance object"),
|
|
124 | 129 |
], None, "Checks whether the given instance can be migrated"), |
125 | 130 |
("migration_info", SINGLE, TMO_NORMAL, [ |
126 |
("instance", INST_TO_DICT, "Instance object"),
|
|
131 |
("instance", ED_INST_DICT, "Instance object"),
|
|
127 | 132 |
], None, |
128 | 133 |
"Gather the information necessary to prepare an instance migration"), |
129 | 134 |
("accept_instance", SINGLE, TMO_NORMAL, [ |
130 |
("instance", INST_TO_DICT, "Instance object"),
|
|
135 |
("instance", ED_INST_DICT, "Instance object"),
|
|
131 | 136 |
("info", None, "Result for the call_migration_info call"), |
132 | 137 |
("target", None, "Target hostname (usually an IP address)"), |
133 | 138 |
], None, "Prepare a node to accept an instance"), |
134 | 139 |
("instance_finalize_migration_dst", SINGLE, TMO_NORMAL, [ |
135 |
("instance", INST_TO_DICT, "Instance object"),
|
|
140 |
("instance", ED_INST_DICT, "Instance object"),
|
|
136 | 141 |
("info", None, "Result for the call_migration_info call"), |
137 | 142 |
("success", None, "Whether the migration was a success or failure"), |
138 | 143 |
], None, "Finalize any target-node migration specific operation"), |
139 | 144 |
("instance_migrate", SINGLE, TMO_SLOW, [ |
140 |
("instance", INST_TO_DICT, "Instance object"),
|
|
145 |
("instance", ED_INST_DICT, "Instance object"),
|
|
141 | 146 |
("target", None, "Target node name"), |
142 | 147 |
("live", None, "Whether the migration should be done live or not"), |
143 | 148 |
], None, "Migrate an instance"), |
144 | 149 |
("instance_finalize_migration_src", SINGLE, TMO_SLOW, [ |
145 |
("instance", INST_TO_DICT, "Instance object"),
|
|
150 |
("instance", ED_INST_DICT, "Instance object"),
|
|
146 | 151 |
("success", None, "Whether the migration succeeded or not"), |
147 | 152 |
("live", None, "Whether the user requested a live migration or not"), |
148 | 153 |
], None, "Finalize the instance migration on the source node"), |
149 | 154 |
("instance_get_migration_status", SINGLE, TMO_SLOW, [ |
150 |
("instance", INST_TO_DICT, "Instance object"),
|
|
155 |
("instance", ED_INST_DICT, "Instance object"),
|
|
151 | 156 |
], "self._MigrationStatusPostProc", "Report migration status"), |
152 | 157 |
("instance_start", SINGLE, TMO_NORMAL, [ |
153 |
("instance_hvp_bep", "self._InstDictHvpBep(%s)", None),
|
|
158 |
("instance_hvp_bep", ED_INST_DICT_HVP_BEP, None),
|
|
154 | 159 |
("startup_paused", None, None), |
155 | 160 |
], None, "Starts an instance"), |
156 | 161 |
("instance_os_add", SINGLE, TMO_1DAY, [ |
157 |
("instance_osp", "self._InstDictOsp(%s)", None),
|
|
162 |
("instance_osp", ED_INST_DICT_OSP, None),
|
|
158 | 163 |
("reinstall", None, None), |
159 | 164 |
("debug", None, None), |
160 | 165 |
], None, "Starts an instance"), |
... | ... | |
162 | 167 |
|
163 | 168 |
_IMPEXP_CALLS = [ |
164 | 169 |
("import_start", SINGLE, TMO_NORMAL, [ |
165 |
("opts", OBJECT_TO_DICT, None),
|
|
166 |
("instance", INST_TO_DICT, None),
|
|
170 |
("opts", ED_OBJECT_DICT, None),
|
|
171 |
("instance", ED_INST_DICT, None),
|
|
167 | 172 |
("component", None, None), |
168 |
("dest", "self._EncodeImportExportIO(%s)", "Import destination"),
|
|
173 |
("dest", ED_IMPEXP_IO, "Import destination"),
|
|
169 | 174 |
], None, "Starts an import daemon"), |
170 | 175 |
("export_start", SINGLE, TMO_NORMAL, [ |
171 |
("opts", OBJECT_TO_DICT, None),
|
|
176 |
("opts", ED_OBJECT_DICT, None),
|
|
172 | 177 |
("host", None, None), |
173 | 178 |
("port", None, None), |
174 |
("instance", INST_TO_DICT, None),
|
|
179 |
("instance", ED_INST_DICT, None),
|
|
175 | 180 |
("component", None, None), |
176 |
("source", "self._EncodeImportExportIO(%s)", "Export source"),
|
|
181 |
("source", ED_IMPEXP_IO, "Export source"),
|
|
177 | 182 |
], None, "Starts an export daemon"), |
178 | 183 |
("impexp_status", SINGLE, TMO_FAST, [ |
179 | 184 |
("names", None, "Import/export names"), |
... | ... | |
188 | 193 |
("path", None, None), |
189 | 194 |
], None, "Queries the export information in a given path"), |
190 | 195 |
("finalize_export", SINGLE, TMO_NORMAL, [ |
191 |
("instance", INST_TO_DICT, None),
|
|
192 |
("snap_disks", "self._PrepareFinalizeExportDisks(%s)", None),
|
|
196 |
("instance", ED_INST_DICT, None),
|
|
197 |
("snap_disks", ED_FINALIZE_EXPORT_DISKS, None),
|
|
193 | 198 |
], None, "Request the completion of an export operation"), |
194 | 199 |
("export_list", MULTI, TMO_FAST, [], None, "Gets the stored exports list"), |
195 | 200 |
("export_remove", SINGLE, TMO_FAST, [ |
... | ... | |
211 | 216 |
("devices", None, None), |
212 | 217 |
], None, "Gets the sizes of requested block devices present on a node"), |
213 | 218 |
("blockdev_create", SINGLE, TMO_NORMAL, [ |
214 |
("bdev", OBJECT_TO_DICT, None),
|
|
219 |
("bdev", ED_OBJECT_DICT, None),
|
|
215 | 220 |
("size", None, None), |
216 | 221 |
("owner", None, None), |
217 | 222 |
("on_primary", None, None), |
218 | 223 |
("info", None, None), |
219 | 224 |
], None, "Request creation of a given block device"), |
220 | 225 |
("blockdev_wipe", SINGLE, TMO_SLOW, [ |
221 |
("bdev", OBJECT_TO_DICT, None),
|
|
226 |
("bdev", ED_OBJECT_DICT, None),
|
|
222 | 227 |
("offset", None, None), |
223 | 228 |
("size", None, None), |
224 | 229 |
], None, |
225 | 230 |
"Request wipe at given offset with given size of a block device"), |
226 | 231 |
("blockdev_remove", SINGLE, TMO_NORMAL, [ |
227 |
("bdev", OBJECT_TO_DICT, None),
|
|
232 |
("bdev", ED_OBJECT_DICT, None),
|
|
228 | 233 |
], None, "Request removal of a given block device"), |
229 | 234 |
("blockdev_pause_resume_sync", SINGLE, TMO_NORMAL, [ |
230 |
("disks", OBJECT_LIST_TO_DICT, None),
|
|
235 |
("disks", ED_OBJECT_DICT_LIST, None),
|
|
231 | 236 |
("pause", None, None), |
232 | 237 |
], None, "Request a pause/resume of given block device"), |
233 | 238 |
("blockdev_assemble", SINGLE, TMO_NORMAL, [ |
234 |
("disk", OBJECT_TO_DICT, None),
|
|
239 |
("disk", ED_OBJECT_DICT, None),
|
|
235 | 240 |
("owner", None, None), |
236 | 241 |
("on_primary", None, None), |
237 | 242 |
("idx", None, None), |
238 | 243 |
], None, "Request assembling of a given block device"), |
239 | 244 |
("blockdev_shutdown", SINGLE, TMO_NORMAL, [ |
240 |
("disk", OBJECT_TO_DICT, None),
|
|
245 |
("disk", ED_OBJECT_DICT, None),
|
|
241 | 246 |
], None, "Request shutdown of a given block device"), |
242 | 247 |
("blockdev_addchildren", SINGLE, TMO_NORMAL, [ |
243 |
("bdev", OBJECT_TO_DICT, None),
|
|
244 |
("ndevs", OBJECT_LIST_TO_DICT, None),
|
|
248 |
("bdev", ED_OBJECT_DICT, None),
|
|
249 |
("ndevs", ED_OBJECT_DICT_LIST, None),
|
|
245 | 250 |
], None, "Request adding a list of children to a (mirroring) device"), |
246 | 251 |
("blockdev_removechildren", SINGLE, TMO_NORMAL, [ |
247 |
("bdev", OBJECT_TO_DICT, None),
|
|
248 |
("ndevs", OBJECT_LIST_TO_DICT, None),
|
|
252 |
("bdev", ED_OBJECT_DICT, None),
|
|
253 |
("ndevs", ED_OBJECT_DICT_LIST, None),
|
|
249 | 254 |
], None, "Request removing a list of children from a (mirroring) device"), |
250 | 255 |
("blockdev_close", SINGLE, TMO_NORMAL, [ |
251 | 256 |
("instance_name", None, None), |
252 |
("disks", OBJECT_LIST_TO_DICT, None),
|
|
257 |
("disks", ED_OBJECT_DICT_LIST, None),
|
|
253 | 258 |
], None, "Closes the given block devices"), |
254 | 259 |
("blockdev_getsize", SINGLE, TMO_NORMAL, [ |
255 |
("disks", OBJECT_LIST_TO_DICT, None),
|
|
260 |
("disks", ED_OBJECT_DICT_LIST, None),
|
|
256 | 261 |
], None, "Returns the size of the given disks"), |
257 | 262 |
("drbd_disconnect_net", MULTI, TMO_NORMAL, [ |
258 | 263 |
("nodes_ip", None, None), |
259 |
("disks", OBJECT_LIST_TO_DICT, None),
|
|
264 |
("disks", ED_OBJECT_DICT_LIST, None),
|
|
260 | 265 |
], None, "Disconnects the network of the given drbd devices"), |
261 | 266 |
("drbd_attach_net", MULTI, TMO_NORMAL, [ |
262 | 267 |
("nodes_ip", None, None), |
263 |
("disks", OBJECT_LIST_TO_DICT, None),
|
|
268 |
("disks", ED_OBJECT_DICT_LIST, None),
|
|
264 | 269 |
("instance_name", None, None), |
265 | 270 |
("multimaster", None, None), |
266 | 271 |
], None, "Connects the given DRBD devices"), |
267 | 272 |
("drbd_wait_sync", MULTI, TMO_SLOW, [ |
268 | 273 |
("nodes_ip", None, None), |
269 |
("disks", OBJECT_LIST_TO_DICT, None),
|
|
274 |
("disks", ED_OBJECT_DICT_LIST, None),
|
|
270 | 275 |
], None, "Waits for the synchronization of drbd devices is complete"), |
271 | 276 |
("blockdev_grow", SINGLE, TMO_NORMAL, [ |
272 |
("cf_bdev", OBJECT_TO_DICT, None),
|
|
277 |
("cf_bdev", ED_OBJECT_DICT, None),
|
|
273 | 278 |
("amount", None, None), |
274 | 279 |
("dryrun", None, None), |
275 | 280 |
], None, "Request a snapshot of the given block device"), |
276 | 281 |
("blockdev_export", SINGLE, TMO_1DAY, [ |
277 |
("cf_bdev", OBJECT_TO_DICT, None),
|
|
282 |
("cf_bdev", ED_OBJECT_DICT, None),
|
|
278 | 283 |
("dest_node", None, None), |
279 | 284 |
("dest_path", None, None), |
280 | 285 |
("cluster_name", None, None), |
281 | 286 |
], None, "Export a given disk to another node"), |
282 | 287 |
("blockdev_snapshot", SINGLE, TMO_NORMAL, [ |
283 |
("cf_bdev", OBJECT_TO_DICT, None),
|
|
288 |
("cf_bdev", ED_OBJECT_DICT, None),
|
|
284 | 289 |
], None, "Export a given disk to another node"), |
285 | 290 |
("blockdev_rename", SINGLE, TMO_NORMAL, [ |
286 |
("devlist", "[(d.ToDict(), uid) for d, uid in %s]", None),
|
|
291 |
("devlist", ED_BLOCKDEV_RENAME, None),
|
|
287 | 292 |
], None, "Request rename of the given block devices"), |
288 | 293 |
("blockdev_find", SINGLE, TMO_NORMAL, [ |
289 |
("disk", OBJECT_TO_DICT, None),
|
|
294 |
("disk", ED_OBJECT_DICT, None),
|
|
290 | 295 |
], "self._BlockdevFindPostProc", |
291 | 296 |
"Request identification of a given block device"), |
292 | 297 |
("blockdev_getmirrorstatus", SINGLE, TMO_NORMAL, [ |
293 |
("disks", OBJECT_LIST_TO_DICT, None),
|
|
298 |
("disks", ED_OBJECT_DICT_LIST, None),
|
|
294 | 299 |
], "self._BlockdevGetMirrorStatusPostProc", |
295 | 300 |
"Request status of a (mirroring) device"), |
296 | 301 |
("blockdev_getmirrorstatus_multi", MULTI, TMO_NORMAL, [ |
297 |
("node_disks", NODE_TO_DISK_DICT, None), |
|
302 |
("node_disks", ED_NODE_TO_DISK_DICT, None),
|
|
298 | 303 |
], "self._BlockdevGetMirrorStatusMultiPostProc", |
299 | 304 |
"Request status of (mirroring) devices from multiple nodes"), |
300 | 305 |
] |
... | ... | |
382 | 387 |
"RpcClientJobQueue": [ |
383 | 388 |
("jobqueue_update", MULTI, TMO_URGENT, [ |
384 | 389 |
("file_name", None, None), |
385 |
("content", "self._Compress(%s)", None),
|
|
390 |
("content", ED_COMPRESS, None),
|
|
386 | 391 |
], None, "Update job queue file"), |
387 | 392 |
("jobqueue_purge", SINGLE, TMO_NORMAL, [], None, "Purge job queue"), |
388 | 393 |
("jobqueue_rename", MULTI, TMO_URGENT, [ |
... | ... | |
410 | 415 |
], |
411 | 416 |
"RpcClientConfig": [ |
412 | 417 |
("upload_file", MULTI, TMO_NORMAL, [ |
413 |
("file_name", "self._PrepareFileUpload(%s)", None),
|
|
418 |
("file_name", ED_FILE_DETAILS, None),
|
|
414 | 419 |
], None, "Upload a file"), |
415 | 420 |
("write_ssconf_files", MULTI, TMO_NORMAL, [ |
416 | 421 |
("values", None, None), |
Also available in: Unified diff