Statistics
| Branch: | Tag: | Revision:

root / lib / rpc_defs.py @ 60154921

History | View | Annotate | Download (19.9 kB)

1 d5a2a550 Michael Hanselmann
#
2 d5a2a550 Michael Hanselmann
#
3 d5a2a550 Michael Hanselmann
4 d5a2a550 Michael Hanselmann
# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Google Inc.
5 d5a2a550 Michael Hanselmann
#
6 d5a2a550 Michael Hanselmann
# This program is free software; you can redistribute it and/or modify
7 d5a2a550 Michael Hanselmann
# it under the terms of the GNU General Public License as published by
8 d5a2a550 Michael Hanselmann
# the Free Software Foundation; either version 2 of the License, or
9 d5a2a550 Michael Hanselmann
# (at your option) any later version.
10 d5a2a550 Michael Hanselmann
#
11 d5a2a550 Michael Hanselmann
# This program is distributed in the hope that it will be useful, but
12 d5a2a550 Michael Hanselmann
# WITHOUT ANY WARRANTY; without even the implied warranty of
13 d5a2a550 Michael Hanselmann
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 d5a2a550 Michael Hanselmann
# General Public License for more details.
15 d5a2a550 Michael Hanselmann
#
16 d5a2a550 Michael Hanselmann
# You should have received a copy of the GNU General Public License
17 d5a2a550 Michael Hanselmann
# along with this program; if not, write to the Free Software
18 d5a2a550 Michael Hanselmann
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 d5a2a550 Michael Hanselmann
# 02110-1301, USA.
20 d5a2a550 Michael Hanselmann
21 d5a2a550 Michael Hanselmann
"""RPC definitions for communication between master and node daemons.
22 d5a2a550 Michael Hanselmann

23 033684dd Michael Hanselmann
RPC definition fields:
24 033684dd Michael Hanselmann

25 033684dd Michael Hanselmann
  - Name as string
26 033684dd Michael Hanselmann
  - L{SINGLE} for single-node calls, L{MULTI} for multi-node
27 f7d9b3aa Michael Hanselmann
  - Timeout (e.g. L{TMO_NORMAL}), or callback receiving all arguments in a
28 f7d9b3aa Michael Hanselmann
    tuple to calculate timeout
29 033684dd Michael Hanselmann
  - List of arguments as tuples
30 033684dd Michael Hanselmann

31 033684dd Michael Hanselmann
    - Name as string
32 cd40dc53 Michael Hanselmann
    - Argument kind used for encoding/decoding
33 033684dd Michael Hanselmann
    - Description for docstring (can be C{None})
34 033684dd Michael Hanselmann

35 60154921 Iustin Pop
  - Custom body encoder (e.g. for preparing per-node bodies)
36 033684dd Michael Hanselmann
  - Return value wrapper (e.g. for deserializing into L{objects}-based objects)
37 033684dd Michael Hanselmann
  - Short call description for docstring
38 033684dd Michael Hanselmann

39 d5a2a550 Michael Hanselmann
"""
40 d5a2a550 Michael Hanselmann
41 a09f9847 Michael Hanselmann
from ganeti import utils
42 26d502d0 Michael Hanselmann
from ganeti import objects
43 a09f9847 Michael Hanselmann
44 d5a2a550 Michael Hanselmann
45 0d1e78dd Michael Hanselmann
# Guidelines for choosing timeouts:
46 0d1e78dd Michael Hanselmann
# - call used during watcher: timeout of 1min, _TMO_URGENT
47 0d1e78dd Michael Hanselmann
# - trivial (but be sure it is trivial) (e.g. reading a file): 5min, _TMO_FAST
48 0d1e78dd Michael Hanselmann
# - other calls: 15 min, _TMO_NORMAL
49 0d1e78dd Michael Hanselmann
# - special calls (instance add, etc.): either _TMO_SLOW (1h) or huge timeouts
50 d5a2a550 Michael Hanselmann
TMO_URGENT = 60 # one minute
51 d5a2a550 Michael Hanselmann
TMO_FAST = 5 * 60 # five minutes
52 d5a2a550 Michael Hanselmann
TMO_NORMAL = 15 * 60 # 15 minutes
53 d5a2a550 Michael Hanselmann
TMO_SLOW = 3600 # one hour
54 d5a2a550 Michael Hanselmann
TMO_4HRS = 4 * 3600
55 d5a2a550 Michael Hanselmann
TMO_1DAY = 86400
56 d5a2a550 Michael Hanselmann
57 d5a2a550 Michael Hanselmann
SINGLE = "single-node"
58 d5a2a550 Michael Hanselmann
MULTI = "multi-node"
59 d5a2a550 Michael Hanselmann
60 cd40dc53 Michael Hanselmann
# Constants for encoding/decoding
61 cd40dc53 Michael Hanselmann
(ED_OBJECT_DICT,
62 cd40dc53 Michael Hanselmann
 ED_OBJECT_DICT_LIST,
63 cd40dc53 Michael Hanselmann
 ED_INST_DICT,
64 cd40dc53 Michael Hanselmann
 ED_INST_DICT_HVP_BEP,
65 cd40dc53 Michael Hanselmann
 ED_NODE_TO_DISK_DICT,
66 cd40dc53 Michael Hanselmann
 ED_INST_DICT_OSP,
67 cd40dc53 Michael Hanselmann
 ED_IMPEXP_IO,
68 cd40dc53 Michael Hanselmann
 ED_FILE_DETAILS,
69 cd40dc53 Michael Hanselmann
 ED_FINALIZE_EXPORT_DISKS,
70 cd40dc53 Michael Hanselmann
 ED_COMPRESS,
71 cd40dc53 Michael Hanselmann
 ED_BLOCKDEV_RENAME) = range(1, 12)
