root / lib / rpc.py @ bad78e66
History | View | Annotate | Download (41.6 kB)
1 | 2f31098c | Iustin Pop | #
|
---|---|---|---|
2 | a8083063 | Iustin Pop | #
|
3 | a8083063 | Iustin Pop | |
4 | a8083063 | Iustin Pop | # Copyright (C) 2006, 2007 Google Inc.
|
5 | a8083063 | Iustin Pop | #
|
6 | a8083063 | Iustin Pop | # This program is free software; you can redistribute it and/or modify
|
7 | a8083063 | Iustin Pop | # it under the terms of the GNU General Public License as published by
|
8 | a8083063 | Iustin Pop | # the Free Software Foundation; either version 2 of the License, or
|
9 | a8083063 | Iustin Pop | # (at your option) any later version.
|
10 | a8083063 | Iustin Pop | #
|
11 | a8083063 | Iustin Pop | # This program is distributed in the hope that it will be useful, but
|
12 | a8083063 | Iustin Pop | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | a8083063 | Iustin Pop | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | a8083063 | Iustin Pop | # General Public License for more details.
|
15 | a8083063 | Iustin Pop | #
|
16 | a8083063 | Iustin Pop | # You should have received a copy of the GNU General Public License
|
17 | a8083063 | Iustin Pop | # along with this program; if not, write to the Free Software
|
18 | a8083063 | Iustin Pop | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
19 | a8083063 | Iustin Pop | # 02110-1301, USA.
|
20 | a8083063 | Iustin Pop | |
21 | a8083063 | Iustin Pop | |
22 | 3ef3c771 | Iustin Pop | """Inter-node RPC library.
|
23 | a8083063 | Iustin Pop |
|
24 | a8083063 | Iustin Pop | """
|
25 | a8083063 | Iustin Pop | |
26 | 72737a7f | Iustin Pop | # pylint: disable-msg=C0103,R0201,R0904
|
27 | 72737a7f | Iustin Pop | # C0103: Invalid name, since call_ are not valid
|
28 | 72737a7f | Iustin Pop | # R0201: Method could be a function, we keep all rpcs instance methods
|
29 | 72737a7f | Iustin Pop | # as not to change them back and forth between static/instance methods
|
30 | 72737a7f | Iustin Pop | # if they need to start using instance attributes
|
31 | 72737a7f | Iustin Pop | # R0904: Too many public methods
|
32 | a8083063 | Iustin Pop | |
33 | a8083063 | Iustin Pop | import os |
34 | 58b311ca | Iustin Pop | import logging |
35 | 12bce260 | Michael Hanselmann | import zlib |
36 | 12bce260 | Michael Hanselmann | import base64 |
37 | a8083063 | Iustin Pop | |
38 | a8083063 | Iustin Pop | from ganeti import utils |
39 | a8083063 | Iustin Pop | from ganeti import objects |
40 | ecfe9491 | Michael Hanselmann | from ganeti import http |
41 | 7c28c575 | Michael Hanselmann | from ganeti import serializer |
42 | eafd8762 | Michael Hanselmann | from ganeti import constants |
43 | 781de953 | Iustin Pop | from ganeti import errors |
44 | a8083063 | Iustin Pop | |
45 | fe267188 | Iustin Pop | # pylint has a bug here, doesn't see this import
|
46 | fe267188 | Iustin Pop | import ganeti.http.client # pylint: disable-msg=W0611 |
47 | ae88ef45 | Michael Hanselmann | |
48 | a8083063 | Iustin Pop | |
49 | 4331f6cd | Michael Hanselmann | # Module level variable
|
50 | 4331f6cd | Michael Hanselmann | _http_manager = None
|
51 | 4331f6cd | Michael Hanselmann | |
52 | 92fd2250 | Iustin Pop | # Various time constants for the timeout table
|
53 | 92fd2250 | Iustin Pop | _TMO_URGENT = 60 # one minute |
54 | 92fd2250 | Iustin Pop | _TMO_FAST = 5 * 60 # five minutes |
55 | 92fd2250 | Iustin Pop | _TMO_NORMAL = 15 * 60 # 15 minutes |
56 | 92fd2250 | Iustin Pop | _TMO_SLOW = 3600 # one hour |
57 | 92fd2250 | Iustin Pop | _TMO_4HRS = 4 * 3600 |
58 | 92fd2250 | Iustin Pop | _TMO_1DAY = 86400
|
59 | 92fd2250 | Iustin Pop | |
60 | 92fd2250 | Iustin Pop | # Timeout table that will be built later by decorators
|
61 | 92fd2250 | Iustin Pop | # Guidelines for choosing timeouts:
|
62 | 92fd2250 | Iustin Pop | # - call used during watcher: timeout -> 1min, _TMO_URGENT
|
63 | 92fd2250 | Iustin Pop | # - trivial (but be sure it is trivial) (e.g. reading a file): 5min, _TMO_FAST
|
64 | 92fd2250 | Iustin Pop | # - other calls: 15 min, _TMO_NORMAL
|
65 | 92fd2250 | Iustin Pop | # - special calls (instance add, etc.): either _TMO_SLOW (1h) or huge timeouts
|
66 | 92fd2250 | Iustin Pop | |
67 | 92fd2250 | Iustin Pop | _TIMEOUTS = { |
68 | 92fd2250 | Iustin Pop | } |
69 | 92fd2250 | Iustin Pop | |
70 | 4331f6cd | Michael Hanselmann | |
71 | 4331f6cd | Michael Hanselmann | def Init(): |
72 | 4331f6cd | Michael Hanselmann | """Initializes the module-global HTTP client manager.
|
73 | 4331f6cd | Michael Hanselmann |
|
74 | 4331f6cd | Michael Hanselmann | Must be called before using any RPC function.
|
75 | 4331f6cd | Michael Hanselmann |
|
76 | 4331f6cd | Michael Hanselmann | """
|
77 | fe267188 | Iustin Pop | global _http_manager # pylint: disable-msg=W0603 |
78 | 4331f6cd | Michael Hanselmann | |
79 | 4331f6cd | Michael Hanselmann | assert not _http_manager, "RPC module initialized more than once" |
80 | 4331f6cd | Michael Hanselmann | |
81 | 8d0a4f99 | Michael Hanselmann | http.InitSsl() |
82 | 8d0a4f99 | Michael Hanselmann | |
83 | ae88ef45 | Michael Hanselmann | _http_manager = http.client.HttpClientManager() |
84 | 4331f6cd | Michael Hanselmann | |
85 | 4331f6cd | Michael Hanselmann | |
86 | 4331f6cd | Michael Hanselmann | def Shutdown(): |
87 | 4331f6cd | Michael Hanselmann | """Stops the module-global HTTP client manager.
|
88 | 4331f6cd | Michael Hanselmann |
|
89 | 4331f6cd | Michael Hanselmann | Must be called before quitting the program.
|
90 | 4331f6cd | Michael Hanselmann |
|
91 | 4331f6cd | Michael Hanselmann | """
|
92 | fe267188 | Iustin Pop | global _http_manager # pylint: disable-msg=W0603 |
93 | 4331f6cd | Michael Hanselmann | |
94 | 4331f6cd | Michael Hanselmann | if _http_manager:
|
95 | 4331f6cd | Michael Hanselmann | _http_manager.Shutdown() |
96 | 4331f6cd | Michael Hanselmann | _http_manager = None
|
97 | 4331f6cd | Michael Hanselmann | |
98 | 4331f6cd | Michael Hanselmann | |
99 | 92fd2250 | Iustin Pop | def _RpcTimeout(secs): |
100 | 92fd2250 | Iustin Pop | """Timeout decorator.
|
101 | 92fd2250 | Iustin Pop |
|
102 | 92fd2250 | Iustin Pop | When applied to a rpc call_* function, it updates the global timeout
|
103 | 92fd2250 | Iustin Pop | table with the given function/timeout.
|
104 | 92fd2250 | Iustin Pop |
|
105 | 92fd2250 | Iustin Pop | """
|
106 | 92fd2250 | Iustin Pop | def decorator(f): |
107 | 92fd2250 | Iustin Pop | name = f.__name__ |
108 | 92fd2250 | Iustin Pop | assert name.startswith("call_") |
109 | 92fd2250 | Iustin Pop | _TIMEOUTS[name[len("call_"):]] = secs |
110 | 92fd2250 | Iustin Pop | return f
|
111 | 92fd2250 | Iustin Pop | return decorator
|
112 | 92fd2250 | Iustin Pop | |
113 | 92fd2250 | Iustin Pop | |
114 | 781de953 | Iustin Pop | class RpcResult(object): |
115 | 781de953 | Iustin Pop | """RPC Result class.
|
116 | 781de953 | Iustin Pop |
|
117 | 781de953 | Iustin Pop | This class holds an RPC result. It is needed since in multi-node
|
118 | 781de953 | Iustin Pop | calls we can't raise an exception just because one one out of many
|
119 | 781de953 | Iustin Pop | failed, and therefore we use this class to encapsulate the result.
|
120 | 781de953 | Iustin Pop |
|
121 | 5bbd3f7f | Michael Hanselmann | @ivar data: the data payload, for successful results, or None
|
122 | ed83f5cc | Iustin Pop | @ivar call: the name of the RPC call
|
123 | ed83f5cc | Iustin Pop | @ivar node: the name of the node to which we made the call
|
124 | ed83f5cc | Iustin Pop | @ivar offline: whether the operation failed because the node was
|
125 | ed83f5cc | Iustin Pop | offline, as opposed to actual failure; offline=True will always
|
126 | ed83f5cc | Iustin Pop | imply failed=True, in order to allow simpler checking if
|
127 | ed83f5cc | Iustin Pop | the user doesn't care about the exact failure mode
|
128 | 4c4e4e1e | Iustin Pop | @ivar fail_msg: the error message if the call failed
|
129 | ed83f5cc | Iustin Pop |
|
130 | 781de953 | Iustin Pop | """
|
131 | ed83f5cc | Iustin Pop | def __init__(self, data=None, failed=False, offline=False, |
132 | ed83f5cc | Iustin Pop | call=None, node=None): |
133 | ed83f5cc | Iustin Pop | self.offline = offline
|
134 | ed83f5cc | Iustin Pop | self.call = call
|
135 | ed83f5cc | Iustin Pop | self.node = node
|
136 | 1645d22d | Michael Hanselmann | |
137 | ed83f5cc | Iustin Pop | if offline:
|
138 | 4c4e4e1e | Iustin Pop | self.fail_msg = "Node is marked offline" |
139 | f2def43a | Iustin Pop | self.data = self.payload = None |
140 | ed83f5cc | Iustin Pop | elif failed:
|
141 | 4c4e4e1e | Iustin Pop | self.fail_msg = self._EnsureErr(data) |
142 | f2def43a | Iustin Pop | self.data = self.payload = None |
143 | 781de953 | Iustin Pop | else:
|
144 | 781de953 | Iustin Pop | self.data = data
|
145 | d3c8b360 | Iustin Pop | if not isinstance(self.data, (tuple, list)): |
146 | 4c4e4e1e | Iustin Pop | self.fail_msg = ("RPC layer error: invalid result type (%s)" % |
147 | 4c4e4e1e | Iustin Pop | type(self.data)) |
148 | 1645d22d | Michael Hanselmann | self.payload = None |
149 | d3c8b360 | Iustin Pop | elif len(data) != 2: |
150 | 4c4e4e1e | Iustin Pop | self.fail_msg = ("RPC layer error: invalid result length (%d), " |
151 | 4c4e4e1e | Iustin Pop | "expected 2" % len(self.data)) |
152 | 1645d22d | Michael Hanselmann | self.payload = None |
153 | d3c8b360 | Iustin Pop | elif not self.data[0]: |
154 | 4c4e4e1e | Iustin Pop | self.fail_msg = self._EnsureErr(self.data[1]) |
155 | 1645d22d | Michael Hanselmann | self.payload = None |
156 | f2def43a | Iustin Pop | else:
|
157 | d3c8b360 | Iustin Pop | # finally success
|
158 | 4c4e4e1e | Iustin Pop | self.fail_msg = None |
159 | d3c8b360 | Iustin Pop | self.payload = data[1] |
160 | d3c8b360 | Iustin Pop | |
161 | 1645d22d | Michael Hanselmann | assert hasattr(self, "call") |
162 | 1645d22d | Michael Hanselmann | assert hasattr(self, "data") |
163 | 1645d22d | Michael Hanselmann | assert hasattr(self, "fail_msg") |
164 | 1645d22d | Michael Hanselmann | assert hasattr(self, "node") |
165 | 1645d22d | Michael Hanselmann | assert hasattr(self, "offline") |
166 | 1645d22d | Michael Hanselmann | assert hasattr(self, "payload") |
167 | 1645d22d | Michael Hanselmann | |
168 | d3c8b360 | Iustin Pop | @staticmethod
|
169 | d3c8b360 | Iustin Pop | def _EnsureErr(val): |
170 | d3c8b360 | Iustin Pop | """Helper to ensure we return a 'True' value for error."""
|
171 | d3c8b360 | Iustin Pop | if val:
|
172 | d3c8b360 | Iustin Pop | return val
|
173 | d3c8b360 | Iustin Pop | else:
|
174 | d3c8b360 | Iustin Pop | return "No error information" |
175 | 781de953 | Iustin Pop | |
176 | 045dd6d9 | Iustin Pop | def Raise(self, msg, prereq=False, ecode=None): |
177 | 781de953 | Iustin Pop | """If the result has failed, raise an OpExecError.
|
178 | 781de953 | Iustin Pop |
|
179 | 781de953 | Iustin Pop | This is used so that LU code doesn't have to check for each
|
180 | 781de953 | Iustin Pop | result, but instead can call this function.
|
181 | 781de953 | Iustin Pop |
|
182 | 781de953 | Iustin Pop | """
|
183 | 4c4e4e1e | Iustin Pop | if not self.fail_msg: |
184 | 4c4e4e1e | Iustin Pop | return
|
185 | 4c4e4e1e | Iustin Pop | |
186 | 4c4e4e1e | Iustin Pop | if not msg: # one could pass None for default message |
187 | 4c4e4e1e | Iustin Pop | msg = ("Call '%s' to node '%s' has failed: %s" %
|
188 | 4c4e4e1e | Iustin Pop | (self.call, self.node, self.fail_msg)) |
189 | 4c4e4e1e | Iustin Pop | else:
|
190 | 4c4e4e1e | Iustin Pop | msg = "%s: %s" % (msg, self.fail_msg) |
191 | 4c4e4e1e | Iustin Pop | if prereq:
|
192 | 4c4e4e1e | Iustin Pop | ec = errors.OpPrereqError |
193 | 4c4e4e1e | Iustin Pop | else:
|
194 | 4c4e4e1e | Iustin Pop | ec = errors.OpExecError |
195 | 045dd6d9 | Iustin Pop | if ecode is not None: |
196 | 27137e55 | Iustin Pop | args = (msg, ecode) |
197 | 045dd6d9 | Iustin Pop | else:
|
198 | 045dd6d9 | Iustin Pop | args = (msg, ) |
199 | 7260cfbe | Iustin Pop | raise ec(*args) # pylint: disable-msg=W0142 |
200 | 781de953 | Iustin Pop | |
201 | 781de953 | Iustin Pop | |
202 | a8083063 | Iustin Pop | class Client: |
203 | a8083063 | Iustin Pop | """RPC Client class.
|
204 | a8083063 | Iustin Pop |
|
205 | 2f8598a5 | Alexander Schreiber | This class, given a (remote) method name, a list of parameters and a
|
206 | a8083063 | Iustin Pop | list of nodes, will contact (in parallel) all nodes, and return a
|
207 | a8083063 | Iustin Pop | dict of results (key: node name, value: result).
|
208 | a8083063 | Iustin Pop |
|
209 | 5bbd3f7f | Michael Hanselmann | One current bug is that generic failure is still signaled by
|
210 | a8083063 | Iustin Pop | 'False' result, which is not good. This overloading of values can
|
211 | a8083063 | Iustin Pop | cause bugs.
|
212 | a8083063 | Iustin Pop |
|
213 | a8083063 | Iustin Pop | """
|
214 | 160e2921 | Iustin Pop | def __init__(self, procedure, body, port): |
215 | 92fd2250 | Iustin Pop | assert procedure in _TIMEOUTS, ("New RPC call not declared in the" |
216 | 92fd2250 | Iustin Pop | " timeouts table")
|
217 | a8083063 | Iustin Pop | self.procedure = procedure
|
218 | 160e2921 | Iustin Pop | self.body = body
|
219 | 160e2921 | Iustin Pop | self.port = port
|
220 | ecfe9491 | Michael Hanselmann | self.nc = {}
|
221 | a8083063 | Iustin Pop | |
222 | d57ae7f7 | Michael Hanselmann | self._ssl_params = \
|
223 | 168c1de2 | Michael Hanselmann | http.HttpSslParams(ssl_key_path=constants.NODED_CERT_FILE, |
224 | 168c1de2 | Michael Hanselmann | ssl_cert_path=constants.NODED_CERT_FILE) |
225 | d57ae7f7 | Michael Hanselmann | |
226 | e0036155 | Iustin Pop | def ConnectList(self, node_list, address_list=None, read_timeout=None): |
227 | a8083063 | Iustin Pop | """Add a list of nodes to the target nodes.
|
228 | a8083063 | Iustin Pop |
|
229 | 3ef3c771 | Iustin Pop | @type node_list: list
|
230 | 3ef3c771 | Iustin Pop | @param node_list: the list of node names to connect
|
231 | bdf7d8c0 | Iustin Pop | @type address_list: list or None
|
232 | bdf7d8c0 | Iustin Pop | @keyword address_list: either None or a list with node addresses,
|
233 | bdf7d8c0 | Iustin Pop | which must have the same length as the node list
|
234 | e0036155 | Iustin Pop | @type read_timeout: int
|
235 | e0036155 | Iustin Pop | @param read_timeout: overwrites the default read timeout for the
|
236 | e0036155 | Iustin Pop | given operation
|
237 | 3ef3c771 | Iustin Pop |
|
238 | a8083063 | Iustin Pop | """
|
239 | bdf7d8c0 | Iustin Pop | if address_list is None: |
240 | bdf7d8c0 | Iustin Pop | address_list = [None for _ in node_list] |
241 | bdf7d8c0 | Iustin Pop | else:
|
242 | bdf7d8c0 | Iustin Pop | assert len(node_list) == len(address_list), \ |
243 | bdf7d8c0 | Iustin Pop | "Name and address lists should have the same length"
|
244 | bdf7d8c0 | Iustin Pop | for node, address in zip(node_list, address_list): |
245 | e0036155 | Iustin Pop | self.ConnectNode(node, address, read_timeout=read_timeout)
|
246 | bdf7d8c0 | Iustin Pop | |
247 | e0036155 | Iustin Pop | def ConnectNode(self, name, address=None, read_timeout=None): |
248 | a8083063 | Iustin Pop | """Add a node to the target list.
|
249 | a8083063 | Iustin Pop |
|
250 | bdf7d8c0 | Iustin Pop | @type name: str
|
251 | bdf7d8c0 | Iustin Pop | @param name: the node name
|
252 | bdf7d8c0 | Iustin Pop | @type address: str
|
253 | bdf7d8c0 | Iustin Pop | @keyword address: the node address, if known
|
254 | bdf7d8c0 | Iustin Pop |
|
255 | a8083063 | Iustin Pop | """
|
256 | ecfe9491 | Michael Hanselmann | if address is None: |
257 | ecfe9491 | Michael Hanselmann | address = name |
258 | ecfe9491 | Michael Hanselmann | |
259 | 92fd2250 | Iustin Pop | if read_timeout is None: |
260 | 92fd2250 | Iustin Pop | read_timeout = _TIMEOUTS[self.procedure]
|
261 | 92fd2250 | Iustin Pop | |
262 | ae88ef45 | Michael Hanselmann | self.nc[name] = \
|
263 | ae88ef45 | Michael Hanselmann | http.client.HttpClientRequest(address, self.port, http.HTTP_PUT,
|
264 | ae88ef45 | Michael Hanselmann | "/%s" % self.procedure, |
265 | ae88ef45 | Michael Hanselmann | post_data=self.body,
|
266 | ae88ef45 | Michael Hanselmann | ssl_params=self._ssl_params,
|
267 | e0036155 | Iustin Pop | ssl_verify_peer=True,
|
268 | e0036155 | Iustin Pop | read_timeout=read_timeout) |
269 | a8083063 | Iustin Pop | |
270 | 3ef3c771 | Iustin Pop | def GetResults(self): |
271 | ecfe9491 | Michael Hanselmann | """Call nodes and return results.
|
272 | ecfe9491 | Michael Hanselmann |
|
273 | ecfe9491 | Michael Hanselmann | @rtype: list
|
274 | 5fcc718f | Iustin Pop | @return: List of RPC results
|
275 | a8083063 | Iustin Pop |
|
276 | a8083063 | Iustin Pop | """
|
277 | 5bbd3f7f | Michael Hanselmann | assert _http_manager, "RPC module not initialized" |
278 | 4331f6cd | Michael Hanselmann | |
279 | 4331f6cd | Michael Hanselmann | _http_manager.ExecRequests(self.nc.values())
|
280 | a8083063 | Iustin Pop | |
281 | ecfe9491 | Michael Hanselmann | results = {} |
282 | a8083063 | Iustin Pop | |
283 | ecfe9491 | Michael Hanselmann | for name, req in self.nc.iteritems(): |
284 | ae88ef45 | Michael Hanselmann | if req.success and req.resp_status_code == http.HTTP_OK: |
285 | 781de953 | Iustin Pop | results[name] = RpcResult(data=serializer.LoadJson(req.resp_body), |
286 | 781de953 | Iustin Pop | node=name, call=self.procedure)
|
287 | ecfe9491 | Michael Hanselmann | continue
|
288 | a8083063 | Iustin Pop | |
289 | d57ae7f7 | Michael Hanselmann | # TODO: Better error reporting
|
290 | ecfe9491 | Michael Hanselmann | if req.error:
|
291 | ecfe9491 | Michael Hanselmann | msg = req.error |
292 | ecfe9491 | Michael Hanselmann | else:
|
293 | ecfe9491 | Michael Hanselmann | msg = req.resp_body |
294 | ecfe9491 | Michael Hanselmann | |
295 | 1b8acf70 | Iustin Pop | logging.error("RPC error in %s from node %s: %s",
|
296 | 1b8acf70 | Iustin Pop | self.procedure, name, msg)
|
297 | 781de953 | Iustin Pop | results[name] = RpcResult(data=msg, failed=True, node=name,
|
298 | 781de953 | Iustin Pop | call=self.procedure)
|
299 | ecfe9491 | Michael Hanselmann | |
300 | ecfe9491 | Michael Hanselmann | return results
|
301 | a8083063 | Iustin Pop | |
302 | a8083063 | Iustin Pop | |
303 | 1651d116 | Michael Hanselmann | def _EncodeImportExportIO(ieio, ieioargs): |
304 | 1651d116 | Michael Hanselmann | """Encodes import/export I/O information.
|
305 | 1651d116 | Michael Hanselmann |
|
306 | 1651d116 | Michael Hanselmann | """
|
307 | 1651d116 | Michael Hanselmann | if ieio == constants.IEIO_RAW_DISK:
|
308 | 1651d116 | Michael Hanselmann | assert len(ieioargs) == 1 |
309 | 1651d116 | Michael Hanselmann | return (ieioargs[0].ToDict(), ) |
310 | 1651d116 | Michael Hanselmann | |
311 | 1651d116 | Michael Hanselmann | if ieio == constants.IEIO_SCRIPT:
|
312 | 1651d116 | Michael Hanselmann | assert len(ieioargs) == 2 |
313 | 1651d116 | Michael Hanselmann | return (ieioargs[0].ToDict(), ieioargs[1]) |
314 | 1651d116 | Michael Hanselmann | |
315 | 1651d116 | Michael Hanselmann | return ieioargs
|
316 | 1651d116 | Michael Hanselmann | |
317 | 1651d116 | Michael Hanselmann | |
318 | 72737a7f | Iustin Pop | class RpcRunner(object): |
319 | 72737a7f | Iustin Pop | """RPC runner class"""
|
320 | a8083063 | Iustin Pop | |
321 | 72737a7f | Iustin Pop | def __init__(self, cfg): |
322 | 72737a7f | Iustin Pop | """Initialized the rpc runner.
|
323 | a8083063 | Iustin Pop |
|
324 | 72737a7f | Iustin Pop | @type cfg: C{config.ConfigWriter}
|
325 | 72737a7f | Iustin Pop | @param cfg: the configuration object that will be used to get data
|
326 | 72737a7f | Iustin Pop | about the cluster
|
327 | a8083063 | Iustin Pop |
|
328 | 72737a7f | Iustin Pop | """
|
329 | 72737a7f | Iustin Pop | self._cfg = cfg
|
330 | cd50653c | Guido Trotter | self.port = utils.GetDaemonPort(constants.NODED)
|
331 | a8083063 | Iustin Pop | |
332 | 1bdcbbab | Iustin Pop | def _InstDict(self, instance, hvp=None, bep=None, osp=None): |
333 | 26ba2bd8 | Iustin Pop | """Convert the given instance to a dict.
|
334 | 26ba2bd8 | Iustin Pop |
|
335 | 26ba2bd8 | Iustin Pop | This is done via the instance's ToDict() method and additionally
|
336 | 26ba2bd8 | Iustin Pop | we fill the hvparams with the cluster defaults.
|
337 | 26ba2bd8 | Iustin Pop |
|
338 | 26ba2bd8 | Iustin Pop | @type instance: L{objects.Instance}
|
339 | 26ba2bd8 | Iustin Pop | @param instance: an Instance object
|
340 | 0eca8e0c | Iustin Pop | @type hvp: dict or None
|
341 | 5bbd3f7f | Michael Hanselmann | @param hvp: a dictionary with overridden hypervisor parameters
|
342 | 0eca8e0c | Iustin Pop | @type bep: dict or None
|
343 | 5bbd3f7f | Michael Hanselmann | @param bep: a dictionary with overridden backend parameters
|
344 | 1bdcbbab | Iustin Pop | @type osp: dict or None
|
345 | 1bdcbbab | Iustin Pop | @param osp: a dictionary with overriden os parameters
|
346 | 26ba2bd8 | Iustin Pop | @rtype: dict
|
347 | 26ba2bd8 | Iustin Pop | @return: the instance dict, with the hvparams filled with the
|
348 | 26ba2bd8 | Iustin Pop | cluster defaults
|
349 | 26ba2bd8 | Iustin Pop |
|
350 | 26ba2bd8 | Iustin Pop | """
|
351 | 26ba2bd8 | Iustin Pop | idict = instance.ToDict() |
352 | 5b442704 | Iustin Pop | cluster = self._cfg.GetClusterInfo()
|
353 | 5b442704 | Iustin Pop | idict["hvparams"] = cluster.FillHV(instance)
|
354 | 0eca8e0c | Iustin Pop | if hvp is not None: |
355 | 0eca8e0c | Iustin Pop | idict["hvparams"].update(hvp)
|
356 | 5b442704 | Iustin Pop | idict["beparams"] = cluster.FillBE(instance)
|
357 | 0eca8e0c | Iustin Pop | if bep is not None: |
358 | 0eca8e0c | Iustin Pop | idict["beparams"].update(bep)
|
359 | 1bdcbbab | Iustin Pop | idict["osparams"] = cluster.SimpleFillOS(instance.os, instance.osparams)
|
360 | 1bdcbbab | Iustin Pop | if osp is not None: |
361 | 1bdcbbab | Iustin Pop | idict["osparams"].update(osp)
|
362 | b848ce79 | Guido Trotter | for nic in idict["nics"]: |
363 | b848ce79 | Guido Trotter | nic['nicparams'] = objects.FillDict(
|
364 | b848ce79 | Guido Trotter | cluster.nicparams[constants.PP_DEFAULT], |
365 | b848ce79 | Guido Trotter | nic['nicparams'])
|
366 | 26ba2bd8 | Iustin Pop | return idict
|
367 | 26ba2bd8 | Iustin Pop | |
368 | e0036155 | Iustin Pop | def _ConnectList(self, client, node_list, call, read_timeout=None): |
369 | 25348212 | Iustin Pop | """Helper for computing node addresses.
|
370 | 25348212 | Iustin Pop |
|
371 | 6af6270a | Iustin Pop | @type client: L{ganeti.rpc.Client}
|
372 | 25348212 | Iustin Pop | @param client: a C{Client} instance
|
373 | 25348212 | Iustin Pop | @type node_list: list
|
374 | 25348212 | Iustin Pop | @param node_list: the node list we should connect
|
375 | 84b45587 | Iustin Pop | @type call: string
|
376 | 84b45587 | Iustin Pop | @param call: the name of the remote procedure call, for filling in
|
377 | 84b45587 | Iustin Pop | correctly any eventual offline nodes' results
|
378 | e0036155 | Iustin Pop | @type read_timeout: int
|
379 | e0036155 | Iustin Pop | @param read_timeout: overwrites the default read timeout for the
|
380 | e0036155 | Iustin Pop | given operation
|
381 | 25348212 | Iustin Pop |
|
382 | 25348212 | Iustin Pop | """
|
383 | 25348212 | Iustin Pop | all_nodes = self._cfg.GetAllNodesInfo()
|
384 | ed83f5cc | Iustin Pop | name_list = [] |
385 | 25348212 | Iustin Pop | addr_list = [] |
386 | ed83f5cc | Iustin Pop | skip_dict = {} |
387 | 25348212 | Iustin Pop | for node in node_list: |
388 | 25348212 | Iustin Pop | if node in all_nodes: |
389 | ed83f5cc | Iustin Pop | if all_nodes[node].offline:
|
390 | 84b45587 | Iustin Pop | skip_dict[node] = RpcResult(node=node, offline=True, call=call)
|
391 | ed83f5cc | Iustin Pop | continue
|
392 | 25348212 | Iustin Pop | val = all_nodes[node].primary_ip |
393 | 25348212 | Iustin Pop | else:
|
394 | 25348212 | Iustin Pop | val = None
|
395 | 25348212 | Iustin Pop | addr_list.append(val) |
396 | ed83f5cc | Iustin Pop | name_list.append(node) |
397 | ed83f5cc | Iustin Pop | if name_list:
|
398 | e0036155 | Iustin Pop | client.ConnectList(name_list, address_list=addr_list, |
399 | e0036155 | Iustin Pop | read_timeout=read_timeout) |
400 | ed83f5cc | Iustin Pop | return skip_dict
|
401 | 25348212 | Iustin Pop | |
402 | e0036155 | Iustin Pop | def _ConnectNode(self, client, node, call, read_timeout=None): |
403 | 25348212 | Iustin Pop | """Helper for computing one node's address.
|
404 | 25348212 | Iustin Pop |
|
405 | 6af6270a | Iustin Pop | @type client: L{ganeti.rpc.Client}
|
406 | 25348212 | Iustin Pop | @param client: a C{Client} instance
|
407 | 25348212 | Iustin Pop | @type node: str
|
408 | 25348212 | Iustin Pop | @param node: the node we should connect
|
409 | 84b45587 | Iustin Pop | @type call: string
|
410 | 84b45587 | Iustin Pop | @param call: the name of the remote procedure call, for filling in
|
411 | 84b45587 | Iustin Pop | correctly any eventual offline nodes' results
|
412 | e0036155 | Iustin Pop | @type read_timeout: int
|
413 | e0036155 | Iustin Pop | @param read_timeout: overwrites the default read timeout for the
|
414 | e0036155 | Iustin Pop | given operation
|
415 | 25348212 | Iustin Pop |
|
416 | 25348212 | Iustin Pop | """
|
417 | 25348212 | Iustin Pop | node_info = self._cfg.GetNodeInfo(node)
|
418 | 25348212 | Iustin Pop | if node_info is not None: |
419 | ed83f5cc | Iustin Pop | if node_info.offline:
|
420 | 84b45587 | Iustin Pop | return RpcResult(node=node, offline=True, call=call) |
421 | 25348212 | Iustin Pop | addr = node_info.primary_ip |
422 | 25348212 | Iustin Pop | else:
|
423 | 25348212 | Iustin Pop | addr = None
|
424 | e0036155 | Iustin Pop | client.ConnectNode(node, address=addr, read_timeout=read_timeout) |
425 | 25348212 | Iustin Pop | |
426 | e0036155 | Iustin Pop | def _MultiNodeCall(self, node_list, procedure, args, read_timeout=None): |
427 | 160e2921 | Iustin Pop | """Helper for making a multi-node call
|
428 | 160e2921 | Iustin Pop |
|
429 | 160e2921 | Iustin Pop | """
|
430 | 160e2921 | Iustin Pop | body = serializer.DumpJson(args, indent=False)
|
431 | 160e2921 | Iustin Pop | c = Client(procedure, body, self.port)
|
432 | e0036155 | Iustin Pop | skip_dict = self._ConnectList(c, node_list, procedure,
|
433 | e0036155 | Iustin Pop | read_timeout=read_timeout) |
434 | ed83f5cc | Iustin Pop | skip_dict.update(c.GetResults()) |
435 | ed83f5cc | Iustin Pop | return skip_dict
|
436 | 9a525d83 | Michael Hanselmann | |
437 | 9a525d83 | Michael Hanselmann | @classmethod
|
438 | 9a525d83 | Michael Hanselmann | def _StaticMultiNodeCall(cls, node_list, procedure, args, |
439 | e0036155 | Iustin Pop | address_list=None, read_timeout=None): |
440 | 160e2921 | Iustin Pop | """Helper for making a multi-node static call
|
441 | 160e2921 | Iustin Pop |
|
442 | 160e2921 | Iustin Pop | """
|
443 | 160e2921 | Iustin Pop | body = serializer.DumpJson(args, indent=False)
|
444 | cd50653c | Guido Trotter | c = Client(procedure, body, utils.GetDaemonPort(constants.NODED)) |
445 | e0036155 | Iustin Pop | c.ConnectList(node_list, address_list=address_list, |
446 | e0036155 | Iustin Pop | read_timeout=read_timeout) |
447 | 9a525d83 | Michael Hanselmann | return c.GetResults()
|
448 | 9a525d83 | Michael Hanselmann | |
449 | e0036155 | Iustin Pop | def _SingleNodeCall(self, node, procedure, args, read_timeout=None): |
450 | 160e2921 | Iustin Pop | """Helper for making a single-node call
|
451 | 9a525d83 | Michael Hanselmann |
|
452 | 9a525d83 | Michael Hanselmann | """
|
453 | 160e2921 | Iustin Pop | body = serializer.DumpJson(args, indent=False)
|
454 | 160e2921 | Iustin Pop | c = Client(procedure, body, self.port)
|
455 | e0036155 | Iustin Pop | result = self._ConnectNode(c, node, procedure, read_timeout=read_timeout)
|
456 | ed83f5cc | Iustin Pop | if result is None: |
457 | ed83f5cc | Iustin Pop | # we did connect, node is not offline
|
458 | ed83f5cc | Iustin Pop | result = c.GetResults()[node] |
459 | ed83f5cc | Iustin Pop | return result
|
460 | 9a525d83 | Michael Hanselmann | |
461 | 9a525d83 | Michael Hanselmann | @classmethod
|
462 | e0036155 | Iustin Pop | def _StaticSingleNodeCall(cls, node, procedure, args, read_timeout=None): |
463 | 160e2921 | Iustin Pop | """Helper for making a single-node static call
|
464 | 9a525d83 | Michael Hanselmann |
|
465 | 9a525d83 | Michael Hanselmann | """
|
466 | 160e2921 | Iustin Pop | body = serializer.DumpJson(args, indent=False)
|
467 | cd50653c | Guido Trotter | c = Client(procedure, body, utils.GetDaemonPort(constants.NODED)) |
468 | e0036155 | Iustin Pop | c.ConnectNode(node, read_timeout=read_timeout) |
469 | ed83f5cc | Iustin Pop | return c.GetResults()[node]
|
470 | 9a525d83 | Michael Hanselmann | |
471 | 12bce260 | Michael Hanselmann | @staticmethod
|
472 | 12bce260 | Michael Hanselmann | def _Compress(data): |
473 | 12bce260 | Michael Hanselmann | """Compresses a string for transport over RPC.
|
474 | 12bce260 | Michael Hanselmann |
|
475 | 12bce260 | Michael Hanselmann | Small amounts of data are not compressed.
|
476 | 12bce260 | Michael Hanselmann |
|
477 | 12bce260 | Michael Hanselmann | @type data: str
|
478 | 12bce260 | Michael Hanselmann | @param data: Data
|
479 | 12bce260 | Michael Hanselmann | @rtype: tuple
|
480 | 12bce260 | Michael Hanselmann | @return: Encoded data to send
|
481 | 12bce260 | Michael Hanselmann |
|
482 | 12bce260 | Michael Hanselmann | """
|
483 | 12bce260 | Michael Hanselmann | # Small amounts of data are not compressed
|
484 | 12bce260 | Michael Hanselmann | if len(data) < 512: |
485 | 12bce260 | Michael Hanselmann | return (constants.RPC_ENCODING_NONE, data)
|
486 | 12bce260 | Michael Hanselmann | |
487 | 12bce260 | Michael Hanselmann | # Compress with zlib and encode in base64
|
488 | 12bce260 | Michael Hanselmann | return (constants.RPC_ENCODING_ZLIB_BASE64,
|
489 | 12bce260 | Michael Hanselmann | base64.b64encode(zlib.compress(data, 3)))
|
490 | 12bce260 | Michael Hanselmann | |
491 | 781de953 | Iustin Pop | #
|
492 | 781de953 | Iustin Pop | # Begin RPC calls
|
493 | 781de953 | Iustin Pop | #
|
494 | 781de953 | Iustin Pop | |
495 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_URGENT)
|
496 | b2a6ccd4 | Iustin Pop | def call_lv_list(self, node_list, vg_name): |
497 | 72737a7f | Iustin Pop | """Gets the logical volumes present in a given volume group.
|
498 | a8083063 | Iustin Pop |
|
499 | 72737a7f | Iustin Pop | This is a multi-node call.
|
500 | a8083063 | Iustin Pop |
|
501 | 72737a7f | Iustin Pop | """
|
502 | b2a6ccd4 | Iustin Pop | return self._MultiNodeCall(node_list, "lv_list", [vg_name]) |
503 | a8083063 | Iustin Pop | |
504 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_URGENT)
|
505 | 72737a7f | Iustin Pop | def call_vg_list(self, node_list): |
506 | 72737a7f | Iustin Pop | """Gets the volume group list.
|
507 | a8083063 | Iustin Pop |
|
508 | 72737a7f | Iustin Pop | This is a multi-node call.
|
509 | a8083063 | Iustin Pop |
|
510 | 72737a7f | Iustin Pop | """
|
511 | 9a525d83 | Michael Hanselmann | return self._MultiNodeCall(node_list, "vg_list", []) |
512 | a8083063 | Iustin Pop | |
513 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
514 | e337de97 | Michael Hanselmann | def call_storage_list(self, node_list, su_name, su_args, name, fields): |
515 | 8979196a | Michael Hanselmann | """Get list of storage units.
|
516 | e337de97 | Michael Hanselmann |
|
517 | e337de97 | Michael Hanselmann | This is a multi-node call.
|
518 | e337de97 | Michael Hanselmann |
|
519 | e337de97 | Michael Hanselmann | """
|
520 | e337de97 | Michael Hanselmann | return self._MultiNodeCall(node_list, "storage_list", |
521 | e337de97 | Michael Hanselmann | [su_name, su_args, name, fields]) |
522 | e337de97 | Michael Hanselmann | |
523 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
524 | 8979196a | Michael Hanselmann | def call_storage_modify(self, node, su_name, su_args, name, changes): |
525 | 8979196a | Michael Hanselmann | """Modify a storage unit.
|
526 | 8979196a | Michael Hanselmann |
|
527 | 8979196a | Michael Hanselmann | This is a single-node call.
|
528 | 8979196a | Michael Hanselmann |
|
529 | 8979196a | Michael Hanselmann | """
|
530 | 8979196a | Michael Hanselmann | return self._SingleNodeCall(node, "storage_modify", |
531 | 8979196a | Michael Hanselmann | [su_name, su_args, name, changes]) |
532 | 8979196a | Michael Hanselmann | |
533 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
534 | 637b8d7e | Michael Hanselmann | def call_storage_execute(self, node, su_name, su_args, name, op): |
535 | 637b8d7e | Michael Hanselmann | """Executes an operation on a storage unit.
|
536 | 637b8d7e | Michael Hanselmann |
|
537 | 637b8d7e | Michael Hanselmann | This is a single-node call.
|
538 | 637b8d7e | Michael Hanselmann |
|
539 | 637b8d7e | Michael Hanselmann | """
|
540 | 637b8d7e | Michael Hanselmann | return self._SingleNodeCall(node, "storage_execute", |
541 | 637b8d7e | Michael Hanselmann | [su_name, su_args, name, op]) |
542 | 637b8d7e | Michael Hanselmann | |
543 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_URGENT)
|
544 | 72737a7f | Iustin Pop | def call_bridges_exist(self, node, bridges_list): |
545 | 72737a7f | Iustin Pop | """Checks if a node has all the bridges given.
|
546 | a8083063 | Iustin Pop |
|
547 | 72737a7f | Iustin Pop | This method checks if all bridges given in the bridges_list are
|
548 | 72737a7f | Iustin Pop | present on the remote node, so that an instance that uses interfaces
|
549 | 72737a7f | Iustin Pop | on those bridges can be started.
|
550 | a8083063 | Iustin Pop |
|
551 | 72737a7f | Iustin Pop | This is a single-node call.
|
552 | a8083063 | Iustin Pop |
|
553 | 72737a7f | Iustin Pop | """
|
554 | 9a525d83 | Michael Hanselmann | return self._SingleNodeCall(node, "bridges_exist", [bridges_list]) |
555 | a8083063 | Iustin Pop | |
556 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
557 | 0eca8e0c | Iustin Pop | def call_instance_start(self, node, instance, hvp, bep): |
558 | 72737a7f | Iustin Pop | """Starts an instance.
|
559 | a8083063 | Iustin Pop |
|
560 | 72737a7f | Iustin Pop | This is a single-node call.
|
561 | a8083063 | Iustin Pop |
|
562 | 72737a7f | Iustin Pop | """
|
563 | 0eca8e0c | Iustin Pop | idict = self._InstDict(instance, hvp=hvp, bep=bep)
|
564 | 0eca8e0c | Iustin Pop | return self._SingleNodeCall(node, "instance_start", [idict]) |
565 | a8083063 | Iustin Pop | |
566 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
567 | 6263189c | Guido Trotter | def call_instance_shutdown(self, node, instance, timeout): |
568 | 72737a7f | Iustin Pop | """Stops an instance.
|
569 | a8083063 | Iustin Pop |
|
570 | 72737a7f | Iustin Pop | This is a single-node call.
|
571 | 2a10865c | Iustin Pop |
|
572 | 72737a7f | Iustin Pop | """
|
573 | 9a525d83 | Michael Hanselmann | return self._SingleNodeCall(node, "instance_shutdown", |
574 | 6263189c | Guido Trotter | [self._InstDict(instance), timeout])
|
575 | 2a10865c | Iustin Pop | |
576 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
577 | 6906a9d8 | Guido Trotter | def call_migration_info(self, node, instance): |
578 | 6906a9d8 | Guido Trotter | """Gather the information necessary to prepare an instance migration.
|
579 | 6906a9d8 | Guido Trotter |
|
580 | 6906a9d8 | Guido Trotter | This is a single-node call.
|
581 | 6906a9d8 | Guido Trotter |
|
582 | 6906a9d8 | Guido Trotter | @type node: string
|
583 | 6906a9d8 | Guido Trotter | @param node: the node on which the instance is currently running
|
584 | 6906a9d8 | Guido Trotter | @type instance: C{objects.Instance}
|
585 | 6906a9d8 | Guido Trotter | @param instance: the instance definition
|
586 | 6906a9d8 | Guido Trotter |
|
587 | 6906a9d8 | Guido Trotter | """
|
588 | 6906a9d8 | Guido Trotter | return self._SingleNodeCall(node, "migration_info", |
589 | 6906a9d8 | Guido Trotter | [self._InstDict(instance)])
|
590 | 6906a9d8 | Guido Trotter | |
591 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
592 | 6906a9d8 | Guido Trotter | def call_accept_instance(self, node, instance, info, target): |
593 | 6906a9d8 | Guido Trotter | """Prepare a node to accept an instance.
|
594 | 6906a9d8 | Guido Trotter |
|
595 | 6906a9d8 | Guido Trotter | This is a single-node call.
|
596 | 6906a9d8 | Guido Trotter |
|
597 | 6906a9d8 | Guido Trotter | @type node: string
|
598 | 6906a9d8 | Guido Trotter | @param node: the target node for the migration
|
599 | 6906a9d8 | Guido Trotter | @type instance: C{objects.Instance}
|
600 | 6906a9d8 | Guido Trotter | @param instance: the instance definition
|
601 | 6906a9d8 | Guido Trotter | @type info: opaque/hypervisor specific (string/data)
|
602 | 6906a9d8 | Guido Trotter | @param info: result for the call_migration_info call
|
603 | 6906a9d8 | Guido Trotter | @type target: string
|
604 | 6906a9d8 | Guido Trotter | @param target: target hostname (usually ip address) (on the node itself)
|
605 | 6906a9d8 | Guido Trotter |
|
606 | 6906a9d8 | Guido Trotter | """
|
607 | 6906a9d8 | Guido Trotter | return self._SingleNodeCall(node, "accept_instance", |
608 | 6906a9d8 | Guido Trotter | [self._InstDict(instance), info, target])
|
609 | 6906a9d8 | Guido Trotter | |
610 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
611 | 6906a9d8 | Guido Trotter | def call_finalize_migration(self, node, instance, info, success): |
612 | 6906a9d8 | Guido Trotter | """Finalize any target-node migration specific operation.
|
613 | 6906a9d8 | Guido Trotter |
|
614 | 6906a9d8 | Guido Trotter | This is called both in case of a successful migration and in case of error
|
615 | 6906a9d8 | Guido Trotter | (in which case it should abort the migration).
|
616 | 6906a9d8 | Guido Trotter |
|
617 | 6906a9d8 | Guido Trotter | This is a single-node call.
|
618 | 6906a9d8 | Guido Trotter |
|
619 | 6906a9d8 | Guido Trotter | @type node: string
|
620 | 6906a9d8 | Guido Trotter | @param node: the target node for the migration
|
621 | 6906a9d8 | Guido Trotter | @type instance: C{objects.Instance}
|
622 | 6906a9d8 | Guido Trotter | @param instance: the instance definition
|
623 | 6906a9d8 | Guido Trotter | @type info: opaque/hypervisor specific (string/data)
|
624 | 6906a9d8 | Guido Trotter | @param info: result for the call_migration_info call
|
625 | 6906a9d8 | Guido Trotter | @type success: boolean
|
626 | 6906a9d8 | Guido Trotter | @param success: whether the migration was a success or a failure
|
627 | 6906a9d8 | Guido Trotter |
|
628 | 6906a9d8 | Guido Trotter | """
|
629 | 6906a9d8 | Guido Trotter | return self._SingleNodeCall(node, "finalize_migration", |
630 | 6906a9d8 | Guido Trotter | [self._InstDict(instance), info, success])
|
631 | 6906a9d8 | Guido Trotter | |
632 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_SLOW)
|
633 | 72737a7f | Iustin Pop | def call_instance_migrate(self, node, instance, target, live): |
634 | 72737a7f | Iustin Pop | """Migrate an instance.
|
635 | 2a10865c | Iustin Pop |
|
636 | 72737a7f | Iustin Pop | This is a single-node call.
|
637 | 2a10865c | Iustin Pop |
|
638 | 72737a7f | Iustin Pop | @type node: string
|
639 | 72737a7f | Iustin Pop | @param node: the node on which the instance is currently running
|
640 | 72737a7f | Iustin Pop | @type instance: C{objects.Instance}
|
641 | 72737a7f | Iustin Pop | @param instance: the instance definition
|
642 | 72737a7f | Iustin Pop | @type target: string
|
643 | 72737a7f | Iustin Pop | @param target: the target node name
|
644 | 72737a7f | Iustin Pop | @type live: boolean
|
645 | 72737a7f | Iustin Pop | @param live: whether the migration should be done live or not (the
|
646 | 72737a7f | Iustin Pop | interpretation of this parameter is left to the hypervisor)
|
647 | 007a2f3e | Alexander Schreiber |
|
648 | 72737a7f | Iustin Pop | """
|
649 | 9a525d83 | Michael Hanselmann | return self._SingleNodeCall(node, "instance_migrate", |
650 | 9a525d83 | Michael Hanselmann | [self._InstDict(instance), target, live])
|
651 | 007a2f3e | Alexander Schreiber | |
652 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
653 | 17c3f802 | Guido Trotter | def call_instance_reboot(self, node, inst, reboot_type, shutdown_timeout): |
654 | 72737a7f | Iustin Pop | """Reboots an instance.
|
655 | 007a2f3e | Alexander Schreiber |
|
656 | 72737a7f | Iustin Pop | This is a single-node call.
|
657 | a8083063 | Iustin Pop |
|
658 | 72737a7f | Iustin Pop | """
|
659 | 9a525d83 | Michael Hanselmann | return self._SingleNodeCall(node, "instance_reboot", |
660 | 17c3f802 | Guido Trotter | [self._InstDict(inst), reboot_type,
|
661 | 17c3f802 | Guido Trotter | shutdown_timeout]) |
662 | a8083063 | Iustin Pop | |
663 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_1DAY)
|
664 | 4a0e011f | Iustin Pop | def call_instance_os_add(self, node, inst, reinstall, debug): |
665 | 72737a7f | Iustin Pop | """Installs an OS on the given instance.
|
666 | a8083063 | Iustin Pop |
|
667 | 72737a7f | Iustin Pop | This is a single-node call.
|
668 | decd5f45 | Iustin Pop |
|
669 | 72737a7f | Iustin Pop | """
|
670 | 9a525d83 | Michael Hanselmann | return self._SingleNodeCall(node, "instance_os_add", |
671 | 4a0e011f | Iustin Pop | [self._InstDict(inst), reinstall, debug])
|
672 | decd5f45 | Iustin Pop | |
673 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_SLOW)
|
674 | 4a0e011f | Iustin Pop | def call_instance_run_rename(self, node, inst, old_name, debug): |
675 | 72737a7f | Iustin Pop | """Run the OS rename script for an instance.
|
676 | decd5f45 | Iustin Pop |
|
677 | 72737a7f | Iustin Pop | This is a single-node call.
|
678 | a8083063 | Iustin Pop |
|
679 | 72737a7f | Iustin Pop | """
|
680 | 9a525d83 | Michael Hanselmann | return self._SingleNodeCall(node, "instance_run_rename", |
681 | 4a0e011f | Iustin Pop | [self._InstDict(inst), old_name, debug])
|
682 | a8083063 | Iustin Pop | |
683 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_URGENT)
|
684 | 72737a7f | Iustin Pop | def call_instance_info(self, node, instance, hname): |
685 | 72737a7f | Iustin Pop | """Returns information about a single instance.
|
686 | a8083063 | Iustin Pop |
|
687 | 72737a7f | Iustin Pop | This is a single-node call.
|
688 | a8083063 | Iustin Pop |
|
689 | 9a525d83 | Michael Hanselmann | @type node: list
|
690 | 9a525d83 | Michael Hanselmann | @param node: the list of nodes to query
|
691 | 72737a7f | Iustin Pop | @type instance: string
|
692 | 72737a7f | Iustin Pop | @param instance: the instance name
|
693 | 72737a7f | Iustin Pop | @type hname: string
|
694 | 72737a7f | Iustin Pop | @param hname: the hypervisor type of the instance
|
695 | a8083063 | Iustin Pop |
|
696 | 72737a7f | Iustin Pop | """
|
697 | 9a525d83 | Michael Hanselmann | return self._SingleNodeCall(node, "instance_info", [instance, hname]) |
698 | e69d05fd | Iustin Pop | |
699 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
700 | 56e7640c | Iustin Pop | def call_instance_migratable(self, node, instance): |
701 | 56e7640c | Iustin Pop | """Checks whether the given instance can be migrated.
|
702 | 56e7640c | Iustin Pop |
|
703 | 56e7640c | Iustin Pop | This is a single-node call.
|
704 | 56e7640c | Iustin Pop |
|
705 | 56e7640c | Iustin Pop | @param node: the node to query
|
706 | 56e7640c | Iustin Pop | @type instance: L{objects.Instance}
|
707 | 56e7640c | Iustin Pop | @param instance: the instance to check
|
708 | 56e7640c | Iustin Pop |
|
709 | 56e7640c | Iustin Pop |
|
710 | 56e7640c | Iustin Pop | """
|
711 | 56e7640c | Iustin Pop | return self._SingleNodeCall(node, "instance_migratable", |
712 | 56e7640c | Iustin Pop | [self._InstDict(instance)])
|
713 | 56e7640c | Iustin Pop | |
714 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_URGENT)
|
715 | 72737a7f | Iustin Pop | def call_all_instances_info(self, node_list, hypervisor_list): |
716 | 72737a7f | Iustin Pop | """Returns information about all instances on the given nodes.
|
717 | a8083063 | Iustin Pop |
|
718 | 72737a7f | Iustin Pop | This is a multi-node call.
|
719 | a8083063 | Iustin Pop |
|
720 | 72737a7f | Iustin Pop | @type node_list: list
|
721 | 72737a7f | Iustin Pop | @param node_list: the list of nodes to query
|
722 | 72737a7f | Iustin Pop | @type hypervisor_list: list
|
723 | 72737a7f | Iustin Pop | @param hypervisor_list: the hypervisors to query for instances
|
724 | a8083063 | Iustin Pop |
|
725 | 72737a7f | Iustin Pop | """
|
726 | 9a525d83 | Michael Hanselmann | return self._MultiNodeCall(node_list, "all_instances_info", |
727 | 9a525d83 | Michael Hanselmann | [hypervisor_list]) |
728 | e69d05fd | Iustin Pop | |
729 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_URGENT)
|
730 | 72737a7f | Iustin Pop | def call_instance_list(self, node_list, hypervisor_list): |
731 | 72737a7f | Iustin Pop | """Returns the list of running instances on a given node.
|
732 | a8083063 | Iustin Pop |
|
733 | 72737a7f | Iustin Pop | This is a multi-node call.
|
734 | a8083063 | Iustin Pop |
|
735 | 72737a7f | Iustin Pop | @type node_list: list
|
736 | 72737a7f | Iustin Pop | @param node_list: the list of nodes to query
|
737 | 72737a7f | Iustin Pop | @type hypervisor_list: list
|
738 | 72737a7f | Iustin Pop | @param hypervisor_list: the hypervisors to query for instances
|
739 | 16abfbc2 | Alexander Schreiber |
|
740 | 72737a7f | Iustin Pop | """
|
741 | 9a525d83 | Michael Hanselmann | return self._MultiNodeCall(node_list, "instance_list", [hypervisor_list]) |
742 | 16abfbc2 | Alexander Schreiber | |
743 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_FAST)
|
744 | 72737a7f | Iustin Pop | def call_node_tcp_ping(self, node, source, target, port, timeout, |
745 | 72737a7f | Iustin Pop | live_port_needed): |
746 | 72737a7f | Iustin Pop | """Do a TcpPing on the remote node
|
747 | a8083063 | Iustin Pop |
|
748 | 72737a7f | Iustin Pop | This is a single-node call.
|
749 | caad16e2 | Iustin Pop |
|
750 | 72737a7f | Iustin Pop | """
|
751 | 9a525d83 | Michael Hanselmann | return self._SingleNodeCall(node, "node_tcp_ping", |
752 | 9a525d83 | Michael Hanselmann | [source, target, port, timeout, |
753 | 72737a7f | Iustin Pop | live_port_needed]) |
754 | a8083063 | Iustin Pop | |
755 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_FAST)
|
756 | caad16e2 | Iustin Pop | def call_node_has_ip_address(self, node, address): |
757 | caad16e2 | Iustin Pop | """Checks if a node has the given IP address.
|
758 | caad16e2 | Iustin Pop |
|
759 | caad16e2 | Iustin Pop | This is a single-node call.
|
760 | caad16e2 | Iustin Pop |
|
761 | caad16e2 | Iustin Pop | """
|
762 | 9a525d83 | Michael Hanselmann | return self._SingleNodeCall(node, "node_has_ip_address", [address]) |
763 | a8083063 | Iustin Pop | |
764 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_URGENT)
|
765 | 72737a7f | Iustin Pop | def call_node_info(self, node_list, vg_name, hypervisor_type): |
766 | 72737a7f | Iustin Pop | """Return node information.
|
767 | e69d05fd | Iustin Pop |
|
768 | 72737a7f | Iustin Pop | This will return memory information and volume group size and free
|
769 | 72737a7f | Iustin Pop | space.
|
770 | a8083063 | Iustin Pop |
|
771 | 72737a7f | Iustin Pop | This is a multi-node call.
|
772 | a8083063 | Iustin Pop |
|
773 | 72737a7f | Iustin Pop | @type node_list: list
|
774 | 72737a7f | Iustin Pop | @param node_list: the list of nodes to query
|
775 | c41eea6e | Iustin Pop | @type vg_name: C{string}
|
776 | c41eea6e | Iustin Pop | @param vg_name: the name of the volume group to ask for disk space
|
777 | 72737a7f | Iustin Pop | information
|
778 | 72737a7f | Iustin Pop | @type hypervisor_type: C{str}
|
779 | 72737a7f | Iustin Pop | @param hypervisor_type: the name of the hypervisor to ask for
|
780 | 72737a7f | Iustin Pop | memory information
|
781 | a8083063 | Iustin Pop |
|
782 | 72737a7f | Iustin Pop | """
|
783 | 070e998b | Iustin Pop | return self._MultiNodeCall(node_list, "node_info", |
784 | 070e998b | Iustin Pop | [vg_name, hypervisor_type]) |
785 | a8083063 | Iustin Pop | |
786 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
787 | 72737a7f | Iustin Pop | def call_node_add(self, node, dsa, dsapub, rsa, rsapub, ssh, sshpub): |
788 | 72737a7f | Iustin Pop | """Add a node to the cluster.
|
789 | a8083063 | Iustin Pop |
|
790 | 72737a7f | Iustin Pop | This is a single-node call.
|
791 | a8083063 | Iustin Pop |
|
792 | 72737a7f | Iustin Pop | """
|
793 | 9a525d83 | Michael Hanselmann | return self._SingleNodeCall(node, "node_add", |
794 | 9a525d83 | Michael Hanselmann | [dsa, dsapub, rsa, rsapub, ssh, sshpub]) |
795 | a8083063 | Iustin Pop | |
796 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
797 | 72737a7f | Iustin Pop | def call_node_verify(self, node_list, checkdict, cluster_name): |
798 | 72737a7f | Iustin Pop | """Request verification of given parameters.
|
799 | a8083063 | Iustin Pop |
|
800 | 72737a7f | Iustin Pop | This is a multi-node call.
|
801 | a8083063 | Iustin Pop |
|
802 | 72737a7f | Iustin Pop | """
|
803 | 9a525d83 | Michael Hanselmann | return self._MultiNodeCall(node_list, "node_verify", |
804 | 9a525d83 | Michael Hanselmann | [checkdict, cluster_name]) |
805 | a8083063 | Iustin Pop | |
806 | 9a525d83 | Michael Hanselmann | @classmethod
|
807 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_FAST)
|
808 | 3583908a | Guido Trotter | def call_node_start_master(cls, node, start_daemons, no_voting): |
809 | 72737a7f | Iustin Pop | """Tells a node to activate itself as a master.
|
810 | a8083063 | Iustin Pop |
|
811 | 72737a7f | Iustin Pop | This is a single-node call.
|
812 | a8083063 | Iustin Pop |
|
813 | 72737a7f | Iustin Pop | """
|
814 | 9a525d83 | Michael Hanselmann | return cls._StaticSingleNodeCall(node, "node_start_master", |
815 | 3583908a | Guido Trotter | [start_daemons, no_voting]) |
816 | a8083063 | Iustin Pop | |
817 | 9a525d83 | Michael Hanselmann | @classmethod
|
818 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_FAST)
|
819 | 9a525d83 | Michael Hanselmann | def call_node_stop_master(cls, node, stop_daemons): |
820 | 72737a7f | Iustin Pop | """Tells a node to demote itself from master status.
|
821 | a8083063 | Iustin Pop |
|
822 | 72737a7f | Iustin Pop | This is a single-node call.
|
823 | 4e071d3b | Iustin Pop |
|
824 | 72737a7f | Iustin Pop | """
|
825 | 9a525d83 | Michael Hanselmann | return cls._StaticSingleNodeCall(node, "node_stop_master", [stop_daemons]) |
826 | 4e071d3b | Iustin Pop | |
827 | 9a525d83 | Michael Hanselmann | @classmethod
|
828 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_URGENT)
|
829 | 9a525d83 | Michael Hanselmann | def call_master_info(cls, node_list): |
830 | 72737a7f | Iustin Pop | """Query master info.
|
831 | 4e071d3b | Iustin Pop |
|
832 | 72737a7f | Iustin Pop | This is a multi-node call.
|
833 | a8083063 | Iustin Pop |
|
834 | 72737a7f | Iustin Pop | """
|
835 | 72737a7f | Iustin Pop | # TODO: should this method query down nodes?
|
836 | 9a525d83 | Michael Hanselmann | return cls._StaticMultiNodeCall(node_list, "master_info", []) |
837 | a8083063 | Iustin Pop | |
838 | 8f215968 | Michael Hanselmann | @classmethod
|
839 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_URGENT)
|
840 | 8f215968 | Michael Hanselmann | def call_version(cls, node_list): |
841 | 72737a7f | Iustin Pop | """Query node version.
|
842 | a8083063 | Iustin Pop |
|
843 | 72737a7f | Iustin Pop | This is a multi-node call.
|
844 | a8083063 | Iustin Pop |
|
845 | 72737a7f | Iustin Pop | """
|
846 | 8f215968 | Michael Hanselmann | return cls._StaticMultiNodeCall(node_list, "version", []) |
847 | a8083063 | Iustin Pop | |
848 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
849 | 72737a7f | Iustin Pop | def call_blockdev_create(self, node, bdev, size, owner, on_primary, info): |
850 | 72737a7f | Iustin Pop | """Request creation of a given block device.
|
851 | a8083063 | Iustin Pop |
|
852 | 72737a7f | Iustin Pop | This is a single-node call.
|
853 | a8083063 | Iustin Pop |
|
854 | 72737a7f | Iustin Pop | """
|
855 | 9a525d83 | Michael Hanselmann | return self._SingleNodeCall(node, "blockdev_create", |
856 | 9a525d83 | Michael Hanselmann | [bdev.ToDict(), size, owner, on_primary, info]) |
857 | a8083063 | Iustin Pop | |
858 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
859 | 72737a7f | Iustin Pop | def call_blockdev_remove(self, node, bdev): |
860 | 72737a7f | Iustin Pop | """Request removal of a given block device.
|
861 | a8083063 | Iustin Pop |
|
862 | 72737a7f | Iustin Pop | This is a single-node call.
|
863 | f3e513ad | Iustin Pop |
|
864 | 72737a7f | Iustin Pop | """
|
865 | 9a525d83 | Michael Hanselmann | return self._SingleNodeCall(node, "blockdev_remove", [bdev.ToDict()]) |
866 | f3e513ad | Iustin Pop | |
867 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
868 | 72737a7f | Iustin Pop | def call_blockdev_rename(self, node, devlist): |
869 | 72737a7f | Iustin Pop | """Request rename of the given block devices.
|
870 | f3e513ad | Iustin Pop |
|
871 | 72737a7f | Iustin Pop | This is a single-node call.
|
872 | a8083063 | Iustin Pop |
|
873 | 72737a7f | Iustin Pop | """
|
874 | 9a525d83 | Michael Hanselmann | return self._SingleNodeCall(node, "blockdev_rename", |
875 | 9a525d83 | Michael Hanselmann | [(d.ToDict(), uid) for d, uid in devlist]) |
876 | a8083063 | Iustin Pop | |
877 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
878 | 72737a7f | Iustin Pop | def call_blockdev_assemble(self, node, disk, owner, on_primary): |
879 | 72737a7f | Iustin Pop | """Request assembling of a given block device.
|
880 | a8083063 | Iustin Pop |
|
881 | 72737a7f | Iustin Pop | This is a single-node call.
|
882 | a8083063 | Iustin Pop |
|
883 | 72737a7f | Iustin Pop | """
|
884 | 9a525d83 | Michael Hanselmann | return self._SingleNodeCall(node, "blockdev_assemble", |
885 | 9a525d83 | Michael Hanselmann | [disk.ToDict(), owner, on_primary]) |
886 | a8083063 | Iustin Pop | |
887 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
888 | 72737a7f | Iustin Pop | def call_blockdev_shutdown(self, node, disk): |
889 | 72737a7f | Iustin Pop | """Request shutdown of a given block device.
|
890 | a8083063 | Iustin Pop |
|
891 | 72737a7f | Iustin Pop | This is a single-node call.
|
892 | a8083063 | Iustin Pop |
|
893 | 72737a7f | Iustin Pop | """
|
894 | 9a525d83 | Michael Hanselmann | return self._SingleNodeCall(node, "blockdev_shutdown", [disk.ToDict()]) |
895 | a8083063 | Iustin Pop | |
896 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
897 | 72737a7f | Iustin Pop | def call_blockdev_addchildren(self, node, bdev, ndevs): |
898 | 72737a7f | Iustin Pop | """Request adding a list of children to a (mirroring) device.
|
899 | a8083063 | Iustin Pop |
|
900 | 72737a7f | Iustin Pop | This is a single-node call.
|
901 | a8083063 | Iustin Pop |
|
902 | 72737a7f | Iustin Pop | """
|
903 | 9a525d83 | Michael Hanselmann | return self._SingleNodeCall(node, "blockdev_addchildren", |
904 | 9a525d83 | Michael Hanselmann | [bdev.ToDict(), |
905 | 9a525d83 | Michael Hanselmann | [disk.ToDict() for disk in ndevs]]) |
906 | a8083063 | Iustin Pop | |
907 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
908 | 72737a7f | Iustin Pop | def call_blockdev_removechildren(self, node, bdev, ndevs): |
909 | 72737a7f | Iustin Pop | """Request removing a list of children from a (mirroring) device.
|
910 | a8083063 | Iustin Pop |
|
911 | 72737a7f | Iustin Pop | This is a single-node call.
|
912 | a8083063 | Iustin Pop |
|
913 | 72737a7f | Iustin Pop | """
|
914 | 9a525d83 | Michael Hanselmann | return self._SingleNodeCall(node, "blockdev_removechildren", |
915 | 9a525d83 | Michael Hanselmann | [bdev.ToDict(), |
916 | 9a525d83 | Michael Hanselmann | [disk.ToDict() for disk in ndevs]]) |
917 | a8083063 | Iustin Pop | |
918 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
919 | 72737a7f | Iustin Pop | def call_blockdev_getmirrorstatus(self, node, disks): |
920 | 72737a7f | Iustin Pop | """Request status of a (mirroring) device.
|
921 | a8083063 | Iustin Pop |
|
922 | 72737a7f | Iustin Pop | This is a single-node call.
|
923 | a8083063 | Iustin Pop |
|
924 | 72737a7f | Iustin Pop | """
|
925 | 36145b12 | Michael Hanselmann | result = self._SingleNodeCall(node, "blockdev_getmirrorstatus", |
926 | 36145b12 | Michael Hanselmann | [dsk.ToDict() for dsk in disks]) |
927 | edb4b374 | Michael Hanselmann | if not result.fail_msg: |
928 | 36145b12 | Michael Hanselmann | result.payload = [objects.BlockDevStatus.FromDict(i) |
929 | 36145b12 | Michael Hanselmann | for i in result.payload] |
930 | 36145b12 | Michael Hanselmann | return result
|
931 | a8083063 | Iustin Pop | |
932 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
933 | 72737a7f | Iustin Pop | def call_blockdev_find(self, node, disk): |
934 | 72737a7f | Iustin Pop | """Request identification of a given block device.
|
935 | 72737a7f | Iustin Pop |
|
936 | 72737a7f | Iustin Pop | This is a single-node call.
|
937 | a8083063 | Iustin Pop |
|
938 | 72737a7f | Iustin Pop | """
|
939 | 96acbc09 | Michael Hanselmann | result = self._SingleNodeCall(node, "blockdev_find", [disk.ToDict()]) |
940 | edb4b374 | Michael Hanselmann | if not result.fail_msg and result.payload is not None: |
941 | 96acbc09 | Michael Hanselmann | result.payload = objects.BlockDevStatus.FromDict(result.payload) |
942 | 96acbc09 | Michael Hanselmann | return result
|
943 | d61cbe76 | Iustin Pop | |
944 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
945 | b2e7666a | Iustin Pop | def call_blockdev_close(self, node, instance_name, disks): |
946 | 72737a7f | Iustin Pop | """Closes the given block devices.
|
947 | d61cbe76 | Iustin Pop |
|
948 | 72737a7f | Iustin Pop | This is a single-node call.
|
949 | d61cbe76 | Iustin Pop |
|
950 | 72737a7f | Iustin Pop | """
|
951 | b2e7666a | Iustin Pop | params = [instance_name, [cf.ToDict() for cf in disks]] |
952 | b2e7666a | Iustin Pop | return self._SingleNodeCall(node, "blockdev_close", params) |
953 | a8083063 | Iustin Pop | |
954 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
955 | 968a7623 | Iustin Pop | def call_blockdev_getsizes(self, node, disks): |
956 | 968a7623 | Iustin Pop | """Returns the size of the given disks.
|
957 | 968a7623 | Iustin Pop |
|
958 | 968a7623 | Iustin Pop | This is a single-node call.
|
959 | 968a7623 | Iustin Pop |
|
960 | 968a7623 | Iustin Pop | """
|
961 | 968a7623 | Iustin Pop | params = [[cf.ToDict() for cf in disks]] |
962 | 968a7623 | Iustin Pop | return self._SingleNodeCall(node, "blockdev_getsize", params) |
963 | 968a7623 | Iustin Pop | |
964 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
965 | 6b93ec9d | Iustin Pop | def call_drbd_disconnect_net(self, node_list, nodes_ip, disks): |
966 | 6b93ec9d | Iustin Pop | """Disconnects the network of the given drbd devices.
|
967 | 6b93ec9d | Iustin Pop |
|
968 | 6b93ec9d | Iustin Pop | This is a multi-node call.
|
969 | 6b93ec9d | Iustin Pop |
|
970 | 6b93ec9d | Iustin Pop | """
|
971 | 6b93ec9d | Iustin Pop | return self._MultiNodeCall(node_list, "drbd_disconnect_net", |
972 | 6b93ec9d | Iustin Pop | [nodes_ip, [cf.ToDict() for cf in disks]]) |
973 | 6b93ec9d | Iustin Pop | |
974 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
975 | 6b93ec9d | Iustin Pop | def call_drbd_attach_net(self, node_list, nodes_ip, |
976 | 6b93ec9d | Iustin Pop | disks, instance_name, multimaster): |
977 | 6b93ec9d | Iustin Pop | """Disconnects the given drbd devices.
|
978 | 6b93ec9d | Iustin Pop |
|
979 | 6b93ec9d | Iustin Pop | This is a multi-node call.
|
980 | 6b93ec9d | Iustin Pop |
|
981 | 6b93ec9d | Iustin Pop | """
|
982 | 6b93ec9d | Iustin Pop | return self._MultiNodeCall(node_list, "drbd_attach_net", |
983 | 6b93ec9d | Iustin Pop | [nodes_ip, [cf.ToDict() for cf in disks], |
984 | 6b93ec9d | Iustin Pop | instance_name, multimaster]) |
985 | 6b93ec9d | Iustin Pop | |
986 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_SLOW)
|
987 | 6b93ec9d | Iustin Pop | def call_drbd_wait_sync(self, node_list, nodes_ip, disks): |
988 | 6b93ec9d | Iustin Pop | """Waits for the synchronization of drbd devices is complete.
|
989 | 6b93ec9d | Iustin Pop |
|
990 | 6b93ec9d | Iustin Pop | This is a multi-node call.
|
991 | 6b93ec9d | Iustin Pop |
|
992 | 6b93ec9d | Iustin Pop | """
|
993 | 6b93ec9d | Iustin Pop | return self._MultiNodeCall(node_list, "drbd_wait_sync", |
994 | 6b93ec9d | Iustin Pop | [nodes_ip, [cf.ToDict() for cf in disks]]) |
995 | 6b93ec9d | Iustin Pop | |
996 | 9a525d83 | Michael Hanselmann | @classmethod
|
997 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
998 | 9a525d83 | Michael Hanselmann | def call_upload_file(cls, node_list, file_name, address_list=None): |
999 | 72737a7f | Iustin Pop | """Upload a file.
|
1000 | 72737a7f | Iustin Pop |
|
1001 | 72737a7f | Iustin Pop | The node will refuse the operation in case the file is not on the
|
1002 | 72737a7f | Iustin Pop | approved file list.
|
1003 | 72737a7f | Iustin Pop |
|
1004 | 72737a7f | Iustin Pop | This is a multi-node call.
|
1005 | a8083063 | Iustin Pop |
|
1006 | 6b294c53 | Iustin Pop | @type node_list: list
|
1007 | 6b294c53 | Iustin Pop | @param node_list: the list of node names to upload to
|
1008 | 6b294c53 | Iustin Pop | @type file_name: str
|
1009 | 6b294c53 | Iustin Pop | @param file_name: the filename to upload
|
1010 | 6b294c53 | Iustin Pop | @type address_list: list or None
|
1011 | 6b294c53 | Iustin Pop | @keyword address_list: an optional list of node addresses, in order
|
1012 | 6b294c53 | Iustin Pop | to optimize the RPC speed
|
1013 | 6b294c53 | Iustin Pop |
|
1014 | 72737a7f | Iustin Pop | """
|
1015 | 12bce260 | Michael Hanselmann | file_contents = utils.ReadFile(file_name) |
1016 | 12bce260 | Michael Hanselmann | data = cls._Compress(file_contents) |
1017 | 72737a7f | Iustin Pop | st = os.stat(file_name) |
1018 | 72737a7f | Iustin Pop | params = [file_name, data, st.st_mode, st.st_uid, st.st_gid, |
1019 | 72737a7f | Iustin Pop | st.st_atime, st.st_mtime] |
1020 | 9a525d83 | Michael Hanselmann | return cls._StaticMultiNodeCall(node_list, "upload_file", params, |
1021 | 9a525d83 | Michael Hanselmann | address_list=address_list) |
1022 | 72737a7f | Iustin Pop | |
1023 | 6ddc95ec | Michael Hanselmann | @classmethod
|
1024 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
1025 | 03d1dba2 | Michael Hanselmann | def call_write_ssconf_files(cls, node_list, values): |
1026 | 6ddc95ec | Michael Hanselmann | """Write ssconf files.
|
1027 | 6ddc95ec | Michael Hanselmann |
|
1028 | 6ddc95ec | Michael Hanselmann | This is a multi-node call.
|
1029 | 6ddc95ec | Michael Hanselmann |
|
1030 | 6ddc95ec | Michael Hanselmann | """
|
1031 | 03d1dba2 | Michael Hanselmann | return cls._StaticMultiNodeCall(node_list, "write_ssconf_files", [values]) |
1032 | 6ddc95ec | Michael Hanselmann | |
1033 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_FAST)
|
1034 | 72737a7f | Iustin Pop | def call_os_diagnose(self, node_list): |
1035 | 72737a7f | Iustin Pop | """Request a diagnose of OS definitions.
|
1036 | 72737a7f | Iustin Pop |
|
1037 | 72737a7f | Iustin Pop | This is a multi-node call.
|
1038 | a8083063 | Iustin Pop |
|
1039 | 72737a7f | Iustin Pop | """
|
1040 | 83d92ad8 | Iustin Pop | return self._MultiNodeCall(node_list, "os_diagnose", []) |
1041 | a8083063 | Iustin Pop | |
1042 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_FAST)
|
1043 | 72737a7f | Iustin Pop | def call_os_get(self, node, name): |
1044 | 72737a7f | Iustin Pop | """Returns an OS definition.
|
1045 | a8083063 | Iustin Pop |
|
1046 | 72737a7f | Iustin Pop | This is a single-node call.
|
1047 | a8083063 | Iustin Pop |
|
1048 | 72737a7f | Iustin Pop | """
|
1049 | 9a525d83 | Michael Hanselmann | result = self._SingleNodeCall(node, "os_get", [name]) |
1050 | 84e3f66f | Guido Trotter | if not result.fail_msg and isinstance(result.payload, dict): |
1051 | 84e3f66f | Guido Trotter | result.payload = objects.OS.FromDict(result.payload) |
1052 | 781de953 | Iustin Pop | return result
|
1053 | a8083063 | Iustin Pop | |
1054 | acd9ff9e | Iustin Pop | @_RpcTimeout(_TMO_FAST)
|
1055 | acd9ff9e | Iustin Pop | def call_os_validate(self, required, nodes, name, checks, params): |
1056 | acd9ff9e | Iustin Pop | """Run a validation routine for a given OS.
|
1057 | acd9ff9e | Iustin Pop |
|
1058 | acd9ff9e | Iustin Pop | This is a multi-node call.
|
1059 | acd9ff9e | Iustin Pop |
|
1060 | acd9ff9e | Iustin Pop | """
|
1061 | acd9ff9e | Iustin Pop | return self._MultiNodeCall(nodes, "os_validate", |
1062 | acd9ff9e | Iustin Pop | [required, name, checks, params]) |
1063 | acd9ff9e | Iustin Pop | |
1064 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
1065 | 72737a7f | Iustin Pop | def call_hooks_runner(self, node_list, hpath, phase, env): |
1066 | 72737a7f | Iustin Pop | """Call the hooks runner.
|
1067 | a8083063 | Iustin Pop |
|
1068 | 72737a7f | Iustin Pop | Args:
|
1069 | 72737a7f | Iustin Pop | - op: the OpCode instance
|
1070 | 72737a7f | Iustin Pop | - env: a dictionary with the environment
|
1071 | a8083063 | Iustin Pop |
|
1072 | 72737a7f | Iustin Pop | This is a multi-node call.
|
1073 | a8083063 | Iustin Pop |
|
1074 | 72737a7f | Iustin Pop | """
|
1075 | 72737a7f | Iustin Pop | params = [hpath, phase, env] |
1076 | 9a525d83 | Michael Hanselmann | return self._MultiNodeCall(node_list, "hooks_runner", params) |
1077 | a8083063 | Iustin Pop | |
1078 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
1079 | 72737a7f | Iustin Pop | def call_iallocator_runner(self, node, name, idata): |
1080 | 72737a7f | Iustin Pop | """Call an iallocator on a remote node
|
1081 | 8d528b7c | Iustin Pop |
|
1082 | 72737a7f | Iustin Pop | Args:
|
1083 | 72737a7f | Iustin Pop | - name: the iallocator name
|
1084 | 72737a7f | Iustin Pop | - input: the json-encoded input string
|
1085 | 8d528b7c | Iustin Pop |
|
1086 | 72737a7f | Iustin Pop | This is a single-node call.
|
1087 | 8d528b7c | Iustin Pop |
|
1088 | 72737a7f | Iustin Pop | """
|
1089 | 9a525d83 | Michael Hanselmann | return self._SingleNodeCall(node, "iallocator_runner", [name, idata]) |
1090 | 8d528b7c | Iustin Pop | |
1091 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
1092 | 72737a7f | Iustin Pop | def call_blockdev_grow(self, node, cf_bdev, amount): |
1093 | 72737a7f | Iustin Pop | """Request a snapshot of the given block device.
|
1094 | 4c8ba8b3 | Iustin Pop |
|
1095 | 72737a7f | Iustin Pop | This is a single-node call.
|
1096 | 4c8ba8b3 | Iustin Pop |
|
1097 | 72737a7f | Iustin Pop | """
|
1098 | 9a525d83 | Michael Hanselmann | return self._SingleNodeCall(node, "blockdev_grow", |
1099 | 9a525d83 | Michael Hanselmann | [cf_bdev.ToDict(), amount]) |
1100 | 4c8ba8b3 | Iustin Pop | |
1101 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_1DAY)
|
1102 | 858f3d18 | Iustin Pop | def call_blockdev_export(self, node, cf_bdev, |
1103 | 858f3d18 | Iustin Pop | dest_node, dest_path, cluster_name): |
1104 | 858f3d18 | Iustin Pop | """Export a given disk to another node.
|
1105 | 858f3d18 | Iustin Pop |
|
1106 | 858f3d18 | Iustin Pop | This is a single-node call.
|
1107 | 858f3d18 | Iustin Pop |
|
1108 | 858f3d18 | Iustin Pop | """
|
1109 | 858f3d18 | Iustin Pop | return self._SingleNodeCall(node, "blockdev_export", |
1110 | 858f3d18 | Iustin Pop | [cf_bdev.ToDict(), dest_node, dest_path, |
1111 | 858f3d18 | Iustin Pop | cluster_name]) |
1112 | 858f3d18 | Iustin Pop | |
1113 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
1114 | 72737a7f | Iustin Pop | def call_blockdev_snapshot(self, node, cf_bdev): |
1115 | 72737a7f | Iustin Pop | """Request a snapshot of the given block device.
|
1116 | a8083063 | Iustin Pop |
|
1117 | 72737a7f | Iustin Pop | This is a single-node call.
|
1118 | a8083063 | Iustin Pop |
|
1119 | 72737a7f | Iustin Pop | """
|
1120 | 9a525d83 | Michael Hanselmann | return self._SingleNodeCall(node, "blockdev_snapshot", [cf_bdev.ToDict()]) |
1121 | a8083063 | Iustin Pop | |
1122 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
1123 | 72737a7f | Iustin Pop | def call_finalize_export(self, node, instance, snap_disks): |
1124 | 72737a7f | Iustin Pop | """Request the completion of an export operation.
|
1125 | a8083063 | Iustin Pop |
|
1126 | 72737a7f | Iustin Pop | This writes the export config file, etc.
|
1127 | a8083063 | Iustin Pop |
|
1128 | 72737a7f | Iustin Pop | This is a single-node call.
|
1129 | a8083063 | Iustin Pop |
|
1130 | 72737a7f | Iustin Pop | """
|
1131 | 72737a7f | Iustin Pop | flat_disks = [] |
1132 | 72737a7f | Iustin Pop | for disk in snap_disks: |
1133 | a97da6b7 | Iustin Pop | if isinstance(disk, bool): |
1134 | a97da6b7 | Iustin Pop | flat_disks.append(disk) |
1135 | a97da6b7 | Iustin Pop | else:
|
1136 | a97da6b7 | Iustin Pop | flat_disks.append(disk.ToDict()) |
1137 | 9a525d83 | Michael Hanselmann | |
1138 | 9a525d83 | Michael Hanselmann | return self._SingleNodeCall(node, "finalize_export", |
1139 | 9a525d83 | Michael Hanselmann | [self._InstDict(instance), flat_disks])
|
1140 | a8083063 | Iustin Pop | |
1141 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_FAST)
|
1142 | 72737a7f | Iustin Pop | def call_export_info(self, node, path): |
1143 | 72737a7f | Iustin Pop | """Queries the export information in a given path.
|
1144 | a8083063 | Iustin Pop |
|
1145 | 72737a7f | Iustin Pop | This is a single-node call.
|
1146 | a8083063 | Iustin Pop |
|
1147 | 72737a7f | Iustin Pop | """
|
1148 | 3eccac06 | Iustin Pop | return self._SingleNodeCall(node, "export_info", [path]) |
1149 | a8083063 | Iustin Pop | |
1150 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_FAST)
|
1151 | 72737a7f | Iustin Pop | def call_export_list(self, node_list): |
1152 | 72737a7f | Iustin Pop | """Gets the stored exports list.
|
1153 | a8083063 | Iustin Pop |
|
1154 | 72737a7f | Iustin Pop | This is a multi-node call.
|
1155 | a8083063 | Iustin Pop |
|
1156 | 72737a7f | Iustin Pop | """
|
1157 | 9a525d83 | Michael Hanselmann | return self._MultiNodeCall(node_list, "export_list", []) |
1158 | a8083063 | Iustin Pop | |
1159 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_FAST)
|
1160 | 72737a7f | Iustin Pop | def call_export_remove(self, node, export): |
1161 | 72737a7f | Iustin Pop | """Requests removal of a given export.
|
1162 | a8083063 | Iustin Pop |
|
1163 | 72737a7f | Iustin Pop | This is a single-node call.
|
1164 | a8083063 | Iustin Pop |
|
1165 | 72737a7f | Iustin Pop | """
|
1166 | 9a525d83 | Michael Hanselmann | return self._SingleNodeCall(node, "export_remove", [export]) |
1167 | a8083063 | Iustin Pop | |
1168 | 9a525d83 | Michael Hanselmann | @classmethod
|
1169 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
1170 | b989b9d9 | Ken Wehr | def call_node_leave_cluster(cls, node, modify_ssh_setup): |
1171 | 72737a7f | Iustin Pop | """Requests a node to clean the cluster information it has.
|
1172 | a8083063 | Iustin Pop |
|
1173 | 72737a7f | Iustin Pop | This will remove the configuration information from the ganeti data
|
1174 | 72737a7f | Iustin Pop | dir.
|
1175 | a8083063 | Iustin Pop |
|
1176 | 72737a7f | Iustin Pop | This is a single-node call.
|
1177 | a8083063 | Iustin Pop |
|
1178 | 72737a7f | Iustin Pop | """
|
1179 | b989b9d9 | Ken Wehr | return cls._StaticSingleNodeCall(node, "node_leave_cluster", |
1180 | b989b9d9 | Ken Wehr | [modify_ssh_setup]) |
1181 | dcb93971 | Michael Hanselmann | |
1182 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_FAST)
|
1183 | 72737a7f | Iustin Pop | def call_node_volumes(self, node_list): |
1184 | 72737a7f | Iustin Pop | """Gets all volumes on node(s).
|
1185 | dcb93971 | Michael Hanselmann |
|
1186 | 72737a7f | Iustin Pop | This is a multi-node call.
|
1187 | dcb93971 | Michael Hanselmann |
|
1188 | 72737a7f | Iustin Pop | """
|
1189 | 9a525d83 | Michael Hanselmann | return self._MultiNodeCall(node_list, "node_volumes", []) |
1190 | 06009e27 | Iustin Pop | |
1191 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_FAST)
|
1192 | 56aa9fd5 | Iustin Pop | def call_node_demote_from_mc(self, node): |
1193 | 56aa9fd5 | Iustin Pop | """Demote a node from the master candidate role.
|
1194 | 56aa9fd5 | Iustin Pop |
|
1195 | 56aa9fd5 | Iustin Pop | This is a single-node call.
|
1196 | 56aa9fd5 | Iustin Pop |
|
1197 | 56aa9fd5 | Iustin Pop | """
|
1198 | 56aa9fd5 | Iustin Pop | return self._SingleNodeCall(node, "node_demote_from_mc", []) |
1199 | 56aa9fd5 | Iustin Pop | |
1200 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
1201 | f5118ade | Iustin Pop | def call_node_powercycle(self, node, hypervisor): |
1202 | f5118ade | Iustin Pop | """Tries to powercycle a node.
|
1203 | f5118ade | Iustin Pop |
|
1204 | f5118ade | Iustin Pop | This is a single-node call.
|
1205 | f5118ade | Iustin Pop |
|
1206 | f5118ade | Iustin Pop | """
|
1207 | f5118ade | Iustin Pop | return self._SingleNodeCall(node, "node_powercycle", [hypervisor]) |
1208 | f5118ade | Iustin Pop | |
1209 | 92fd2250 | Iustin Pop | @_RpcTimeout(None) |
1210 | 72737a7f | Iustin Pop | def call_test_delay(self, node_list, duration): |
1211 | 72737a7f | Iustin Pop | """Sleep for a fixed time on given node(s).
|
1212 | 06009e27 | Iustin Pop |
|
1213 | 72737a7f | Iustin Pop | This is a multi-node call.
|
1214 | 06009e27 | Iustin Pop |
|
1215 | 72737a7f | Iustin Pop | """
|
1216 | 92fd2250 | Iustin Pop | return self._MultiNodeCall(node_list, "test_delay", [duration], |
1217 | 92fd2250 | Iustin Pop | read_timeout=int(duration + 5)) |
1218 | 5e04ed8b | Manuel Franceschini | |
1219 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_FAST)
|
1220 | 72737a7f | Iustin Pop | def call_file_storage_dir_create(self, node, file_storage_dir): |
1221 | 72737a7f | Iustin Pop | """Create the given file storage directory.
|
1222 | 5e04ed8b | Manuel Franceschini |
|
1223 | 72737a7f | Iustin Pop | This is a single-node call.
|
1224 | 5e04ed8b | Manuel Franceschini |
|
1225 | 72737a7f | Iustin Pop | """
|
1226 | 9a525d83 | Michael Hanselmann | return self._SingleNodeCall(node, "file_storage_dir_create", |
1227 | 9a525d83 | Michael Hanselmann | [file_storage_dir]) |
1228 | 5e04ed8b | Manuel Franceschini | |
1229 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_FAST)
|
1230 | 72737a7f | Iustin Pop | def call_file_storage_dir_remove(self, node, file_storage_dir): |
1231 | 72737a7f | Iustin Pop | """Remove the given file storage directory.
|
1232 | 5e04ed8b | Manuel Franceschini |
|
1233 | 72737a7f | Iustin Pop | This is a single-node call.
|
1234 | 5e04ed8b | Manuel Franceschini |
|
1235 | 72737a7f | Iustin Pop | """
|
1236 | 9a525d83 | Michael Hanselmann | return self._SingleNodeCall(node, "file_storage_dir_remove", |
1237 | 9a525d83 | Michael Hanselmann | [file_storage_dir]) |
1238 | 5e04ed8b | Manuel Franceschini | |
1239 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_FAST)
|
1240 | 72737a7f | Iustin Pop | def call_file_storage_dir_rename(self, node, old_file_storage_dir, |
1241 | 72737a7f | Iustin Pop | new_file_storage_dir): |
1242 | 72737a7f | Iustin Pop | """Rename file storage directory.
|
1243 | 5e04ed8b | Manuel Franceschini |
|
1244 | 72737a7f | Iustin Pop | This is a single-node call.
|
1245 | 5e04ed8b | Manuel Franceschini |
|
1246 | 72737a7f | Iustin Pop | """
|
1247 | 9a525d83 | Michael Hanselmann | return self._SingleNodeCall(node, "file_storage_dir_rename", |
1248 | 9a525d83 | Michael Hanselmann | [old_file_storage_dir, new_file_storage_dir]) |
1249 | ca52cdeb | Michael Hanselmann | |
1250 | 9a525d83 | Michael Hanselmann | @classmethod
|
1251 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_FAST)
|
1252 | 9a525d83 | Michael Hanselmann | def call_jobqueue_update(cls, node_list, address_list, file_name, content): |
1253 | 72737a7f | Iustin Pop | """Update job queue.
|
1254 | ca52cdeb | Michael Hanselmann |
|
1255 | 72737a7f | Iustin Pop | This is a multi-node call.
|
1256 | ca52cdeb | Michael Hanselmann |
|
1257 | 72737a7f | Iustin Pop | """
|
1258 | 9a525d83 | Michael Hanselmann | return cls._StaticMultiNodeCall(node_list, "jobqueue_update", |
1259 | 12bce260 | Michael Hanselmann | [file_name, cls._Compress(content)], |
1260 | 9a525d83 | Michael Hanselmann | address_list=address_list) |
1261 | ca52cdeb | Michael Hanselmann | |
1262 | 9a525d83 | Michael Hanselmann | @classmethod
|
1263 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
1264 | 9a525d83 | Michael Hanselmann | def call_jobqueue_purge(cls, node): |
1265 | 72737a7f | Iustin Pop | """Purge job queue.
|
1266 | ca52cdeb | Michael Hanselmann |
|
1267 | 72737a7f | Iustin Pop | This is a single-node call.
|
1268 | ca52cdeb | Michael Hanselmann |
|
1269 | 72737a7f | Iustin Pop | """
|
1270 | 9a525d83 | Michael Hanselmann | return cls._StaticSingleNodeCall(node, "jobqueue_purge", []) |
1271 | af5ebcb1 | Michael Hanselmann | |
1272 | 9a525d83 | Michael Hanselmann | @classmethod
|
1273 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_FAST)
|
1274 | dd875d32 | Michael Hanselmann | def call_jobqueue_rename(cls, node_list, address_list, rename): |
1275 | 72737a7f | Iustin Pop | """Rename a job queue file.
|
1276 | af5ebcb1 | Michael Hanselmann |
|
1277 | 72737a7f | Iustin Pop | This is a multi-node call.
|
1278 | af5ebcb1 | Michael Hanselmann |
|
1279 | 72737a7f | Iustin Pop | """
|
1280 | dd875d32 | Michael Hanselmann | return cls._StaticMultiNodeCall(node_list, "jobqueue_rename", rename, |
1281 | 9a525d83 | Michael Hanselmann | address_list=address_list) |
1282 | 6217e295 | Iustin Pop | |
1283 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
1284 | 6217e295 | Iustin Pop | def call_hypervisor_validate_params(self, node_list, hvname, hvparams): |
1285 | 6217e295 | Iustin Pop | """Validate the hypervisor params.
|
1286 | 6217e295 | Iustin Pop |
|
1287 | 6217e295 | Iustin Pop | This is a multi-node call.
|
1288 | 6217e295 | Iustin Pop |
|
1289 | 6217e295 | Iustin Pop | @type node_list: list
|
1290 | 6217e295 | Iustin Pop | @param node_list: the list of nodes to query
|
1291 | 6217e295 | Iustin Pop | @type hvname: string
|
1292 | 6217e295 | Iustin Pop | @param hvname: the hypervisor name
|
1293 | 6217e295 | Iustin Pop | @type hvparams: dict
|
1294 | 6217e295 | Iustin Pop | @param hvparams: the hypervisor parameters to be validated
|
1295 | 6217e295 | Iustin Pop |
|
1296 | 6217e295 | Iustin Pop | """
|
1297 | 6217e295 | Iustin Pop | cluster = self._cfg.GetClusterInfo()
|
1298 | abe609b2 | Guido Trotter | hv_full = objects.FillDict(cluster.hvparams.get(hvname, {}), hvparams) |
1299 | 9a525d83 | Michael Hanselmann | return self._MultiNodeCall(node_list, "hypervisor_validate_params", |
1300 | 9a525d83 | Michael Hanselmann | [hvname, hv_full]) |
1301 | f942a838 | Michael Hanselmann | |
1302 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
1303 | 37549316 | Michael Hanselmann | def call_x509_cert_create(self, node, validity): |
1304 | f942a838 | Michael Hanselmann | """Creates a new X509 certificate for SSL/TLS.
|
1305 | f942a838 | Michael Hanselmann |
|
1306 | f942a838 | Michael Hanselmann | This is a single-node call.
|
1307 | f942a838 | Michael Hanselmann |
|
1308 | f942a838 | Michael Hanselmann | @type validity: int
|
1309 | f942a838 | Michael Hanselmann | @param validity: Validity in seconds
|
1310 | f942a838 | Michael Hanselmann |
|
1311 | f942a838 | Michael Hanselmann | """
|
1312 | 37549316 | Michael Hanselmann | return self._SingleNodeCall(node, "x509_cert_create", [validity]) |
1313 | f942a838 | Michael Hanselmann | |
1314 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
1315 | 37549316 | Michael Hanselmann | def call_x509_cert_remove(self, node, name): |
1316 | f942a838 | Michael Hanselmann | """Removes a X509 certificate.
|
1317 | f942a838 | Michael Hanselmann |
|
1318 | f942a838 | Michael Hanselmann | This is a single-node call.
|
1319 | f942a838 | Michael Hanselmann |
|
1320 | f942a838 | Michael Hanselmann | @type name: string
|
1321 | f942a838 | Michael Hanselmann | @param name: Certificate name
|
1322 | f942a838 | Michael Hanselmann |
|
1323 | f942a838 | Michael Hanselmann | """
|
1324 | 37549316 | Michael Hanselmann | return self._SingleNodeCall(node, "x509_cert_remove", [name]) |
1325 | 1651d116 | Michael Hanselmann | |
1326 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
1327 | eb630f50 | Michael Hanselmann | def call_import_start(self, node, opts, instance, dest, dest_args): |
1328 | 1651d116 | Michael Hanselmann | """Starts a listener for an import.
|
1329 | 1651d116 | Michael Hanselmann |
|
1330 | 1651d116 | Michael Hanselmann | This is a single-node call.
|
1331 | 1651d116 | Michael Hanselmann |
|
1332 | 1651d116 | Michael Hanselmann | @type node: string
|
1333 | 1651d116 | Michael Hanselmann | @param node: Node name
|
1334 | 1651d116 | Michael Hanselmann | @type instance: C{objects.Instance}
|
1335 | 1651d116 | Michael Hanselmann | @param instance: Instance object
|
1336 | 1651d116 | Michael Hanselmann |
|
1337 | 1651d116 | Michael Hanselmann | """
|
1338 | ef40fbfb | Michael Hanselmann | return self._SingleNodeCall(node, "import_start", |
1339 | eb630f50 | Michael Hanselmann | [opts.ToDict(), |
1340 | 1651d116 | Michael Hanselmann | self._InstDict(instance), dest,
|
1341 | 1651d116 | Michael Hanselmann | _EncodeImportExportIO(dest, dest_args)]) |
1342 | 1651d116 | Michael Hanselmann | |
1343 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
1344 | eb630f50 | Michael Hanselmann | def call_export_start(self, node, opts, host, port, |
1345 | 1651d116 | Michael Hanselmann | instance, source, source_args): |
1346 | 1651d116 | Michael Hanselmann | """Starts an export daemon.
|
1347 | 1651d116 | Michael Hanselmann |
|
1348 | 1651d116 | Michael Hanselmann | This is a single-node call.
|
1349 | 1651d116 | Michael Hanselmann |
|
1350 | 1651d116 | Michael Hanselmann | @type node: string
|
1351 | 1651d116 | Michael Hanselmann | @param node: Node name
|
1352 | 1651d116 | Michael Hanselmann | @type instance: C{objects.Instance}
|
1353 | 1651d116 | Michael Hanselmann | @param instance: Instance object
|
1354 | 1651d116 | Michael Hanselmann |
|
1355 | 1651d116 | Michael Hanselmann | """
|
1356 | ef40fbfb | Michael Hanselmann | return self._SingleNodeCall(node, "export_start", |
1357 | eb630f50 | Michael Hanselmann | [opts.ToDict(), host, port, |
1358 | 1651d116 | Michael Hanselmann | self._InstDict(instance), source,
|
1359 | 1651d116 | Michael Hanselmann | _EncodeImportExportIO(source, source_args)]) |
1360 | 1651d116 | Michael Hanselmann | |
1361 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_FAST)
|
1362 | ef40fbfb | Michael Hanselmann | def call_impexp_status(self, node, names): |
1363 | 1651d116 | Michael Hanselmann | """Gets the status of an import or export.
|
1364 | 1651d116 | Michael Hanselmann |
|
1365 | 1651d116 | Michael Hanselmann | This is a single-node call.
|
1366 | 1651d116 | Michael Hanselmann |
|
1367 | 1651d116 | Michael Hanselmann | @type node: string
|
1368 | 1651d116 | Michael Hanselmann | @param node: Node name
|
1369 | 1651d116 | Michael Hanselmann | @type names: List of strings
|
1370 | 1651d116 | Michael Hanselmann | @param names: Import/export names
|
1371 | 1651d116 | Michael Hanselmann | @rtype: List of L{objects.ImportExportStatus} instances
|
1372 | 1651d116 | Michael Hanselmann | @return: Returns a list of the state of each named import/export or None if
|
1373 | 1651d116 | Michael Hanselmann | a status couldn't be retrieved
|
1374 | 1651d116 | Michael Hanselmann |
|
1375 | 1651d116 | Michael Hanselmann | """
|
1376 | ef40fbfb | Michael Hanselmann | result = self._SingleNodeCall(node, "impexp_status", [names]) |
1377 | 1651d116 | Michael Hanselmann | |
1378 | 1651d116 | Michael Hanselmann | if not result.fail_msg: |
1379 | 1651d116 | Michael Hanselmann | decoded = [] |
1380 | 1651d116 | Michael Hanselmann | |
1381 | 1651d116 | Michael Hanselmann | for i in result.payload: |
1382 | 1651d116 | Michael Hanselmann | if i is None: |
1383 | 1651d116 | Michael Hanselmann | decoded.append(None)
|
1384 | 1651d116 | Michael Hanselmann | continue
|
1385 | 1651d116 | Michael Hanselmann | decoded.append(objects.ImportExportStatus.FromDict(i)) |
1386 | 1651d116 | Michael Hanselmann | |
1387 | 1651d116 | Michael Hanselmann | result.payload = decoded |
1388 | 1651d116 | Michael Hanselmann | |
1389 | 1651d116 | Michael Hanselmann | return result
|
1390 | 1651d116 | Michael Hanselmann | |
1391 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
1392 | f81c4737 | Michael Hanselmann | def call_impexp_abort(self, node, name): |
1393 | f81c4737 | Michael Hanselmann | """Aborts an import or export.
|
1394 | f81c4737 | Michael Hanselmann |
|
1395 | f81c4737 | Michael Hanselmann | This is a single-node call.
|
1396 | f81c4737 | Michael Hanselmann |
|
1397 | f81c4737 | Michael Hanselmann | @type node: string
|
1398 | f81c4737 | Michael Hanselmann | @param node: Node name
|
1399 | f81c4737 | Michael Hanselmann | @type name: string
|
1400 | f81c4737 | Michael Hanselmann | @param name: Import/export name
|
1401 | f81c4737 | Michael Hanselmann |
|
1402 | f81c4737 | Michael Hanselmann | """
|
1403 | f81c4737 | Michael Hanselmann | return self._SingleNodeCall(node, "impexp_abort", [name]) |
1404 | f81c4737 | Michael Hanselmann | |
1405 | 92fd2250 | Iustin Pop | @_RpcTimeout(_TMO_NORMAL)
|
1406 | ef40fbfb | Michael Hanselmann | def call_impexp_cleanup(self, node, name): |
1407 | 1651d116 | Michael Hanselmann | """Cleans up after an import or export.
|
1408 | 1651d116 | Michael Hanselmann |
|
1409 | 1651d116 | Michael Hanselmann | This is a single-node call.
|
1410 | 1651d116 | Michael Hanselmann |
|
1411 | 1651d116 | Michael Hanselmann | @type node: string
|
1412 | 1651d116 | Michael Hanselmann | @param node: Node name
|
1413 | 1651d116 | Michael Hanselmann | @type name: string
|
1414 | 1651d116 | Michael Hanselmann | @param name: Import/export name
|
1415 | 1651d116 | Michael Hanselmann |
|
1416 | 1651d116 | Michael Hanselmann | """
|
1417 | ef40fbfb | Michael Hanselmann | return self._SingleNodeCall(node, "impexp_cleanup", [name]) |