Revision 26d502d0 lib/rpc_defs.py
b/lib/rpc_defs.py | ||
---|---|---|
37 | 37 |
""" |
38 | 38 |
|
39 | 39 |
from ganeti import utils |
40 |
from ganeti import objects |
|
40 | 41 |
|
41 | 42 |
|
42 | 43 |
# Guidelines for choosing timeouts: |
... | ... | |
75 | 76 |
return utils.SequenceToDict(calls) |
76 | 77 |
|
77 | 78 |
|
79 |
def _MigrationStatusPostProc(result): |
|
80 |
"""Post-processor for L{rpc.RpcRunner.call_instance_get_migration_status}. |
|
81 |
|
|
82 |
""" |
|
83 |
if not result.fail_msg and result.payload is not None: |
|
84 |
result.payload = objects.MigrationStatus.FromDict(result.payload) |
|
85 |
return result |
|
86 |
|
|
87 |
|
|
88 |
def _BlockdevFindPostProc(result): |
|
89 |
"""Post-processor for L{rpc.RpcRunner.call_blockdev_find}. |
|
90 |
|
|
91 |
""" |
|
92 |
if not result.fail_msg and result.payload is not None: |
|
93 |
result.payload = objects.BlockDevStatus.FromDict(result.payload) |
|
94 |
return result |
|
95 |
|
|
96 |
|
|
97 |
def _BlockdevGetMirrorStatusPostProc(result): |
|
98 |
"""Post-processor for L{rpc.RpcRunner.call_blockdev_getmirrorstatus}. |
|
99 |
|
|
100 |
""" |
|
101 |
if not result.fail_msg: |
|
102 |
result.payload = map(objects.BlockDevStatus.FromDict, result.payload) |
|
103 |
return result |
|
104 |
|
|
105 |
|
|
106 |
def _BlockdevGetMirrorStatusMultiPostProc(result): |
|
107 |
"""Post-processor for L{rpc.RpcRunner.call_blockdev_getmirrorstatus_multi}. |
|
108 |
|
|
109 |
""" |
|
110 |
for nres in result.values(): |
|
111 |
if nres.fail_msg: |
|
112 |
continue |
|
113 |
|
|
114 |
for idx, (success, status) in enumerate(nres.payload): |
|
115 |
if success: |
|
116 |
nres.payload[idx] = (success, objects.BlockDevStatus.FromDict(status)) |
|
117 |
|
|
118 |
return result |
|
119 |
|
|
120 |
|
|
121 |
def _OsGetPostProc(result): |
|
122 |
"""Post-processor for L{rpc.RpcRunner.call_os_get}. |
|
123 |
|
|
124 |
""" |
|
125 |
if not result.fail_msg and isinstance(result.payload, dict): |
|
126 |
result.payload = objects.OS.FromDict(result.payload) |
|
127 |
return result |
|
128 |
|
|
129 |
|
|
130 |
def _ImpExpStatusPostProc(result): |
|
131 |
"""Post-processor for import/export status. |
|
132 |
|
|
133 |
@rtype: Payload containing list of L{objects.ImportExportStatus} instances |
|
134 |
@return: Returns a list of the state of each named import/export or None if |
|
135 |
a status couldn't be retrieved |
|
136 |
|
|
137 |
""" |
|
138 |
if not result.fail_msg: |
|
139 |
decoded = [] |
|
140 |
|
|
141 |
for i in result.payload: |
|
142 |
if i is None: |
|
143 |
decoded.append(None) |
|
144 |
continue |
|
145 |
decoded.append(objects.ImportExportStatus.FromDict(i)) |
|
146 |
|
|
147 |
result.payload = decoded |
|
148 |
|
|
149 |
return result |
|
150 |
|
|
151 |
|
|
78 | 152 |
_FILE_STORAGE_CALLS = [ |
79 | 153 |
("file_storage_dir_create", SINGLE, TMO_FAST, [ |
80 | 154 |
("file_storage_dir", None, "File storage directory"), |
... | ... | |
163 | 237 |
], None, "Finalize the instance migration on the source node"), |
164 | 238 |
("instance_get_migration_status", SINGLE, TMO_SLOW, [ |
165 | 239 |
("instance", ED_INST_DICT, "Instance object"), |
166 |
], "self._MigrationStatusPostProc", "Report migration status"),
|
|
240 |
], _MigrationStatusPostProc, "Report migration status"),
|
|
167 | 241 |
("instance_start", SINGLE, TMO_NORMAL, [ |
168 | 242 |
("instance_hvp_bep", ED_INST_DICT_HVP_BEP, None), |
169 | 243 |
("startup_paused", None, None), |
... | ... | |
192 | 266 |
], None, "Starts an export daemon"), |
193 | 267 |
("impexp_status", SINGLE, TMO_FAST, [ |
194 | 268 |
("names", None, "Import/export names"), |
195 |
], "self._ImpExpStatusPostProc", "Gets the status of an import or export"),
|
|
269 |
], _ImpExpStatusPostProc, "Gets the status of an import or export"),
|
|
196 | 270 |
("impexp_abort", SINGLE, TMO_NORMAL, [ |
197 | 271 |
("name", None, "Import/export name"), |
198 | 272 |
], None, "Aborts an import or export"), |
... | ... | |
302 | 376 |
], None, "Request rename of the given block devices"), |
303 | 377 |
("blockdev_find", SINGLE, TMO_NORMAL, [ |
304 | 378 |
("disk", ED_OBJECT_DICT, None), |
305 |
], "self._BlockdevFindPostProc",
|
|
379 |
], _BlockdevFindPostProc,
|
|
306 | 380 |
"Request identification of a given block device"), |
307 | 381 |
("blockdev_getmirrorstatus", SINGLE, TMO_NORMAL, [ |
308 | 382 |
("disks", ED_OBJECT_DICT_LIST, None), |
309 |
], "self._BlockdevGetMirrorStatusPostProc",
|
|
383 |
], _BlockdevGetMirrorStatusPostProc,
|
|
310 | 384 |
"Request status of a (mirroring) device"), |
311 | 385 |
("blockdev_getmirrorstatus_multi", MULTI, TMO_NORMAL, [ |
312 | 386 |
("node_disks", ED_NODE_TO_DISK_DICT, None), |
313 |
], "self._BlockdevGetMirrorStatusMultiPostProc",
|
|
387 |
], _BlockdevGetMirrorStatusMultiPostProc,
|
|
314 | 388 |
"Request status of (mirroring) devices from multiple nodes"), |
315 | 389 |
] |
316 | 390 |
|
... | ... | |
325 | 399 |
], None, "Run a validation routine for a given OS"), |
326 | 400 |
("os_get", SINGLE, TMO_FAST, [ |
327 | 401 |
("name", None, None), |
328 |
], "self._OsGetPostProc", "Returns an OS definition"),
|
|
402 |
], _OsGetPostProc, "Returns an OS definition"),
|
|
329 | 403 |
] |
330 | 404 |
|
331 | 405 |
_NODE_CALLS = [ |
Also available in: Unified diff