72 d565f83f Michael Hanselmann
73 a09f9847 Michael Hanselmann
74 a09f9847 Michael Hanselmann
def _Prepare(calls):
75 a09f9847 Michael Hanselmann
  """Converts list of calls to dictionary.
76 a09f9847 Michael Hanselmann

77 a09f9847 Michael Hanselmann
  """
78 a09f9847 Michael Hanselmann
  return utils.SequenceToDict(calls)
79 a09f9847 Michael Hanselmann
80 a09f9847 Michael Hanselmann
81 26d502d0 Michael Hanselmann
def _MigrationStatusPostProc(result):
82 26d502d0 Michael Hanselmann
  """Post-processor for L{rpc.RpcRunner.call_instance_get_migration_status}.
83 26d502d0 Michael Hanselmann

84 26d502d0 Michael Hanselmann
  """
85 26d502d0 Michael Hanselmann
  if not result.fail_msg and result.payload is not None:
86 26d502d0 Michael Hanselmann
    result.payload = objects.MigrationStatus.FromDict(result.payload)
87 26d502d0 Michael Hanselmann
  return result
88 26d502d0 Michael Hanselmann
89 26d502d0 Michael Hanselmann
90 26d502d0 Michael Hanselmann
def _BlockdevFindPostProc(result):
91 26d502d0 Michael Hanselmann
  """Post-processor for L{rpc.RpcRunner.call_blockdev_find}.
92 26d502d0 Michael Hanselmann

93 26d502d0 Michael Hanselmann
  """
94 26d502d0 Michael Hanselmann
  if not result.fail_msg and result.payload is not None:
95 26d502d0 Michael Hanselmann
    result.payload = objects.BlockDevStatus.FromDict(result.payload)
96 26d502d0 Michael Hanselmann
  return result
97 26d502d0 Michael Hanselmann
98 26d502d0 Michael Hanselmann
99 26d502d0 Michael Hanselmann
def _BlockdevGetMirrorStatusPostProc(result):
100 26d502d0 Michael Hanselmann
  """Post-processor for L{rpc.RpcRunner.call_blockdev_getmirrorstatus}.
101 26d502d0 Michael Hanselmann

102 26d502d0 Michael Hanselmann
  """
103 26d502d0 Michael Hanselmann
  if not result.fail_msg:
104 26d502d0 Michael Hanselmann
    result.payload = map(objects.BlockDevStatus.FromDict, result.payload)
105 26d502d0 Michael Hanselmann
  return result
106 26d502d0 Michael Hanselmann
107 26d502d0 Michael Hanselmann
108 26d502d0 Michael Hanselmann
def _BlockdevGetMirrorStatusMultiPostProc(result):
109 26d502d0 Michael Hanselmann
  """Post-processor for L{rpc.RpcRunner.call_blockdev_getmirrorstatus_multi}.
110 26d502d0 Michael Hanselmann

111 26d502d0 Michael Hanselmann
  """
112 82cce526 Michael Hanselmann
  if not result.fail_msg:
113 82cce526 Michael Hanselmann
    for idx, (success, status) in enumerate(result.payload):
114 26d502d0 Michael Hanselmann
      if success:
115 82cce526 Michael Hanselmann
        result.payload[idx] = (success, objects.BlockDevStatus.FromDict(status))
116 26d502d0 Michael Hanselmann
117 26d502d0 Michael Hanselmann
  return result
118 26d502d0 Michael Hanselmann
119 26d502d0 Michael Hanselmann
120 26d502d0 Michael Hanselmann
def _OsGetPostProc(result):
121 26d502d0 Michael Hanselmann
  """Post-processor for L{rpc.RpcRunner.call_os_get}.
122 26d502d0 Michael Hanselmann

123 26d502d0 Michael Hanselmann
  """
124 26d502d0 Michael Hanselmann
  if not result.fail_msg and isinstance(result.payload, dict):
125 26d502d0 Michael Hanselmann
    result.payload = objects.OS.FromDict(result.payload)
126 26d502d0 Michael Hanselmann
  return result
127 26d502d0 Michael Hanselmann
128 26d502d0 Michael Hanselmann
129 26d502d0 Michael Hanselmann
def _ImpExpStatusPostProc(result):
130 26d502d0 Michael Hanselmann
  """Post-processor for import/export status.
131 26d502d0 Michael Hanselmann

132 26d502d0 Michael Hanselmann
  @rtype: Payload containing list of L{objects.ImportExportStatus} instances
133 26d502d0 Michael Hanselmann
  @return: Returns a list of the state of each named import/export or None if
134 26d502d0 Michael Hanselmann
           a status couldn't be retrieved
135 26d502d0 Michael Hanselmann

136 26d502d0 Michael Hanselmann
  """
137 26d502d0 Michael Hanselmann
  if not result.fail_msg:
138 26d502d0 Michael Hanselmann
    decoded = []
139 26d502d0 Michael Hanselmann
140 26d502d0 Michael Hanselmann
    for i in result.payload:
141 26d502d0 Michael Hanselmann
      if i is None:
142 26d502d0 Michael Hanselmann
        decoded.append(None)
143 26d502d0 Michael Hanselmann
        continue
144 26d502d0 Michael Hanselmann
      decoded.append(objects.ImportExportStatus.FromDict(i))
145 26d502d0 Michael Hanselmann
146 26d502d0 Michael Hanselmann
    result.payload = decoded
147 26d502d0 Michael Hanselmann
148 26d502d0 Michael Hanselmann
  return result
149 26d502d0 Michael Hanselmann
150 26d502d0 Michael Hanselmann
151 f7d9b3aa Michael Hanselmann
def _TestDelayTimeout((duration, )):
152 f7d9b3aa Michael Hanselmann
  """Calculate timeout for "test_delay" RPC.
153 f7d9b3aa Michael Hanselmann

154 f7d9b3aa Michael Hanselmann
  """
