Statistics
| Branch: | Tag: | Revision:

root / lib / rpc_defs.py @ aedf5fd7

History | View | Annotate | Download (21.2 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 dd6d2d09 Michael Hanselmann
  - Name resolver option(s), can be callable receiving all arguments in a tuple
28 f7d9b3aa Michael Hanselmann
  - Timeout (e.g. L{TMO_NORMAL}), or callback receiving all arguments in a
29 f7d9b3aa Michael Hanselmann
    tuple to calculate timeout
30 033684dd Michael Hanselmann
  - List of arguments as tuples
31 033684dd Michael Hanselmann

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

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

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

82 a09f9847 Michael Hanselmann
  """
83 a09f9847 Michael Hanselmann
  return utils.SequenceToDict(calls)
84 a09f9847 Michael Hanselmann
85 a09f9847 Michael Hanselmann
86 26d502d0 Michael Hanselmann
def _MigrationStatusPostProc(result):
87 26d502d0 Michael Hanselmann
  """Post-processor for L{rpc.RpcRunner.call_instance_get_migration_status}.
88 26d502d0 Michael Hanselmann

89 26d502d0 Michael Hanselmann
  """
90 26d502d0 Michael Hanselmann
  if not result.fail_msg and result.payload is not None:
91 26d502d0 Michael Hanselmann
    result.payload = objects.MigrationStatus.FromDict(result.payload)
92 26d502d0 Michael Hanselmann
  return result
93 26d502d0 Michael Hanselmann
94 26d502d0 Michael Hanselmann
95 26d502d0 Michael Hanselmann
def _BlockdevFindPostProc(result):
96 26d502d0 Michael Hanselmann
  """Post-processor for L{rpc.RpcRunner.call_blockdev_find}.
97 26d502d0 Michael Hanselmann

98 26d502d0 Michael Hanselmann
  """
99 26d502d0 Michael Hanselmann
  if not result.fail_msg and result.payload is not None:
100 26d502d0 Michael Hanselmann
    result.payload = objects.BlockDevStatus.FromDict(result.payload)
101 26d502d0 Michael Hanselmann
  return result
102 26d502d0 Michael Hanselmann
103 26d502d0 Michael Hanselmann
104 26d502d0 Michael Hanselmann
def _BlockdevGetMirrorStatusPostProc(result):
105 26d502d0 Michael Hanselmann
  """Post-processor for L{rpc.RpcRunner.call_blockdev_getmirrorstatus}.
106 26d502d0 Michael Hanselmann

107 26d502d0 Michael Hanselmann
  """
108 26d502d0 Michael Hanselmann
  if not result.fail_msg:
109 26d502d0 Michael Hanselmann
    result.payload = map(objects.BlockDevStatus.FromDict, result.payload)
110 26d502d0 Michael Hanselmann
  return result
111 26d502d0 Michael Hanselmann
112 26d502d0 Michael Hanselmann
113 5449685e Iustin Pop
def _BlockdevGetMirrorStatusMultiPreProc(node, args):
114 5449685e Iustin Pop
  """Prepares the appropriate node values for blockdev_getmirrorstatus_multi.
115 5449685e Iustin Pop

116 5449685e Iustin Pop
  """
117 5449685e Iustin Pop
  # there should be only one argument to this RPC, already holding a
118 5449685e Iustin Pop
  # node->disks dictionary, we just need to extract the value for the
119 5449685e Iustin Pop
  # current node
120 5449685e Iustin Pop
  assert len(args) == 1
121 5449685e Iustin Pop
  return [args[0][node]]
122 5449685e Iustin Pop
123 5449685e Iustin Pop
124 26d502d0 Michael Hanselmann
def _BlockdevGetMirrorStatusMultiPostProc(result):
125 26d502d0 Michael Hanselmann
  """Post-processor for L{rpc.RpcRunner.call_blockdev_getmirrorstatus_multi}.
126 26d502d0 Michael Hanselmann

127 26d502d0 Michael Hanselmann
  """
128 82cce526 Michael Hanselmann
  if not result.fail_msg:
129 82cce526 Michael Hanselmann
    for idx, (success, status) in enumerate(result.payload):
130 26d502d0 Michael Hanselmann
      if success:
131 82cce526 Michael Hanselmann
        result.payload[idx] = (success, objects.BlockDevStatus.FromDict(status))
132 26d502d0 Michael Hanselmann
133 26d502d0 Michael Hanselmann
  return result
134 26d502d0 Michael Hanselmann
135 26d502d0 Michael Hanselmann
136 26d502d0 Michael Hanselmann
def _OsGetPostProc(result):
137 26d502d0 Michael Hanselmann
  """Post-processor for L{rpc.RpcRunner.call_os_get}.
138 26d502d0 Michael Hanselmann

139 26d502d0 Michael Hanselmann
  """
140 26d502d0 Michael Hanselmann
  if not result.fail_msg and isinstance(result.payload, dict):
141 26d502d0 Michael Hanselmann
    result.payload = objects.OS.FromDict(result.payload)
142 26d502d0 Michael Hanselmann
  return result
143 26d502d0 Michael Hanselmann
144 26d502d0 Michael Hanselmann
145 26d502d0 Michael Hanselmann
def _ImpExpStatusPostProc(result):
146 26d502d0 Michael Hanselmann
  """Post-processor for import/export status.
147 26d502d0 Michael Hanselmann

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

152 26d502d0 Michael Hanselmann
  """
153 26d502d0 Michael Hanselmann
  if not result.fail_msg:
154 26d502d0 Michael Hanselmann
    decoded = []
155 26d502d0 Michael Hanselmann
156 26d502d0 Michael Hanselmann
    for i in result.payload:
157 26d502d0 Michael Hanselmann
      if i is None:
158 26d502d0 Michael Hanselmann
        decoded.append(None)
159 26d502d0 Michael Hanselmann
        continue
160 26d502d0 Michael Hanselmann
      decoded.append(objects.ImportExportStatus.FromDict(i))
161 26d502d0 Michael Hanselmann
162 26d502d0 Michael Hanselmann
    result.payload = decoded
163 26d502d0 Michael Hanselmann
164 26d502d0 Michael Hanselmann
  return result
165 26d502d0 Michael Hanselmann
166 26d502d0 Michael Hanselmann
167 f7d9b3aa Michael Hanselmann
def _TestDelayTimeout((duration, )):
168 f7d9b3aa Michael Hanselmann
  """Calculate timeout for "test_delay" RPC.
169 f7d9b3aa Michael Hanselmann

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