root / lib / rapi / rlib2.py @ 8140e24f
History | View | Annotate | Download (38.2 kB)
1 | 10b207d4 | Oleksiy Mishchenko | #
|
---|---|---|---|
2 | 10b207d4 | Oleksiy Mishchenko | #
|
3 | 10b207d4 | Oleksiy Mishchenko | |
4 | 37e61a77 | Iustin Pop | # Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Google Inc.
|
5 | 10b207d4 | Oleksiy Mishchenko | #
|
6 | 10b207d4 | Oleksiy Mishchenko | # This program is free software; you can redistribute it and/or modify
|
7 | 10b207d4 | Oleksiy Mishchenko | # it under the terms of the GNU General Public License as published by
|
8 | 10b207d4 | Oleksiy Mishchenko | # the Free Software Foundation; either version 2 of the License, or
|
9 | 10b207d4 | Oleksiy Mishchenko | # (at your option) any later version.
|
10 | 10b207d4 | Oleksiy Mishchenko | #
|
11 | 10b207d4 | Oleksiy Mishchenko | # This program is distributed in the hope that it will be useful, but
|
12 | 10b207d4 | Oleksiy Mishchenko | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 10b207d4 | Oleksiy Mishchenko | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | 10b207d4 | Oleksiy Mishchenko | # General Public License for more details.
|
15 | 10b207d4 | Oleksiy Mishchenko | #
|
16 | 10b207d4 | Oleksiy Mishchenko | # You should have received a copy of the GNU General Public License
|
17 | 10b207d4 | Oleksiy Mishchenko | # along with this program; if not, write to the Free Software
|
18 | 10b207d4 | Oleksiy Mishchenko | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
19 | 10b207d4 | Oleksiy Mishchenko | # 02110-1301, USA.
|
20 | 10b207d4 | Oleksiy Mishchenko | |
21 | 10b207d4 | Oleksiy Mishchenko | |
22 | f3c1a70c | Michael Hanselmann | """Remote API resource implementations.
|
23 | 10b207d4 | Oleksiy Mishchenko |
|
24 | f3c1a70c | Michael Hanselmann | PUT or POST?
|
25 | f3c1a70c | Michael Hanselmann | ============
|
26 | 88394aa7 | René Nussbaumer |
|
27 | f3c1a70c | Michael Hanselmann | According to RFC2616 the main difference between PUT and POST is that
|
28 | f3c1a70c | Michael Hanselmann | POST can create new resources but PUT can only create the resource the
|
29 | f3c1a70c | Michael Hanselmann | URI was pointing to on the PUT request.
|
30 | 88394aa7 | René Nussbaumer |
|
31 | d91a933f | Michael Hanselmann | In the context of this module POST on ``/2/instances`` to change an existing
|
32 | f3c1a70c | Michael Hanselmann | entity is legitimate, while PUT would not be. PUT creates a new entity (e.g. a
|
33 | f3c1a70c | Michael Hanselmann | new instance) with a name specified in the request.
|
34 | 88394aa7 | René Nussbaumer |
|
35 | 140ff718 | Michael Hanselmann | Quoting from RFC2616, section 9.6::
|
36 | f3c1a70c | Michael Hanselmann |
|
37 | f3c1a70c | Michael Hanselmann | The fundamental difference between the POST and PUT requests is reflected in
|
38 | f3c1a70c | Michael Hanselmann | the different meaning of the Request-URI. The URI in a POST request
|
39 | f3c1a70c | Michael Hanselmann | identifies the resource that will handle the enclosed entity. That resource
|
40 | f3c1a70c | Michael Hanselmann | might be a data-accepting process, a gateway to some other protocol, or a
|
41 | f3c1a70c | Michael Hanselmann | separate entity that accepts annotations. In contrast, the URI in a PUT
|
42 | f3c1a70c | Michael Hanselmann | request identifies the entity enclosed with the request -- the user agent
|
43 | f3c1a70c | Michael Hanselmann | knows what URI is intended and the server MUST NOT attempt to apply the
|
44 | f3c1a70c | Michael Hanselmann | request to some other resource. If the server desires that the request be
|
45 | f3c1a70c | Michael Hanselmann | applied to a different URI, it MUST send a 301 (Moved Permanently) response;
|
46 | f3c1a70c | Michael Hanselmann | the user agent MAY then make its own decision regarding whether or not to
|
47 | f3c1a70c | Michael Hanselmann | redirect the request.
|
48 | f3c1a70c | Michael Hanselmann |
|
49 | f3c1a70c | Michael Hanselmann | So when adding new methods, if they are operating on the URI entity itself,
|
50 | f3c1a70c | Michael Hanselmann | PUT should be prefered over POST.
|
51 | 88394aa7 | René Nussbaumer |
|
52 | 10b207d4 | Oleksiy Mishchenko | """
|
53 | 10b207d4 | Oleksiy Mishchenko | |
54 | b459a848 | Andrea Spadaccini | # pylint: disable=C0103
|
55 | fe267188 | Iustin Pop | |
56 | fe267188 | Iustin Pop | # C0103: Invalid name, since the R_* names are not conforming
|
57 | fe267188 | Iustin Pop | |
58 | 59b4eeef | Iustin Pop | from ganeti import opcodes |
59 | e5ff1a47 | René Nussbaumer | from ganeti import objects |
60 | 15fd9fd5 | Oleksiy Mishchenko | from ganeti import http |
61 | 15fd9fd5 | Oleksiy Mishchenko | from ganeti import constants |
62 | 59b4eeef | Iustin Pop | from ganeti import cli |
63 | 8381fa2d | Michael Hanselmann | from ganeti import rapi |
64 | d1c172de | Michael Hanselmann | from ganeti import ht |
65 | e987f166 | Michael Hanselmann | from ganeti import compat |
66 | be1ddd09 | Michael Hanselmann | from ganeti import ssconf |
67 | 38206f3c | Iustin Pop | from ganeti.rapi import baserlib |
68 | 10b207d4 | Oleksiy Mishchenko | |
69 | 4e5a68f8 | Oleksiy Mishchenko | |
70 | 7118a0df | Iustin Pop | _COMMON_FIELDS = ["ctime", "mtime", "uuid", "serial_no", "tags"] |
71 | 9031ee8e | Iustin Pop | I_FIELDS = ["name", "admin_state", "os", |
72 | 9031ee8e | Iustin Pop | "pnode", "snodes", |
73 | 9031ee8e | Iustin Pop | "disk_template",
|
74 | 4588b4bd | Dimitris Aragiorgis | "nic.ips", "nic.macs", "nic.modes", |
75 | 4588b4bd | Dimitris Aragiorgis | "nic.links", "nic.networks", "nic.bridges", |
76 | a8b16c4e | Tim Boring | "network_port",
|
77 | 024e157f | Iustin Pop | "disk.sizes", "disk_usage", |
78 | a5b9d725 | Iustin Pop | "beparams", "hvparams", |
79 | 4ea3de4e | Balazs Lecz | "oper_state", "oper_ram", "oper_vcpus", "status", |
80 | 90224407 | Iustin Pop | "custom_hvparams", "custom_beparams", "custom_nicparams", |
81 | 7118a0df | Iustin Pop | ] + _COMMON_FIELDS |
82 | 9031ee8e | Iustin Pop | |
83 | 0b2454b9 | Iustin Pop | N_FIELDS = ["name", "offline", "master_candidate", "drained", |
84 | 9031ee8e | Iustin Pop | "dtotal", "dfree", |
85 | 4e5a68f8 | Oleksiy Mishchenko | "mtotal", "mnode", "mfree", |
86 | 7118a0df | Iustin Pop | "pinst_cnt", "sinst_cnt", |
87 | 0105bad3 | Iustin Pop | "ctotal", "cnodes", "csockets", |
88 | 7118a0df | Iustin Pop | "pip", "sip", "role", |
89 | 93962b80 | Iustin Pop | "pinst_list", "sinst_list", |
90 | c190e817 | Iustin Pop | "master_capable", "vm_capable", |
91 | 37e61a77 | Iustin Pop | "ndparams",
|
92 | fd254195 | Iustin Pop | "group.uuid",
|
93 | 7118a0df | Iustin Pop | ] + _COMMON_FIELDS |
94 | 4e5a68f8 | Oleksiy Mishchenko | |
95 | 4588b4bd | Dimitris Aragiorgis | NET_FIELDS = ["name", "network", "gateway", |
96 | 4588b4bd | Dimitris Aragiorgis | "network6", "gateway6", |
97 | 4588b4bd | Dimitris Aragiorgis | "mac_prefix", "network_type", |
98 | 4588b4bd | Dimitris Aragiorgis | "free_count", "reserved_count", |
99 | 4588b4bd | Dimitris Aragiorgis | "map", "group_list", "inst_list", |
100 | 8140e24f | Dimitris Aragiorgis | "external_reservations", "tags", |
101 | 4588b4bd | Dimitris Aragiorgis | ] |
102 | 4588b4bd | Dimitris Aragiorgis | |
103 | f4e86448 | Michael Hanselmann | G_FIELDS = [ |
104 | f4e86448 | Michael Hanselmann | "alloc_policy",
|
105 | f4e86448 | Michael Hanselmann | "name",
|
106 | f4e86448 | Michael Hanselmann | "node_cnt",
|
107 | f4e86448 | Michael Hanselmann | "node_list",
|
108 | edd49f9b | Agata Murawska | "ipolicy",
|
109 | 003306f9 | Iustin Pop | "custom_ipolicy",
|
110 | 003306f9 | Iustin Pop | "diskparams",
|
111 | 003306f9 | Iustin Pop | "custom_diskparams",
|
112 | 003306f9 | Iustin Pop | "ndparams",
|
113 | 003306f9 | Iustin Pop | "custom_ndparams",
|
114 | f4e86448 | Michael Hanselmann | ] + _COMMON_FIELDS |
115 | 0897dc97 | Adeodato Simo | |
116 | bd7b2070 | Michael Hanselmann | J_FIELDS_BULK = [ |
117 | e987f166 | Michael Hanselmann | "id", "ops", "status", "summary", |
118 | bd7b2070 | Michael Hanselmann | "opstatus",
|
119 | e987f166 | Michael Hanselmann | "received_ts", "start_ts", "end_ts", |
120 | e987f166 | Michael Hanselmann | ] |
121 | e987f166 | Michael Hanselmann | |
122 | bd7b2070 | Michael Hanselmann | J_FIELDS = J_FIELDS_BULK + [ |
123 | bd7b2070 | Michael Hanselmann | "oplog",
|
124 | bd7b2070 | Michael Hanselmann | "opresult",
|
125 | bd7b2070 | Michael Hanselmann | ] |
126 | bd7b2070 | Michael Hanselmann | |
127 | 64dae8fc | Michael Hanselmann | _NR_DRAINED = "drained"
|
128 | 51cc8637 | Michael Hanselmann | _NR_MASTER_CANDIDATE = "master-candidate"
|
129 | 64dae8fc | Michael Hanselmann | _NR_MASTER = "master"
|
130 | 64dae8fc | Michael Hanselmann | _NR_OFFLINE = "offline"
|
131 | 64dae8fc | Michael Hanselmann | _NR_REGULAR = "regular"
|
132 | 64dae8fc | Michael Hanselmann | |
133 | 64dae8fc | Michael Hanselmann | _NR_MAP = { |
134 | 1e28e3b8 | Michael Hanselmann | constants.NR_MASTER: _NR_MASTER, |
135 | 51cc8637 | Michael Hanselmann | constants.NR_MCANDIDATE: _NR_MASTER_CANDIDATE, |
136 | 1e28e3b8 | Michael Hanselmann | constants.NR_DRAINED: _NR_DRAINED, |
137 | 1e28e3b8 | Michael Hanselmann | constants.NR_OFFLINE: _NR_OFFLINE, |
138 | 1e28e3b8 | Michael Hanselmann | constants.NR_REGULAR: _NR_REGULAR, |
139 | 64dae8fc | Michael Hanselmann | } |
140 | 64dae8fc | Michael Hanselmann | |
141 | 1e28e3b8 | Michael Hanselmann | assert frozenset(_NR_MAP.keys()) == constants.NR_ALL |
142 | 1e28e3b8 | Michael Hanselmann | |
143 | d975f482 | Michael Hanselmann | # Request data version field
|
144 | d975f482 | Michael Hanselmann | _REQ_DATA_VERSION = "__version__"
|
145 | d975f482 | Michael Hanselmann | |
146 | 6395cebb | Michael Hanselmann | # Feature string for instance creation request data version 1
|
147 | 6395cebb | Michael Hanselmann | _INST_CREATE_REQV1 = "instance-create-reqv1"
|
148 | 6395cebb | Michael Hanselmann | |
149 | c744425f | Michael Hanselmann | # Feature string for instance reinstall request version 1
|
150 | c744425f | Michael Hanselmann | _INST_REINSTALL_REQV1 = "instance-reinstall-reqv1"
|
151 | c744425f | Michael Hanselmann | |
152 | b7a1c816 | Michael Hanselmann | # Feature string for node migration version 1
|
153 | b7a1c816 | Michael Hanselmann | _NODE_MIGRATE_REQV1 = "node-migrate-reqv1"
|
154 | b7a1c816 | Michael Hanselmann | |
155 | de40437a | Michael Hanselmann | # Feature string for node evacuation with LU-generated jobs
|
156 | de40437a | Michael Hanselmann | _NODE_EVAC_RES1 = "node-evac-res1"
|
157 | de40437a | Michael Hanselmann | |
158 | b4fcee5b | Michael Hanselmann | ALL_FEATURES = frozenset([
|
159 | b4fcee5b | Michael Hanselmann | _INST_CREATE_REQV1, |
160 | b4fcee5b | Michael Hanselmann | _INST_REINSTALL_REQV1, |
161 | b4fcee5b | Michael Hanselmann | _NODE_MIGRATE_REQV1, |
162 | b4fcee5b | Michael Hanselmann | _NODE_EVAC_RES1, |
163 | b4fcee5b | Michael Hanselmann | ]) |
164 | b4fcee5b | Michael Hanselmann | |
165 | 793a8f7c | Michael Hanselmann | # Timeout for /2/jobs/[job_id]/wait. Gives job up to 10 seconds to change.
|
166 | 793a8f7c | Michael Hanselmann | _WFJC_TIMEOUT = 10
|
167 | 793a8f7c | Michael Hanselmann | |
168 | 4e5a68f8 | Oleksiy Mishchenko | |
169 | 28a45bfc | René Nussbaumer | # FIXME: For compatibility we update the beparams/memory field. Needs to be
|
170 | 28a45bfc | René Nussbaumer | # removed in Ganeti 2.7
|
171 | 28a45bfc | René Nussbaumer | def _UpdateBeparams(inst): |
172 | 28a45bfc | René Nussbaumer | """Updates the beparams dict of inst to support the memory field.
|
173 | 28a45bfc | René Nussbaumer |
|
174 | 28a45bfc | René Nussbaumer | @param inst: Inst dict
|
175 | 28a45bfc | René Nussbaumer | @return: Updated inst dict
|
176 | 28a45bfc | René Nussbaumer |
|
177 | 28a45bfc | René Nussbaumer | """
|
178 | 28a45bfc | René Nussbaumer | beparams = inst["beparams"]
|
179 | 28a45bfc | René Nussbaumer | beparams[constants.BE_MEMORY] = beparams[constants.BE_MAXMEM] |
180 | 28a45bfc | René Nussbaumer | |
181 | 28a45bfc | René Nussbaumer | return inst
|
182 | 28a45bfc | René Nussbaumer | |
183 | 28a45bfc | René Nussbaumer | |
184 | 26ff6ee2 | Michael Hanselmann | class R_root(baserlib.ResourceBase): |
185 | 0f945c65 | Michael Hanselmann | """/ resource.
|
186 | 0f945c65 | Michael Hanselmann |
|
187 | 0f945c65 | Michael Hanselmann | """
|
188 | 0f945c65 | Michael Hanselmann | @staticmethod
|
189 | 0f945c65 | Michael Hanselmann | def GET(): |
190 | 0f945c65 | Michael Hanselmann | """Supported for legacy reasons.
|
191 | 0f945c65 | Michael Hanselmann |
|
192 | 0f945c65 | Michael Hanselmann | """
|
193 | 0f945c65 | Michael Hanselmann | return None |
194 | 0f945c65 | Michael Hanselmann | |
195 | 0f945c65 | Michael Hanselmann | |
196 | 132cdb87 | Michael Hanselmann | class R_2(R_root): |
197 | 132cdb87 | Michael Hanselmann | """/2 resource.
|
198 | 132cdb87 | Michael Hanselmann |
|
199 | 132cdb87 | Michael Hanselmann | """
|
200 | 132cdb87 | Michael Hanselmann | |
201 | 132cdb87 | Michael Hanselmann | |
202 | 26ff6ee2 | Michael Hanselmann | class R_version(baserlib.ResourceBase): |
203 | 4e5a68f8 | Oleksiy Mishchenko | """/version resource.
|
204 | 4e5a68f8 | Oleksiy Mishchenko |
|
205 | 4e5a68f8 | Oleksiy Mishchenko | This resource should be used to determine the remote API version and
|
206 | 4e5a68f8 | Oleksiy Mishchenko | to adapt clients accordingly.
|
207 | 4e5a68f8 | Oleksiy Mishchenko |
|
208 | 4e5a68f8 | Oleksiy Mishchenko | """
|
209 | 7e950d31 | Iustin Pop | @staticmethod
|
210 | 7e950d31 | Iustin Pop | def GET(): |
211 | 4e5a68f8 | Oleksiy Mishchenko | """Returns the remote API version.
|
212 | 4e5a68f8 | Oleksiy Mishchenko |
|
213 | 4e5a68f8 | Oleksiy Mishchenko | """
|
214 | 4e5a68f8 | Oleksiy Mishchenko | return constants.RAPI_VERSION
|
215 | 4e5a68f8 | Oleksiy Mishchenko | |
216 | 4e5a68f8 | Oleksiy Mishchenko | |
217 | f6ce0ba2 | Michael Hanselmann | class R_2_info(baserlib.OpcodeResource): |
218 | b58a4d16 | Michael Hanselmann | """/2/info resource.
|
219 | 4e5a68f8 | Oleksiy Mishchenko |
|
220 | 4e5a68f8 | Oleksiy Mishchenko | """
|
221 | f6ce0ba2 | Michael Hanselmann | GET_OPCODE = opcodes.OpClusterQuery |
222 | f6ce0ba2 | Michael Hanselmann | |
223 | be1ddd09 | Michael Hanselmann | def GET(self): |
224 | 4e5a68f8 | Oleksiy Mishchenko | """Returns cluster information.
|
225 | 4e5a68f8 | Oleksiy Mishchenko |
|
226 | 4e5a68f8 | Oleksiy Mishchenko | """
|
227 | a2160e57 | Iustin Pop | client = self.GetClient(query=True) |
228 | 9031ee8e | Iustin Pop | return client.QueryClusterInfo()
|
229 | 4e5a68f8 | Oleksiy Mishchenko | |
230 | 4e5a68f8 | Oleksiy Mishchenko | |
231 | 26ff6ee2 | Michael Hanselmann | class R_2_features(baserlib.ResourceBase): |
232 | 7eac4a4d | Michael Hanselmann | """/2/features resource.
|
233 | 7eac4a4d | Michael Hanselmann |
|
234 | 7eac4a4d | Michael Hanselmann | """
|
235 | 7eac4a4d | Michael Hanselmann | @staticmethod
|
236 | 7eac4a4d | Michael Hanselmann | def GET(): |
237 | 7eac4a4d | Michael Hanselmann | """Returns list of optional RAPI features implemented.
|
238 | 7eac4a4d | Michael Hanselmann |
|
239 | 7eac4a4d | Michael Hanselmann | """
|
240 | b4fcee5b | Michael Hanselmann | return list(ALL_FEATURES) |
241 | 7eac4a4d | Michael Hanselmann | |
242 | 7eac4a4d | Michael Hanselmann | |
243 | f6ce0ba2 | Michael Hanselmann | class R_2_os(baserlib.OpcodeResource): |
244 | 4e5a68f8 | Oleksiy Mishchenko | """/2/os resource.
|
245 | 4e5a68f8 | Oleksiy Mishchenko |
|
246 | 4e5a68f8 | Oleksiy Mishchenko | """
|
247 | f6ce0ba2 | Michael Hanselmann | GET_OPCODE = opcodes.OpOsDiagnose |
248 | f6ce0ba2 | Michael Hanselmann | |
249 | be1ddd09 | Michael Hanselmann | def GET(self): |
250 | 4e5a68f8 | Oleksiy Mishchenko | """Return a list of all OSes.
|
251 | 4e5a68f8 | Oleksiy Mishchenko |
|
252 | 4e5a68f8 | Oleksiy Mishchenko | Can return error 500 in case of a problem.
|
253 | 4e5a68f8 | Oleksiy Mishchenko |
|
254 | 4e5a68f8 | Oleksiy Mishchenko | Example: ["debian-etch"]
|
255 | 4e5a68f8 | Oleksiy Mishchenko |
|
256 | 4e5a68f8 | Oleksiy Mishchenko | """
|
257 | be1ddd09 | Michael Hanselmann | cl = self.GetClient()
|
258 | da2d02e7 | Iustin Pop | op = opcodes.OpOsDiagnose(output_fields=["name", "variants"], names=[]) |
259 | be1ddd09 | Michael Hanselmann | job_id = self.SubmitJob([op], cl=cl)
|
260 | 59b4eeef | Iustin Pop | # we use custom feedback function, instead of print we log the status
|
261 | 59b4eeef | Iustin Pop | result = cli.PollJob(job_id, cl, feedback_fn=baserlib.FeedbackFn) |
262 | 59b4eeef | Iustin Pop | diagnose_data = result[0]
|
263 | 4e5a68f8 | Oleksiy Mishchenko | |
264 | 4e5a68f8 | Oleksiy Mishchenko | if not isinstance(diagnose_data, list): |
265 | 59b4eeef | Iustin Pop | raise http.HttpBadGateway(message="Can't get OS list") |
266 | 4e5a68f8 | Oleksiy Mishchenko | |
267 | e3ac208c | Guido Trotter | os_names = [] |
268 | d22dfef7 | Iustin Pop | for (name, variants) in diagnose_data: |
269 | d22dfef7 | Iustin Pop | os_names.extend(cli.CalculateOSNames(name, variants)) |
270 | e3ac208c | Guido Trotter | |
271 | e3ac208c | Guido Trotter | return os_names
|
272 | 51ee2f49 | Oleksiy Mishchenko | |
273 | 10b207d4 | Oleksiy Mishchenko | |
274 | 8fd625fc | Michael Hanselmann | class R_2_redist_config(baserlib.OpcodeResource): |
275 | 508e9b20 | Michael Hanselmann | """/2/redistribute-config resource.
|
276 | 508e9b20 | Michael Hanselmann |
|
277 | 508e9b20 | Michael Hanselmann | """
|
278 | 8fd625fc | Michael Hanselmann | PUT_OPCODE = opcodes.OpClusterRedistConf |
279 | 508e9b20 | Michael Hanselmann | |
280 | 508e9b20 | Michael Hanselmann | |
281 | 50c7d82e | Michael Hanselmann | class R_2_cluster_modify(baserlib.OpcodeResource): |
282 | 62e999a5 | Michael Hanselmann | """/2/modify resource.
|
283 | 62e999a5 | Michael Hanselmann |
|
284 | 62e999a5 | Michael Hanselmann | """
|
285 | 50c7d82e | Michael Hanselmann | PUT_OPCODE = opcodes.OpClusterSetParams |
286 | 62e999a5 | Michael Hanselmann | |
287 | 62e999a5 | Michael Hanselmann | |
288 | 26ff6ee2 | Michael Hanselmann | class R_2_jobs(baserlib.ResourceBase): |
289 | 10b207d4 | Oleksiy Mishchenko | """/2/jobs resource.
|
290 | 10b207d4 | Oleksiy Mishchenko |
|
291 | 10b207d4 | Oleksiy Mishchenko | """
|
292 | e987f166 | Michael Hanselmann | def GET(self): |
293 | 10b207d4 | Oleksiy Mishchenko | """Returns a dictionary of jobs.
|
294 | 10b207d4 | Oleksiy Mishchenko |
|
295 | c41eea6e | Iustin Pop | @return: a dictionary with jobs id and uri.
|
296 | 38206f3c | Iustin Pop |
|
297 | 10b207d4 | Oleksiy Mishchenko | """
|
298 | be1ddd09 | Michael Hanselmann | client = self.GetClient()
|
299 | e987f166 | Michael Hanselmann | |
300 | e987f166 | Michael Hanselmann | if self.useBulk(): |
301 | bd7b2070 | Michael Hanselmann | bulkdata = client.QueryJobs(None, J_FIELDS_BULK)
|
302 | bd7b2070 | Michael Hanselmann | return baserlib.MapBulkFields(bulkdata, J_FIELDS_BULK)
|
303 | e987f166 | Michael Hanselmann | else:
|
304 | e987f166 | Michael Hanselmann | jobdata = map(compat.fst, client.QueryJobs(None, ["id"])) |
305 | e987f166 | Michael Hanselmann | return baserlib.BuildUriList(jobdata, "/2/jobs/%s", |
306 | e987f166 | Michael Hanselmann | uri_fields=("id", "uri")) |
307 | 10b207d4 | Oleksiy Mishchenko | |
308 | 10b207d4 | Oleksiy Mishchenko | |
309 | 26ff6ee2 | Michael Hanselmann | class R_2_jobs_id(baserlib.ResourceBase): |
310 | 10b207d4 | Oleksiy Mishchenko | """/2/jobs/[job_id] resource.
|
311 | 10b207d4 | Oleksiy Mishchenko |
|
312 | 10b207d4 | Oleksiy Mishchenko | """
|
313 | 10b207d4 | Oleksiy Mishchenko | def GET(self): |
314 | 10b207d4 | Oleksiy Mishchenko | """Returns a job status.
|
315 | 10b207d4 | Oleksiy Mishchenko |
|
316 | c41eea6e | Iustin Pop | @return: a dictionary with job parameters.
|
317 | c41eea6e | Iustin Pop | The result includes:
|
318 | c41eea6e | Iustin Pop | - id: job ID as a number
|
319 | c41eea6e | Iustin Pop | - status: current job status as a string
|
320 | c41eea6e | Iustin Pop | - ops: involved OpCodes as a list of dictionaries for each
|
321 | c41eea6e | Iustin Pop | opcodes in the job
|
322 | c41eea6e | Iustin Pop | - opstatus: OpCodes status as a list
|
323 | c41eea6e | Iustin Pop | - opresult: OpCodes results as a list of lists
|
324 | 38206f3c | Iustin Pop |
|
325 | 10b207d4 | Oleksiy Mishchenko | """
|
326 | 10b207d4 | Oleksiy Mishchenko | job_id = self.items[0] |
327 | be1ddd09 | Michael Hanselmann | result = self.GetClient().QueryJobs([job_id, ], J_FIELDS)[0] |
328 | ee69c97f | Iustin Pop | if result is None: |
329 | ee69c97f | Iustin Pop | raise http.HttpNotFound()
|
330 | e987f166 | Michael Hanselmann | return baserlib.MapFields(J_FIELDS, result)
|
331 | 10b207d4 | Oleksiy Mishchenko | |
332 | c7f5f338 | Oleksiy Mishchenko | def DELETE(self): |
333 | c7f5f338 | Oleksiy Mishchenko | """Cancel not-yet-started job.
|
334 | c7f5f338 | Oleksiy Mishchenko |
|
335 | c7f5f338 | Oleksiy Mishchenko | """
|
336 | c7f5f338 | Oleksiy Mishchenko | job_id = self.items[0] |
337 | be1ddd09 | Michael Hanselmann | result = self.GetClient().CancelJob(job_id)
|
338 | c7f5f338 | Oleksiy Mishchenko | return result
|
339 | c7f5f338 | Oleksiy Mishchenko | |
340 | 10b207d4 | Oleksiy Mishchenko | |
341 | 26ff6ee2 | Michael Hanselmann | class R_2_jobs_id_wait(baserlib.ResourceBase): |
342 | 793a8f7c | Michael Hanselmann | """/2/jobs/[job_id]/wait resource.
|
343 | 793a8f7c | Michael Hanselmann |
|
344 | 793a8f7c | Michael Hanselmann | """
|
345 | 793a8f7c | Michael Hanselmann | # WaitForJobChange provides access to sensitive information and blocks
|
346 | 793a8f7c | Michael Hanselmann | # machine resources (it's a blocking RAPI call), hence restricting access.
|
347 | 793a8f7c | Michael Hanselmann | GET_ACCESS = [rapi.RAPI_ACCESS_WRITE] |
348 | 793a8f7c | Michael Hanselmann | |
349 | 793a8f7c | Michael Hanselmann | def GET(self): |
350 | 793a8f7c | Michael Hanselmann | """Waits for job changes.
|
351 | 793a8f7c | Michael Hanselmann |
|
352 | 793a8f7c | Michael Hanselmann | """
|
353 | 793a8f7c | Michael Hanselmann | job_id = self.items[0] |
354 | 793a8f7c | Michael Hanselmann | |
355 | 793a8f7c | Michael Hanselmann | fields = self.getBodyParameter("fields") |
356 | 793a8f7c | Michael Hanselmann | prev_job_info = self.getBodyParameter("previous_job_info", None) |
357 | 793a8f7c | Michael Hanselmann | prev_log_serial = self.getBodyParameter("previous_log_serial", None) |
358 | 793a8f7c | Michael Hanselmann | |
359 | 793a8f7c | Michael Hanselmann | if not isinstance(fields, list): |
360 | 793a8f7c | Michael Hanselmann | raise http.HttpBadRequest("The 'fields' parameter should be a list") |
361 | 793a8f7c | Michael Hanselmann | |
362 | 793a8f7c | Michael Hanselmann | if not (prev_job_info is None or isinstance(prev_job_info, list)): |
363 | 793a8f7c | Michael Hanselmann | raise http.HttpBadRequest("The 'previous_job_info' parameter should" |
364 | 793a8f7c | Michael Hanselmann | " be a list")
|
365 | 793a8f7c | Michael Hanselmann | |
366 | 793a8f7c | Michael Hanselmann | if not (prev_log_serial is None or |
367 | 793a8f7c | Michael Hanselmann | isinstance(prev_log_serial, (int, long))): |
368 | 793a8f7c | Michael Hanselmann | raise http.HttpBadRequest("The 'previous_log_serial' parameter should" |
369 | 793a8f7c | Michael Hanselmann | " be a number")
|
370 | 793a8f7c | Michael Hanselmann | |
371 | be1ddd09 | Michael Hanselmann | client = self.GetClient()
|
372 | 793a8f7c | Michael Hanselmann | result = client.WaitForJobChangeOnce(job_id, fields, |
373 | 793a8f7c | Michael Hanselmann | prev_job_info, prev_log_serial, |
374 | 793a8f7c | Michael Hanselmann | timeout=_WFJC_TIMEOUT) |
375 | 793a8f7c | Michael Hanselmann | if not result: |
376 | 793a8f7c | Michael Hanselmann | raise http.HttpNotFound()
|
377 | 793a8f7c | Michael Hanselmann | |
378 | 793a8f7c | Michael Hanselmann | if result == constants.JOB_NOTCHANGED:
|
379 | 793a8f7c | Michael Hanselmann | # No changes
|
380 | 793a8f7c | Michael Hanselmann | return None |
381 | 793a8f7c | Michael Hanselmann | |
382 | 793a8f7c | Michael Hanselmann | (job_info, log_entries) = result |
383 | 793a8f7c | Michael Hanselmann | |
384 | 793a8f7c | Michael Hanselmann | return {
|
385 | 793a8f7c | Michael Hanselmann | "job_info": job_info,
|
386 | 793a8f7c | Michael Hanselmann | "log_entries": log_entries,
|
387 | 793a8f7c | Michael Hanselmann | } |
388 | 793a8f7c | Michael Hanselmann | |
389 | 793a8f7c | Michael Hanselmann | |
390 | f6ce0ba2 | Michael Hanselmann | class R_2_nodes(baserlib.OpcodeResource): |
391 | 10b207d4 | Oleksiy Mishchenko | """/2/nodes resource.
|
392 | 10b207d4 | Oleksiy Mishchenko |
|
393 | 10b207d4 | Oleksiy Mishchenko | """
|
394 | f6ce0ba2 | Michael Hanselmann | GET_OPCODE = opcodes.OpNodeQuery |
395 | f6ce0ba2 | Michael Hanselmann | |
396 | 10b207d4 | Oleksiy Mishchenko | def GET(self): |
397 | 10b207d4 | Oleksiy Mishchenko | """Returns a list of all nodes.
|
398 | 38206f3c | Iustin Pop |
|
399 | 10b207d4 | Oleksiy Mishchenko | """
|
400 | 9fbf0098 | Iustin Pop | client = self.GetClient(query=True) |
401 | 38206f3c | Iustin Pop | |
402 | 3d103742 | Iustin Pop | if self.useBulk(): |
403 | 9031ee8e | Iustin Pop | bulkdata = client.QueryNodes([], N_FIELDS, False)
|
404 | a0dcf7c2 | Oleksiy Mishchenko | return baserlib.MapBulkFields(bulkdata, N_FIELDS)
|
405 | 9031ee8e | Iustin Pop | else:
|
406 | 9031ee8e | Iustin Pop | nodesdata = client.QueryNodes([], ["name"], False) |
407 | 9031ee8e | Iustin Pop | nodeslist = [row[0] for row in nodesdata] |
408 | 9031ee8e | Iustin Pop | return baserlib.BuildUriList(nodeslist, "/2/nodes/%s", |
409 | 9031ee8e | Iustin Pop | uri_fields=("id", "uri")) |
410 | 441e7cfd | Oleksiy Mishchenko | |
411 | 441e7cfd | Oleksiy Mishchenko | |
412 | f6ce0ba2 | Michael Hanselmann | class R_2_nodes_name(baserlib.OpcodeResource): |
413 | b58a4d16 | Michael Hanselmann | """/2/nodes/[node_name] resource.
|
414 | 028c6b76 | Oleksiy Mishchenko |
|
415 | 028c6b76 | Oleksiy Mishchenko | """
|
416 | f6ce0ba2 | Michael Hanselmann | GET_OPCODE = opcodes.OpNodeQuery |
417 | f6ce0ba2 | Michael Hanselmann | |
418 | 4e5a68f8 | Oleksiy Mishchenko | def GET(self): |
419 | 4e5a68f8 | Oleksiy Mishchenko | """Send information about a node.
|
420 | 4e5a68f8 | Oleksiy Mishchenko |
|
421 | 4e5a68f8 | Oleksiy Mishchenko | """
|
422 | 4e5a68f8 | Oleksiy Mishchenko | node_name = self.items[0] |
423 | 9fbf0098 | Iustin Pop | client = self.GetClient(query=True) |
424 | e8ebbd2b | Michael Hanselmann | |
425 | e8ebbd2b | Michael Hanselmann | result = baserlib.HandleItemQueryErrors(client.QueryNodes, |
426 | e8ebbd2b | Michael Hanselmann | names=[node_name], fields=N_FIELDS, |
427 | e8ebbd2b | Michael Hanselmann | use_locking=self.useLocking())
|
428 | 4e5a68f8 | Oleksiy Mishchenko | |
429 | 4e5a68f8 | Oleksiy Mishchenko | return baserlib.MapFields(N_FIELDS, result[0]) |
430 | 028c6b76 | Oleksiy Mishchenko | |
431 | 028c6b76 | Oleksiy Mishchenko | |
432 | 42d4d8b9 | Michael Hanselmann | class R_2_nodes_name_powercycle(baserlib.OpcodeResource): |
433 | 42d4d8b9 | Michael Hanselmann | """/2/nodes/[node_name]/powercycle resource.
|
434 | 42d4d8b9 | Michael Hanselmann |
|
435 | 42d4d8b9 | Michael Hanselmann | """
|
436 | 42d4d8b9 | Michael Hanselmann | POST_OPCODE = opcodes.OpNodePowercycle |
437 | 42d4d8b9 | Michael Hanselmann | |
438 | 42d4d8b9 | Michael Hanselmann | def GetPostOpInput(self): |
439 | 42d4d8b9 | Michael Hanselmann | """Tries to powercycle a node.
|
440 | 42d4d8b9 | Michael Hanselmann |
|
441 | 42d4d8b9 | Michael Hanselmann | """
|
442 | 42d4d8b9 | Michael Hanselmann | return (self.request_body, { |
443 | 42d4d8b9 | Michael Hanselmann | "node_name": self.items[0], |
444 | 42d4d8b9 | Michael Hanselmann | "force": self.useForce(), |
445 | 42d4d8b9 | Michael Hanselmann | }) |
446 | 42d4d8b9 | Michael Hanselmann | |
447 | 42d4d8b9 | Michael Hanselmann | |
448 | 51cc8637 | Michael Hanselmann | class R_2_nodes_name_role(baserlib.OpcodeResource): |
449 | 51cc8637 | Michael Hanselmann | """/2/nodes/[node_name]/role resource.
|
450 | 64dae8fc | Michael Hanselmann |
|
451 | 64dae8fc | Michael Hanselmann | """
|
452 | 51cc8637 | Michael Hanselmann | PUT_OPCODE = opcodes.OpNodeSetParams |
453 | 51cc8637 | Michael Hanselmann | |
454 | 64dae8fc | Michael Hanselmann | def GET(self): |
455 | 64dae8fc | Michael Hanselmann | """Returns the current node role.
|
456 | 64dae8fc | Michael Hanselmann |
|
457 | 64dae8fc | Michael Hanselmann | @return: Node role
|
458 | 64dae8fc | Michael Hanselmann |
|
459 | 64dae8fc | Michael Hanselmann | """
|
460 | 64dae8fc | Michael Hanselmann | node_name = self.items[0] |
461 | 9fbf0098 | Iustin Pop | client = self.GetClient(query=True) |
462 | 64dae8fc | Michael Hanselmann | result = client.QueryNodes(names=[node_name], fields=["role"],
|
463 | 64dae8fc | Michael Hanselmann | use_locking=self.useLocking())
|
464 | 64dae8fc | Michael Hanselmann | |
465 | 64dae8fc | Michael Hanselmann | return _NR_MAP[result[0][0]] |
466 | 64dae8fc | Michael Hanselmann | |
467 | 51cc8637 | Michael Hanselmann | def GetPutOpInput(self): |
468 | 64dae8fc | Michael Hanselmann | """Sets the node role.
|
469 | 64dae8fc | Michael Hanselmann |
|
470 | 64dae8fc | Michael Hanselmann | """
|
471 | 51cc8637 | Michael Hanselmann | baserlib.CheckType(self.request_body, basestring, "Body contents") |
472 | 64dae8fc | Michael Hanselmann | |
473 | 627ad739 | Michael Hanselmann | role = self.request_body
|
474 | 64dae8fc | Michael Hanselmann | |
475 | 64dae8fc | Michael Hanselmann | if role == _NR_REGULAR:
|
476 | 64dae8fc | Michael Hanselmann | candidate = False
|
477 | 64dae8fc | Michael Hanselmann | offline = False
|
478 | 64dae8fc | Michael Hanselmann | drained = False
|
479 | 64dae8fc | Michael Hanselmann | |
480 | 51cc8637 | Michael Hanselmann | elif role == _NR_MASTER_CANDIDATE:
|
481 | 64dae8fc | Michael Hanselmann | candidate = True
|
482 | 64dae8fc | Michael Hanselmann | offline = drained = None
|
483 | 64dae8fc | Michael Hanselmann | |
484 | 64dae8fc | Michael Hanselmann | elif role == _NR_DRAINED:
|
485 | 64dae8fc | Michael Hanselmann | drained = True
|
486 | 64dae8fc | Michael Hanselmann | candidate = offline = None
|
487 | 64dae8fc | Michael Hanselmann | |
488 | 64dae8fc | Michael Hanselmann | elif role == _NR_OFFLINE:
|
489 | 64dae8fc | Michael Hanselmann | offline = True
|
490 | 64dae8fc | Michael Hanselmann | candidate = drained = None
|
491 | 64dae8fc | Michael Hanselmann | |
492 | 64dae8fc | Michael Hanselmann | else:
|
493 | 64dae8fc | Michael Hanselmann | raise http.HttpBadRequest("Can't set '%s' role" % role) |
494 | 64dae8fc | Michael Hanselmann | |
495 | 51cc8637 | Michael Hanselmann | assert len(self.items) == 1 |
496 | 64dae8fc | Michael Hanselmann | |
497 | 51cc8637 | Michael Hanselmann | return ({}, {
|
498 | 51cc8637 | Michael Hanselmann | "node_name": self.items[0], |
499 | 51cc8637 | Michael Hanselmann | "master_candidate": candidate,
|
500 | 51cc8637 | Michael Hanselmann | "offline": offline,
|
501 | 51cc8637 | Michael Hanselmann | "drained": drained,
|
502 | 51cc8637 | Michael Hanselmann | "force": self.useForce(), |
503 | 682878d9 | Guido Trotter | "auto_promote": bool(self._checkIntVariable("auto-promote", default=0)), |
504 | 51cc8637 | Michael Hanselmann | }) |
505 | 64dae8fc | Michael Hanselmann | |
506 | 64dae8fc | Michael Hanselmann | |
507 | 7fa91722 | Michael Hanselmann | class R_2_nodes_name_evacuate(baserlib.OpcodeResource): |
508 | 73452f12 | Michael Hanselmann | """/2/nodes/[node_name]/evacuate resource.
|
509 | 73452f12 | Michael Hanselmann |
|
510 | 73452f12 | Michael Hanselmann | """
|
511 | 7fa91722 | Michael Hanselmann | POST_OPCODE = opcodes.OpNodeEvacuate |
512 | 7fa91722 | Michael Hanselmann | |
513 | 7fa91722 | Michael Hanselmann | def GetPostOpInput(self): |
514 | de40437a | Michael Hanselmann | """Evacuate all instances off a node.
|
515 | 73452f12 | Michael Hanselmann |
|
516 | 73452f12 | Michael Hanselmann | """
|
517 | 7fa91722 | Michael Hanselmann | return (self.request_body, { |
518 | de40437a | Michael Hanselmann | "node_name": self.items[0], |
519 | de40437a | Michael Hanselmann | "dry_run": self.dryRun(), |
520 | de40437a | Michael Hanselmann | }) |
521 | 941b9309 | Iustin Pop | |
522 | 73452f12 | Michael Hanselmann | |
523 | 55168cc7 | Michael Hanselmann | class R_2_nodes_name_migrate(baserlib.OpcodeResource): |
524 | 7a95a954 | Michael Hanselmann | """/2/nodes/[node_name]/migrate resource.
|
525 | 1c482bab | Michael Hanselmann |
|
526 | 1c482bab | Michael Hanselmann | """
|
527 | 55168cc7 | Michael Hanselmann | POST_OPCODE = opcodes.OpNodeMigrate |
528 | 55168cc7 | Michael Hanselmann | |
529 | 55168cc7 | Michael Hanselmann | def GetPostOpInput(self): |
530 | 1c482bab | Michael Hanselmann | """Migrate all primary instances from a node.
|
531 | 1c482bab | Michael Hanselmann |
|
532 | 1c482bab | Michael Hanselmann | """
|
533 | b7a1c816 | Michael Hanselmann | if self.queryargs: |
534 | b7a1c816 | Michael Hanselmann | # Support old-style requests
|
535 | b7a1c816 | Michael Hanselmann | if "live" in self.queryargs and "mode" in self.queryargs: |
536 | b7a1c816 | Michael Hanselmann | raise http.HttpBadRequest("Only one of 'live' and 'mode' should" |
537 | b7a1c816 | Michael Hanselmann | " be passed")
|
538 | b7a1c816 | Michael Hanselmann | |
539 | b7a1c816 | Michael Hanselmann | if "live" in self.queryargs: |
540 | b7a1c816 | Michael Hanselmann | if self._checkIntVariable("live", default=1): |
541 | b7a1c816 | Michael Hanselmann | mode = constants.HT_MIGRATION_LIVE |
542 | b7a1c816 | Michael Hanselmann | else:
|
543 | b7a1c816 | Michael Hanselmann | mode = constants.HT_MIGRATION_NONLIVE |
544 | 52194140 | Iustin Pop | else:
|
545 | b7a1c816 | Michael Hanselmann | mode = self._checkStringVariable("mode", default=None) |
546 | b7a1c816 | Michael Hanselmann | |
547 | b7a1c816 | Michael Hanselmann | data = { |
548 | b7a1c816 | Michael Hanselmann | "mode": mode,
|
549 | b7a1c816 | Michael Hanselmann | } |
550 | 52194140 | Iustin Pop | else:
|
551 | b7a1c816 | Michael Hanselmann | data = self.request_body
|
552 | 52194140 | Iustin Pop | |
553 | 55168cc7 | Michael Hanselmann | return (data, {
|
554 | 55168cc7 | Michael Hanselmann | "node_name": self.items[0], |
555 | b7a1c816 | Michael Hanselmann | }) |
556 | 1c482bab | Michael Hanselmann | |
557 | 1c482bab | Michael Hanselmann | |
558 | 682878d9 | Guido Trotter | class R_2_nodes_name_modify(baserlib.OpcodeResource): |
559 | 94497dd1 | Michael Hanselmann | """/2/nodes/[node_name]/modify resource.
|
560 | 94497dd1 | Michael Hanselmann |
|
561 | 94497dd1 | Michael Hanselmann | """
|
562 | 8b8f54dd | Guido Trotter | POST_OPCODE = opcodes.OpNodeSetParams |
563 | 94497dd1 | Michael Hanselmann | |
564 | 8b8f54dd | Guido Trotter | def GetPostOpInput(self): |
565 | 682878d9 | Guido Trotter | """Changes parameters of a node.
|
566 | 94497dd1 | Michael Hanselmann |
|
567 | 94497dd1 | Michael Hanselmann | """
|
568 | 682878d9 | Guido Trotter | assert len(self.items) == 1 |
569 | 94497dd1 | Michael Hanselmann | |
570 | 682878d9 | Guido Trotter | return (self.request_body, { |
571 | 370f2042 | Guido Trotter | "node_name": self.items[0], |
572 | 94497dd1 | Michael Hanselmann | }) |
573 | 94497dd1 | Michael Hanselmann | |
574 | 94497dd1 | Michael Hanselmann | |
575 | eb08e09d | Michael Hanselmann | class R_2_nodes_name_storage(baserlib.OpcodeResource): |
576 | b58a4d16 | Michael Hanselmann | """/2/nodes/[node_name]/storage resource.
|
577 | 7a95a954 | Michael Hanselmann |
|
578 | 7a95a954 | Michael Hanselmann | """
|
579 | ad8d0595 | Iustin Pop | # LUNodeQueryStorage acquires locks, hence restricting access to GET
|
580 | 7a95a954 | Michael Hanselmann | GET_ACCESS = [rapi.RAPI_ACCESS_WRITE] |
581 | eb08e09d | Michael Hanselmann | GET_OPCODE = opcodes.OpNodeQueryStorage |
582 | 7a95a954 | Michael Hanselmann | |
583 | eb08e09d | Michael Hanselmann | def GetGetOpInput(self): |
584 | eb08e09d | Michael Hanselmann | """List storage available on a node.
|
585 | 7a95a954 | Michael Hanselmann |
|
586 | eb08e09d | Michael Hanselmann | """
|
587 | 7a95a954 | Michael Hanselmann | storage_type = self._checkStringVariable("storage_type", None) |
588 | 7a95a954 | Michael Hanselmann | output_fields = self._checkStringVariable("output_fields", None) |
589 | eb08e09d | Michael Hanselmann | |
590 | 7a95a954 | Michael Hanselmann | if not output_fields: |
591 | 7a95a954 | Michael Hanselmann | raise http.HttpBadRequest("Missing the required 'output_fields'" |
592 | 7a95a954 | Michael Hanselmann | " parameter")
|
593 | 7a95a954 | Michael Hanselmann | |
594 | eb08e09d | Michael Hanselmann | return ({}, {
|
595 | eb08e09d | Michael Hanselmann | "nodes": [self.items[0]], |
596 | eb08e09d | Michael Hanselmann | "storage_type": storage_type,
|
597 | eb08e09d | Michael Hanselmann | "output_fields": output_fields.split(","), |
598 | eb08e09d | Michael Hanselmann | }) |
599 | 7a95a954 | Michael Hanselmann | |
600 | 7a95a954 | Michael Hanselmann | |
601 | 8d232068 | Michael Hanselmann | class R_2_nodes_name_storage_modify(baserlib.OpcodeResource): |
602 | b58a4d16 | Michael Hanselmann | """/2/nodes/[node_name]/storage/modify resource.
|
603 | 1e82bc80 | Michael Hanselmann |
|
604 | 1e82bc80 | Michael Hanselmann | """
|
605 | 8d232068 | Michael Hanselmann | PUT_OPCODE = opcodes.OpNodeModifyStorage |
606 | 1e82bc80 | Michael Hanselmann | |
607 | 8d232068 | Michael Hanselmann | def GetPutOpInput(self): |
608 | 8d232068 | Michael Hanselmann | """Modifies a storage volume on a node.
|
609 | 1e82bc80 | Michael Hanselmann |
|
610 | 8d232068 | Michael Hanselmann | """
|
611 | 8d232068 | Michael Hanselmann | storage_type = self._checkStringVariable("storage_type", None) |
612 | 1e82bc80 | Michael Hanselmann | name = self._checkStringVariable("name", None) |
613 | 8d232068 | Michael Hanselmann | |
614 | 1e82bc80 | Michael Hanselmann | if not name: |
615 | 1e82bc80 | Michael Hanselmann | raise http.HttpBadRequest("Missing the required 'name'" |
616 | 1e82bc80 | Michael Hanselmann | " parameter")
|
617 | 1e82bc80 | Michael Hanselmann | |
618 | 1e82bc80 | Michael Hanselmann | changes = {} |
619 | 1e82bc80 | Michael Hanselmann | |
620 | 1e82bc80 | Michael Hanselmann | if "allocatable" in self.queryargs: |
621 | 1e82bc80 | Michael Hanselmann | changes[constants.SF_ALLOCATABLE] = \ |
622 | 1e82bc80 | Michael Hanselmann | bool(self._checkIntVariable("allocatable", default=1)) |
623 | 1e82bc80 | Michael Hanselmann | |
624 | 8d232068 | Michael Hanselmann | return ({}, {
|
625 | 8d232068 | Michael Hanselmann | "node_name": self.items[0], |
626 | 8d232068 | Michael Hanselmann | "storage_type": storage_type,
|
627 | 8d232068 | Michael Hanselmann | "name": name,
|
628 | 8d232068 | Michael Hanselmann | "changes": changes,
|
629 | 8d232068 | Michael Hanselmann | }) |
630 | 1e82bc80 | Michael Hanselmann | |
631 | 1e82bc80 | Michael Hanselmann | |
632 | 98270691 | Michael Hanselmann | class R_2_nodes_name_storage_repair(baserlib.OpcodeResource): |
633 | b58a4d16 | Michael Hanselmann | """/2/nodes/[node_name]/storage/repair resource.
|
634 | 723f4565 | Michael Hanselmann |
|
635 | 723f4565 | Michael Hanselmann | """
|
636 | 98270691 | Michael Hanselmann | PUT_OPCODE = opcodes.OpRepairNodeStorage |
637 | 723f4565 | Michael Hanselmann | |
638 | 98270691 | Michael Hanselmann | def GetPutOpInput(self): |
639 | 98270691 | Michael Hanselmann | """Repairs a storage volume on a node.
|
640 | 723f4565 | Michael Hanselmann |
|
641 | 98270691 | Michael Hanselmann | """
|
642 | 98270691 | Michael Hanselmann | storage_type = self._checkStringVariable("storage_type", None) |
643 | 723f4565 | Michael Hanselmann | name = self._checkStringVariable("name", None) |
644 | 723f4565 | Michael Hanselmann | if not name: |
645 | 723f4565 | Michael Hanselmann | raise http.HttpBadRequest("Missing the required 'name'" |
646 | 723f4565 | Michael Hanselmann | " parameter")
|
647 | 723f4565 | Michael Hanselmann | |
648 | 98270691 | Michael Hanselmann | return ({}, {
|
649 | 98270691 | Michael Hanselmann | "node_name": self.items[0], |
650 | 98270691 | Michael Hanselmann | "storage_type": storage_type,
|
651 | 98270691 | Michael Hanselmann | "name": name,
|
652 | 98270691 | Michael Hanselmann | }) |
653 | 723f4565 | Michael Hanselmann | |
654 | 723f4565 | Michael Hanselmann | |
655 | 4588b4bd | Dimitris Aragiorgis | class R_2_networks(baserlib.OpcodeResource): |
656 | 4588b4bd | Dimitris Aragiorgis | """/2/networks resource.
|
657 | 4588b4bd | Dimitris Aragiorgis |
|
658 | 4588b4bd | Dimitris Aragiorgis | """
|
659 | 4588b4bd | Dimitris Aragiorgis | GET_OPCODE = opcodes.OpNetworkQuery |
660 | 4588b4bd | Dimitris Aragiorgis | POST_OPCODE = opcodes.OpNetworkAdd |
661 | 4588b4bd | Dimitris Aragiorgis | POST_RENAME = { |
662 | 4588b4bd | Dimitris Aragiorgis | "name": "network_name", |
663 | 4588b4bd | Dimitris Aragiorgis | } |
664 | 4588b4bd | Dimitris Aragiorgis | |
665 | 4588b4bd | Dimitris Aragiorgis | def GetPostOpInput(self): |
666 | 4588b4bd | Dimitris Aragiorgis | """Create a network.
|
667 | 4588b4bd | Dimitris Aragiorgis |
|
668 | 4588b4bd | Dimitris Aragiorgis | """
|
669 | 4588b4bd | Dimitris Aragiorgis | assert not self.items |
670 | 4588b4bd | Dimitris Aragiorgis | return (self.request_body, { |
671 | 4588b4bd | Dimitris Aragiorgis | "dry_run": self.dryRun(), |
672 | 4588b4bd | Dimitris Aragiorgis | }) |
673 | 4588b4bd | Dimitris Aragiorgis | |
674 | 4588b4bd | Dimitris Aragiorgis | def GET(self): |
675 | 4588b4bd | Dimitris Aragiorgis | """Returns a list of all networks.
|
676 | 4588b4bd | Dimitris Aragiorgis |
|
677 | 4588b4bd | Dimitris Aragiorgis | """
|
678 | 4588b4bd | Dimitris Aragiorgis | client = self.GetClient()
|
679 | 4588b4bd | Dimitris Aragiorgis | |
680 | 4588b4bd | Dimitris Aragiorgis | if self.useBulk(): |
681 | 4588b4bd | Dimitris Aragiorgis | bulkdata = client.QueryNetworks([], NET_FIELDS, False)
|
682 | 4588b4bd | Dimitris Aragiorgis | return baserlib.MapBulkFields(bulkdata, NET_FIELDS)
|
683 | 4588b4bd | Dimitris Aragiorgis | else:
|
684 | 4588b4bd | Dimitris Aragiorgis | data = client.QueryNetworks([], ["name"], False) |
685 | 4588b4bd | Dimitris Aragiorgis | networknames = [row[0] for row in data] |
686 | 4588b4bd | Dimitris Aragiorgis | return baserlib.BuildUriList(networknames, "/2/networks/%s", |
687 | 4588b4bd | Dimitris Aragiorgis | uri_fields=("name", "uri")) |
688 | 4588b4bd | Dimitris Aragiorgis | |
689 | 4588b4bd | Dimitris Aragiorgis | |
690 | 4588b4bd | Dimitris Aragiorgis | class R_2_networks_name(baserlib.OpcodeResource): |
691 | 4588b4bd | Dimitris Aragiorgis | """/2/network/[network_name] resource.
|
692 | 4588b4bd | Dimitris Aragiorgis |
|
693 | 4588b4bd | Dimitris Aragiorgis | """
|
694 | 4588b4bd | Dimitris Aragiorgis | DELETE_OPCODE = opcodes.OpNetworkRemove |
695 | 4588b4bd | Dimitris Aragiorgis | |
696 | 4588b4bd | Dimitris Aragiorgis | def GET(self): |
697 | 4588b4bd | Dimitris Aragiorgis | """Send information about a network.
|
698 | 4588b4bd | Dimitris Aragiorgis |
|
699 | 4588b4bd | Dimitris Aragiorgis | """
|
700 | 4588b4bd | Dimitris Aragiorgis | network_name = self.items[0] |
701 | 4588b4bd | Dimitris Aragiorgis | client = self.GetClient()
|
702 | 4588b4bd | Dimitris Aragiorgis | |
703 | 4588b4bd | Dimitris Aragiorgis | result = baserlib.HandleItemQueryErrors(client.QueryNetworks, |
704 | 4588b4bd | Dimitris Aragiorgis | names=[network_name], |
705 | 4588b4bd | Dimitris Aragiorgis | fields=NET_FIELDS, |
706 | 4588b4bd | Dimitris Aragiorgis | use_locking=self.useLocking())
|
707 | 4588b4bd | Dimitris Aragiorgis | |
708 | 4588b4bd | Dimitris Aragiorgis | return baserlib.MapFields(NET_FIELDS, result[0]) |
709 | 4588b4bd | Dimitris Aragiorgis | |
710 | 4588b4bd | Dimitris Aragiorgis | def GetDeleteOpInput(self): |
711 | 4588b4bd | Dimitris Aragiorgis | """Delete a network.
|
712 | 4588b4bd | Dimitris Aragiorgis |
|
713 | 4588b4bd | Dimitris Aragiorgis | """
|
714 | 4588b4bd | Dimitris Aragiorgis | assert len(self.items) == 1 |
715 | 4588b4bd | Dimitris Aragiorgis | return (self.request_body, { |
716 | 4588b4bd | Dimitris Aragiorgis | "network_name": self.items[0], |
717 | 4588b4bd | Dimitris Aragiorgis | "dry_run": self.dryRun(), |
718 | 4588b4bd | Dimitris Aragiorgis | }) |
719 | 4588b4bd | Dimitris Aragiorgis | |
720 | 4588b4bd | Dimitris Aragiorgis | class R_2_networks_name_connect(baserlib.OpcodeResource): |
721 | 4588b4bd | Dimitris Aragiorgis | """/2/network/[network_name]/connect.
|
722 | 4588b4bd | Dimitris Aragiorgis |
|
723 | 4588b4bd | Dimitris Aragiorgis | """
|
724 | 4588b4bd | Dimitris Aragiorgis | PUT_OPCODE = opcodes.OpNetworkConnect |
725 | 4588b4bd | Dimitris Aragiorgis | |
726 | 4588b4bd | Dimitris Aragiorgis | def GetPutOpInput(self): |
727 | 4588b4bd | Dimitris Aragiorgis | """Changes some parameters of node group.
|
728 | 4588b4bd | Dimitris Aragiorgis |
|
729 | 4588b4bd | Dimitris Aragiorgis | """
|
730 | 4588b4bd | Dimitris Aragiorgis | assert self.items |
731 | 4588b4bd | Dimitris Aragiorgis | return (self.request_body, { |
732 | 4588b4bd | Dimitris Aragiorgis | "network_name": self.items[0], |
733 | 4588b4bd | Dimitris Aragiorgis | }) |
734 | 4588b4bd | Dimitris Aragiorgis | |
735 | 4588b4bd | Dimitris Aragiorgis | class R_2_networks_name_disconnect(baserlib.OpcodeResource): |
736 | 4588b4bd | Dimitris Aragiorgis | """/2/network/[network_name]/disconnect.
|
737 | 4588b4bd | Dimitris Aragiorgis |
|
738 | 4588b4bd | Dimitris Aragiorgis | """
|
739 | 4588b4bd | Dimitris Aragiorgis | PUT_OPCODE = opcodes.OpNetworkDisconnect |
740 | 4588b4bd | Dimitris Aragiorgis | |
741 | 4588b4bd | Dimitris Aragiorgis | def GetPutOpInput(self): |
742 | 4588b4bd | Dimitris Aragiorgis | """Changes some parameters of node group.
|
743 | 4588b4bd | Dimitris Aragiorgis |
|
744 | 4588b4bd | Dimitris Aragiorgis | """
|
745 | 4588b4bd | Dimitris Aragiorgis | assert self.items |
746 | 4588b4bd | Dimitris Aragiorgis | return (self.request_body, { |
747 | 4588b4bd | Dimitris Aragiorgis | "network_name": self.items[0], |
748 | 4588b4bd | Dimitris Aragiorgis | }) |
749 | 4588b4bd | Dimitris Aragiorgis | |
750 | c91407bc | Michael Hanselmann | class R_2_groups(baserlib.OpcodeResource): |
751 | c91407bc | Michael Hanselmann | """/2/groups resource.
|
752 | 90e99856 | Adeodato Simo |
|
753 | 90e99856 | Adeodato Simo | """
|
754 | f6ce0ba2 | Michael Hanselmann | GET_OPCODE = opcodes.OpGroupQuery |
755 | c91407bc | Michael Hanselmann | POST_OPCODE = opcodes.OpGroupAdd |
756 | c91407bc | Michael Hanselmann | POST_RENAME = { |
757 | 527fbde8 | Michael Hanselmann | "name": "group_name", |
758 | 527fbde8 | Michael Hanselmann | } |
759 | 527fbde8 | Michael Hanselmann | |
760 | c91407bc | Michael Hanselmann | def GetPostOpInput(self): |
761 | c91407bc | Michael Hanselmann | """Create a node group.
|
762 | 90e99856 | Adeodato Simo |
|
763 | 4588b4bd | Dimitris Aragiorgis |
|
764 | c91407bc | Michael Hanselmann | """
|
765 | c91407bc | Michael Hanselmann | assert not self.items |
766 | c91407bc | Michael Hanselmann | return (self.request_body, { |
767 | c91407bc | Michael Hanselmann | "dry_run": self.dryRun(), |
768 | c91407bc | Michael Hanselmann | }) |
769 | 0897dc97 | Adeodato Simo | |
770 | 0897dc97 | Adeodato Simo | def GET(self): |
771 | 0897dc97 | Adeodato Simo | """Returns a list of all node groups.
|
772 | 0897dc97 | Adeodato Simo |
|
773 | 0897dc97 | Adeodato Simo | """
|
774 | 9fbf0098 | Iustin Pop | client = self.GetClient(query=True) |
775 | 0897dc97 | Adeodato Simo | |
776 | 0897dc97 | Adeodato Simo | if self.useBulk(): |
777 | 0897dc97 | Adeodato Simo | bulkdata = client.QueryGroups([], G_FIELDS, False)
|
778 | 0897dc97 | Adeodato Simo | return baserlib.MapBulkFields(bulkdata, G_FIELDS)
|
779 | 0897dc97 | Adeodato Simo | else:
|
780 | 0897dc97 | Adeodato Simo | data = client.QueryGroups([], ["name"], False) |
781 | 0897dc97 | Adeodato Simo | groupnames = [row[0] for row in data] |
782 | 0897dc97 | Adeodato Simo | return baserlib.BuildUriList(groupnames, "/2/groups/%s", |
783 | 0897dc97 | Adeodato Simo | uri_fields=("name", "uri")) |
784 | 0897dc97 | Adeodato Simo | |
785 | 0897dc97 | Adeodato Simo | |
786 | 86f1f5d4 | Michael Hanselmann | class R_2_groups_name(baserlib.OpcodeResource): |
787 | b58a4d16 | Michael Hanselmann | """/2/groups/[group_name] resource.
|
788 | 0897dc97 | Adeodato Simo |
|
789 | 0897dc97 | Adeodato Simo | """
|
790 | 86f1f5d4 | Michael Hanselmann | DELETE_OPCODE = opcodes.OpGroupRemove |
791 | 86f1f5d4 | Michael Hanselmann | |
792 | 0897dc97 | Adeodato Simo | def GET(self): |
793 | 0897dc97 | Adeodato Simo | """Send information about a node group.
|
794 | 0897dc97 | Adeodato Simo |
|
795 | 0897dc97 | Adeodato Simo | """
|
796 | 0897dc97 | Adeodato Simo | group_name = self.items[0] |
797 | 9fbf0098 | Iustin Pop | client = self.GetClient(query=True) |
798 | 0897dc97 | Adeodato Simo | |
799 | 0897dc97 | Adeodato Simo | result = baserlib.HandleItemQueryErrors(client.QueryGroups, |
800 | 0897dc97 | Adeodato Simo | names=[group_name], fields=G_FIELDS, |
801 | 0897dc97 | Adeodato Simo | use_locking=self.useLocking())
|
802 | 0897dc97 | Adeodato Simo | |
803 | 0897dc97 | Adeodato Simo | return baserlib.MapFields(G_FIELDS, result[0]) |
804 | 0897dc97 | Adeodato Simo | |
805 | 86f1f5d4 | Michael Hanselmann | def GetDeleteOpInput(self): |
806 | 0dbaa9ca | Adeodato Simo | """Delete a node group.
|
807 | 0dbaa9ca | Adeodato Simo |
|
808 | 0dbaa9ca | Adeodato Simo | """
|
809 | 86f1f5d4 | Michael Hanselmann | assert len(self.items) == 1 |
810 | 86f1f5d4 | Michael Hanselmann | return ({}, {
|
811 | 86f1f5d4 | Michael Hanselmann | "group_name": self.items[0], |
812 | 86f1f5d4 | Michael Hanselmann | "dry_run": self.dryRun(), |
813 | 86f1f5d4 | Michael Hanselmann | }) |
814 | 0dbaa9ca | Adeodato Simo | |
815 | 0dbaa9ca | Adeodato Simo | |
816 | d5211458 | Michael Hanselmann | class R_2_groups_name_modify(baserlib.OpcodeResource): |
817 | f18fab7d | Adeodato Simo | """/2/groups/[group_name]/modify resource.
|
818 | f18fab7d | Adeodato Simo |
|
819 | f18fab7d | Adeodato Simo | """
|
820 | d5211458 | Michael Hanselmann | PUT_OPCODE = opcodes.OpGroupSetParams |
821 | f18fab7d | Adeodato Simo | |
822 | d5211458 | Michael Hanselmann | def GetPutOpInput(self): |
823 | d5211458 | Michael Hanselmann | """Changes some parameters of node group.
|
824 | f18fab7d | Adeodato Simo |
|
825 | f18fab7d | Adeodato Simo | """
|
826 | d5211458 | Michael Hanselmann | assert self.items |
827 | d5211458 | Michael Hanselmann | return (self.request_body, { |
828 | d5211458 | Michael Hanselmann | "group_name": self.items[0], |
829 | d5211458 | Michael Hanselmann | }) |
830 | f18fab7d | Adeodato Simo | |
831 | f18fab7d | Adeodato Simo | |
832 | cd0d4d5a | Michael Hanselmann | class R_2_groups_name_rename(baserlib.OpcodeResource): |
833 | b58a4d16 | Michael Hanselmann | """/2/groups/[group_name]/rename resource.
|
834 | 0dbaa9ca | Adeodato Simo |
|
835 | 0dbaa9ca | Adeodato Simo | """
|
836 | cd0d4d5a | Michael Hanselmann | PUT_OPCODE = opcodes.OpGroupRename |
837 | 0dbaa9ca | Adeodato Simo | |
838 | cd0d4d5a | Michael Hanselmann | def GetPutOpInput(self): |
839 | cd0d4d5a | Michael Hanselmann | """Changes the name of a node group.
|
840 | 0dbaa9ca | Adeodato Simo |
|
841 | 0dbaa9ca | Adeodato Simo | """
|
842 | cd0d4d5a | Michael Hanselmann | assert len(self.items) == 1 |
843 | cd0d4d5a | Michael Hanselmann | return (self.request_body, { |
844 | cd0d4d5a | Michael Hanselmann | "group_name": self.items[0], |
845 | cd0d4d5a | Michael Hanselmann | "dry_run": self.dryRun(), |
846 | cd0d4d5a | Michael Hanselmann | }) |
847 | 0897dc97 | Adeodato Simo | |
848 | 0897dc97 | Adeodato Simo | |
849 | 87fd3ec7 | Michael Hanselmann | class R_2_groups_name_assign_nodes(baserlib.OpcodeResource): |
850 | b58a4d16 | Michael Hanselmann | """/2/groups/[group_name]/assign-nodes resource.
|
851 | 4245446f | Adeodato Simo |
|
852 | 4245446f | Adeodato Simo | """
|
853 | 87fd3ec7 | Michael Hanselmann | PUT_OPCODE = opcodes.OpGroupAssignNodes |
854 | 4245446f | Adeodato Simo | |
855 | 87fd3ec7 | Michael Hanselmann | def GetPutOpInput(self): |
856 | 87fd3ec7 | Michael Hanselmann | """Assigns nodes to a group.
|
857 | 4245446f | Adeodato Simo |
|
858 | 4245446f | Adeodato Simo | """
|
859 | 87fd3ec7 | Michael Hanselmann | assert len(self.items) == 1 |
860 | 87fd3ec7 | Michael Hanselmann | return (self.request_body, { |
861 | 4245446f | Adeodato Simo | "group_name": self.items[0], |
862 | 4245446f | Adeodato Simo | "dry_run": self.dryRun(), |
863 | 4245446f | Adeodato Simo | "force": self.useForce(), |
864 | 4245446f | Adeodato Simo | }) |
865 | 4245446f | Adeodato Simo | |
866 | 4245446f | Adeodato Simo | |
867 | 09a43b39 | Michael Hanselmann | class R_2_instances(baserlib.OpcodeResource): |
868 | 09a43b39 | Michael Hanselmann | """/2/instances resource.
|
869 | 6395cebb | Michael Hanselmann |
|
870 | 6395cebb | Michael Hanselmann | """
|
871 | f6ce0ba2 | Michael Hanselmann | GET_OPCODE = opcodes.OpInstanceQuery |
872 | 09a43b39 | Michael Hanselmann | POST_OPCODE = opcodes.OpInstanceCreate |
873 | 09a43b39 | Michael Hanselmann | POST_RENAME = { |
874 | 526a662a | Michael Hanselmann | "os": "os_type", |
875 | 526a662a | Michael Hanselmann | "name": "instance_name", |
876 | 526a662a | Michael Hanselmann | } |
877 | 526a662a | Michael Hanselmann | |
878 | 441e7cfd | Oleksiy Mishchenko | def GET(self): |
879 | 441e7cfd | Oleksiy Mishchenko | """Returns a list of all available instances.
|
880 | 441e7cfd | Oleksiy Mishchenko |
|
881 | 441e7cfd | Oleksiy Mishchenko | """
|
882 | be1ddd09 | Michael Hanselmann | client = self.GetClient()
|
883 | 441e7cfd | Oleksiy Mishchenko | |
884 | 3d103742 | Iustin Pop | use_locking = self.useLocking()
|
885 | 3d103742 | Iustin Pop | if self.useBulk(): |
886 | 3d103742 | Iustin Pop | bulkdata = client.QueryInstances([], I_FIELDS, use_locking) |
887 | 28a45bfc | René Nussbaumer | return map(_UpdateBeparams, baserlib.MapBulkFields(bulkdata, I_FIELDS)) |
888 | 441e7cfd | Oleksiy Mishchenko | else:
|
889 | 3d103742 | Iustin Pop | instancesdata = client.QueryInstances([], ["name"], use_locking)
|
890 | 9031ee8e | Iustin Pop | instanceslist = [row[0] for row in instancesdata] |
891 | 441e7cfd | Oleksiy Mishchenko | return baserlib.BuildUriList(instanceslist, "/2/instances/%s", |
892 | 441e7cfd | Oleksiy Mishchenko | uri_fields=("id", "uri")) |
893 | 441e7cfd | Oleksiy Mishchenko | |
894 | 09a43b39 | Michael Hanselmann | def GetPostOpInput(self): |
895 | d975f482 | Michael Hanselmann | """Create an instance.
|
896 | d975f482 | Michael Hanselmann |
|
897 | d975f482 | Michael Hanselmann | @return: a job id
|
898 | d975f482 | Michael Hanselmann |
|
899 | d975f482 | Michael Hanselmann | """
|
900 | 09a43b39 | Michael Hanselmann | baserlib.CheckType(self.request_body, dict, "Body contents") |
901 | d975f482 | Michael Hanselmann | |
902 | d975f482 | Michael Hanselmann | # Default to request data version 0
|
903 | d975f482 | Michael Hanselmann | data_version = self.getBodyParameter(_REQ_DATA_VERSION, 0) |
904 | d975f482 | Michael Hanselmann | |
905 | d975f482 | Michael Hanselmann | if data_version == 0: |
906 | 3fd7f652 | Michael Hanselmann | raise http.HttpBadRequest("Instance creation request version 0 is no" |
907 | 3fd7f652 | Michael Hanselmann | " longer supported")
|
908 | 09a43b39 | Michael Hanselmann | elif data_version != 1: |
909 | d975f482 | Michael Hanselmann | raise http.HttpBadRequest("Unsupported request data version %s" % |
910 | 12eff9b9 | Michael Hanselmann | data_version) |
911 | d975f482 | Michael Hanselmann | |
912 | 09a43b39 | Michael Hanselmann | data = self.request_body.copy()
|
913 | 09a43b39 | Michael Hanselmann | # Remove "__version__"
|
914 | 09a43b39 | Michael Hanselmann | data.pop(_REQ_DATA_VERSION, None)
|
915 | 09a43b39 | Michael Hanselmann | |
916 | 09a43b39 | Michael Hanselmann | return (data, {
|
917 | 09a43b39 | Michael Hanselmann | "dry_run": self.dryRun(), |
918 | 09a43b39 | Michael Hanselmann | }) |
919 | 2f7635f4 | Oleksiy Mishchenko | |
920 | 441e7cfd | Oleksiy Mishchenko | |
921 | 4ee72287 | René Nussbaumer | class R_2_instances_multi_alloc(baserlib.OpcodeResource): |
922 | 4ee72287 | René Nussbaumer | """/2/instances-multi-alloc resource.
|
923 | 4ee72287 | René Nussbaumer |
|
924 | 4ee72287 | René Nussbaumer | """
|
925 | 4ee72287 | René Nussbaumer | POST_OPCODE = opcodes.OpInstanceMultiAlloc |
926 | 4ee72287 | René Nussbaumer | |
927 | 4ee72287 | René Nussbaumer | def GetPostOpInput(self): |
928 | 4ee72287 | René Nussbaumer | """Try to allocate multiple instances.
|
929 | 4ee72287 | René Nussbaumer |
|
930 | 4ee72287 | René Nussbaumer | @return: A dict with submitted jobs, allocatable instances and failed
|
931 | 4ee72287 | René Nussbaumer | allocations
|
932 | 4ee72287 | René Nussbaumer |
|
933 | 4ee72287 | René Nussbaumer | """
|
934 | e5ff1a47 | René Nussbaumer | if "instances" not in self.request_body: |
935 | e5ff1a47 | René Nussbaumer | raise http.HttpBadRequest("Request is missing required 'instances' field" |
936 | e5ff1a47 | René Nussbaumer | " in body")
|
937 | e5ff1a47 | René Nussbaumer | |
938 | e5ff1a47 | René Nussbaumer | op_id = { |
939 | e5ff1a47 | René Nussbaumer | "OP_ID": self.POST_OPCODE.OP_ID, # pylint: disable=E1101 |
940 | e5ff1a47 | René Nussbaumer | } |
941 | e5ff1a47 | René Nussbaumer | body = objects.FillDict(self.request_body, {
|
942 | e5ff1a47 | René Nussbaumer | "instances": [objects.FillDict(inst, op_id)
|
943 | e5ff1a47 | René Nussbaumer | for inst in self.request_body["instances"]], |
944 | e5ff1a47 | René Nussbaumer | }) |
945 | e5ff1a47 | René Nussbaumer | |
946 | e5ff1a47 | René Nussbaumer | return (body, {
|
947 | 4ee72287 | René Nussbaumer | "dry_run": self.dryRun(), |
948 | 4ee72287 | René Nussbaumer | }) |
949 | 4ee72287 | René Nussbaumer | |
950 | 4ee72287 | René Nussbaumer | |
951 | a6fa7892 | Michael Hanselmann | class R_2_instances_name(baserlib.OpcodeResource): |
952 | b58a4d16 | Michael Hanselmann | """/2/instances/[instance_name] resource.
|
953 | 028c6b76 | Oleksiy Mishchenko |
|
954 | 028c6b76 | Oleksiy Mishchenko | """
|
955 | f6ce0ba2 | Michael Hanselmann | GET_OPCODE = opcodes.OpInstanceQuery |
956 | a6fa7892 | Michael Hanselmann | DELETE_OPCODE = opcodes.OpInstanceRemove |
957 | a6fa7892 | Michael Hanselmann | |
958 | 4e5a68f8 | Oleksiy Mishchenko | def GET(self): |
959 | 4e5a68f8 | Oleksiy Mishchenko | """Send information about an instance.
|
960 | 4e5a68f8 | Oleksiy Mishchenko |
|
961 | 4e5a68f8 | Oleksiy Mishchenko | """
|
962 | be1ddd09 | Michael Hanselmann | client = self.GetClient()
|
963 | 4e5a68f8 | Oleksiy Mishchenko | instance_name = self.items[0] |
964 | e8ebbd2b | Michael Hanselmann | |
965 | e8ebbd2b | Michael Hanselmann | result = baserlib.HandleItemQueryErrors(client.QueryInstances, |
966 | e8ebbd2b | Michael Hanselmann | names=[instance_name], |
967 | e8ebbd2b | Michael Hanselmann | fields=I_FIELDS, |
968 | e8ebbd2b | Michael Hanselmann | use_locking=self.useLocking())
|
969 | 4e5a68f8 | Oleksiy Mishchenko | |
970 | 28a45bfc | René Nussbaumer | return _UpdateBeparams(baserlib.MapFields(I_FIELDS, result[0])) |
971 | 028c6b76 | Oleksiy Mishchenko | |
972 | a6fa7892 | Michael Hanselmann | def GetDeleteOpInput(self): |
973 | 6e99c5a0 | Iustin Pop | """Delete an instance.
|
974 | 6e99c5a0 | Iustin Pop |
|
975 | 6e99c5a0 | Iustin Pop | """
|
976 | a6fa7892 | Michael Hanselmann | assert len(self.items) == 1 |
977 | a6fa7892 | Michael Hanselmann | return ({}, {
|
978 | a6fa7892 | Michael Hanselmann | "instance_name": self.items[0], |
979 | a6fa7892 | Michael Hanselmann | "ignore_failures": False, |
980 | a6fa7892 | Michael Hanselmann | "dry_run": self.dryRun(), |
981 | a6fa7892 | Michael Hanselmann | }) |
982 | 6e99c5a0 | Iustin Pop | |
983 | 028c6b76 | Oleksiy Mishchenko | |
984 | 7b3df961 | Michael Hanselmann | class R_2_instances_name_info(baserlib.OpcodeResource): |
985 | d8260842 | Michael Hanselmann | """/2/instances/[instance_name]/info resource.
|
986 | d8260842 | Michael Hanselmann |
|
987 | d8260842 | Michael Hanselmann | """
|
988 | 7b3df961 | Michael Hanselmann | GET_OPCODE = opcodes.OpInstanceQueryData |
989 | 7b3df961 | Michael Hanselmann | |
990 | 7b3df961 | Michael Hanselmann | def GetGetOpInput(self): |
991 | d8260842 | Michael Hanselmann | """Request detailed instance information.
|
992 | d8260842 | Michael Hanselmann |
|
993 | d8260842 | Michael Hanselmann | """
|
994 | 7b3df961 | Michael Hanselmann | assert len(self.items) == 1 |
995 | 7b3df961 | Michael Hanselmann | return ({}, {
|
996 | 7b3df961 | Michael Hanselmann | "instances": [self.items[0]], |
997 | 7b3df961 | Michael Hanselmann | "static": bool(self._checkIntVariable("static", default=0)), |
998 | 7b3df961 | Michael Hanselmann | }) |
999 | d8260842 | Michael Hanselmann | |
1000 | d8260842 | Michael Hanselmann | |
1001 | ac4888c1 | Michael Hanselmann | class R_2_instances_name_reboot(baserlib.OpcodeResource): |
1002 | 2276aa29 | Oleksiy Mishchenko | """/2/instances/[instance_name]/reboot resource.
|
1003 | 2276aa29 | Oleksiy Mishchenko |
|
1004 | 2276aa29 | Oleksiy Mishchenko | Implements an instance reboot.
|
1005 | 2276aa29 | Oleksiy Mishchenko |
|
1006 | 2276aa29 | Oleksiy Mishchenko | """
|
1007 | ac4888c1 | Michael Hanselmann | POST_OPCODE = opcodes.OpInstanceReboot |
1008 | ac4888c1 | Michael Hanselmann | |
1009 | ac4888c1 | Michael Hanselmann | def GetPostOpInput(self): |
1010 | 2276aa29 | Oleksiy Mishchenko | """Reboot an instance.
|
1011 | 2276aa29 | Oleksiy Mishchenko |
|
1012 | 0c55c24b | Oleksiy Mishchenko | The URI takes type=[hard|soft|full] and
|
1013 | 0c55c24b | Oleksiy Mishchenko | ignore_secondaries=[False|True] parameters.
|
1014 | 0c55c24b | Oleksiy Mishchenko |
|
1015 | 2276aa29 | Oleksiy Mishchenko | """
|
1016 | ac4888c1 | Michael Hanselmann | return ({}, {
|
1017 | ac4888c1 | Michael Hanselmann | "instance_name": self.items[0], |
1018 | ac4888c1 | Michael Hanselmann | "reboot_type":
|
1019 | ac4888c1 | Michael Hanselmann | self.queryargs.get("type", [constants.INSTANCE_REBOOT_HARD])[0], |
1020 | ac4888c1 | Michael Hanselmann | "ignore_secondaries": bool(self._checkIntVariable("ignore_secondaries")), |
1021 | ac4888c1 | Michael Hanselmann | "dry_run": self.dryRun(), |
1022 | ac4888c1 | Michael Hanselmann | }) |
1023 | 2276aa29 | Oleksiy Mishchenko | |
1024 | 2276aa29 | Oleksiy Mishchenko | |
1025 | 4717e6eb | Michael Hanselmann | class R_2_instances_name_startup(baserlib.OpcodeResource): |
1026 | 0c55c24b | Oleksiy Mishchenko | """/2/instances/[instance_name]/startup resource.
|
1027 | 0c55c24b | Oleksiy Mishchenko |
|
1028 | 0c55c24b | Oleksiy Mishchenko | Implements an instance startup.
|
1029 | 0c55c24b | Oleksiy Mishchenko |
|
1030 | 0c55c24b | Oleksiy Mishchenko | """
|
1031 | 4717e6eb | Michael Hanselmann | PUT_OPCODE = opcodes.OpInstanceStartup |
1032 | 4717e6eb | Michael Hanselmann | |
1033 | 4717e6eb | Michael Hanselmann | def GetPutOpInput(self): |
1034 | 0c55c24b | Oleksiy Mishchenko | """Startup an instance.
|
1035 | 0c55c24b | Oleksiy Mishchenko |
|
1036 | c41eea6e | Iustin Pop | The URI takes force=[False|True] parameter to start the instance
|
1037 | c41eea6e | Iustin Pop | if even if secondary disks are failing.
|
1038 | 0c55c24b | Oleksiy Mishchenko |
|
1039 | 0c55c24b | Oleksiy Mishchenko | """
|
1040 | 4717e6eb | Michael Hanselmann | return ({}, {
|
1041 | 4717e6eb | Michael Hanselmann | "instance_name": self.items[0], |
1042 | 4717e6eb | Michael Hanselmann | "force": self.useForce(), |
1043 | 4717e6eb | Michael Hanselmann | "dry_run": self.dryRun(), |
1044 | 4717e6eb | Michael Hanselmann | "no_remember": bool(self._checkIntVariable("no_remember")), |
1045 | 4717e6eb | Michael Hanselmann | }) |
1046 | 0c55c24b | Oleksiy Mishchenko | |
1047 | 0c55c24b | Oleksiy Mishchenko | |
1048 | 3175ade6 | Michael Hanselmann | class R_2_instances_name_shutdown(baserlib.OpcodeResource): |
1049 | 0c55c24b | Oleksiy Mishchenko | """/2/instances/[instance_name]/shutdown resource.
|
1050 | 0c55c24b | Oleksiy Mishchenko |
|
1051 | 0c55c24b | Oleksiy Mishchenko | Implements an instance shutdown.
|
1052 | 0c55c24b | Oleksiy Mishchenko |
|
1053 | 0c55c24b | Oleksiy Mishchenko | """
|
1054 | 3175ade6 | Michael Hanselmann | PUT_OPCODE = opcodes.OpInstanceShutdown |
1055 | 0c55c24b | Oleksiy Mishchenko | |
1056 | 3175ade6 | Michael Hanselmann | def GetPutOpInput(self): |
1057 | 3175ade6 | Michael Hanselmann | """Shutdown an instance.
|
1058 | 7fa310f6 | René Nussbaumer |
|
1059 | 0c55c24b | Oleksiy Mishchenko | """
|
1060 | 3175ade6 | Michael Hanselmann | return (self.request_body, { |
1061 | 3175ade6 | Michael Hanselmann | "instance_name": self.items[0], |
1062 | 3175ade6 | Michael Hanselmann | "no_remember": bool(self._checkIntVariable("no_remember")), |
1063 | 3175ade6 | Michael Hanselmann | "dry_run": self.dryRun(), |
1064 | 3175ade6 | Michael Hanselmann | }) |
1065 | 0c55c24b | Oleksiy Mishchenko | |
1066 | 0c55c24b | Oleksiy Mishchenko | |
1067 | c744425f | Michael Hanselmann | def _ParseInstanceReinstallRequest(name, data): |
1068 | c744425f | Michael Hanselmann | """Parses a request for reinstalling an instance.
|
1069 | c744425f | Michael Hanselmann |
|
1070 | c744425f | Michael Hanselmann | """
|
1071 | c744425f | Michael Hanselmann | if not isinstance(data, dict): |
1072 | c744425f | Michael Hanselmann | raise http.HttpBadRequest("Invalid body contents, not a dictionary") |
1073 | c744425f | Michael Hanselmann | |
1074 | bd0807fe | Guido Trotter | ostype = baserlib.CheckParameter(data, "os", default=None) |
1075 | c744425f | Michael Hanselmann | start = baserlib.CheckParameter(data, "start", exptype=bool, |
1076 | c744425f | Michael Hanselmann | default=True)
|
1077 | c744425f | Michael Hanselmann | osparams = baserlib.CheckParameter(data, "osparams", default=None) |
1078 | c744425f | Michael Hanselmann | |
1079 | c744425f | Michael Hanselmann | ops = [ |
1080 | ee3e37a7 | Iustin Pop | opcodes.OpInstanceShutdown(instance_name=name), |
1081 | 5073fd8f | Iustin Pop | opcodes.OpInstanceReinstall(instance_name=name, os_type=ostype, |
1082 | c744425f | Michael Hanselmann | osparams=osparams), |
1083 | c744425f | Michael Hanselmann | ] |
1084 | c744425f | Michael Hanselmann | |
1085 | c744425f | Michael Hanselmann | if start:
|
1086 | c873d91c | Iustin Pop | ops.append(opcodes.OpInstanceStartup(instance_name=name, force=False))
|
1087 | c744425f | Michael Hanselmann | |
1088 | c744425f | Michael Hanselmann | return ops
|
1089 | c744425f | Michael Hanselmann | |
1090 | c744425f | Michael Hanselmann | |
1091 | f6ce0ba2 | Michael Hanselmann | class R_2_instances_name_reinstall(baserlib.OpcodeResource): |
1092 | e5b7c4ca | Iustin Pop | """/2/instances/[instance_name]/reinstall resource.
|
1093 | e5b7c4ca | Iustin Pop |
|
1094 | e5b7c4ca | Iustin Pop | Implements an instance reinstall.
|
1095 | e5b7c4ca | Iustin Pop |
|
1096 | e5b7c4ca | Iustin Pop | """
|
1097 | f6ce0ba2 | Michael Hanselmann | POST_OPCODE = opcodes.OpInstanceReinstall |
1098 | f6ce0ba2 | Michael Hanselmann | |
1099 | e5b7c4ca | Iustin Pop | def POST(self): |
1100 | e5b7c4ca | Iustin Pop | """Reinstall an instance.
|
1101 | e5b7c4ca | Iustin Pop |
|
1102 | e5b7c4ca | Iustin Pop | The URI takes os=name and nostartup=[0|1] optional
|
1103 | e5b7c4ca | Iustin Pop | parameters. By default, the instance will be started
|
1104 | e5b7c4ca | Iustin Pop | automatically.
|
1105 | e5b7c4ca | Iustin Pop |
|
1106 | e5b7c4ca | Iustin Pop | """
|
1107 | c744425f | Michael Hanselmann | if self.request_body: |
1108 | c744425f | Michael Hanselmann | if self.queryargs: |
1109 | c744425f | Michael Hanselmann | raise http.HttpBadRequest("Can't combine query and body parameters") |
1110 | c744425f | Michael Hanselmann | |
1111 | c744425f | Michael Hanselmann | body = self.request_body
|
1112 | bd0807fe | Guido Trotter | elif self.queryargs: |
1113 | c744425f | Michael Hanselmann | # Legacy interface, do not modify/extend
|
1114 | c744425f | Michael Hanselmann | body = { |
1115 | c744425f | Michael Hanselmann | "os": self._checkStringVariable("os"), |
1116 | c744425f | Michael Hanselmann | "start": not self._checkIntVariable("nostartup"), |
1117 | c744425f | Michael Hanselmann | } |
1118 | bd0807fe | Guido Trotter | else:
|
1119 | bd0807fe | Guido Trotter | body = {} |
1120 | c744425f | Michael Hanselmann | |
1121 | c744425f | Michael Hanselmann | ops = _ParseInstanceReinstallRequest(self.items[0], body) |
1122 | c744425f | Michael Hanselmann | |
1123 | be1ddd09 | Michael Hanselmann | return self.SubmitJob(ops) |
1124 | e5b7c4ca | Iustin Pop | |
1125 | e5b7c4ca | Iustin Pop | |
1126 | 0dbc732c | Michael Hanselmann | class R_2_instances_name_replace_disks(baserlib.OpcodeResource): |
1127 | 4c98b915 | Michael Hanselmann | """/2/instances/[instance_name]/replace-disks resource.
|
1128 | 4c98b915 | Michael Hanselmann |
|
1129 | 4c98b915 | Michael Hanselmann | """
|
1130 | 0dbc732c | Michael Hanselmann | POST_OPCODE = opcodes.OpInstanceReplaceDisks |
1131 | 0dbc732c | Michael Hanselmann | |
1132 | 0dbc732c | Michael Hanselmann | def GetPostOpInput(self): |
1133 | 4c98b915 | Michael Hanselmann | """Replaces disks on an instance.
|
1134 | 4c98b915 | Michael Hanselmann |
|
1135 | 4c98b915 | Michael Hanselmann | """
|
1136 | 0dbc732c | Michael Hanselmann | static = { |
1137 | 0dbc732c | Michael Hanselmann | "instance_name": self.items[0], |
1138 | 0dbc732c | Michael Hanselmann | } |
1139 | 4c98b915 | Michael Hanselmann | |
1140 | 539d65ba | Michael Hanselmann | if self.request_body: |
1141 | 7dcf333d | Michael Hanselmann | data = self.request_body
|
1142 | 539d65ba | Michael Hanselmann | elif self.queryargs: |
1143 | 539d65ba | Michael Hanselmann | # Legacy interface, do not modify/extend
|
1144 | 7dcf333d | Michael Hanselmann | data = { |
1145 | 539d65ba | Michael Hanselmann | "remote_node": self._checkStringVariable("remote_node", default=None), |
1146 | 539d65ba | Michael Hanselmann | "mode": self._checkStringVariable("mode", default=None), |
1147 | 539d65ba | Michael Hanselmann | "disks": self._checkStringVariable("disks", default=None), |
1148 | 539d65ba | Michael Hanselmann | "iallocator": self._checkStringVariable("iallocator", default=None), |
1149 | 539d65ba | Michael Hanselmann | } |
1150 | 539d65ba | Michael Hanselmann | else:
|
1151 | 7dcf333d | Michael Hanselmann | data = {} |
1152 | 539d65ba | Michael Hanselmann | |
1153 | 0dbc732c | Michael Hanselmann | # Parse disks
|
1154 | 0dbc732c | Michael Hanselmann | try:
|
1155 | 7dcf333d | Michael Hanselmann | raw_disks = data.pop("disks")
|
1156 | 0dbc732c | Michael Hanselmann | except KeyError: |
1157 | 0dbc732c | Michael Hanselmann | pass
|
1158 | 0dbc732c | Michael Hanselmann | else:
|
1159 | 7dcf333d | Michael Hanselmann | if raw_disks:
|
1160 | 7dcf333d | Michael Hanselmann | if ht.TListOf(ht.TInt)(raw_disks): # pylint: disable=E1102 |
1161 | 7dcf333d | Michael Hanselmann | data["disks"] = raw_disks
|
1162 | 7dcf333d | Michael Hanselmann | else:
|
1163 | 7dcf333d | Michael Hanselmann | # Backwards compatibility for strings of the format "1, 2, 3"
|
1164 | 7dcf333d | Michael Hanselmann | try:
|
1165 | 7dcf333d | Michael Hanselmann | data["disks"] = [int(part) for part in raw_disks.split(",")] |
1166 | 7dcf333d | Michael Hanselmann | except (TypeError, ValueError), err: |
1167 | 7dcf333d | Michael Hanselmann | raise http.HttpBadRequest("Invalid disk index passed: %s" % err) |
1168 | 0dbc732c | Michael Hanselmann | |
1169 | 0dbc732c | Michael Hanselmann | return (data, static)
|
1170 | 4c98b915 | Michael Hanselmann | |
1171 | 4c98b915 | Michael Hanselmann | |
1172 | 1824a7a1 | Michael Hanselmann | class R_2_instances_name_activate_disks(baserlib.OpcodeResource): |
1173 | 2197b66f | René Nussbaumer | """/2/instances/[instance_name]/activate-disks resource.
|
1174 | 2197b66f | René Nussbaumer |
|
1175 | 2197b66f | René Nussbaumer | """
|
1176 | 1824a7a1 | Michael Hanselmann | PUT_OPCODE = opcodes.OpInstanceActivateDisks |
1177 | 1824a7a1 | Michael Hanselmann | |
1178 | 1824a7a1 | Michael Hanselmann | def GetPutOpInput(self): |
1179 | 2197b66f | René Nussbaumer | """Activate disks for an instance.
|
1180 | 2197b66f | René Nussbaumer |
|
1181 | 2197b66f | René Nussbaumer | The URI might contain ignore_size to ignore current recorded size.
|
1182 | 2197b66f | René Nussbaumer |
|
1183 | 2197b66f | René Nussbaumer | """
|
1184 | 1824a7a1 | Michael Hanselmann | return ({}, {
|
1185 | 1824a7a1 | Michael Hanselmann | "instance_name": self.items[0], |
1186 | 1824a7a1 | Michael Hanselmann | "ignore_size": bool(self._checkIntVariable("ignore_size")), |
1187 | 1824a7a1 | Michael Hanselmann | }) |
1188 | 2197b66f | René Nussbaumer | |
1189 | 2197b66f | René Nussbaumer | |
1190 | 973ec124 | Michael Hanselmann | class R_2_instances_name_deactivate_disks(baserlib.OpcodeResource): |
1191 | 0a37de5f | René Nussbaumer | """/2/instances/[instance_name]/deactivate-disks resource.
|
1192 | 0a37de5f | René Nussbaumer |
|
1193 | 0a37de5f | René Nussbaumer | """
|
1194 | 973ec124 | Michael Hanselmann | PUT_OPCODE = opcodes.OpInstanceDeactivateDisks |
1195 | 973ec124 | Michael Hanselmann | |
1196 | 973ec124 | Michael Hanselmann | def GetPutOpInput(self): |
1197 | 0a37de5f | René Nussbaumer | """Deactivate disks for an instance.
|
1198 | 0a37de5f | René Nussbaumer |
|
1199 | 0a37de5f | René Nussbaumer | """
|
1200 | 973ec124 | Michael Hanselmann | return ({}, {
|
1201 | 973ec124 | Michael Hanselmann | "instance_name": self.items[0], |
1202 | 973ec124 | Michael Hanselmann | }) |
1203 | 0a37de5f | René Nussbaumer | |
1204 | 0a37de5f | René Nussbaumer | |
1205 | a52978c7 | Michael Hanselmann | class R_2_instances_name_recreate_disks(baserlib.OpcodeResource): |
1206 | a52978c7 | Michael Hanselmann | """/2/instances/[instance_name]/recreate-disks resource.
|
1207 | a52978c7 | Michael Hanselmann |
|
1208 | a52978c7 | Michael Hanselmann | """
|
1209 | a52978c7 | Michael Hanselmann | POST_OPCODE = opcodes.OpInstanceRecreateDisks |
1210 | a52978c7 | Michael Hanselmann | |
1211 | a52978c7 | Michael Hanselmann | def GetPostOpInput(self): |
1212 | a52978c7 | Michael Hanselmann | """Recreate disks for an instance.
|
1213 | a52978c7 | Michael Hanselmann |
|
1214 | a52978c7 | Michael Hanselmann | """
|
1215 | a52978c7 | Michael Hanselmann | return ({}, {
|
1216 | a52978c7 | Michael Hanselmann | "instance_name": self.items[0], |
1217 | a52978c7 | Michael Hanselmann | }) |
1218 | a52978c7 | Michael Hanselmann | |
1219 | a52978c7 | Michael Hanselmann | |
1220 | 1c63311d | Michael Hanselmann | class R_2_instances_name_prepare_export(baserlib.OpcodeResource): |
1221 | ebeb600f | Michael Hanselmann | """/2/instances/[instance_name]/prepare-export resource.
|
1222 | ebeb600f | Michael Hanselmann |
|
1223 | ebeb600f | Michael Hanselmann | """
|
1224 | 1c63311d | Michael Hanselmann | PUT_OPCODE = opcodes.OpBackupPrepare |
1225 | ebeb600f | Michael Hanselmann | |
1226 | 1c63311d | Michael Hanselmann | def GetPutOpInput(self): |
1227 | 1c63311d | Michael Hanselmann | """Prepares an export for an instance.
|
1228 | ebeb600f | Michael Hanselmann |
|
1229 | ebeb600f | Michael Hanselmann | """
|
1230 | 1c63311d | Michael Hanselmann | return ({}, {
|
1231 | 1c63311d | Michael Hanselmann | "instance_name": self.items[0], |
1232 | 1c63311d | Michael Hanselmann | "mode": self._checkStringVariable("mode"), |
1233 | 1c63311d | Michael Hanselmann | }) |
1234 | ebeb600f | Michael Hanselmann | |
1235 | ebeb600f | Michael Hanselmann | |
1236 | 134afbe7 | Michael Hanselmann | class R_2_instances_name_export(baserlib.OpcodeResource): |
1237 | ebeb600f | Michael Hanselmann | """/2/instances/[instance_name]/export resource.
|
1238 | ebeb600f | Michael Hanselmann |
|
1239 | ebeb600f | Michael Hanselmann | """
|
1240 | 134afbe7 | Michael Hanselmann | PUT_OPCODE = opcodes.OpBackupExport |
1241 | 134afbe7 | Michael Hanselmann | PUT_RENAME = { |
1242 | 134afbe7 | Michael Hanselmann | "destination": "target_node", |
1243 | 134afbe7 | Michael Hanselmann | } |
1244 | ebeb600f | Michael Hanselmann | |
1245 | 134afbe7 | Michael Hanselmann | def GetPutOpInput(self): |
1246 | 134afbe7 | Michael Hanselmann | """Exports an instance.
|
1247 | ebeb600f | Michael Hanselmann |
|
1248 | ebeb600f | Michael Hanselmann | """
|
1249 | 134afbe7 | Michael Hanselmann | return (self.request_body, { |
1250 | 134afbe7 | Michael Hanselmann | "instance_name": self.items[0], |
1251 | 134afbe7 | Michael Hanselmann | }) |
1252 | ebeb600f | Michael Hanselmann | |
1253 | ebeb600f | Michael Hanselmann | |
1254 | 075a29be | Michael Hanselmann | class R_2_instances_name_migrate(baserlib.OpcodeResource): |
1255 | 5823e0d2 | Michael Hanselmann | """/2/instances/[instance_name]/migrate resource.
|
1256 | 5823e0d2 | Michael Hanselmann |
|
1257 | 5823e0d2 | Michael Hanselmann | """
|
1258 | 075a29be | Michael Hanselmann | PUT_OPCODE = opcodes.OpInstanceMigrate |
1259 | 5823e0d2 | Michael Hanselmann | |
1260 | 075a29be | Michael Hanselmann | def GetPutOpInput(self): |
1261 | 075a29be | Michael Hanselmann | """Migrates an instance.
|
1262 | 5823e0d2 | Michael Hanselmann |
|
1263 | 5823e0d2 | Michael Hanselmann | """
|
1264 | 075a29be | Michael Hanselmann | return (self.request_body, { |
1265 | 075a29be | Michael Hanselmann | "instance_name": self.items[0], |
1266 | 075a29be | Michael Hanselmann | }) |
1267 | 5823e0d2 | Michael Hanselmann | |
1268 | 5823e0d2 | Michael Hanselmann | |
1269 | b5f2ab80 | Michael Hanselmann | class R_2_instances_name_failover(baserlib.OpcodeResource): |
1270 | c0a146a1 | Michael Hanselmann | """/2/instances/[instance_name]/failover resource.
|
1271 | c0a146a1 | Michael Hanselmann |
|
1272 | c0a146a1 | Michael Hanselmann | """
|
1273 | b5f2ab80 | Michael Hanselmann | PUT_OPCODE = opcodes.OpInstanceFailover |
1274 | c0a146a1 | Michael Hanselmann | |
1275 | b5f2ab80 | Michael Hanselmann | def GetPutOpInput(self): |
1276 | b5f2ab80 | Michael Hanselmann | """Does a failover of an instance.
|
1277 | c0a146a1 | Michael Hanselmann |
|
1278 | c0a146a1 | Michael Hanselmann | """
|
1279 | b5f2ab80 | Michael Hanselmann | return (self.request_body, { |
1280 | c0a146a1 | Michael Hanselmann | "instance_name": self.items[0], |
1281 | c0a146a1 | Michael Hanselmann | }) |
1282 | c0a146a1 | Michael Hanselmann | |
1283 | c0a146a1 | Michael Hanselmann | |
1284 | d76f9b5d | Michael Hanselmann | class R_2_instances_name_rename(baserlib.OpcodeResource): |
1285 | d56e7dc7 | Michael Hanselmann | """/2/instances/[instance_name]/rename resource.
|
1286 | d56e7dc7 | Michael Hanselmann |
|
1287 | d56e7dc7 | Michael Hanselmann | """
|
1288 | d76f9b5d | Michael Hanselmann | PUT_OPCODE = opcodes.OpInstanceRename |
1289 | d56e7dc7 | Michael Hanselmann | |
1290 | d76f9b5d | Michael Hanselmann | def GetPutOpInput(self): |
1291 | d76f9b5d | Michael Hanselmann | """Changes the name of an instance.
|
1292 | d56e7dc7 | Michael Hanselmann |
|
1293 | d56e7dc7 | Michael Hanselmann | """
|
1294 | d76f9b5d | Michael Hanselmann | return (self.request_body, { |
1295 | d76f9b5d | Michael Hanselmann | "instance_name": self.items[0], |
1296 | d76f9b5d | Michael Hanselmann | }) |
1297 | d56e7dc7 | Michael Hanselmann | |
1298 | d56e7dc7 | Michael Hanselmann | |
1299 | f3db88ba | Michael Hanselmann | class R_2_instances_name_modify(baserlib.OpcodeResource): |
1300 | 3882937a | Michael Hanselmann | """/2/instances/[instance_name]/modify resource.
|
1301 | 3882937a | Michael Hanselmann |
|
1302 | 3882937a | Michael Hanselmann | """
|
1303 | f3db88ba | Michael Hanselmann | PUT_OPCODE = opcodes.OpInstanceSetParams |
1304 | 3882937a | Michael Hanselmann | |
1305 | f3db88ba | Michael Hanselmann | def GetPutOpInput(self): |
1306 | f3db88ba | Michael Hanselmann | """Changes parameters of an instance.
|
1307 | 3882937a | Michael Hanselmann |
|
1308 | 3882937a | Michael Hanselmann | """
|
1309 | f3db88ba | Michael Hanselmann | return (self.request_body, { |
1310 | f3db88ba | Michael Hanselmann | "instance_name": self.items[0], |
1311 | f3db88ba | Michael Hanselmann | }) |
1312 | 3882937a | Michael Hanselmann | |
1313 | 3882937a | Michael Hanselmann | |
1314 | 335965b9 | Michael Hanselmann | class R_2_instances_name_disk_grow(baserlib.OpcodeResource): |
1315 | b58a4d16 | Michael Hanselmann | """/2/instances/[instance_name]/disk/[disk_index]/grow resource.
|
1316 | e23881ed | Michael Hanselmann |
|
1317 | e23881ed | Michael Hanselmann | """
|
1318 | 335965b9 | Michael Hanselmann | POST_OPCODE = opcodes.OpInstanceGrowDisk |
1319 | e23881ed | Michael Hanselmann | |
1320 | 335965b9 | Michael Hanselmann | def GetPostOpInput(self): |
1321 | 335965b9 | Michael Hanselmann | """Increases the size of an instance disk.
|
1322 | e23881ed | Michael Hanselmann |
|
1323 | e23881ed | Michael Hanselmann | """
|
1324 | 335965b9 | Michael Hanselmann | return (self.request_body, { |
1325 | e23881ed | Michael Hanselmann | "instance_name": self.items[0], |
1326 | e23881ed | Michael Hanselmann | "disk": int(self.items[1]), |
1327 | e23881ed | Michael Hanselmann | }) |
1328 | e23881ed | Michael Hanselmann | |
1329 | e23881ed | Michael Hanselmann | |
1330 | 26ff6ee2 | Michael Hanselmann | class R_2_instances_name_console(baserlib.ResourceBase): |
1331 | b82d4c5e | Michael Hanselmann | """/2/instances/[instance_name]/console resource.
|
1332 | b82d4c5e | Michael Hanselmann |
|
1333 | b82d4c5e | Michael Hanselmann | """
|
1334 | 5e12acfe | Michael Hanselmann | GET_ACCESS = [rapi.RAPI_ACCESS_WRITE, rapi.RAPI_ACCESS_READ] |
1335 | f6ce0ba2 | Michael Hanselmann | GET_OPCODE = opcodes.OpInstanceConsole |
1336 | b82d4c5e | Michael Hanselmann | |
1337 | b82d4c5e | Michael Hanselmann | def GET(self): |
1338 | b82d4c5e | Michael Hanselmann | """Request information for connecting to instance's console.
|
1339 | b82d4c5e | Michael Hanselmann |
|
1340 | b82d4c5e | Michael Hanselmann | @return: Serialized instance console description, see
|
1341 | b82d4c5e | Michael Hanselmann | L{objects.InstanceConsole}
|
1342 | b82d4c5e | Michael Hanselmann |
|
1343 | b82d4c5e | Michael Hanselmann | """
|
1344 | be1ddd09 | Michael Hanselmann | client = self.GetClient()
|
1345 | b82d4c5e | Michael Hanselmann | |
1346 | b82d4c5e | Michael Hanselmann | ((console, ), ) = client.QueryInstances([self.items[0]], ["console"], False) |
1347 | b82d4c5e | Michael Hanselmann | |
1348 | b82d4c5e | Michael Hanselmann | if console is None: |
1349 | b82d4c5e | Michael Hanselmann | raise http.HttpServiceUnavailable("Instance console unavailable") |
1350 | b82d4c5e | Michael Hanselmann | |
1351 | b82d4c5e | Michael Hanselmann | assert isinstance(console, dict) |
1352 | b82d4c5e | Michael Hanselmann | return console
|
1353 | b82d4c5e | Michael Hanselmann | |
1354 | b82d4c5e | Michael Hanselmann | |
1355 | 208a6cff | Michael Hanselmann | def _GetQueryFields(args): |
1356 | 2a38e913 | Michael Hanselmann | """Tries to extract C{fields} query parameter.
|
1357 | 2a38e913 | Michael Hanselmann |
|
1358 | 2a38e913 | Michael Hanselmann | @type args: dictionary
|
1359 | 2a38e913 | Michael Hanselmann | @rtype: list of string
|
1360 | 2a38e913 | Michael Hanselmann | @raise http.HttpBadRequest: When parameter can't be found
|
1361 | 208a6cff | Michael Hanselmann |
|
1362 | 208a6cff | Michael Hanselmann | """
|
1363 | 208a6cff | Michael Hanselmann | try:
|
1364 | 208a6cff | Michael Hanselmann | fields = args["fields"]
|
1365 | 208a6cff | Michael Hanselmann | except KeyError: |
1366 | 208a6cff | Michael Hanselmann | raise http.HttpBadRequest("Missing 'fields' query argument") |
1367 | 208a6cff | Michael Hanselmann | |
1368 | 208a6cff | Michael Hanselmann | return _SplitQueryFields(fields[0]) |
1369 | 208a6cff | Michael Hanselmann | |
1370 | 208a6cff | Michael Hanselmann | |
1371 | 208a6cff | Michael Hanselmann | def _SplitQueryFields(fields): |
1372 | 2a38e913 | Michael Hanselmann | """Splits fields as given for a query request.
|
1373 | 2a38e913 | Michael Hanselmann |
|
1374 | 2a38e913 | Michael Hanselmann | @type fields: string
|
1375 | 2a38e913 | Michael Hanselmann | @rtype: list of string
|
1376 | 208a6cff | Michael Hanselmann |
|
1377 | 208a6cff | Michael Hanselmann | """
|
1378 | 208a6cff | Michael Hanselmann | return [i.strip() for i in fields.split(",")] |
1379 | 208a6cff | Michael Hanselmann | |
1380 | 208a6cff | Michael Hanselmann | |
1381 | 26ff6ee2 | Michael Hanselmann | class R_2_query(baserlib.ResourceBase): |
1382 | 208a6cff | Michael Hanselmann | """/2/query/[resource] resource.
|
1383 | 208a6cff | Michael Hanselmann |
|
1384 | 208a6cff | Michael Hanselmann | """
|
1385 | 208a6cff | Michael Hanselmann | # Results might contain sensitive information
|
1386 | 5e12acfe | Michael Hanselmann | GET_ACCESS = [rapi.RAPI_ACCESS_WRITE, rapi.RAPI_ACCESS_READ] |
1387 | 5e12acfe | Michael Hanselmann | PUT_ACCESS = GET_ACCESS |
1388 | f6ce0ba2 | Michael Hanselmann | GET_OPCODE = opcodes.OpQuery |
1389 | f6ce0ba2 | Michael Hanselmann | PUT_OPCODE = opcodes.OpQuery |
1390 | 208a6cff | Michael Hanselmann | |
1391 | 2e5c33db | Iustin Pop | def _Query(self, fields, qfilter): |
1392 | 2e5c33db | Iustin Pop | return self.GetClient().Query(self.items[0], fields, qfilter).ToDict() |
1393 | 208a6cff | Michael Hanselmann | |
1394 | 208a6cff | Michael Hanselmann | def GET(self): |
1395 | 208a6cff | Michael Hanselmann | """Returns resource information.
|
1396 | 208a6cff | Michael Hanselmann |
|
1397 | 208a6cff | Michael Hanselmann | @return: Query result, see L{objects.QueryResponse}
|
1398 | 208a6cff | Michael Hanselmann |
|
1399 | 208a6cff | Michael Hanselmann | """
|
1400 | 208a6cff | Michael Hanselmann | return self._Query(_GetQueryFields(self.queryargs), None) |
1401 | 208a6cff | Michael Hanselmann | |
1402 | 208a6cff | Michael Hanselmann | def PUT(self): |
1403 | 208a6cff | Michael Hanselmann | """Submits job querying for resources.
|
1404 | 208a6cff | Michael Hanselmann |
|
1405 | 208a6cff | Michael Hanselmann | @return: Query result, see L{objects.QueryResponse}
|
1406 | 208a6cff | Michael Hanselmann |
|
1407 | 208a6cff | Michael Hanselmann | """
|
1408 | 208a6cff | Michael Hanselmann | body = self.request_body
|
1409 | 208a6cff | Michael Hanselmann | |
1410 | 208a6cff | Michael Hanselmann | baserlib.CheckType(body, dict, "Body contents") |
1411 | 208a6cff | Michael Hanselmann | |
1412 | 208a6cff | Michael Hanselmann | try:
|
1413 | 208a6cff | Michael Hanselmann | fields = body["fields"]
|
1414 | 208a6cff | Michael Hanselmann | except KeyError: |
1415 | 208a6cff | Michael Hanselmann | fields = _GetQueryFields(self.queryargs)
|
1416 | 208a6cff | Michael Hanselmann | |
1417 | 2e5c33db | Iustin Pop | qfilter = body.get("qfilter", None) |
1418 | 2e5c33db | Iustin Pop | # TODO: remove this after 2.7
|
1419 | 2e5c33db | Iustin Pop | if qfilter is None: |
1420 | 2e5c33db | Iustin Pop | qfilter = body.get("filter", None) |
1421 | 2e5c33db | Iustin Pop | |
1422 | 2e5c33db | Iustin Pop | return self._Query(fields, qfilter) |
1423 | 208a6cff | Michael Hanselmann | |
1424 | 208a6cff | Michael Hanselmann | |
1425 | 26ff6ee2 | Michael Hanselmann | class R_2_query_fields(baserlib.ResourceBase): |
1426 | 208a6cff | Michael Hanselmann | """/2/query/[resource]/fields resource.
|
1427 | 208a6cff | Michael Hanselmann |
|
1428 | 208a6cff | Michael Hanselmann | """
|
1429 | f6ce0ba2 | Michael Hanselmann | GET_OPCODE = opcodes.OpQueryFields |
1430 | f6ce0ba2 | Michael Hanselmann | |
1431 | 208a6cff | Michael Hanselmann | def GET(self): |
1432 | 208a6cff | Michael Hanselmann | """Retrieves list of available fields for a resource.
|
1433 | 208a6cff | Michael Hanselmann |
|
1434 | 208a6cff | Michael Hanselmann | @return: List of serialized L{objects.QueryFieldDefinition}
|
1435 | 208a6cff | Michael Hanselmann |
|
1436 | 208a6cff | Michael Hanselmann | """
|
1437 | 208a6cff | Michael Hanselmann | try:
|
1438 | 208a6cff | Michael Hanselmann | raw_fields = self.queryargs["fields"] |
1439 | 208a6cff | Michael Hanselmann | except KeyError: |
1440 | 208a6cff | Michael Hanselmann | fields = None
|
1441 | 208a6cff | Michael Hanselmann | else:
|
1442 | 208a6cff | Michael Hanselmann | fields = _SplitQueryFields(raw_fields[0])
|
1443 | 208a6cff | Michael Hanselmann | |
1444 | be1ddd09 | Michael Hanselmann | return self.GetClient().QueryFields(self.items[0], fields).ToDict() |
1445 | 208a6cff | Michael Hanselmann | |
1446 | 208a6cff | Michael Hanselmann | |
1447 | 460ef073 | Michael Hanselmann | class _R_Tags(baserlib.OpcodeResource): |
1448 | 3bd0f3d8 | Iustin Pop | """Quasiclass for tagging resources.
|
1449 | 441e7cfd | Oleksiy Mishchenko |
|
1450 | c8e0a534 | Iustin Pop | Manages tags. When inheriting this class you must define the
|
1451 | 18cb43a2 | Oleksiy Mishchenko | TAG_LEVEL for it.
|
1452 | 441e7cfd | Oleksiy Mishchenko |
|
1453 | 441e7cfd | Oleksiy Mishchenko | """
|
1454 | 7a6b9510 | Iustin Pop | TAG_LEVEL = None
|
1455 | f6ce0ba2 | Michael Hanselmann | GET_OPCODE = opcodes.OpTagsGet |
1456 | 460ef073 | Michael Hanselmann | PUT_OPCODE = opcodes.OpTagsSet |
1457 | 460ef073 | Michael Hanselmann | DELETE_OPCODE = opcodes.OpTagsDel |
1458 | 18cb43a2 | Oleksiy Mishchenko | |
1459 | 460ef073 | Michael Hanselmann | def __init__(self, items, queryargs, req, **kwargs): |
1460 | 18cb43a2 | Oleksiy Mishchenko | """A tag resource constructor.
|
1461 | 18cb43a2 | Oleksiy Mishchenko |
|
1462 | 18cb43a2 | Oleksiy Mishchenko | We have to override the default to sort out cluster naming case.
|
1463 | 18cb43a2 | Oleksiy Mishchenko |
|
1464 | 18cb43a2 | Oleksiy Mishchenko | """
|
1465 | 460ef073 | Michael Hanselmann | baserlib.OpcodeResource.__init__(self, items, queryargs, req, **kwargs)
|
1466 | 18cb43a2 | Oleksiy Mishchenko | |
1467 | 5313eed7 | Michael Hanselmann | if self.TAG_LEVEL == constants.TAG_CLUSTER: |
1468 | 5313eed7 | Michael Hanselmann | self.name = None |
1469 | 18cb43a2 | Oleksiy Mishchenko | else:
|
1470 | 5313eed7 | Michael Hanselmann | self.name = items[0] |
1471 | 441e7cfd | Oleksiy Mishchenko | |
1472 | 441e7cfd | Oleksiy Mishchenko | def GET(self): |
1473 | 18cb43a2 | Oleksiy Mishchenko | """Returns a list of tags.
|
1474 | 441e7cfd | Oleksiy Mishchenko |
|
1475 | 441e7cfd | Oleksiy Mishchenko | Example: ["tag1", "tag2", "tag3"]
|
1476 | 441e7cfd | Oleksiy Mishchenko |
|
1477 | 441e7cfd | Oleksiy Mishchenko | """
|
1478 | f87ec53f | Michael Hanselmann | kind = self.TAG_LEVEL
|
1479 | f87ec53f | Michael Hanselmann | |
1480 | f87ec53f | Michael Hanselmann | if kind in (constants.TAG_INSTANCE, |
1481 | f87ec53f | Michael Hanselmann | constants.TAG_NODEGROUP, |
1482 | f87ec53f | Michael Hanselmann | constants.TAG_NODE): |
1483 | f87ec53f | Michael Hanselmann | if not self.name: |
1484 | f87ec53f | Michael Hanselmann | raise http.HttpBadRequest("Missing name on tag request") |
1485 | f87ec53f | Michael Hanselmann | |
1486 | f2374060 | Iustin Pop | cl = self.GetClient(query=True) |
1487 | cebd85d8 | Iustin Pop | tags = list(cl.QueryTags(kind, self.name)) |
1488 | f87ec53f | Michael Hanselmann | |
1489 | f87ec53f | Michael Hanselmann | elif kind == constants.TAG_CLUSTER:
|
1490 | f87ec53f | Michael Hanselmann | assert not self.name |
1491 | f87ec53f | Michael Hanselmann | # TODO: Use query API?
|
1492 | f87ec53f | Michael Hanselmann | ssc = ssconf.SimpleStore() |
1493 | f87ec53f | Michael Hanselmann | tags = ssc.GetClusterTags() |
1494 | f87ec53f | Michael Hanselmann | |
1495 | f87ec53f | Michael Hanselmann | return list(tags) |
1496 | 441e7cfd | Oleksiy Mishchenko | |
1497 | 460ef073 | Michael Hanselmann | def GetPutOpInput(self): |
1498 | 18cb43a2 | Oleksiy Mishchenko | """Add a set of tags.
|
1499 | 441e7cfd | Oleksiy Mishchenko |
|
1500 | c41eea6e | Iustin Pop | The request as a list of strings should be PUT to this URI. And
|
1501 | c41eea6e | Iustin Pop | you'll have back a job id.
|
1502 | 441e7cfd | Oleksiy Mishchenko |
|
1503 | 441e7cfd | Oleksiy Mishchenko | """
|
1504 | 460ef073 | Michael Hanselmann | return ({}, {
|
1505 | 460ef073 | Michael Hanselmann | "kind": self.TAG_LEVEL, |
1506 | 460ef073 | Michael Hanselmann | "name": self.name, |
1507 | 460ef073 | Michael Hanselmann | "tags": self.queryargs.get("tag", []), |
1508 | 460ef073 | Michael Hanselmann | "dry_run": self.dryRun(), |
1509 | 460ef073 | Michael Hanselmann | }) |
1510 | 15fd9fd5 | Oleksiy Mishchenko | |
1511 | 460ef073 | Michael Hanselmann | def GetDeleteOpInput(self): |
1512 | 15fd9fd5 | Oleksiy Mishchenko | """Delete a tag.
|
1513 | 15fd9fd5 | Oleksiy Mishchenko |
|
1514 | 18cb43a2 | Oleksiy Mishchenko | In order to delete a set of tags, the DELETE
|
1515 | c41eea6e | Iustin Pop | request should be addressed to URI like:
|
1516 | 18cb43a2 | Oleksiy Mishchenko | /tags?tag=[tag]&tag=[tag]
|
1517 | 15fd9fd5 | Oleksiy Mishchenko |
|
1518 | 15fd9fd5 | Oleksiy Mishchenko | """
|
1519 | 460ef073 | Michael Hanselmann | # Re-use code
|
1520 | 460ef073 | Michael Hanselmann | return self.GetPutOpInput() |
1521 | 18cb43a2 | Oleksiy Mishchenko | |
1522 | 18cb43a2 | Oleksiy Mishchenko | |
1523 | 18cb43a2 | Oleksiy Mishchenko | class R_2_instances_name_tags(_R_Tags): |
1524 | 18cb43a2 | Oleksiy Mishchenko | """ /2/instances/[instance_name]/tags resource.
|
1525 | 18cb43a2 | Oleksiy Mishchenko |
|
1526 | 18cb43a2 | Oleksiy Mishchenko | Manages per-instance tags.
|
1527 | 18cb43a2 | Oleksiy Mishchenko |
|
1528 | 18cb43a2 | Oleksiy Mishchenko | """
|
1529 | 18cb43a2 | Oleksiy Mishchenko | TAG_LEVEL = constants.TAG_INSTANCE |
1530 | 18cb43a2 | Oleksiy Mishchenko | |
1531 | 18cb43a2 | Oleksiy Mishchenko | |
1532 | 18cb43a2 | Oleksiy Mishchenko | class R_2_nodes_name_tags(_R_Tags): |
1533 | 18cb43a2 | Oleksiy Mishchenko | """ /2/nodes/[node_name]/tags resource.
|
1534 | 18cb43a2 | Oleksiy Mishchenko |
|
1535 | 18cb43a2 | Oleksiy Mishchenko | Manages per-node tags.
|
1536 | 18cb43a2 | Oleksiy Mishchenko |
|
1537 | 18cb43a2 | Oleksiy Mishchenko | """
|
1538 | 18cb43a2 | Oleksiy Mishchenko | TAG_LEVEL = constants.TAG_NODE |
1539 | 18cb43a2 | Oleksiy Mishchenko | |
1540 | 18cb43a2 | Oleksiy Mishchenko | |
1541 | 414ebaf1 | Michael Hanselmann | class R_2_groups_name_tags(_R_Tags): |
1542 | 414ebaf1 | Michael Hanselmann | """ /2/groups/[group_name]/tags resource.
|
1543 | 414ebaf1 | Michael Hanselmann |
|
1544 | 414ebaf1 | Michael Hanselmann | Manages per-nodegroup tags.
|
1545 | 414ebaf1 | Michael Hanselmann |
|
1546 | 414ebaf1 | Michael Hanselmann | """
|
1547 | 414ebaf1 | Michael Hanselmann | TAG_LEVEL = constants.TAG_NODEGROUP |
1548 | 414ebaf1 | Michael Hanselmann | |
1549 | 414ebaf1 | Michael Hanselmann | |
1550 | 18cb43a2 | Oleksiy Mishchenko | class R_2_tags(_R_Tags): |
1551 | b58a4d16 | Michael Hanselmann | """ /2/tags resource.
|
1552 | 18cb43a2 | Oleksiy Mishchenko |
|
1553 | 18cb43a2 | Oleksiy Mishchenko | Manages cluster tags.
|
1554 | 18cb43a2 | Oleksiy Mishchenko |
|
1555 | 18cb43a2 | Oleksiy Mishchenko | """
|
1556 | 18cb43a2 | Oleksiy Mishchenko | TAG_LEVEL = constants.TAG_CLUSTER |