155 f7d9b3aa Michael Hanselmann
  return int(duration + 5)
156 f7d9b3aa Michael Hanselmann
157 f7d9b3aa Michael Hanselmann
158 033684dd Michael Hanselmann
_FILE_STORAGE_CALLS = [
159 033684dd Michael Hanselmann
  ("file_storage_dir_create", SINGLE, TMO_FAST, [
160 033684dd Michael Hanselmann
    ("file_storage_dir", None, "File storage directory"),
161 60154921 Iustin Pop
    ], None, None, "Create the given file storage directory"),
162 033684dd Michael Hanselmann
  ("file_storage_dir_remove", SINGLE, TMO_FAST, [
163 033684dd Michael Hanselmann
    ("file_storage_dir", None, "File storage directory"),
164 60154921 Iustin Pop
    ], None, None, "Remove the given file storage directory"),
165 033684dd Michael Hanselmann
  ("file_storage_dir_rename", SINGLE, TMO_FAST, [
166 033684dd Michael Hanselmann
    ("old_file_storage_dir", None, "Old name"),
167 033684dd Michael Hanselmann
    ("new_file_storage_dir", None, "New name"),
168 60154921 Iustin Pop
    ], None, None, "Rename file storage directory"),
169 033684dd Michael Hanselmann
  ]
170 033684dd Michael Hanselmann
171 033684dd Michael Hanselmann
_STORAGE_CALLS = [
172 033684dd Michael Hanselmann
  ("storage_list", MULTI, TMO_NORMAL, [
173 033684dd Michael Hanselmann
    ("su_name", None, None),
174 033684dd Michael Hanselmann
    ("su_args", None, None),
175 033684dd Michael Hanselmann
    ("name", None, None),
176 033684dd Michael Hanselmann
    ("fields", None, None),
177 60154921 Iustin Pop
    ], None, None, "Get list of storage units"),
178 033684dd Michael Hanselmann
  ("storage_modify", SINGLE, TMO_NORMAL, [
179 033684dd Michael Hanselmann
    ("su_name", None, None),
180 033684dd Michael Hanselmann
    ("su_args", None, None),
181 033684dd Michael Hanselmann
    ("name", None, None),
182 033684dd Michael Hanselmann
    ("changes", None, None),
183 60154921 Iustin Pop
    ], None, None, "Modify a storage unit"),
184 033684dd Michael Hanselmann
  ("storage_execute", SINGLE, TMO_NORMAL, [
185 033684dd Michael Hanselmann
    ("su_name", None, None),
186 033684dd Michael Hanselmann
    ("su_args", None, None),
187 033684dd Michael Hanselmann
    ("name", None, None),
188 033684dd Michael Hanselmann
    ("op", None, None),
189 60154921 Iustin Pop
    ], None, None, "Executes an operation on a storage unit"),
190 033684dd Michael Hanselmann
  ]
