root / lib / rpc.py @ e69d05fd
History | View | Annotate | Download (19.9 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 | a8083063 | Iustin Pop | """Script to show add a new node to the cluster
|
23 | a8083063 | Iustin Pop |
|
24 | a8083063 | Iustin Pop | """
|
25 | a8083063 | Iustin Pop | |
26 | a8083063 | Iustin Pop | # pylint: disable-msg=C0103
|
27 | a8083063 | Iustin Pop | |
28 | a8083063 | Iustin Pop | import os |
29 | 81010134 | Iustin Pop | import socket |
30 | 81010134 | Iustin Pop | import httplib |
31 | a8083063 | Iustin Pop | |
32 | 81010134 | Iustin Pop | import simplejson |
33 | a8083063 | Iustin Pop | |
34 | a8083063 | Iustin Pop | from ganeti import logger |
35 | a8083063 | Iustin Pop | from ganeti import utils |
36 | a8083063 | Iustin Pop | from ganeti import objects |
37 | a8083063 | Iustin Pop | |
38 | 7c0d6283 | Michael Hanselmann | |
39 | a8083063 | Iustin Pop | class NodeController: |
40 | a8083063 | Iustin Pop | """Node-handling class.
|
41 | a8083063 | Iustin Pop |
|
42 | a8083063 | Iustin Pop | For each node that we speak with, we create an instance of this
|
43 | a8083063 | Iustin Pop | class, so that we have a safe place to store the details of this
|
44 | a8083063 | Iustin Pop | individual call.
|
45 | a8083063 | Iustin Pop |
|
46 | a8083063 | Iustin Pop | """
|
47 | a8083063 | Iustin Pop | def __init__(self, parent, node): |
48 | a8083063 | Iustin Pop | self.parent = parent
|
49 | a8083063 | Iustin Pop | self.node = node
|
50 | 81010134 | Iustin Pop | self.failed = False |
51 | a8083063 | Iustin Pop | |
52 | 81010134 | Iustin Pop | self.http_conn = hc = httplib.HTTPConnection(node, self.parent.port) |
53 | a8083063 | Iustin Pop | try:
|
54 | 81010134 | Iustin Pop | hc.connect() |
55 | 81010134 | Iustin Pop | hc.putrequest('PUT', "/%s" % self.parent.procedure, |
56 | 81010134 | Iustin Pop | skip_accept_encoding=True)
|
57 | 81010134 | Iustin Pop | hc.putheader('Content-Length', str(len(parent.body))) |
58 | 81010134 | Iustin Pop | hc.endheaders() |
59 | 81010134 | Iustin Pop | hc.send(parent.body) |
60 | 81010134 | Iustin Pop | except socket.error, err:
|
61 | 81010134 | Iustin Pop | logger.Error("Error connecting to %s: %s" % (node, str(err))) |
62 | 81010134 | Iustin Pop | self.failed = True |
63 | 81010134 | Iustin Pop | |
64 | 81010134 | Iustin Pop | def get_response(self): |
65 | 81010134 | Iustin Pop | """Try to process the response from the node.
|
66 | a8083063 | Iustin Pop |
|
67 | a8083063 | Iustin Pop | """
|
68 | 81010134 | Iustin Pop | if self.failed: |
69 | 81010134 | Iustin Pop | # we already failed in connect
|
70 | a8083063 | Iustin Pop | return False |
71 | 81010134 | Iustin Pop | resp = self.http_conn.getresponse()
|
72 | 81010134 | Iustin Pop | if resp.status != 200: |
73 | a8083063 | Iustin Pop | return False |
74 | 81010134 | Iustin Pop | try:
|
75 | 81010134 | Iustin Pop | length = int(resp.getheader('Content-Length', '0')) |
76 | 81010134 | Iustin Pop | except ValueError: |
77 | 81010134 | Iustin Pop | return False |
78 | 81010134 | Iustin Pop | if not length: |
79 | 81010134 | Iustin Pop | logger.Error("Zero-length reply from %s" % self.node) |
80 | 81010134 | Iustin Pop | return False |
81 | 81010134 | Iustin Pop | payload = resp.read(length) |
82 | 81010134 | Iustin Pop | unload = simplejson.loads(payload) |
83 | 81010134 | Iustin Pop | return unload
|
84 | a8083063 | Iustin Pop | |
85 | a8083063 | Iustin Pop | |
86 | a8083063 | Iustin Pop | class Client: |
87 | a8083063 | Iustin Pop | """RPC Client class.
|
88 | a8083063 | Iustin Pop |
|
89 | 2f8598a5 | Alexander Schreiber | This class, given a (remote) method name, a list of parameters and a
|
90 | a8083063 | Iustin Pop | list of nodes, will contact (in parallel) all nodes, and return a
|
91 | a8083063 | Iustin Pop | dict of results (key: node name, value: result).
|
92 | a8083063 | Iustin Pop |
|
93 | a8083063 | Iustin Pop | One current bug is that generic failure is still signalled by
|
94 | a8083063 | Iustin Pop | 'False' result, which is not good. This overloading of values can
|
95 | a8083063 | Iustin Pop | cause bugs.
|
96 | a8083063 | Iustin Pop |
|
97 | a8083063 | Iustin Pop | """
|
98 | a8083063 | Iustin Pop | result_set = False
|
99 | a8083063 | Iustin Pop | result = False
|
100 | a8083063 | Iustin Pop | allresult = [] |
101 | a8083063 | Iustin Pop | |
102 | a8083063 | Iustin Pop | def __init__(self, procedure, args): |
103 | eb1328a9 | Michael Hanselmann | self.port = utils.GetNodeDaemonPort()
|
104 | eb1328a9 | Michael Hanselmann | self.nodepw = utils.GetNodeDaemonPassword()
|
105 | a8083063 | Iustin Pop | self.nc = {}
|
106 | a8083063 | Iustin Pop | self.results = {}
|
107 | a8083063 | Iustin Pop | self.procedure = procedure
|
108 | a8083063 | Iustin Pop | self.args = args
|
109 | 81010134 | Iustin Pop | self.body = simplejson.dumps(args)
|
110 | a8083063 | Iustin Pop | |
111 | a8083063 | Iustin Pop | #--- generic connector -------------
|
112 | a8083063 | Iustin Pop | |
113 | a8083063 | Iustin Pop | def connect_list(self, node_list): |
114 | a8083063 | Iustin Pop | """Add a list of nodes to the target nodes.
|
115 | a8083063 | Iustin Pop |
|
116 | a8083063 | Iustin Pop | """
|
117 | a8083063 | Iustin Pop | for node in node_list: |
118 | a8083063 | Iustin Pop | self.connect(node)
|
119 | a8083063 | Iustin Pop | |
120 | a8083063 | Iustin Pop | def connect(self, connect_node): |
121 | a8083063 | Iustin Pop | """Add a node to the target list.
|
122 | a8083063 | Iustin Pop |
|
123 | a8083063 | Iustin Pop | """
|
124 | a8083063 | Iustin Pop | self.nc[connect_node] = nc = NodeController(self, connect_node) |
125 | a8083063 | Iustin Pop | |
126 | a8083063 | Iustin Pop | def getresult(self): |
127 | a8083063 | Iustin Pop | """Return the results of the call.
|
128 | a8083063 | Iustin Pop |
|
129 | a8083063 | Iustin Pop | """
|
130 | a8083063 | Iustin Pop | return self.results |
131 | a8083063 | Iustin Pop | |
132 | a8083063 | Iustin Pop | def run(self): |
133 | a8083063 | Iustin Pop | """Wrapper over reactor.run().
|
134 | a8083063 | Iustin Pop |
|
135 | a8083063 | Iustin Pop | This function simply calls reactor.run() if we have any requests
|
136 | a8083063 | Iustin Pop | queued, otherwise it does nothing.
|
137 | a8083063 | Iustin Pop |
|
138 | a8083063 | Iustin Pop | """
|
139 | 81010134 | Iustin Pop | for node, nc in self.nc.items(): |
140 | 81010134 | Iustin Pop | self.results[node] = nc.get_response()
|
141 | a8083063 | Iustin Pop | |
142 | a8083063 | Iustin Pop | |
143 | a8083063 | Iustin Pop | def call_volume_list(node_list, vg_name): |
144 | a8083063 | Iustin Pop | """Gets the logical volumes present in a given volume group.
|
145 | a8083063 | Iustin Pop |
|
146 | a8083063 | Iustin Pop | This is a multi-node call.
|
147 | a8083063 | Iustin Pop |
|
148 | a8083063 | Iustin Pop | """
|
149 | a8083063 | Iustin Pop | c = Client("volume_list", [vg_name])
|
150 | a8083063 | Iustin Pop | c.connect_list(node_list) |
151 | a8083063 | Iustin Pop | c.run() |
152 | a8083063 | Iustin Pop | return c.getresult()
|
153 | a8083063 | Iustin Pop | |
154 | a8083063 | Iustin Pop | |
155 | a8083063 | Iustin Pop | def call_vg_list(node_list): |
156 | a8083063 | Iustin Pop | """Gets the volume group list.
|
157 | a8083063 | Iustin Pop |
|
158 | a8083063 | Iustin Pop | This is a multi-node call.
|
159 | a8083063 | Iustin Pop |
|
160 | a8083063 | Iustin Pop | """
|
161 | a8083063 | Iustin Pop | c = Client("vg_list", [])
|
162 | a8083063 | Iustin Pop | c.connect_list(node_list) |
163 | a8083063 | Iustin Pop | c.run() |
164 | a8083063 | Iustin Pop | return c.getresult()
|
165 | a8083063 | Iustin Pop | |
166 | a8083063 | Iustin Pop | |
167 | a8083063 | Iustin Pop | def call_bridges_exist(node, bridges_list): |
168 | a8083063 | Iustin Pop | """Checks if a node has all the bridges given.
|
169 | a8083063 | Iustin Pop |
|
170 | a8083063 | Iustin Pop | This method checks if all bridges given in the bridges_list are
|
171 | a8083063 | Iustin Pop | present on the remote node, so that an instance that uses interfaces
|
172 | a8083063 | Iustin Pop | on those bridges can be started.
|
173 | a8083063 | Iustin Pop |
|
174 | a8083063 | Iustin Pop | This is a single-node call.
|
175 | a8083063 | Iustin Pop |
|
176 | a8083063 | Iustin Pop | """
|
177 | a8083063 | Iustin Pop | c = Client("bridges_exist", [bridges_list])
|
178 | a8083063 | Iustin Pop | c.connect(node) |
179 | a8083063 | Iustin Pop | c.run() |
180 | a8083063 | Iustin Pop | return c.getresult().get(node, False) |
181 | a8083063 | Iustin Pop | |
182 | a8083063 | Iustin Pop | |
183 | a8083063 | Iustin Pop | def call_instance_start(node, instance, extra_args): |
184 | 2f8598a5 | Alexander Schreiber | """Starts an instance.
|
185 | a8083063 | Iustin Pop |
|
186 | a8083063 | Iustin Pop | This is a single-node call.
|
187 | a8083063 | Iustin Pop |
|
188 | a8083063 | Iustin Pop | """
|
189 | 319856a9 | Michael Hanselmann | c = Client("instance_start", [instance.ToDict(), extra_args])
|
190 | a8083063 | Iustin Pop | c.connect(node) |
191 | a8083063 | Iustin Pop | c.run() |
192 | a8083063 | Iustin Pop | return c.getresult().get(node, False) |
193 | a8083063 | Iustin Pop | |
194 | a8083063 | Iustin Pop | |
195 | a8083063 | Iustin Pop | def call_instance_shutdown(node, instance): |
196 | a8083063 | Iustin Pop | """Stops an instance.
|
197 | a8083063 | Iustin Pop |
|
198 | a8083063 | Iustin Pop | This is a single-node call.
|
199 | a8083063 | Iustin Pop |
|
200 | a8083063 | Iustin Pop | """
|
201 | 319856a9 | Michael Hanselmann | c = Client("instance_shutdown", [instance.ToDict()])
|
202 | a8083063 | Iustin Pop | c.connect(node) |
203 | a8083063 | Iustin Pop | c.run() |
204 | a8083063 | Iustin Pop | return c.getresult().get(node, False) |
205 | a8083063 | Iustin Pop | |
206 | a8083063 | Iustin Pop | |
207 | 2a10865c | Iustin Pop | def call_instance_migrate(node, instance, target, live): |
208 | 2a10865c | Iustin Pop | """Migrate an instance.
|
209 | 2a10865c | Iustin Pop |
|
210 | 2a10865c | Iustin Pop | This is a single-node call.
|
211 | 2a10865c | Iustin Pop |
|
212 | 9f0e6b37 | Iustin Pop | @type node: string
|
213 | 9f0e6b37 | Iustin Pop | @param node: the node on which the instance is currently running
|
214 | e69d05fd | Iustin Pop | @type instance: C{objects.Instance}
|
215 | 9f0e6b37 | Iustin Pop | @param instance: the instance definition
|
216 | 9f0e6b37 | Iustin Pop | @type target: string
|
217 | 9f0e6b37 | Iustin Pop | @param target: the target node name
|
218 | 9f0e6b37 | Iustin Pop | @type live: boolean
|
219 | 9f0e6b37 | Iustin Pop | @param live: whether the migration should be done live or not (the
|
220 | 9f0e6b37 | Iustin Pop | interpretation of this parameter is left to the hypervisor)
|
221 | 9f0e6b37 | Iustin Pop |
|
222 | 2a10865c | Iustin Pop | """
|
223 | 9f0e6b37 | Iustin Pop | c = Client("instance_migrate", [instance.ToDict(), target, live])
|
224 | 2a10865c | Iustin Pop | c.connect(node) |
225 | 2a10865c | Iustin Pop | c.run() |
226 | 2a10865c | Iustin Pop | return c.getresult().get(node, False) |
227 | 2a10865c | Iustin Pop | |
228 | 2a10865c | Iustin Pop | |
229 | 007a2f3e | Alexander Schreiber | def call_instance_reboot(node, instance, reboot_type, extra_args): |
230 | 007a2f3e | Alexander Schreiber | """Reboots an instance.
|
231 | 007a2f3e | Alexander Schreiber |
|
232 | 007a2f3e | Alexander Schreiber | This is a single-node call.
|
233 | 007a2f3e | Alexander Schreiber |
|
234 | 007a2f3e | Alexander Schreiber | """
|
235 | 007a2f3e | Alexander Schreiber | c = Client("instance_reboot", [instance.ToDict(), reboot_type, extra_args])
|
236 | 007a2f3e | Alexander Schreiber | c.connect(node) |
237 | 007a2f3e | Alexander Schreiber | c.run() |
238 | 007a2f3e | Alexander Schreiber | return c.getresult().get(node, False) |
239 | 007a2f3e | Alexander Schreiber | |
240 | 007a2f3e | Alexander Schreiber | |
241 | a8083063 | Iustin Pop | def call_instance_os_add(node, inst, osdev, swapdev): |
242 | a8083063 | Iustin Pop | """Installs an OS on the given instance.
|
243 | a8083063 | Iustin Pop |
|
244 | a8083063 | Iustin Pop | This is a single-node call.
|
245 | a8083063 | Iustin Pop |
|
246 | a8083063 | Iustin Pop | """
|
247 | 319856a9 | Michael Hanselmann | params = [inst.ToDict(), osdev, swapdev] |
248 | a8083063 | Iustin Pop | c = Client("instance_os_add", params)
|
249 | a8083063 | Iustin Pop | c.connect(node) |
250 | a8083063 | Iustin Pop | c.run() |
251 | a8083063 | Iustin Pop | return c.getresult().get(node, False) |
252 | a8083063 | Iustin Pop | |
253 | a8083063 | Iustin Pop | |
254 | decd5f45 | Iustin Pop | def call_instance_run_rename(node, inst, old_name, osdev, swapdev): |
255 | decd5f45 | Iustin Pop | """Run the OS rename script for an instance.
|
256 | decd5f45 | Iustin Pop |
|
257 | decd5f45 | Iustin Pop | This is a single-node call.
|
258 | decd5f45 | Iustin Pop |
|
259 | decd5f45 | Iustin Pop | """
|
260 | 319856a9 | Michael Hanselmann | params = [inst.ToDict(), old_name, osdev, swapdev] |
261 | decd5f45 | Iustin Pop | c = Client("instance_run_rename", params)
|
262 | decd5f45 | Iustin Pop | c.connect(node) |
263 | decd5f45 | Iustin Pop | c.run() |
264 | decd5f45 | Iustin Pop | return c.getresult().get(node, False) |
265 | decd5f45 | Iustin Pop | |
266 | decd5f45 | Iustin Pop | |
267 | e69d05fd | Iustin Pop | def call_instance_info(node, instance, hname): |
268 | a8083063 | Iustin Pop | """Returns information about a single instance.
|
269 | a8083063 | Iustin Pop |
|
270 | a8083063 | Iustin Pop | This is a single-node call.
|
271 | a8083063 | Iustin Pop |
|
272 | e69d05fd | Iustin Pop | @type node_list: list
|
273 | e69d05fd | Iustin Pop | @param node_list: the list of nodes to query
|
274 | e69d05fd | Iustin Pop | @type instance: string
|
275 | e69d05fd | Iustin Pop | @param instance: the instance name
|
276 | e69d05fd | Iustin Pop | @type hname: string
|
277 | e69d05fd | Iustin Pop | @param hname: the hypervisor type of the instance
|
278 | e69d05fd | Iustin Pop |
|
279 | a8083063 | Iustin Pop | """
|
280 | a8083063 | Iustin Pop | c = Client("instance_info", [instance])
|
281 | a8083063 | Iustin Pop | c.connect(node) |
282 | a8083063 | Iustin Pop | c.run() |
283 | a8083063 | Iustin Pop | return c.getresult().get(node, False) |
284 | a8083063 | Iustin Pop | |
285 | a8083063 | Iustin Pop | |
286 | e69d05fd | Iustin Pop | def call_all_instances_info(node_list, hypervisor_list): |
287 | e69d05fd | Iustin Pop | """Returns information about all instances on the given nodes.
|
288 | a8083063 | Iustin Pop |
|
289 | e69d05fd | Iustin Pop | This is a multi-node call.
|
290 | e69d05fd | Iustin Pop |
|
291 | e69d05fd | Iustin Pop | @type node_list: list
|
292 | e69d05fd | Iustin Pop | @param node_list: the list of nodes to query
|
293 | e69d05fd | Iustin Pop | @type hypervisor_list: list
|
294 | e69d05fd | Iustin Pop | @param hypervisor_list: the hypervisors to query for instances
|
295 | a8083063 | Iustin Pop |
|
296 | a8083063 | Iustin Pop | """
|
297 | e69d05fd | Iustin Pop | c = Client("all_instances_info", [hypervisor_list])
|
298 | a8083063 | Iustin Pop | c.connect_list(node_list) |
299 | a8083063 | Iustin Pop | c.run() |
300 | a8083063 | Iustin Pop | return c.getresult()
|
301 | a8083063 | Iustin Pop | |
302 | a8083063 | Iustin Pop | |
303 | e69d05fd | Iustin Pop | def call_instance_list(node_list, hypervisor_list): |
304 | a8083063 | Iustin Pop | """Returns the list of running instances on a given node.
|
305 | a8083063 | Iustin Pop |
|
306 | e69d05fd | Iustin Pop | This is a multi-node call.
|
307 | e69d05fd | Iustin Pop |
|
308 | e69d05fd | Iustin Pop | @type node_list: list
|
309 | e69d05fd | Iustin Pop | @param node_list: the list of nodes to query
|
310 | e69d05fd | Iustin Pop | @type hypervisor_list: list
|
311 | e69d05fd | Iustin Pop | @param hypervisor_list: the hypervisors to query for instances
|
312 | a8083063 | Iustin Pop |
|
313 | a8083063 | Iustin Pop | """
|
314 | e69d05fd | Iustin Pop | c = Client("instance_list", [hypervisor_list])
|
315 | a8083063 | Iustin Pop | c.connect_list(node_list) |
316 | a8083063 | Iustin Pop | c.run() |
317 | a8083063 | Iustin Pop | return c.getresult()
|
318 | a8083063 | Iustin Pop | |
319 | a8083063 | Iustin Pop | |
320 | 16abfbc2 | Alexander Schreiber | def call_node_tcp_ping(node, source, target, port, timeout, live_port_needed): |
321 | 16abfbc2 | Alexander Schreiber | """Do a TcpPing on the remote node
|
322 | 16abfbc2 | Alexander Schreiber |
|
323 | 16abfbc2 | Alexander Schreiber | This is a single-node call.
|
324 | 16abfbc2 | Alexander Schreiber | """
|
325 | 16abfbc2 | Alexander Schreiber | c = Client("node_tcp_ping", [source, target, port, timeout,
|
326 | 16abfbc2 | Alexander Schreiber | live_port_needed]) |
327 | 16abfbc2 | Alexander Schreiber | c.connect(node) |
328 | 16abfbc2 | Alexander Schreiber | c.run() |
329 | 16abfbc2 | Alexander Schreiber | return c.getresult().get(node, False) |
330 | 16abfbc2 | Alexander Schreiber | |
331 | 16abfbc2 | Alexander Schreiber | |
332 | e69d05fd | Iustin Pop | def call_node_info(node_list, vg_name, hypervisor_type): |
333 | a8083063 | Iustin Pop | """Return node information.
|
334 | a8083063 | Iustin Pop |
|
335 | a8083063 | Iustin Pop | This will return memory information and volume group size and free
|
336 | a8083063 | Iustin Pop | space.
|
337 | a8083063 | Iustin Pop |
|
338 | a8083063 | Iustin Pop | This is a multi-node call.
|
339 | a8083063 | Iustin Pop |
|
340 | e69d05fd | Iustin Pop | @type node_list: list
|
341 | e69d05fd | Iustin Pop | @param node_list: the list of nodes to query
|
342 | e69d05fd | Iustin Pop | @type vgname: C{string}
|
343 | e69d05fd | Iustin Pop | @param vgname: the name of the volume group to ask for disk space information
|
344 | e69d05fd | Iustin Pop | @type hypervisor_type: C{str}
|
345 | e69d05fd | Iustin Pop | @param hypervisor_type: the name of the hypervisor to ask for
|
346 | e69d05fd | Iustin Pop | memory information
|
347 | e69d05fd | Iustin Pop |
|
348 | a8083063 | Iustin Pop | """
|
349 | e69d05fd | Iustin Pop | c = Client("node_info", [vg_name, hypervisor_type])
|
350 | a8083063 | Iustin Pop | c.connect_list(node_list) |
351 | a8083063 | Iustin Pop | c.run() |
352 | a8083063 | Iustin Pop | retux = c.getresult() |
353 | a8083063 | Iustin Pop | |
354 | a8083063 | Iustin Pop | for node_name in retux: |
355 | a8083063 | Iustin Pop | ret = retux.get(node_name, False)
|
356 | a8083063 | Iustin Pop | if type(ret) != dict: |
357 | a8083063 | Iustin Pop | logger.Error("could not connect to node %s" % (node_name))
|
358 | a8083063 | Iustin Pop | ret = {} |
359 | a8083063 | Iustin Pop | |
360 | a8083063 | Iustin Pop | utils.CheckDict(ret, |
361 | a8083063 | Iustin Pop | { 'memory_total' : '-', |
362 | a8083063 | Iustin Pop | 'memory_dom0' : '-', |
363 | a8083063 | Iustin Pop | 'memory_free' : '-', |
364 | a8083063 | Iustin Pop | 'vg_size' : 'node_unreachable', |
365 | a8083063 | Iustin Pop | 'vg_free' : '-' }, |
366 | a8083063 | Iustin Pop | "call_node_info",
|
367 | a8083063 | Iustin Pop | ) |
368 | a8083063 | Iustin Pop | return retux
|
369 | a8083063 | Iustin Pop | |
370 | a8083063 | Iustin Pop | |
371 | a8083063 | Iustin Pop | def call_node_add(node, dsa, dsapub, rsa, rsapub, ssh, sshpub): |
372 | a8083063 | Iustin Pop | """Add a node to the cluster.
|
373 | a8083063 | Iustin Pop |
|
374 | a8083063 | Iustin Pop | This is a single-node call.
|
375 | a8083063 | Iustin Pop |
|
376 | a8083063 | Iustin Pop | """
|
377 | a8083063 | Iustin Pop | params = [dsa, dsapub, rsa, rsapub, ssh, sshpub] |
378 | a8083063 | Iustin Pop | c = Client("node_add", params)
|
379 | a8083063 | Iustin Pop | c.connect(node) |
380 | a8083063 | Iustin Pop | c.run() |
381 | a8083063 | Iustin Pop | return c.getresult().get(node, False) |
382 | a8083063 | Iustin Pop | |
383 | a8083063 | Iustin Pop | |
384 | 62c9ec92 | Iustin Pop | def call_node_verify(node_list, checkdict, cluster_name): |
385 | a8083063 | Iustin Pop | """Request verification of given parameters.
|
386 | a8083063 | Iustin Pop |
|
387 | a8083063 | Iustin Pop | This is a multi-node call.
|
388 | a8083063 | Iustin Pop |
|
389 | a8083063 | Iustin Pop | """
|
390 | 62c9ec92 | Iustin Pop | c = Client("node_verify", [checkdict, cluster_name])
|
391 | a8083063 | Iustin Pop | c.connect_list(node_list) |
392 | a8083063 | Iustin Pop | c.run() |
393 | a8083063 | Iustin Pop | return c.getresult()
|
394 | a8083063 | Iustin Pop | |
395 | a8083063 | Iustin Pop | |
396 | 1c65840b | Iustin Pop | def call_node_start_master(node, start_daemons): |
397 | a8083063 | Iustin Pop | """Tells a node to activate itself as a master.
|
398 | a8083063 | Iustin Pop |
|
399 | a8083063 | Iustin Pop | This is a single-node call.
|
400 | a8083063 | Iustin Pop |
|
401 | a8083063 | Iustin Pop | """
|
402 | 1c65840b | Iustin Pop | c = Client("node_start_master", [start_daemons])
|
403 | a8083063 | Iustin Pop | c.connect(node) |
404 | a8083063 | Iustin Pop | c.run() |
405 | a8083063 | Iustin Pop | return c.getresult().get(node, False) |
406 | a8083063 | Iustin Pop | |
407 | a8083063 | Iustin Pop | |
408 | 1c65840b | Iustin Pop | def call_node_stop_master(node, stop_daemons): |
409 | a8083063 | Iustin Pop | """Tells a node to demote itself from master status.
|
410 | a8083063 | Iustin Pop |
|
411 | a8083063 | Iustin Pop | This is a single-node call.
|
412 | a8083063 | Iustin Pop |
|
413 | a8083063 | Iustin Pop | """
|
414 | 1c65840b | Iustin Pop | c = Client("node_stop_master", [stop_daemons])
|
415 | a8083063 | Iustin Pop | c.connect(node) |
416 | a8083063 | Iustin Pop | c.run() |
417 | a8083063 | Iustin Pop | return c.getresult().get(node, False) |
418 | a8083063 | Iustin Pop | |
419 | a8083063 | Iustin Pop | |
420 | 4e071d3b | Iustin Pop | def call_master_info(node_list): |
421 | 4e071d3b | Iustin Pop | """Query master info.
|
422 | 4e071d3b | Iustin Pop |
|
423 | 4e071d3b | Iustin Pop | This is a multi-node call.
|
424 | 4e071d3b | Iustin Pop |
|
425 | 4e071d3b | Iustin Pop | """
|
426 | 4e071d3b | Iustin Pop | c = Client("master_info", [])
|
427 | 4e071d3b | Iustin Pop | c.connect_list(node_list) |
428 | 4e071d3b | Iustin Pop | c.run() |
429 | 4e071d3b | Iustin Pop | return c.getresult()
|
430 | 4e071d3b | Iustin Pop | |
431 | 4e071d3b | Iustin Pop | |
432 | a8083063 | Iustin Pop | def call_version(node_list): |
433 | a8083063 | Iustin Pop | """Query node version.
|
434 | a8083063 | Iustin Pop |
|
435 | a8083063 | Iustin Pop | This is a multi-node call.
|
436 | a8083063 | Iustin Pop |
|
437 | a8083063 | Iustin Pop | """
|
438 | a8083063 | Iustin Pop | c = Client("version", [])
|
439 | a8083063 | Iustin Pop | c.connect_list(node_list) |
440 | a8083063 | Iustin Pop | c.run() |
441 | a8083063 | Iustin Pop | return c.getresult()
|
442 | a8083063 | Iustin Pop | |
443 | a8083063 | Iustin Pop | |
444 | 3f78eef2 | Iustin Pop | def call_blockdev_create(node, bdev, size, owner, on_primary, info): |
445 | a8083063 | Iustin Pop | """Request creation of a given block device.
|
446 | a8083063 | Iustin Pop |
|
447 | a8083063 | Iustin Pop | This is a single-node call.
|
448 | a8083063 | Iustin Pop |
|
449 | a8083063 | Iustin Pop | """
|
450 | 3f78eef2 | Iustin Pop | params = [bdev.ToDict(), size, owner, on_primary, info] |
451 | a8083063 | Iustin Pop | c = Client("blockdev_create", params)
|
452 | a8083063 | Iustin Pop | c.connect(node) |
453 | a8083063 | Iustin Pop | c.run() |
454 | a8083063 | Iustin Pop | return c.getresult().get(node, False) |
455 | a8083063 | Iustin Pop | |
456 | a8083063 | Iustin Pop | |
457 | a8083063 | Iustin Pop | def call_blockdev_remove(node, bdev): |
458 | a8083063 | Iustin Pop | """Request removal of a given block device.
|
459 | a8083063 | Iustin Pop |
|
460 | a8083063 | Iustin Pop | This is a single-node call.
|
461 | a8083063 | Iustin Pop |
|
462 | a8083063 | Iustin Pop | """
|
463 | 319856a9 | Michael Hanselmann | c = Client("blockdev_remove", [bdev.ToDict()])
|
464 | a8083063 | Iustin Pop | c.connect(node) |
465 | a8083063 | Iustin Pop | c.run() |
466 | a8083063 | Iustin Pop | return c.getresult().get(node, False) |
467 | a8083063 | Iustin Pop | |
468 | a8083063 | Iustin Pop | |
469 | f3e513ad | Iustin Pop | def call_blockdev_rename(node, devlist): |
470 | f3e513ad | Iustin Pop | """Request rename of the given block devices.
|
471 | f3e513ad | Iustin Pop |
|
472 | f3e513ad | Iustin Pop | This is a single-node call.
|
473 | f3e513ad | Iustin Pop |
|
474 | f3e513ad | Iustin Pop | """
|
475 | f3e513ad | Iustin Pop | params = [(d.ToDict(), uid) for d, uid in devlist] |
476 | f3e513ad | Iustin Pop | c = Client("blockdev_rename", params)
|
477 | f3e513ad | Iustin Pop | c.connect(node) |
478 | f3e513ad | Iustin Pop | c.run() |
479 | f3e513ad | Iustin Pop | return c.getresult().get(node, False) |
480 | f3e513ad | Iustin Pop | |
481 | f3e513ad | Iustin Pop | |
482 | 3f78eef2 | Iustin Pop | def call_blockdev_assemble(node, disk, owner, on_primary): |
483 | a8083063 | Iustin Pop | """Request assembling of a given block device.
|
484 | a8083063 | Iustin Pop |
|
485 | a8083063 | Iustin Pop | This is a single-node call.
|
486 | a8083063 | Iustin Pop |
|
487 | a8083063 | Iustin Pop | """
|
488 | 3f78eef2 | Iustin Pop | params = [disk.ToDict(), owner, on_primary] |
489 | a8083063 | Iustin Pop | c = Client("blockdev_assemble", params)
|
490 | a8083063 | Iustin Pop | c.connect(node) |
491 | a8083063 | Iustin Pop | c.run() |
492 | a8083063 | Iustin Pop | return c.getresult().get(node, False) |
493 | a8083063 | Iustin Pop | |
494 | a8083063 | Iustin Pop | |
495 | a8083063 | Iustin Pop | def call_blockdev_shutdown(node, disk): |
496 | a8083063 | Iustin Pop | """Request shutdown of a given block device.
|
497 | a8083063 | Iustin Pop |
|
498 | a8083063 | Iustin Pop | This is a single-node call.
|
499 | a8083063 | Iustin Pop |
|
500 | a8083063 | Iustin Pop | """
|
501 | 319856a9 | Michael Hanselmann | c = Client("blockdev_shutdown", [disk.ToDict()])
|
502 | a8083063 | Iustin Pop | c.connect(node) |
503 | a8083063 | Iustin Pop | c.run() |
504 | a8083063 | Iustin Pop | return c.getresult().get(node, False) |
505 | a8083063 | Iustin Pop | |
506 | a8083063 | Iustin Pop | |
507 | 153d9724 | Iustin Pop | def call_blockdev_addchildren(node, bdev, ndevs): |
508 | 153d9724 | Iustin Pop | """Request adding a list of children to a (mirroring) device.
|
509 | a8083063 | Iustin Pop |
|
510 | a8083063 | Iustin Pop | This is a single-node call.
|
511 | a8083063 | Iustin Pop |
|
512 | a8083063 | Iustin Pop | """
|
513 | 153d9724 | Iustin Pop | params = [bdev.ToDict(), [disk.ToDict() for disk in ndevs]] |
514 | 153d9724 | Iustin Pop | c = Client("blockdev_addchildren", params)
|
515 | a8083063 | Iustin Pop | c.connect(node) |
516 | a8083063 | Iustin Pop | c.run() |
517 | a8083063 | Iustin Pop | return c.getresult().get(node, False) |
518 | a8083063 | Iustin Pop | |
519 | a8083063 | Iustin Pop | |
520 | 153d9724 | Iustin Pop | def call_blockdev_removechildren(node, bdev, ndevs): |
521 | 153d9724 | Iustin Pop | """Request removing a list of children from a (mirroring) device.
|
522 | a8083063 | Iustin Pop |
|
523 | a8083063 | Iustin Pop | This is a single-node call.
|
524 | a8083063 | Iustin Pop |
|
525 | a8083063 | Iustin Pop | """
|
526 | 153d9724 | Iustin Pop | params = [bdev.ToDict(), [disk.ToDict() for disk in ndevs]] |
527 | 153d9724 | Iustin Pop | c = Client("blockdev_removechildren", params)
|
528 | a8083063 | Iustin Pop | c.connect(node) |
529 | a8083063 | Iustin Pop | c.run() |
530 | a8083063 | Iustin Pop | return c.getresult().get(node, False) |
531 | a8083063 | Iustin Pop | |
532 | a8083063 | Iustin Pop | |
533 | a8083063 | Iustin Pop | def call_blockdev_getmirrorstatus(node, disks): |
534 | a8083063 | Iustin Pop | """Request status of a (mirroring) device.
|
535 | a8083063 | Iustin Pop |
|
536 | a8083063 | Iustin Pop | This is a single-node call.
|
537 | a8083063 | Iustin Pop |
|
538 | a8083063 | Iustin Pop | """
|
539 | 319856a9 | Michael Hanselmann | params = [dsk.ToDict() for dsk in disks] |
540 | a8083063 | Iustin Pop | c = Client("blockdev_getmirrorstatus", params)
|
541 | a8083063 | Iustin Pop | c.connect(node) |
542 | a8083063 | Iustin Pop | c.run() |
543 | a8083063 | Iustin Pop | return c.getresult().get(node, False) |
544 | a8083063 | Iustin Pop | |
545 | a8083063 | Iustin Pop | |
546 | a8083063 | Iustin Pop | def call_blockdev_find(node, disk): |
547 | a8083063 | Iustin Pop | """Request identification of a given block device.
|
548 | a8083063 | Iustin Pop |
|
549 | a8083063 | Iustin Pop | This is a single-node call.
|
550 | a8083063 | Iustin Pop |
|
551 | a8083063 | Iustin Pop | """
|
552 | 319856a9 | Michael Hanselmann | c = Client("blockdev_find", [disk.ToDict()])
|
553 | a8083063 | Iustin Pop | c.connect(node) |
554 | a8083063 | Iustin Pop | c.run() |
555 | a8083063 | Iustin Pop | return c.getresult().get(node, False) |
556 | a8083063 | Iustin Pop | |
557 | a8083063 | Iustin Pop | |
558 | d61cbe76 | Iustin Pop | def call_blockdev_close(node, disks): |
559 | d61cbe76 | Iustin Pop | """Closes the given block devices.
|
560 | d61cbe76 | Iustin Pop |
|
561 | d61cbe76 | Iustin Pop | This is a single-node call.
|
562 | d61cbe76 | Iustin Pop |
|
563 | d61cbe76 | Iustin Pop | """
|
564 | d61cbe76 | Iustin Pop | params = [cf.ToDict() for cf in disks] |
565 | d61cbe76 | Iustin Pop | c = Client("blockdev_close", params)
|
566 | d61cbe76 | Iustin Pop | c.connect(node) |
567 | d61cbe76 | Iustin Pop | c.run() |
568 | d61cbe76 | Iustin Pop | return c.getresult().get(node, False) |
569 | d61cbe76 | Iustin Pop | |
570 | d61cbe76 | Iustin Pop | |
571 | a8083063 | Iustin Pop | def call_upload_file(node_list, file_name): |
572 | a8083063 | Iustin Pop | """Upload a file.
|
573 | a8083063 | Iustin Pop |
|
574 | a8083063 | Iustin Pop | The node will refuse the operation in case the file is not on the
|
575 | a8083063 | Iustin Pop | approved file list.
|
576 | a8083063 | Iustin Pop |
|
577 | a8083063 | Iustin Pop | This is a multi-node call.
|
578 | a8083063 | Iustin Pop |
|
579 | a8083063 | Iustin Pop | """
|
580 | a8083063 | Iustin Pop | fh = file(file_name)
|
581 | a8083063 | Iustin Pop | try:
|
582 | a8083063 | Iustin Pop | data = fh.read() |
583 | a8083063 | Iustin Pop | finally:
|
584 | a8083063 | Iustin Pop | fh.close() |
585 | a8083063 | Iustin Pop | st = os.stat(file_name) |
586 | a8083063 | Iustin Pop | params = [file_name, data, st.st_mode, st.st_uid, st.st_gid, |
587 | a8083063 | Iustin Pop | st.st_atime, st.st_mtime] |
588 | a8083063 | Iustin Pop | c = Client("upload_file", params)
|
589 | a8083063 | Iustin Pop | c.connect_list(node_list) |
590 | a8083063 | Iustin Pop | c.run() |
591 | a8083063 | Iustin Pop | return c.getresult()
|
592 | a8083063 | Iustin Pop | |
593 | a8083063 | Iustin Pop | |
594 | a8083063 | Iustin Pop | def call_os_diagnose(node_list): |
595 | a8083063 | Iustin Pop | """Request a diagnose of OS definitions.
|
596 | a8083063 | Iustin Pop |
|
597 | a8083063 | Iustin Pop | This is a multi-node call.
|
598 | a8083063 | Iustin Pop |
|
599 | a8083063 | Iustin Pop | """
|
600 | a8083063 | Iustin Pop | c = Client("os_diagnose", [])
|
601 | a8083063 | Iustin Pop | c.connect_list(node_list) |
602 | a8083063 | Iustin Pop | c.run() |
603 | a8083063 | Iustin Pop | result = c.getresult() |
604 | a8083063 | Iustin Pop | new_result = {} |
605 | a8083063 | Iustin Pop | for node_name in result: |
606 | a8083063 | Iustin Pop | if result[node_name]:
|
607 | 4e679f11 | Guido Trotter | nr = [objects.OS.FromDict(oss) for oss in result[node_name]] |
608 | 4e679f11 | Guido Trotter | else:
|
609 | 4e679f11 | Guido Trotter | nr = [] |
610 | a8083063 | Iustin Pop | new_result[node_name] = nr |
611 | a8083063 | Iustin Pop | return new_result
|
612 | a8083063 | Iustin Pop | |
613 | a8083063 | Iustin Pop | |
614 | 00fe9e38 | Guido Trotter | def call_os_get(node, name): |
615 | a8083063 | Iustin Pop | """Returns an OS definition.
|
616 | a8083063 | Iustin Pop |
|
617 | 00fe9e38 | Guido Trotter | This is a single-node call.
|
618 | a8083063 | Iustin Pop |
|
619 | a8083063 | Iustin Pop | """
|
620 | a8083063 | Iustin Pop | c = Client("os_get", [name])
|
621 | 00fe9e38 | Guido Trotter | c.connect(node) |
622 | a8083063 | Iustin Pop | c.run() |
623 | 00fe9e38 | Guido Trotter | result = c.getresult().get(node, False)
|
624 | 00fe9e38 | Guido Trotter | if isinstance(result, dict): |
625 | dfa96ded | Guido Trotter | return objects.OS.FromDict(result)
|
626 | 00fe9e38 | Guido Trotter | else:
|
627 | dfa96ded | Guido Trotter | return result
|
628 | a8083063 | Iustin Pop | |
629 | a8083063 | Iustin Pop | |
630 | a8083063 | Iustin Pop | def call_hooks_runner(node_list, hpath, phase, env): |
631 | a8083063 | Iustin Pop | """Call the hooks runner.
|
632 | a8083063 | Iustin Pop |
|
633 | a8083063 | Iustin Pop | Args:
|
634 | a8083063 | Iustin Pop | - op: the OpCode instance
|
635 | a8083063 | Iustin Pop | - env: a dictionary with the environment
|
636 | a8083063 | Iustin Pop |
|
637 | a8083063 | Iustin Pop | This is a multi-node call.
|
638 | a8083063 | Iustin Pop |
|
639 | a8083063 | Iustin Pop | """
|
640 | a8083063 | Iustin Pop | params = [hpath, phase, env] |
641 | a8083063 | Iustin Pop | c = Client("hooks_runner", params)
|
642 | a8083063 | Iustin Pop | c.connect_list(node_list) |
643 | a8083063 | Iustin Pop | c.run() |
644 | a8083063 | Iustin Pop | result = c.getresult() |
645 | a8083063 | Iustin Pop | return result
|
646 | a8083063 | Iustin Pop | |
647 | a8083063 | Iustin Pop | |
648 | 8d528b7c | Iustin Pop | def call_iallocator_runner(node, name, idata): |
649 | 8d528b7c | Iustin Pop | """Call an iallocator on a remote node
|
650 | 8d528b7c | Iustin Pop |
|
651 | 8d528b7c | Iustin Pop | Args:
|
652 | 8d528b7c | Iustin Pop | - name: the iallocator name
|
653 | 8d528b7c | Iustin Pop | - input: the json-encoded input string
|
654 | 8d528b7c | Iustin Pop |
|
655 | 8d528b7c | Iustin Pop | This is a single-node call.
|
656 | 8d528b7c | Iustin Pop |
|
657 | 8d528b7c | Iustin Pop | """
|
658 | 8d528b7c | Iustin Pop | params = [name, idata] |
659 | 8d528b7c | Iustin Pop | c = Client("iallocator_runner", params)
|
660 | 8d528b7c | Iustin Pop | c.connect(node) |
661 | 8d528b7c | Iustin Pop | c.run() |
662 | 8d528b7c | Iustin Pop | result = c.getresult().get(node, False)
|
663 | 8d528b7c | Iustin Pop | return result
|
664 | 8d528b7c | Iustin Pop | |
665 | 8d528b7c | Iustin Pop | |
666 | 4c8ba8b3 | Iustin Pop | def call_blockdev_grow(node, cf_bdev, amount): |
667 | 4c8ba8b3 | Iustin Pop | """Request a snapshot of the given block device.
|
668 | 4c8ba8b3 | Iustin Pop |
|
669 | 4c8ba8b3 | Iustin Pop | This is a single-node call.
|
670 | 4c8ba8b3 | Iustin Pop |
|
671 | 4c8ba8b3 | Iustin Pop | """
|
672 | 4c8ba8b3 | Iustin Pop | c = Client("blockdev_grow", [cf_bdev.ToDict(), amount])
|
673 | 4c8ba8b3 | Iustin Pop | c.connect(node) |
674 | 4c8ba8b3 | Iustin Pop | c.run() |
675 | 4c8ba8b3 | Iustin Pop | return c.getresult().get(node, False) |
676 | 4c8ba8b3 | Iustin Pop | |
677 | 4c8ba8b3 | Iustin Pop | |
678 | a8083063 | Iustin Pop | def call_blockdev_snapshot(node, cf_bdev): |
679 | a8083063 | Iustin Pop | """Request a snapshot of the given block device.
|
680 | a8083063 | Iustin Pop |
|
681 | a8083063 | Iustin Pop | This is a single-node call.
|
682 | a8083063 | Iustin Pop |
|
683 | a8083063 | Iustin Pop | """
|
684 | 319856a9 | Michael Hanselmann | c = Client("blockdev_snapshot", [cf_bdev.ToDict()])
|
685 | a8083063 | Iustin Pop | c.connect(node) |
686 | a8083063 | Iustin Pop | c.run() |
687 | a8083063 | Iustin Pop | return c.getresult().get(node, False) |
688 | a8083063 | Iustin Pop | |
689 | a8083063 | Iustin Pop | |
690 | 62c9ec92 | Iustin Pop | def call_snapshot_export(node, snap_bdev, dest_node, instance, cluster_name): |
691 | a8083063 | Iustin Pop | """Request the export of a given snapshot.
|
692 | a8083063 | Iustin Pop |
|
693 | a8083063 | Iustin Pop | This is a single-node call.
|
694 | a8083063 | Iustin Pop |
|
695 | a8083063 | Iustin Pop | """
|
696 | 62c9ec92 | Iustin Pop | params = [snap_bdev.ToDict(), dest_node, instance.ToDict(), cluster_name] |
697 | a8083063 | Iustin Pop | c = Client("snapshot_export", params)
|
698 | a8083063 | Iustin Pop | c.connect(node) |
699 | a8083063 | Iustin Pop | c.run() |
700 | a8083063 | Iustin Pop | return c.getresult().get(node, False) |
701 | a8083063 | Iustin Pop | |
702 | a8083063 | Iustin Pop | |
703 | a8083063 | Iustin Pop | def call_finalize_export(node, instance, snap_disks): |
704 | a8083063 | Iustin Pop | """Request the completion of an export operation.
|
705 | a8083063 | Iustin Pop |
|
706 | a8083063 | Iustin Pop | This writes the export config file, etc.
|
707 | a8083063 | Iustin Pop |
|
708 | a8083063 | Iustin Pop | This is a single-node call.
|
709 | a8083063 | Iustin Pop |
|
710 | a8083063 | Iustin Pop | """
|
711 | a8083063 | Iustin Pop | flat_disks = [] |
712 | a8083063 | Iustin Pop | for disk in snap_disks: |
713 | 319856a9 | Michael Hanselmann | flat_disks.append(disk.ToDict()) |
714 | 319856a9 | Michael Hanselmann | params = [instance.ToDict(), flat_disks] |
715 | a8083063 | Iustin Pop | c = Client("finalize_export", params)
|
716 | a8083063 | Iustin Pop | c.connect(node) |
717 | a8083063 | Iustin Pop | c.run() |
718 | a8083063 | Iustin Pop | return c.getresult().get(node, False) |
719 | a8083063 | Iustin Pop | |
720 | a8083063 | Iustin Pop | |
721 | a8083063 | Iustin Pop | def call_export_info(node, path): |
722 | a8083063 | Iustin Pop | """Queries the export information in a given path.
|
723 | a8083063 | Iustin Pop |
|
724 | a8083063 | Iustin Pop | This is a single-node call.
|
725 | a8083063 | Iustin Pop |
|
726 | a8083063 | Iustin Pop | """
|
727 | a8083063 | Iustin Pop | c = Client("export_info", [path])
|
728 | a8083063 | Iustin Pop | c.connect(node) |
729 | a8083063 | Iustin Pop | c.run() |
730 | a8083063 | Iustin Pop | result = c.getresult().get(node, False)
|
731 | a8083063 | Iustin Pop | if not result: |
732 | a8083063 | Iustin Pop | return result
|
733 | 2d3e73c4 | Michael Hanselmann | return objects.SerializableConfigParser.Loads(str(result)) |
734 | a8083063 | Iustin Pop | |
735 | a8083063 | Iustin Pop | |
736 | 62c9ec92 | Iustin Pop | def call_instance_os_import(node, inst, osdev, swapdev, |
737 | 62c9ec92 | Iustin Pop | src_node, src_image, cluster_name): |
738 | a8083063 | Iustin Pop | """Request the import of a backup into an instance.
|
739 | a8083063 | Iustin Pop |
|
740 | a8083063 | Iustin Pop | This is a single-node call.
|
741 | a8083063 | Iustin Pop |
|
742 | a8083063 | Iustin Pop | """
|
743 | 62c9ec92 | Iustin Pop | params = [inst.ToDict(), osdev, swapdev, src_node, src_image, cluster_name] |
744 | a8083063 | Iustin Pop | c = Client("instance_os_import", params)
|
745 | a8083063 | Iustin Pop | c.connect(node) |
746 | a8083063 | Iustin Pop | c.run() |
747 | a8083063 | Iustin Pop | return c.getresult().get(node, False) |
748 | a8083063 | Iustin Pop | |
749 | a8083063 | Iustin Pop | |
750 | a8083063 | Iustin Pop | def call_export_list(node_list): |
751 | a8083063 | Iustin Pop | """Gets the stored exports list.
|
752 | a8083063 | Iustin Pop |
|
753 | a8083063 | Iustin Pop | This is a multi-node call.
|
754 | a8083063 | Iustin Pop |
|
755 | a8083063 | Iustin Pop | """
|
756 | a8083063 | Iustin Pop | c = Client("export_list", [])
|
757 | a8083063 | Iustin Pop | c.connect_list(node_list) |
758 | a8083063 | Iustin Pop | c.run() |
759 | a8083063 | Iustin Pop | result = c.getresult() |
760 | a8083063 | Iustin Pop | return result
|
761 | a8083063 | Iustin Pop | |
762 | a8083063 | Iustin Pop | |
763 | a8083063 | Iustin Pop | def call_export_remove(node, export): |
764 | a8083063 | Iustin Pop | """Requests removal of a given export.
|
765 | a8083063 | Iustin Pop |
|
766 | a8083063 | Iustin Pop | This is a single-node call.
|
767 | a8083063 | Iustin Pop |
|
768 | a8083063 | Iustin Pop | """
|
769 | a8083063 | Iustin Pop | c = Client("export_remove", [export])
|
770 | a8083063 | Iustin Pop | c.connect(node) |
771 | a8083063 | Iustin Pop | c.run() |
772 | a8083063 | Iustin Pop | return c.getresult().get(node, False) |
773 | a8083063 | Iustin Pop | |
774 | a8083063 | Iustin Pop | |
775 | a8083063 | Iustin Pop | def call_node_leave_cluster(node): |
776 | a8083063 | Iustin Pop | """Requests a node to clean the cluster information it has.
|
777 | a8083063 | Iustin Pop |
|
778 | a8083063 | Iustin Pop | This will remove the configuration information from the ganeti data
|
779 | a8083063 | Iustin Pop | dir.
|
780 | a8083063 | Iustin Pop |
|
781 | a8083063 | Iustin Pop | This is a single-node call.
|
782 | a8083063 | Iustin Pop |
|
783 | a8083063 | Iustin Pop | """
|
784 | a8083063 | Iustin Pop | c = Client("node_leave_cluster", [])
|
785 | a8083063 | Iustin Pop | c.connect(node) |
786 | a8083063 | Iustin Pop | c.run() |
787 | a8083063 | Iustin Pop | return c.getresult().get(node, False) |
788 | dcb93971 | Michael Hanselmann | |
789 | dcb93971 | Michael Hanselmann | |
790 | dcb93971 | Michael Hanselmann | def call_node_volumes(node_list): |
791 | dcb93971 | Michael Hanselmann | """Gets all volumes on node(s).
|
792 | dcb93971 | Michael Hanselmann |
|
793 | dcb93971 | Michael Hanselmann | This is a multi-node call.
|
794 | dcb93971 | Michael Hanselmann |
|
795 | dcb93971 | Michael Hanselmann | """
|
796 | dcb93971 | Michael Hanselmann | c = Client("node_volumes", [])
|
797 | dcb93971 | Michael Hanselmann | c.connect_list(node_list) |
798 | dcb93971 | Michael Hanselmann | c.run() |
799 | dcb93971 | Michael Hanselmann | return c.getresult()
|
800 | 06009e27 | Iustin Pop | |
801 | 06009e27 | Iustin Pop | |
802 | 06009e27 | Iustin Pop | def call_test_delay(node_list, duration): |
803 | 06009e27 | Iustin Pop | """Sleep for a fixed time on given node(s).
|
804 | 06009e27 | Iustin Pop |
|
805 | 06009e27 | Iustin Pop | This is a multi-node call.
|
806 | 06009e27 | Iustin Pop |
|
807 | 06009e27 | Iustin Pop | """
|
808 | 06009e27 | Iustin Pop | c = Client("test_delay", [duration])
|
809 | 06009e27 | Iustin Pop | c.connect_list(node_list) |
810 | 06009e27 | Iustin Pop | c.run() |
811 | 06009e27 | Iustin Pop | return c.getresult()
|
812 | 5e04ed8b | Manuel Franceschini | |
813 | 5e04ed8b | Manuel Franceschini | |
814 | 5e04ed8b | Manuel Franceschini | def call_file_storage_dir_create(node, file_storage_dir): |
815 | 5e04ed8b | Manuel Franceschini | """Create the given file storage directory.
|
816 | 5e04ed8b | Manuel Franceschini |
|
817 | 5e04ed8b | Manuel Franceschini | This is a single-node call.
|
818 | 5e04ed8b | Manuel Franceschini |
|
819 | 5e04ed8b | Manuel Franceschini | """
|
820 | 5e04ed8b | Manuel Franceschini | c = Client("file_storage_dir_create", [file_storage_dir])
|
821 | 5e04ed8b | Manuel Franceschini | c.connect(node) |
822 | 5e04ed8b | Manuel Franceschini | c.run() |
823 | 5e04ed8b | Manuel Franceschini | return c.getresult().get(node, False) |
824 | 5e04ed8b | Manuel Franceschini | |
825 | 5e04ed8b | Manuel Franceschini | |
826 | 5e04ed8b | Manuel Franceschini | def call_file_storage_dir_remove(node, file_storage_dir): |
827 | 5e04ed8b | Manuel Franceschini | """Remove the given file storage directory.
|
828 | 5e04ed8b | Manuel Franceschini |
|
829 | 5e04ed8b | Manuel Franceschini | This is a single-node call.
|
830 | 5e04ed8b | Manuel Franceschini |
|
831 | 5e04ed8b | Manuel Franceschini | """
|
832 | 5e04ed8b | Manuel Franceschini | c = Client("file_storage_dir_remove", [file_storage_dir])
|
833 | 5e04ed8b | Manuel Franceschini | c.connect(node) |
834 | 5e04ed8b | Manuel Franceschini | c.run() |
835 | 5e04ed8b | Manuel Franceschini | return c.getresult().get(node, False) |
836 | 5e04ed8b | Manuel Franceschini | |
837 | 5e04ed8b | Manuel Franceschini | |
838 | 5e04ed8b | Manuel Franceschini | def call_file_storage_dir_rename(node, old_file_storage_dir, |
839 | 5e04ed8b | Manuel Franceschini | new_file_storage_dir): |
840 | 5e04ed8b | Manuel Franceschini | """Rename file storage directory.
|
841 | 5e04ed8b | Manuel Franceschini |
|
842 | 5e04ed8b | Manuel Franceschini | This is a single-node call.
|
843 | 5e04ed8b | Manuel Franceschini |
|
844 | 5e04ed8b | Manuel Franceschini | """
|
845 | 5e04ed8b | Manuel Franceschini | c = Client("file_storage_dir_rename",
|
846 | 5e04ed8b | Manuel Franceschini | [old_file_storage_dir, new_file_storage_dir]) |
847 | 5e04ed8b | Manuel Franceschini | c.connect(node) |
848 | 5e04ed8b | Manuel Franceschini | c.run() |
849 | 5e04ed8b | Manuel Franceschini | return c.getresult().get(node, False) |
850 | ca52cdeb | Michael Hanselmann | |
851 | ca52cdeb | Michael Hanselmann | |
852 | ca52cdeb | Michael Hanselmann | def call_jobqueue_update(node_list, file_name, content): |
853 | ca52cdeb | Michael Hanselmann | """Update job queue.
|
854 | ca52cdeb | Michael Hanselmann |
|
855 | ca52cdeb | Michael Hanselmann | This is a multi-node call.
|
856 | ca52cdeb | Michael Hanselmann |
|
857 | ca52cdeb | Michael Hanselmann | """
|
858 | ca52cdeb | Michael Hanselmann | c = Client("jobqueue_update", [file_name, content])
|
859 | ca52cdeb | Michael Hanselmann | c.connect_list(node_list) |
860 | ca52cdeb | Michael Hanselmann | c.run() |
861 | ca52cdeb | Michael Hanselmann | result = c.getresult() |
862 | ca52cdeb | Michael Hanselmann | return result
|
863 | ca52cdeb | Michael Hanselmann | |
864 | ca52cdeb | Michael Hanselmann | |
865 | ca52cdeb | Michael Hanselmann | def call_jobqueue_purge(node): |
866 | ca52cdeb | Michael Hanselmann | """Purge job queue.
|
867 | ca52cdeb | Michael Hanselmann |
|
868 | ca52cdeb | Michael Hanselmann | This is a single-node call.
|
869 | ca52cdeb | Michael Hanselmann |
|
870 | ca52cdeb | Michael Hanselmann | """
|
871 | ca52cdeb | Michael Hanselmann | c = Client("jobqueue_purge", [])
|
872 | ca52cdeb | Michael Hanselmann | c.connect(node) |
873 | ca52cdeb | Michael Hanselmann | c.run() |
874 | ca52cdeb | Michael Hanselmann | return c.getresult().get(node, False) |
875 | af5ebcb1 | Michael Hanselmann | |
876 | af5ebcb1 | Michael Hanselmann | |
877 | af5ebcb1 | Michael Hanselmann | def call_jobqueue_rename(node_list, old, new): |
878 | af5ebcb1 | Michael Hanselmann | """Rename a job queue file.
|
879 | af5ebcb1 | Michael Hanselmann |
|
880 | af5ebcb1 | Michael Hanselmann | This is a multi-node call.
|
881 | af5ebcb1 | Michael Hanselmann |
|
882 | af5ebcb1 | Michael Hanselmann | """
|
883 | af5ebcb1 | Michael Hanselmann | c = Client("jobqueue_rename", [old, new])
|
884 | af5ebcb1 | Michael Hanselmann | c.connect_list(node_list) |
885 | af5ebcb1 | Michael Hanselmann | c.run() |
886 | af5ebcb1 | Michael Hanselmann | result = c.getresult() |
887 | af5ebcb1 | Michael Hanselmann | return result |