root / lib / rapi / rlib1.py @ 5bf7b5cf
History | View | Annotate | Download (7.5 kB)
1 | 8c229cc7 | Oleksiy Mishchenko | #
|
---|---|---|---|
2 | 8c229cc7 | Oleksiy Mishchenko | #
|
3 | 8c229cc7 | Oleksiy Mishchenko | |
4 | 8c229cc7 | Oleksiy Mishchenko | # Copyright (C) 2006, 2007, 2008 Google Inc.
|
5 | 8c229cc7 | Oleksiy Mishchenko | #
|
6 | 8c229cc7 | Oleksiy Mishchenko | # This program is free software; you can redistribute it and/or modify
|
7 | 8c229cc7 | Oleksiy Mishchenko | # it under the terms of the GNU General Public License as published by
|
8 | 8c229cc7 | Oleksiy Mishchenko | # the Free Software Foundation; either version 2 of the License, or
|
9 | 8c229cc7 | Oleksiy Mishchenko | # (at your option) any later version.
|
10 | 8c229cc7 | Oleksiy Mishchenko | #
|
11 | 8c229cc7 | Oleksiy Mishchenko | # This program is distributed in the hope that it will be useful, but
|
12 | 8c229cc7 | Oleksiy Mishchenko | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 8c229cc7 | Oleksiy Mishchenko | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | 8c229cc7 | Oleksiy Mishchenko | # General Public License for more details.
|
15 | 8c229cc7 | Oleksiy Mishchenko | #
|
16 | 8c229cc7 | Oleksiy Mishchenko | # You should have received a copy of the GNU General Public License
|
17 | 8c229cc7 | Oleksiy Mishchenko | # along with this program; if not, write to the Free Software
|
18 | 8c229cc7 | Oleksiy Mishchenko | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
19 | 8c229cc7 | Oleksiy Mishchenko | # 02110-1301, USA.
|
20 | 8c229cc7 | Oleksiy Mishchenko | |
21 | 8c229cc7 | Oleksiy Mishchenko | |
22 | 10b207d4 | Oleksiy Mishchenko | """Remote API version 1 resources library.
|
23 | 8c229cc7 | Oleksiy Mishchenko |
|
24 | 8c229cc7 | Oleksiy Mishchenko | """
|
25 | 8c229cc7 | Oleksiy Mishchenko | |
26 | 8c229cc7 | Oleksiy Mishchenko | import ganeti.cli |
27 | 10b207d4 | Oleksiy Mishchenko | import ganeti.errors |
28 | 10b207d4 | Oleksiy Mishchenko | import ganeti.opcodes |
29 | 8c229cc7 | Oleksiy Mishchenko | |
30 | 8c229cc7 | Oleksiy Mishchenko | from ganeti import constants |
31 | 8c229cc7 | Oleksiy Mishchenko | |
32 | 38206f3c | Iustin Pop | from ganeti.rapi import baserlib |
33 | 38206f3c | Iustin Pop | from ganeti.rapi import httperror |
34 | 8c229cc7 | Oleksiy Mishchenko | |
35 | 8c229cc7 | Oleksiy Mishchenko | |
36 | 51ee2f49 | Oleksiy Mishchenko | I_FIELDS = ["name", "os", "pnode", "snodes", |
37 | 51ee2f49 | Oleksiy Mishchenko | "admin_state", "admin_ram", |
38 | 51ee2f49 | Oleksiy Mishchenko | "disk_template", "ip", "mac", "bridge", |
39 | 51ee2f49 | Oleksiy Mishchenko | "sda_size", "sdb_size", "vcpus", |
40 | 51ee2f49 | Oleksiy Mishchenko | "oper_state", "status", "tags"] |
41 | 51ee2f49 | Oleksiy Mishchenko | |
42 | 38206f3c | Iustin Pop | N_FIELDS = ["name", "dtotal", "dfree", |
43 | 51ee2f49 | Oleksiy Mishchenko | "mtotal", "mnode", "mfree", |
44 | 51ee2f49 | Oleksiy Mishchenko | "pinst_cnt", "sinst_cnt", "tags"] |
45 | 51ee2f49 | Oleksiy Mishchenko | |
46 | 51ee2f49 | Oleksiy Mishchenko | |
47 | 10b207d4 | Oleksiy Mishchenko | class R_version(baserlib.R_Generic): |
48 | 8c229cc7 | Oleksiy Mishchenko | """/version resource.
|
49 | 8c229cc7 | Oleksiy Mishchenko |
|
50 | 8c229cc7 | Oleksiy Mishchenko | This resource should be used to determine the remote API version and to adapt
|
51 | 8c229cc7 | Oleksiy Mishchenko | clients accordingly.
|
52 | 8c229cc7 | Oleksiy Mishchenko |
|
53 | 8c229cc7 | Oleksiy Mishchenko | """
|
54 | 8c229cc7 | Oleksiy Mishchenko | DOC_URI = "/version"
|
55 | 8c229cc7 | Oleksiy Mishchenko | |
56 | 8c229cc7 | Oleksiy Mishchenko | def GET(self): |
57 | 8c229cc7 | Oleksiy Mishchenko | """Returns the remote API version.
|
58 | 8c229cc7 | Oleksiy Mishchenko |
|
59 | 8c229cc7 | Oleksiy Mishchenko | """
|
60 | 8c229cc7 | Oleksiy Mishchenko | return constants.RAPI_VERSION
|
61 | 8c229cc7 | Oleksiy Mishchenko | |
62 | 8c229cc7 | Oleksiy Mishchenko | |
63 | 10b207d4 | Oleksiy Mishchenko | class R_tags(baserlib.R_Generic): |
64 | 8c229cc7 | Oleksiy Mishchenko | """/tags resource.
|
65 | 8c229cc7 | Oleksiy Mishchenko |
|
66 | 8c229cc7 | Oleksiy Mishchenko | Manages cluster tags.
|
67 | 8c229cc7 | Oleksiy Mishchenko |
|
68 | 8c229cc7 | Oleksiy Mishchenko | """
|
69 | 8c229cc7 | Oleksiy Mishchenko | DOC_URI = "/tags"
|
70 | 8c229cc7 | Oleksiy Mishchenko | |
71 | 8c229cc7 | Oleksiy Mishchenko | def GET(self): |
72 | 8c229cc7 | Oleksiy Mishchenko | """Returns a list of all cluster tags.
|
73 | 8c229cc7 | Oleksiy Mishchenko |
|
74 | 8c229cc7 | Oleksiy Mishchenko | Example: ["tag1", "tag2", "tag3"]
|
75 | 8c229cc7 | Oleksiy Mishchenko |
|
76 | 8c229cc7 | Oleksiy Mishchenko | """
|
77 | 10b207d4 | Oleksiy Mishchenko | return baserlib._Tags_GET(constants.TAG_CLUSTER)
|
78 | 8c229cc7 | Oleksiy Mishchenko | |
79 | 8c229cc7 | Oleksiy Mishchenko | |
80 | 10b207d4 | Oleksiy Mishchenko | class R_info(baserlib.R_Generic): |
81 | 8c229cc7 | Oleksiy Mishchenko | """Cluster info.
|
82 | 8c229cc7 | Oleksiy Mishchenko |
|
83 | 8c229cc7 | Oleksiy Mishchenko | """
|
84 | 8c229cc7 | Oleksiy Mishchenko | DOC_URI = "/info"
|
85 | 8c229cc7 | Oleksiy Mishchenko | |
86 | 8c229cc7 | Oleksiy Mishchenko | def GET(self): |
87 | 8c229cc7 | Oleksiy Mishchenko | """Returns cluster information.
|
88 | 8c229cc7 | Oleksiy Mishchenko |
|
89 | 8c229cc7 | Oleksiy Mishchenko | Example: {
|
90 | 8c229cc7 | Oleksiy Mishchenko | "config_version": 3,
|
91 | 8c229cc7 | Oleksiy Mishchenko | "name": "cluster1.example.com",
|
92 | 8c229cc7 | Oleksiy Mishchenko | "software_version": "1.2.4",
|
93 | 8c229cc7 | Oleksiy Mishchenko | "os_api_version": 5,
|
94 | 8c229cc7 | Oleksiy Mishchenko | "export_version": 0,
|
95 | 8c229cc7 | Oleksiy Mishchenko | "master": "node1.example.com",
|
96 | 8c229cc7 | Oleksiy Mishchenko | "architecture": [
|
97 | 8c229cc7 | Oleksiy Mishchenko | "64bit",
|
98 | 8c229cc7 | Oleksiy Mishchenko | "x86_64"
|
99 | 8c229cc7 | Oleksiy Mishchenko | ],
|
100 | e49099a4 | Alexander Schreiber | "hypervisor_type": "xen-pvm",
|
101 | 8c229cc7 | Oleksiy Mishchenko | "protocol_version": 12
|
102 | 8c229cc7 | Oleksiy Mishchenko | }
|
103 | 8c229cc7 | Oleksiy Mishchenko |
|
104 | 8c229cc7 | Oleksiy Mishchenko | """
|
105 | 8c229cc7 | Oleksiy Mishchenko | op = ganeti.opcodes.OpQueryClusterInfo() |
106 | 8c229cc7 | Oleksiy Mishchenko | return ganeti.cli.SubmitOpCode(op)
|
107 | 8c229cc7 | Oleksiy Mishchenko | |
108 | 8c229cc7 | Oleksiy Mishchenko | |
109 | 10b207d4 | Oleksiy Mishchenko | class R_nodes(baserlib.R_Generic): |
110 | 8c229cc7 | Oleksiy Mishchenko | """/nodes resource.
|
111 | 8c229cc7 | Oleksiy Mishchenko |
|
112 | 8c229cc7 | Oleksiy Mishchenko | """
|
113 | 8c229cc7 | Oleksiy Mishchenko | DOC_URI = "/nodes"
|
114 | 38206f3c | Iustin Pop | |
115 | 8c229cc7 | Oleksiy Mishchenko | def GET(self): |
116 | 8c229cc7 | Oleksiy Mishchenko | """Returns a list of all nodes.
|
117 | 38206f3c | Iustin Pop |
|
118 | 8c229cc7 | Oleksiy Mishchenko | Returns:
|
119 | 8c229cc7 | Oleksiy Mishchenko | A dictionary with 'name' and 'uri' keys for each of them.
|
120 | 8c229cc7 | Oleksiy Mishchenko |
|
121 | 8c229cc7 | Oleksiy Mishchenko | Example: [
|
122 | 8c229cc7 | Oleksiy Mishchenko | {
|
123 | 8c229cc7 | Oleksiy Mishchenko | "name": "node1.example.com",
|
124 | 8c229cc7 | Oleksiy Mishchenko | "uri": "\/instances\/node1.example.com"
|
125 | 8c229cc7 | Oleksiy Mishchenko | },
|
126 | 8c229cc7 | Oleksiy Mishchenko | {
|
127 | 8c229cc7 | Oleksiy Mishchenko | "name": "node2.example.com",
|
128 | 8c229cc7 | Oleksiy Mishchenko | "uri": "\/instances\/node2.example.com"
|
129 | 8c229cc7 | Oleksiy Mishchenko | }]
|
130 | 8c229cc7 | Oleksiy Mishchenko |
|
131 | 38206f3c | Iustin Pop | If the optional 'bulk' argument is provided and set to 'true'
|
132 | 8c229cc7 | Oleksiy Mishchenko | value (i.e '?bulk=1'), the output contains detailed
|
133 | 8075ce7e | Oleksiy Mishchenko | information about nodes as a list.
|
134 | 8c229cc7 | Oleksiy Mishchenko |
|
135 | 8c229cc7 | Oleksiy Mishchenko | Example: [
|
136 | 8c229cc7 | Oleksiy Mishchenko | {
|
137 | 8c229cc7 | Oleksiy Mishchenko | "pinst_cnt": 1,
|
138 | 8c229cc7 | Oleksiy Mishchenko | "mfree": 31280,
|
139 | 8c229cc7 | Oleksiy Mishchenko | "mtotal": 32763,
|
140 | 8c229cc7 | Oleksiy Mishchenko | "name": "www.example.com",
|
141 | 8c229cc7 | Oleksiy Mishchenko | "tags": [],
|
142 | 8c229cc7 | Oleksiy Mishchenko | "mnode": 512,
|
143 | 8c229cc7 | Oleksiy Mishchenko | "dtotal": 5246208,
|
144 | 8c229cc7 | Oleksiy Mishchenko | "sinst_cnt": 2,
|
145 | 8c229cc7 | Oleksiy Mishchenko | "dfree": 5171712
|
146 | 8c229cc7 | Oleksiy Mishchenko | },
|
147 | 8c229cc7 | Oleksiy Mishchenko | ...
|
148 | 8c229cc7 | Oleksiy Mishchenko | ]
|
149 | 8c229cc7 | Oleksiy Mishchenko |
|
150 | 8c229cc7 | Oleksiy Mishchenko | """
|
151 | 8c229cc7 | Oleksiy Mishchenko | op = ganeti.opcodes.OpQueryNodes(output_fields=["name"], names=[])
|
152 | 10b207d4 | Oleksiy Mishchenko | nodeslist = baserlib.ExtractField(ganeti.cli.SubmitOpCode(op), 0)
|
153 | 38206f3c | Iustin Pop | |
154 | 8c229cc7 | Oleksiy Mishchenko | if 'bulk' in self.queryargs: |
155 | 51ee2f49 | Oleksiy Mishchenko | op = ganeti.opcodes.OpQueryNodes(output_fields=N_FIELDS, |
156 | 51ee2f49 | Oleksiy Mishchenko | names=nodeslist) |
157 | 51ee2f49 | Oleksiy Mishchenko | result = ganeti.cli.SubmitOpCode(op) |
158 | 51ee2f49 | Oleksiy Mishchenko | return baserlib.MapBulkFields(result, N_FIELDS)
|
159 | 8c229cc7 | Oleksiy Mishchenko | |
160 | 10b207d4 | Oleksiy Mishchenko | return baserlib.BuildUriList(nodeslist, "/nodes/%s") |
161 | 8c229cc7 | Oleksiy Mishchenko | |
162 | 8c229cc7 | Oleksiy Mishchenko | |
163 | 10b207d4 | Oleksiy Mishchenko | class R_nodes_name(baserlib.R_Generic): |
164 | 8c229cc7 | Oleksiy Mishchenko | """/nodes/[node_name] resources.
|
165 | 8c229cc7 | Oleksiy Mishchenko |
|
166 | 8c229cc7 | Oleksiy Mishchenko | """
|
167 | 8c229cc7 | Oleksiy Mishchenko | DOC_URI = "/nodes/[node_name]"
|
168 | 8c229cc7 | Oleksiy Mishchenko | |
169 | 8c229cc7 | Oleksiy Mishchenko | def GET(self): |
170 | 38206f3c | Iustin Pop | """Send information about a node.
|
171 | 8c229cc7 | Oleksiy Mishchenko |
|
172 | 8c229cc7 | Oleksiy Mishchenko | """
|
173 | 8c229cc7 | Oleksiy Mishchenko | node_name = self.items[0] |
174 | 51ee2f49 | Oleksiy Mishchenko | op = ganeti.opcodes.OpQueryNodes(output_fields=N_FIELDS, |
175 | 8c229cc7 | Oleksiy Mishchenko | names=[node_name]) |
176 | 8c229cc7 | Oleksiy Mishchenko | result = ganeti.cli.SubmitOpCode(op) |
177 | 8c229cc7 | Oleksiy Mishchenko | |
178 | 51ee2f49 | Oleksiy Mishchenko | return baserlib.MapFields(N_FIELDS, result[0]) |
179 | 8c229cc7 | Oleksiy Mishchenko | |
180 | 8c229cc7 | Oleksiy Mishchenko | |
181 | 10b207d4 | Oleksiy Mishchenko | class R_nodes_name_tags(baserlib.R_Generic): |
182 | 8c229cc7 | Oleksiy Mishchenko | """/nodes/[node_name]/tags resource.
|
183 | 8c229cc7 | Oleksiy Mishchenko |
|
184 | 8c229cc7 | Oleksiy Mishchenko | Manages per-node tags.
|
185 | 8c229cc7 | Oleksiy Mishchenko |
|
186 | 8c229cc7 | Oleksiy Mishchenko | """
|
187 | 8c229cc7 | Oleksiy Mishchenko | DOC_URI = "/nodes/[node_name]/tags"
|
188 | 8c229cc7 | Oleksiy Mishchenko | |
189 | 8c229cc7 | Oleksiy Mishchenko | def GET(self): |
190 | 8c229cc7 | Oleksiy Mishchenko | """Returns a list of node tags.
|
191 | 8c229cc7 | Oleksiy Mishchenko |
|
192 | 8c229cc7 | Oleksiy Mishchenko | Example: ["tag1", "tag2", "tag3"]
|
193 | 8c229cc7 | Oleksiy Mishchenko |
|
194 | 8c229cc7 | Oleksiy Mishchenko | """
|
195 | 10b207d4 | Oleksiy Mishchenko | return baserlib._Tags_GET(constants.TAG_NODE, name=self.items[0]) |
196 | 8c229cc7 | Oleksiy Mishchenko | |
197 | 8c229cc7 | Oleksiy Mishchenko | |
198 | 10b207d4 | Oleksiy Mishchenko | class R_instances(baserlib.R_Generic): |
199 | 8c229cc7 | Oleksiy Mishchenko | """/instances resource.
|
200 | 8c229cc7 | Oleksiy Mishchenko |
|
201 | 8c229cc7 | Oleksiy Mishchenko | """
|
202 | 8c229cc7 | Oleksiy Mishchenko | DOC_URI = "/instances"
|
203 | 8c229cc7 | Oleksiy Mishchenko | |
204 | 8c229cc7 | Oleksiy Mishchenko | |
205 | 8c229cc7 | Oleksiy Mishchenko | def GET(self): |
206 | 8c229cc7 | Oleksiy Mishchenko | """Returns a list of all available instances.
|
207 | 38206f3c | Iustin Pop |
|
208 | 8c229cc7 | Oleksiy Mishchenko | Returns:
|
209 | 8c229cc7 | Oleksiy Mishchenko | A dictionary with 'name' and 'uri' keys for each of them.
|
210 | 8c229cc7 | Oleksiy Mishchenko |
|
211 | 8c229cc7 | Oleksiy Mishchenko | Example: [
|
212 | 8c229cc7 | Oleksiy Mishchenko | {
|
213 | 8c229cc7 | Oleksiy Mishchenko | "name": "web.example.com",
|
214 | 8c229cc7 | Oleksiy Mishchenko | "uri": "\/instances\/web.example.com"
|
215 | 8c229cc7 | Oleksiy Mishchenko | },
|
216 | 8c229cc7 | Oleksiy Mishchenko | {
|
217 | 8c229cc7 | Oleksiy Mishchenko | "name": "mail.example.com",
|
218 | 8c229cc7 | Oleksiy Mishchenko | "uri": "\/instances\/mail.example.com"
|
219 | 8c229cc7 | Oleksiy Mishchenko | }]
|
220 | 8c229cc7 | Oleksiy Mishchenko |
|
221 | 38206f3c | Iustin Pop | If the optional 'bulk' argument is provided and set to 'true'
|
222 | 8c229cc7 | Oleksiy Mishchenko | value (i.e '?bulk=1'), the output contains detailed
|
223 | 8075ce7e | Oleksiy Mishchenko | information about instances as a list.
|
224 | 8c229cc7 | Oleksiy Mishchenko |
|
225 | 8c229cc7 | Oleksiy Mishchenko | Example: [
|
226 | 8c229cc7 | Oleksiy Mishchenko | {
|
227 | 8c229cc7 | Oleksiy Mishchenko | "status": "running",
|
228 | 8c229cc7 | Oleksiy Mishchenko | "bridge": "xen-br0",
|
229 | 8c229cc7 | Oleksiy Mishchenko | "name": "web.example.com",
|
230 | 8c229cc7 | Oleksiy Mishchenko | "tags": ["tag1", "tag2"],
|
231 | 8c229cc7 | Oleksiy Mishchenko | "admin_ram": 512,
|
232 | 8c229cc7 | Oleksiy Mishchenko | "sda_size": 20480,
|
233 | 8c229cc7 | Oleksiy Mishchenko | "pnode": "node1.example.com",
|
234 | 8c229cc7 | Oleksiy Mishchenko | "mac": "01:23:45:67:89:01",
|
235 | 8c229cc7 | Oleksiy Mishchenko | "sdb_size": 4096,
|
236 | 8c229cc7 | Oleksiy Mishchenko | "snodes": ["node2.example.com"],
|
237 | 8c229cc7 | Oleksiy Mishchenko | "disk_template": "drbd",
|
238 | 8c229cc7 | Oleksiy Mishchenko | "ip": null,
|
239 | 8c229cc7 | Oleksiy Mishchenko | "admin_state": true,
|
240 | 8c229cc7 | Oleksiy Mishchenko | "os": "debian-etch",
|
241 | 8c229cc7 | Oleksiy Mishchenko | "vcpus": 2,
|
242 | 8c229cc7 | Oleksiy Mishchenko | "oper_state": true
|
243 | 8c229cc7 | Oleksiy Mishchenko | },
|
244 | 8c229cc7 | Oleksiy Mishchenko | ...
|
245 | 8c229cc7 | Oleksiy Mishchenko | ]
|
246 | 8c229cc7 | Oleksiy Mishchenko |
|
247 | 8c229cc7 | Oleksiy Mishchenko | """
|
248 | 8c229cc7 | Oleksiy Mishchenko | op = ganeti.opcodes.OpQueryInstances(output_fields=["name"], names=[])
|
249 | 10b207d4 | Oleksiy Mishchenko | instanceslist = baserlib.ExtractField(ganeti.cli.SubmitOpCode(op), 0)
|
250 | 38206f3c | Iustin Pop | |
251 | 8c229cc7 | Oleksiy Mishchenko | if 'bulk' in self.queryargs: |
252 | 51ee2f49 | Oleksiy Mishchenko | op = ganeti.opcodes.OpQueryInstances(output_fields=I_FIELDS, |
253 | 51ee2f49 | Oleksiy Mishchenko | names=instanceslist) |
254 | 51ee2f49 | Oleksiy Mishchenko | result = ganeti.cli.SubmitOpCode(op) |
255 | 51ee2f49 | Oleksiy Mishchenko | return baserlib.MapBulkFields(result, I_FIELDS)
|
256 | 51ee2f49 | Oleksiy Mishchenko | |
257 | 8c229cc7 | Oleksiy Mishchenko | |
258 | 8c229cc7 | Oleksiy Mishchenko | else:
|
259 | 10b207d4 | Oleksiy Mishchenko | return baserlib.BuildUriList(instanceslist, "/instances/%s") |
260 | 8c229cc7 | Oleksiy Mishchenko | |
261 | 8c229cc7 | Oleksiy Mishchenko | |
262 | 10b207d4 | Oleksiy Mishchenko | class R_instances_name(baserlib.R_Generic): |
263 | 8c229cc7 | Oleksiy Mishchenko | """/instances/[instance_name] resources.
|
264 | 8c229cc7 | Oleksiy Mishchenko |
|
265 | 8c229cc7 | Oleksiy Mishchenko | """
|
266 | 8c229cc7 | Oleksiy Mishchenko | DOC_URI = "/instances/[instance_name]"
|
267 | 8c229cc7 | Oleksiy Mishchenko | |
268 | 8c229cc7 | Oleksiy Mishchenko | def GET(self): |
269 | 8c229cc7 | Oleksiy Mishchenko | """Send information about an instance.
|
270 | 8c229cc7 | Oleksiy Mishchenko |
|
271 | 8c229cc7 | Oleksiy Mishchenko | """
|
272 | 8c229cc7 | Oleksiy Mishchenko | instance_name = self.items[0] |
273 | 51ee2f49 | Oleksiy Mishchenko | op = ganeti.opcodes.OpQueryInstances(output_fields=I_FIELDS, |
274 | 8c229cc7 | Oleksiy Mishchenko | names=[instance_name]) |
275 | 8c229cc7 | Oleksiy Mishchenko | result = ganeti.cli.SubmitOpCode(op) |
276 | 8c229cc7 | Oleksiy Mishchenko | |
277 | 51ee2f49 | Oleksiy Mishchenko | return baserlib.MapFields(I_FIELDS, result[0]) |
278 | 8c229cc7 | Oleksiy Mishchenko | |
279 | 8c229cc7 | Oleksiy Mishchenko | |
280 | 10b207d4 | Oleksiy Mishchenko | class R_instances_name_tags(baserlib.R_Generic): |
281 | 8c229cc7 | Oleksiy Mishchenko | """/instances/[instance_name]/tags resource.
|
282 | 8c229cc7 | Oleksiy Mishchenko |
|
283 | 8c229cc7 | Oleksiy Mishchenko | Manages per-instance tags.
|
284 | 8c229cc7 | Oleksiy Mishchenko |
|
285 | 8c229cc7 | Oleksiy Mishchenko | """
|
286 | 8c229cc7 | Oleksiy Mishchenko | DOC_URI = "/instances/[instance_name]/tags"
|
287 | 8c229cc7 | Oleksiy Mishchenko | |
288 | 8c229cc7 | Oleksiy Mishchenko | def GET(self): |
289 | 8c229cc7 | Oleksiy Mishchenko | """Returns a list of instance tags.
|
290 | 8c229cc7 | Oleksiy Mishchenko |
|
291 | 8c229cc7 | Oleksiy Mishchenko | Example: ["tag1", "tag2", "tag3"]
|
292 | 8c229cc7 | Oleksiy Mishchenko |
|
293 | 8c229cc7 | Oleksiy Mishchenko | """
|
294 | 10b207d4 | Oleksiy Mishchenko | return baserlib._Tags_GET(constants.TAG_INSTANCE, name=self.items[0]) |
295 | 8c229cc7 | Oleksiy Mishchenko | |
296 | 8c229cc7 | Oleksiy Mishchenko | |
297 | 10b207d4 | Oleksiy Mishchenko | class R_os(baserlib.R_Generic): |
298 | 8c229cc7 | Oleksiy Mishchenko | """/os resource.
|
299 | 8c229cc7 | Oleksiy Mishchenko |
|
300 | 8c229cc7 | Oleksiy Mishchenko | """
|
301 | 8c229cc7 | Oleksiy Mishchenko | DOC_URI = "/os"
|
302 | 8c229cc7 | Oleksiy Mishchenko | |
303 | 8c229cc7 | Oleksiy Mishchenko | def GET(self): |
304 | 8c229cc7 | Oleksiy Mishchenko | """Return a list of all OSes.
|
305 | 8c229cc7 | Oleksiy Mishchenko |
|
306 | 8c229cc7 | Oleksiy Mishchenko | Can return error 500 in case of a problem.
|
307 | 8c229cc7 | Oleksiy Mishchenko |
|
308 | 8c229cc7 | Oleksiy Mishchenko | Example: ["debian-etch"]
|
309 | 8c229cc7 | Oleksiy Mishchenko |
|
310 | 8c229cc7 | Oleksiy Mishchenko | """
|
311 | 8c229cc7 | Oleksiy Mishchenko | op = ganeti.opcodes.OpDiagnoseOS(output_fields=["name", "valid"], |
312 | 8c229cc7 | Oleksiy Mishchenko | names=[]) |
313 | 8c229cc7 | Oleksiy Mishchenko | diagnose_data = ganeti.cli.SubmitOpCode(op) |
314 | 8c229cc7 | Oleksiy Mishchenko | |
315 | 8c229cc7 | Oleksiy Mishchenko | if not isinstance(diagnose_data, list): |
316 | 8c229cc7 | Oleksiy Mishchenko | raise httperror.HTTPInternalError(message="Can't get OS list") |
317 | 8c229cc7 | Oleksiy Mishchenko | |
318 | 8c229cc7 | Oleksiy Mishchenko | return [row[0] for row in diagnose_data if row[1]] |