191 033684dd Michael Hanselmann
192 033684dd Michael Hanselmann
_INSTANCE_CALLS = [
193 033684dd Michael Hanselmann
  ("instance_info", SINGLE, TMO_URGENT, [
194 033684dd Michael Hanselmann
    ("instance", None, "Instance name"),
195 033684dd Michael Hanselmann
    ("hname", None, "Hypervisor type"),
196 60154921 Iustin Pop
    ], None, None, "Returns information about a single instance"),
197 033684dd Michael Hanselmann
  ("all_instances_info", MULTI, TMO_URGENT, [
198 033684dd Michael Hanselmann
    ("hypervisor_list", None, "Hypervisors to query for instances"),
199 60154921 Iustin Pop
    ], None, None,
200 60154921 Iustin Pop
   "Returns information about all instances on the given nodes"),
201 033684dd Michael Hanselmann
  ("instance_list", MULTI, TMO_URGENT, [
202 033684dd Michael Hanselmann
    ("hypervisor_list", None, "Hypervisors to query for instances"),
203 60154921 Iustin Pop
    ], None, None, "Returns the list of running instances on the given nodes"),
204 033684dd Michael Hanselmann
  ("instance_reboot", SINGLE, TMO_NORMAL, [
205 cd40dc53 Michael Hanselmann
    ("inst", ED_INST_DICT, "Instance object"),
206 033684dd Michael Hanselmann
    ("reboot_type", None, None),
207 033684dd Michael Hanselmann
    ("shutdown_timeout", None, None),
208 60154921 Iustin Pop
    ], None, None, "Returns the list of running instances on the given nodes"),
209 033684dd Michael Hanselmann
  ("instance_shutdown", SINGLE, TMO_NORMAL, [
210 cd40dc53 Michael Hanselmann
    ("instance", ED_INST_DICT, "Instance object"),
211 033684dd Michael Hanselmann
    ("timeout", None, None),
212 60154921 Iustin Pop
    ], None, None, "Stops an instance"),
213 033684dd Michael Hanselmann
  ("instance_run_rename", SINGLE, TMO_SLOW, [
214 cd40dc53 Michael Hanselmann
    ("instance", ED_INST_DICT, "Instance object"),
215 033684dd Michael Hanselmann
    ("old_name", None, None),
216 033684dd Michael Hanselmann
    ("debug", None, None),
217 60154921 Iustin Pop
    ], None, None, "Run the OS rename script for an instance"),
218 033684dd Michael Hanselmann
  ("instance_migratable", SINGLE, TMO_NORMAL, [
219 cd40dc53 Michael Hanselmann
    ("instance", ED_INST_DICT, "Instance object"),
220 60154921 Iustin Pop
    ], None, None, "Checks whether the given instance can be migrated"),
221 033684dd Michael Hanselmann
  ("migration_info", SINGLE, TMO_NORMAL, [
222 cd40dc53 Michael Hanselmann
    ("instance", ED_INST_DICT, "Instance object"),
223 60154921 Iustin Pop
    ], None, None,
224 033684dd Michael Hanselmann
    "Gather the information necessary to prepare an instance migration"),
225 033684dd Michael Hanselmann
  ("accept_instance", SINGLE, TMO_NORMAL, [
226 cd40dc53 Michael Hanselmann
    ("instance", ED_INST_DICT, "Instance object"),
227 033684dd Michael Hanselmann
    ("info", None, "Result for the call_migration_info call"),
228 033684dd Michael Hanselmann
    ("target", None, "Target hostname (usually an IP address)"),
229 60154921 Iustin Pop
    ], None, None, "Prepare a node to accept an instance"),
230 033684dd Michael Hanselmann
  ("instance_finalize_migration_dst", SINGLE, TMO_NORMAL, [
231 cd40dc53 Michael Hanselmann
    ("instance", ED_INST_DICT, "Instance object"),
232 033684dd Michael Hanselmann
    ("info", None, "Result for the call_migration_info call"),
233 033684dd Michael Hanselmann
    ("success", None, "Whether the migration was a success or failure"),
234 60154921 Iustin Pop
    ], None, None, "Finalize any target-node migration specific operation"),
235 033684dd Michael Hanselmann
  ("instance_migrate", SINGLE, TMO_SLOW, [
236 cd40dc53 Michael Hanselmann
    ("instance", ED_INST_DICT, "Instance object"),
237 033684dd Michael Hanselmann
    ("target", None, "Target node name"),
238 033684dd Michael Hanselmann
    ("live", None, "Whether the migration should be done live or not"),
239 60154921 Iustin Pop
    ], None, None, "Migrate an instance"),
240 033684dd Michael Hanselmann
  ("instance_finalize_migration_src", SINGLE, TMO_SLOW, [
241 cd40dc53 Michael Hanselmann
    ("instance", ED_INST_DICT, "Instance object"),
242 033684dd Michael Hanselmann
    ("success", None, "Whether the migration succeeded or not"),
243 033684dd Michael Hanselmann
    ("live", None, "Whether the user requested a live migration or not"),
244 60154921 Iustin Pop
    ], None, None, "Finalize the instance migration on the source node"),
245 e3ac8406 Andrea Spadaccini
  ("instance_get_migration_status", SINGLE, TMO_SLOW, [
246 cd40dc53 Michael Hanselmann
    ("instance", ED_INST_DICT, "Instance object"),
247 60154921 Iustin Pop
    ], None, _MigrationStatusPostProc, "Report migration status"),
248 c4de9b7a Michael Hanselmann
  ("instance_start", SINGLE, TMO_NORMAL, [
249 cd40dc53 Michael Hanselmann
    ("instance_hvp_bep", ED_INST_DICT_HVP_BEP, None),
250 c4de9b7a Michael Hanselmann
    ("startup_paused", None, None),
251 60154921 Iustin Pop
    ], None, None, "Starts an instance"),
252 c4de9b7a Michael Hanselmann
  ("instance_os_add", SINGLE, TMO_1DAY, [
253 cd40dc53 Michael Hanselmann
    ("instance_osp", ED_INST_DICT_OSP, None),
254 c4de9b7a Michael Hanselmann
    ("reinstall", None, None),
255 c4de9b7a Michael Hanselmann
    ("debug", None, None),
256 60154921 Iustin Pop
    ], None, None, "Starts an instance"),
257 033684dd Michael Hanselmann
  ]
258 033684dd Michael Hanselmann
259 033684dd Michael Hanselmann
_IMPEXP_CALLS = [
260 46c293f0 Michael Hanselmann
  ("import_start", SINGLE, TMO_NORMAL, [
261 cd40dc53 Michael Hanselmann
    ("opts", ED_OBJECT_DICT, None),
262 cd40dc53 Michael Hanselmann
    ("instance", ED_INST_DICT, None),
263 46c293f0 Michael Hanselmann
    ("component", None, None),
264 cd40dc53 Michael Hanselmann
    ("dest", ED_IMPEXP_IO, "Import destination"),
265 60154921 Iustin Pop
    ], None, None, "Starts an import daemon"),
266 46c293f0 Michael Hanselmann
  ("export_start", SINGLE, TMO_NORMAL, [
267 cd40dc53 Michael Hanselmann
    ("opts", ED_OBJECT_DICT, None),
268 46c293f0 Michael Hanselmann
    ("host", None, None),
269 46c293f0 Michael Hanselmann
    ("port", None, None),
270 cd40dc53 Michael Hanselmann
    ("instance", ED_INST_DICT, None),
271 46c293f0 Michael Hanselmann
    ("component", None, None),
272 cd40dc53 Michael Hanselmann
    ("source", ED_IMPEXP_IO, "Export source"),
273 60154921 Iustin Pop
    ], None, None, "Starts an export daemon"),
274 033684dd Michael Hanselmann
  ("impexp_status", SINGLE, TMO_FAST, [
275 033684dd Michael Hanselmann
    ("names", None, "Import/export names"),
276 60154921 Iustin Pop
    ], None, _ImpExpStatusPostProc, "Gets the status of an import or export"),
277 033684dd Michael Hanselmann
  ("impexp_abort", SINGLE, TMO_NORMAL, [
278 033684dd Michael Hanselmann
    ("name", None, "Import/export name"),
279 60154921 Iustin Pop
    ], None, None, "Aborts an import or export"),
280 033684dd Michael Hanselmann
  ("impexp_cleanup", SINGLE, TMO_NORMAL, [
281 033684dd Michael Hanselmann
    ("name", None, "Import/export name"),
282 60154921 Iustin Pop
    ], None, None, "Cleans up after an import or export"),
283 033684dd Michael Hanselmann
  ("export_info", SINGLE, TMO_FAST, [
284 033684dd Michael Hanselmann
    ("path", None, None),
285 60154921 Iustin Pop
    ], None, None, "Queries the export information in a given path"),
286 033684dd Michael Hanselmann
  ("finalize_export", SINGLE, TMO_NORMAL, [
287 cd40dc53 Michael Hanselmann
    ("instance", ED_INST_DICT, None),
288 cd40dc53 Michael Hanselmann
    ("snap_disks", ED_FINALIZE_EXPORT_DISKS, None),
289 60154921 Iustin Pop
    ], None, None, "Request the completion of an export operation"),
290 60154921 Iustin Pop
  ("export_list", MULTI, TMO_FAST, [], None, None,
291 60154921 Iustin Pop
   "Gets the stored exports list"),
292 033684dd Michael Hanselmann
  ("export_remove", SINGLE, TMO_FAST, [
293 033684dd Michael Hanselmann
    ("export", None, None),
294 60154921 Iustin Pop
    ], None, None, "Requests removal of a given export"),
295 033684dd Michael Hanselmann
  ]
296 033684dd Michael Hanselmann
297 033684dd Michael Hanselmann
_X509_CALLS = [
298 033684dd Michael Hanselmann
  ("x509_cert_create", SINGLE, TMO_NORMAL, [
299 033684dd Michael Hanselmann
    ("validity", None, "Validity in seconds"),
300 60154921 Iustin Pop
    ], None, None, "Creates a new X509 certificate for SSL/TLS"),
301 033684dd Michael Hanselmann
  ("x509_cert_remove", SINGLE, TMO_NORMAL, [
302 033684dd Michael Hanselmann
    ("name", None, "Certificate name"),
303 60154921 Iustin Pop
    ], None, None, "Removes a X509 certificate"),
304 033684dd Michael Hanselmann
  ]
305 033684dd Michael Hanselmann
306 033684dd Michael Hanselmann
_BLOCKDEV_CALLS = [
307 033684dd Michael Hanselmann
  ("bdev_sizes", MULTI, TMO_URGENT, [
308 033684dd Michael Hanselmann
    ("devices", None, None),
309 60154921 Iustin Pop
    ], None, None,
310 60154921 Iustin Pop
   "Gets the sizes of requested block devices present on a node"),
311 033684dd Michael Hanselmann
  ("blockdev_create", SINGLE, TMO_NORMAL, [
312 cd40dc53 Michael Hanselmann
    ("bdev", ED_OBJECT_DICT, None),
313 033684dd Michael Hanselmann
    ("size", None, None),
314 033684dd Michael Hanselmann
    ("owner", None, None),
315 033684dd Michael Hanselmann
    ("on_primary", None, None),
316 033684dd Michael Hanselmann
    ("info", None, None),
317 60154921 Iustin Pop
    ], None, None, "Request creation of a given block device"),
318 033684dd Michael Hanselmann
  ("blockdev_wipe", SINGLE, TMO_SLOW, [
319 cd40dc53 Michael Hanselmann
    ("bdev", ED_OBJECT_DICT, None),
320 033684dd Michael Hanselmann
    ("offset", None, None),
321 033684dd Michael Hanselmann
    ("size", None, None),
322 60154921 Iustin Pop
    ], None, None,
323 033684dd Michael Hanselmann
    "Request wipe at given offset with given size of a block device"),
324 033684dd Michael Hanselmann
  ("blockdev_remove", SINGLE, TMO_NORMAL, [
325 cd40dc53 Michael Hanselmann
    ("bdev", ED_OBJECT_DICT, None),
326 60154921 Iustin Pop
    ], None, None, "Request removal of a given block device"),
327 033684dd Michael Hanselmann
  ("blockdev_pause_resume_sync", SINGLE, TMO_NORMAL, [
328 cd40dc53 Michael Hanselmann
    ("disks", ED_OBJECT_DICT_LIST, None),
329 033684dd Michael Hanselmann
    ("pause", None, None),
330 60154921 Iustin Pop
    ], None, None, "Request a pause/resume of given block device"),
331 033684dd Michael Hanselmann
  ("blockdev_assemble", SINGLE, TMO_NORMAL, [
332 cd40dc53 Michael Hanselmann
    ("disk", ED_OBJECT_DICT, None),
333 033684dd Michael Hanselmann
    ("owner", None, None),
334 033684dd Michael Hanselmann
    ("on_primary", None, None),
335 033684dd Michael Hanselmann
    ("idx", None, None),
336 60154921 Iustin Pop
    ], None, None, "Request assembling of a given block device"),
337 033684dd Michael Hanselmann
  ("blockdev_shutdown", SINGLE, TMO_NORMAL, [
338 cd40dc53 Michael Hanselmann
    ("disk", ED_OBJECT_DICT, None),
339 60154921 Iustin Pop
    ], None, None, "Request shutdown of a given block device"),
340 033684dd Michael Hanselmann
  ("blockdev_addchildren", SINGLE, TMO_NORMAL, [
341 cd40dc53 Michael Hanselmann
    ("bdev", ED_OBJECT_DICT, None),
342 cd40dc53 Michael Hanselmann
    ("ndevs", ED_OBJECT_DICT_LIST, None),
343 60154921 Iustin Pop
    ], None, None,
344 60154921 Iustin Pop
   "Request adding a list of children to a (mirroring) device"),
345 033684dd Michael Hanselmann
  ("blockdev_removechildren", SINGLE, TMO_NORMAL, [
346 cd40dc53 Michael Hanselmann
    ("bdev", ED_OBJECT_DICT, None),
347 cd40dc53 Michael Hanselmann
    ("ndevs", ED_OBJECT_DICT_LIST, None),
348 60154921 Iustin Pop
    ], None, None,
349 60154921 Iustin Pop
   "Request removing a list of children from a (mirroring) device"),
350 033684dd Michael Hanselmann
  ("blockdev_close", SINGLE, TMO_NORMAL, [
351 033684dd Michael Hanselmann
    ("instance_name", None, None),
352 cd40dc53 Michael Hanselmann
    ("disks", ED_OBJECT_DICT_LIST, None),
353 60154921 Iustin Pop
    ], None, None, "Closes the given block devices"),
354 033684dd Michael Hanselmann
  ("blockdev_getsize", SINGLE, TMO_NORMAL, [
355 cd40dc53 Michael Hanselmann
    ("disks", ED_OBJECT_DICT_LIST, None),
356 60154921 Iustin Pop
    ], None, None, "Returns the size of the given disks"),
357 033684dd Michael Hanselmann
  ("drbd_disconnect_net", MULTI, TMO_NORMAL, [
358 033684dd Michael Hanselmann
    ("nodes_ip", None, None),
359 cd40dc53 Michael Hanselmann
    ("disks", ED_OBJECT_DICT_LIST, None),
360 60154921 Iustin Pop
    ], None, None, "Disconnects the network of the given drbd devices"),
361 033684dd Michael Hanselmann
  ("drbd_attach_net", MULTI, TMO_NORMAL, [
362 033684dd Michael Hanselmann
    ("nodes_ip", None, None),
363 cd40dc53 Michael Hanselmann
    ("disks", ED_OBJECT_DICT_LIST, None),
364 033684dd Michael Hanselmann
    ("instance_name", None, None),
365 033684dd Michael Hanselmann
    ("multimaster", None, None),
366 60154921 Iustin Pop
    ], None, None, "Connects the given DRBD devices"),
367 033684dd Michael Hanselmann
  ("drbd_wait_sync", MULTI, TMO_SLOW, [
368 033684dd Michael Hanselmann
    ("nodes_ip", None, None),
369 cd40dc53 Michael Hanselmann
    ("disks", ED_OBJECT_DICT_LIST, None),
370 60154921 Iustin Pop
    ], None, None,
371 60154921 Iustin Pop
   "Waits for the synchronization of drbd devices is complete"),
372 033684dd Michael Hanselmann
  ("blockdev_grow", SINGLE, TMO_NORMAL, [
373 cd40dc53 Michael Hanselmann
    ("cf_bdev", ED_OBJECT_DICT, None),
374 033684dd Michael Hanselmann
    ("amount", None, None),
375 033684dd Michael Hanselmann
    ("dryrun", None, None),
376 60154921 Iustin Pop
    ], None, None, "Request a snapshot of the given block device"),
377 033684dd Michael Hanselmann
  ("blockdev_export", SINGLE, TMO_1DAY, [
378 cd40dc53 Michael Hanselmann
    ("cf_bdev", ED_OBJECT_DICT, None),
379 033684dd Michael Hanselmann
    ("dest_node", None, None),
380 033684dd Michael Hanselmann
    ("dest_path", None, None),
381 033684dd Michael Hanselmann
    ("cluster_name", None, None),
382 60154921 Iustin Pop
    ], None, None, "Export a given disk to another node"),
383 033684dd Michael Hanselmann
  ("blockdev_snapshot", SINGLE, TMO_NORMAL, [
384 cd40dc53 Michael Hanselmann
    ("cf_bdev", ED_OBJECT_DICT, None),
385 60154921 Iustin Pop
    ], None, None, "Export a given disk to another node"),
386 033684dd Michael Hanselmann
  ("blockdev_rename", SINGLE, TMO_NORMAL, [
387 cd40dc53 Michael Hanselmann
    ("devlist", ED_BLOCKDEV_RENAME, None),
388 60154921 Iustin Pop
    ], None, None, "Request rename of the given block devices"),
389 033684dd Michael Hanselmann
  ("blockdev_find", SINGLE, TMO_NORMAL, [
390 cd40dc53 Michael Hanselmann
    ("disk", ED_OBJECT_DICT, None),
391 60154921 Iustin Pop
    ], None, _BlockdevFindPostProc,
392 033684dd Michael Hanselmann
    "Request identification of a given block device"),
393 033684dd Michael Hanselmann
  ("blockdev_getmirrorstatus", SINGLE, TMO_NORMAL, [
394 cd40dc53 Michael Hanselmann
    ("disks", ED_OBJECT_DICT_LIST, None),
395 60154921 Iustin Pop
    ], None, _BlockdevGetMirrorStatusPostProc,
396 033684dd Michael Hanselmann
    "Request status of a (mirroring) device"),
397 033684dd Michael Hanselmann
  ("blockdev_getmirrorstatus_multi", MULTI, TMO_NORMAL, [
398 cd40dc53 Michael Hanselmann
    ("node_disks", ED_NODE_TO_DISK_DICT, None),
399 60154921 Iustin Pop
    ], None, _BlockdevGetMirrorStatusMultiPostProc,
400 033684dd Michael Hanselmann
    "Request status of (mirroring) devices from multiple nodes"),
401 033684dd Michael Hanselmann
  ]
402 033684dd Michael Hanselmann
403 033684dd Michael Hanselmann
_OS_CALLS = [
404 60154921 Iustin Pop
  ("os_diagnose", MULTI, TMO_FAST, [], None, None,
405 033684dd Michael Hanselmann
   "Request a diagnose of OS definitions"),
406 033684dd Michael Hanselmann
  ("os_validate", MULTI, TMO_FAST, [
407 033684dd Michael Hanselmann
    ("required", None, None),
408 033684dd Michael Hanselmann
    ("name", None, None),
409 033684dd Michael Hanselmann
    ("checks", None, None),
410 033684dd Michael Hanselmann
    ("params", None, None),
411 60154921 Iustin Pop
    ], None, None, "Run a validation routine for a given OS"),
412 033684dd Michael Hanselmann
  ("os_get", SINGLE, TMO_FAST, [
413 033684dd Michael Hanselmann
    ("name", None, None),
414 60154921 Iustin Pop
    ], None, _OsGetPostProc, "Returns an OS definition"),
415 033684dd Michael Hanselmann
  ]
416 033684dd Michael Hanselmann
417 033684dd Michael Hanselmann
_NODE_CALLS = [
418 033684dd Michael Hanselmann
  ("node_has_ip_address", SINGLE, TMO_FAST, [
419 033684dd Michael Hanselmann
    ("address", None, "IP address"),
420 60154921 Iustin Pop
    ], None, None, "Checks if a node has the given IP address"),
421 033684dd Michael Hanselmann
  ("node_info", MULTI, TMO_URGENT, [
422 78519c10 Michael Hanselmann
    ("vg_names", None,
423 78519c10 Michael Hanselmann
     "Names of the volume groups to ask for disk space information"),
424 78519c10 Michael Hanselmann
    ("hv_names", None,
425 78519c10 Michael Hanselmann
     "Names of the hypervisors to ask for node information"),
426 60154921 Iustin Pop
    ], None, None, "Return node information"),
427 033684dd Michael Hanselmann
  ("node_verify", MULTI, TMO_NORMAL, [
428 033684dd Michael Hanselmann
    ("checkdict", None, None),
429 033684dd Michael Hanselmann
    ("cluster_name", None, None),
430 60154921 Iustin Pop
    ], None, None, "Request verification of given parameters"),
431 60154921 Iustin Pop
  ("node_volumes", MULTI, TMO_FAST, [], None, None,
432 60154921 Iustin Pop
   "Gets all volumes on node(s)"),
433 60154921 Iustin Pop
  ("node_demote_from_mc", SINGLE, TMO_FAST, [], None, None,
434 033684dd Michael Hanselmann
   "Demote a node from the master candidate role"),
435 033684dd Michael Hanselmann
  ("node_powercycle", SINGLE, TMO_NORMAL, [
436 033684dd Michael Hanselmann
    ("hypervisor", None, "Hypervisor type"),
437 60154921 Iustin Pop
    ], None, None, "Tries to powercycle a node"),
438 033684dd Michael Hanselmann
  ]
439 033684dd Michael Hanselmann
440 033684dd Michael Hanselmann
_MISC_CALLS = [
441 033684dd Michael Hanselmann
  ("lv_list", MULTI, TMO_URGENT, [
442 033684dd Michael Hanselmann
    ("vg_name", None, None),
443 60154921 Iustin Pop
    ], None, None, "Gets the logical volumes present in a given volume group"),
444 60154921 Iustin Pop
  ("vg_list", MULTI, TMO_URGENT, [], None, None, "Gets the volume group list"),
445 033684dd Michael Hanselmann
  ("bridges_exist", SINGLE, TMO_URGENT, [
446 033684dd Michael Hanselmann
    ("bridges_list", None, "Bridges which must be present on remote node"),
447 60154921 Iustin Pop
    ], None, None, "Checks if a node has all the bridges given"),
448 033684dd Michael Hanselmann
  ("etc_hosts_modify", SINGLE, TMO_NORMAL, [
449 033684dd Michael Hanselmann
    ("mode", None,
450 033684dd Michael Hanselmann
     "Mode to operate; currently L{constants.ETC_HOSTS_ADD} or"
451 033684dd Michael Hanselmann
     " L{constants.ETC_HOSTS_REMOVE}"),
452 033684dd Michael Hanselmann
    ("name", None, "Hostname to be modified"),
453 033684dd Michael Hanselmann
    ("ip", None, "IP address (L{constants.ETC_HOSTS_ADD} only)"),
454 60154921 Iustin Pop
    ], None, None, "Modify hosts file with name"),
455 60154921 Iustin Pop
  ("drbd_helper", MULTI, TMO_URGENT, [], None, None, "Gets DRBD helper"),
456 033684dd Michael Hanselmann
  ("run_oob", SINGLE, TMO_NORMAL, [
457 033684dd Michael Hanselmann
    ("oob_program", None, None),
458 033684dd Michael Hanselmann
    ("command", None, None),
459 033684dd Michael Hanselmann
    ("remote_node", None, None),
460 033684dd Michael Hanselmann
    ("timeout", None, None),
461 60154921 Iustin Pop
    ], None, None, "Runs out-of-band command"),
462 033684dd Michael Hanselmann
  ("hooks_runner", MULTI, TMO_NORMAL, [
463 033684dd Michael Hanselmann
    ("hpath", None, None),
464 033684dd Michael Hanselmann
    ("phase", None, None),
465 033684dd Michael Hanselmann
    ("env", None, None),
466 60154921 Iustin Pop
    ], None, None, "Call the hooks runner"),
467 033684dd Michael Hanselmann
  ("iallocator_runner", SINGLE, TMO_NORMAL, [
468 033684dd Michael Hanselmann
    ("name", None, "Iallocator name"),
469 033684dd Michael Hanselmann
    ("idata", None, "JSON-encoded input string"),
470 60154921 Iustin Pop
    ], None, None, "Call an iallocator on a remote node"),
471 f68cc544 Michael Hanselmann
  ("test_delay", MULTI, _TestDelayTimeout, [
472 033684dd Michael Hanselmann
    ("duration", None, None),
473 60154921 Iustin Pop
    ], None, None, "Sleep for a fixed time on given node(s)"),
474 68959ca5 Michael Hanselmann
  ("hypervisor_validate_params", MULTI, TMO_NORMAL, [
475 68959ca5 Michael Hanselmann
    ("hvname", None, "Hypervisor name"),
476 68959ca5 Michael Hanselmann
    ("hvfull", None, "Parameters to be validated"),
477 60154921 Iustin Pop
    ], None, None, "Validate hypervisor params"),
478 033684dd Michael Hanselmann
  ]
479 033684dd Michael Hanselmann
480 d5a2a550 Michael Hanselmann
CALLS = {
481 a09f9847 Michael Hanselmann
  "RpcClientDefault": \
482 a09f9847 Michael Hanselmann
    _Prepare(_IMPEXP_CALLS + _X509_CALLS + _OS_CALLS + _NODE_CALLS +
483 a09f9847 Michael Hanselmann
             _FILE_STORAGE_CALLS + _MISC_CALLS + _INSTANCE_CALLS +
484 a09f9847 Michael Hanselmann
             _BLOCKDEV_CALLS + _STORAGE_CALLS),
485 a09f9847 Michael Hanselmann
  "RpcClientJobQueue": _Prepare([
486 fb1ffbca Michael Hanselmann
    ("jobqueue_update", MULTI, TMO_URGENT, [
487 fb1ffbca Michael Hanselmann
      ("file_name", None, None),
488 cd40dc53 Michael Hanselmann
      ("content", ED_COMPRESS, None),
489 60154921 Iustin Pop
      ], None, None, "Update job queue file"),
490 60154921 Iustin Pop
    ("jobqueue_purge", SINGLE, TMO_NORMAL, [], None, None, "Purge job queue"),
491 fb1ffbca Michael Hanselmann
    ("jobqueue_rename", MULTI, TMO_URGENT, [
492 fb1ffbca Michael Hanselmann
      ("rename", None, None),
493 60154921 Iustin Pop
      ], None, None, "Rename job queue file"),
494 a09f9847 Michael Hanselmann
    ]),
495 a09f9847 Michael Hanselmann
  "RpcClientBootstrap": _Prepare([
496 db04ce5d Michael Hanselmann
    ("node_start_master_daemons", SINGLE, TMO_FAST, [
497 db04ce5d Michael Hanselmann
      ("no_voting", None, None),
498 60154921 Iustin Pop
      ], None, None, "Starts master daemons on a node"),
499 8da2bd43 Andrea Spadaccini
    ("node_activate_master_ip", SINGLE, TMO_FAST, [
500 c79198a0 Andrea Spadaccini
      ("master_params", ED_OBJECT_DICT, "Network parameters of the master"),
501 57c7bc57 Andrea Spadaccini
      ("use_external_mip_script", None,
502 57c7bc57 Andrea Spadaccini
       "Whether to use the user-provided master IP address setup script"),
503 60154921 Iustin Pop
      ], None, None,
504 8da2bd43 Andrea Spadaccini
      "Activates master IP on a node"),
505 60154921 Iustin Pop
    ("node_stop_master", SINGLE, TMO_FAST, [], None, None,
506 db04ce5d Michael Hanselmann
     "Deactivates master IP and stops master daemons on a node"),
507 96e0d5cc Andrea Spadaccini
    ("node_deactivate_master_ip", SINGLE, TMO_FAST, [
508 c79198a0 Andrea Spadaccini
      ("master_params", ED_OBJECT_DICT, "Network parameters of the master"),
509 57c7bc57 Andrea Spadaccini
      ("use_external_mip_script", None,
510 57c7bc57 Andrea Spadaccini
       "Whether to use the user-provided master IP address setup script"),
511 60154921 Iustin Pop
      ], None, None,
512 db04ce5d Michael Hanselmann
     "Deactivates master IP on a node"),
513 db04ce5d Michael Hanselmann
    ("node_change_master_netmask", SINGLE, TMO_FAST, [
514 41e079ce Andrea Spadaccini
      ("old_netmask", None, "The old value of the netmask"),
515 41e079ce Andrea Spadaccini
      ("netmask", None, "The new value of the netmask"),
516 41e079ce Andrea Spadaccini
      ("master_ip", None, "The master IP"),
517 41e079ce Andrea Spadaccini
      ("master_netdev", None, "The master network device"),
518 60154921 Iustin Pop
      ], None, None, "Change master IP netmask"),
519 db04ce5d Michael Hanselmann
    ("node_leave_cluster", SINGLE, TMO_NORMAL, [
520 db04ce5d Michael Hanselmann
      ("modify_ssh_setup", None, None),
521 60154921 Iustin Pop
      ], None, None,
522 60154921 Iustin Pop
     "Requests a node to clean the cluster information it has"),
523 60154921 Iustin Pop
    ("master_info", MULTI, TMO_URGENT, [], None, None, "Query master info"),
524 60154921 Iustin Pop
    ("version", MULTI, TMO_URGENT, [], None, None, "Query node version"),
525 a09f9847 Michael Hanselmann
    ]),
526 a09f9847 Michael Hanselmann
  "RpcClientConfig": _Prepare([
527 415a7304 Michael Hanselmann
    ("upload_file", MULTI, TMO_NORMAL, [
528 cd40dc53 Michael Hanselmann
      ("file_name", ED_FILE_DETAILS, None),
529 60154921 Iustin Pop
      ], None, None, "Upload a file"),
530 415a7304 Michael Hanselmann
    ("write_ssconf_files", MULTI, TMO_NORMAL, [
531 415a7304 Michael Hanselmann
      ("values", None, None),
532 60154921 Iustin Pop
      ], None, None, "Write ssconf files"),
533 a09f9847 Michael Hanselmann
    ]),
534 d5a2a550 Michael Hanselmann
  }