root / snf-astakos-app / astakos / scripts / snf_service_export.py @ e28a4841
History | View | Annotate | Download (8.2 kB)
1 |
import os |
---|---|
2 |
os.environ['DJANGO_SETTINGS_MODULE'] = 'synnefo.settings' |
3 |
from optparse import OptionParser |
4 |
from synnefo.lib.services import fill_endpoints, filter_public |
5 |
from django.utils import simplejson as json |
6 |
|
7 |
|
8 |
astakos_services = { |
9 |
'astakos_account': {
|
10 |
'type': 'account', |
11 |
'component': 'astakos', |
12 |
'prefix': 'account', |
13 |
'public': True, |
14 |
'endpoints': [
|
15 |
{'versionId': 'v1.0', |
16 |
'publicURL': None}, |
17 |
], |
18 |
'resources': {
|
19 |
'pending_app': {
|
20 |
'desc': "Number of pending project applications", |
21 |
'name': "astakos.pending_app", |
22 |
'service_type': "account", |
23 |
'service_origin': "astakos_account", |
24 |
"ui_visible": False, |
25 |
"api_visible": False}, |
26 |
}, |
27 |
}, |
28 |
|
29 |
'astakos_identity': {
|
30 |
'type': 'identity', |
31 |
'component': 'astakos', |
32 |
'prefix': 'identity', |
33 |
'public': True, |
34 |
'endpoints': [
|
35 |
{'versionId': 'v2.0', |
36 |
'publicURL': None}, |
37 |
], |
38 |
'resources': {},
|
39 |
}, |
40 |
|
41 |
'astakos_weblogin': {
|
42 |
'type': 'astakos_weblogin', |
43 |
'component': 'astakos', |
44 |
'prefix': 'weblogin', |
45 |
'public': True, |
46 |
'endpoints': [
|
47 |
{'versionId': '', |
48 |
'publicURL': None}, |
49 |
], |
50 |
}, |
51 |
|
52 |
'astakos_ui': {
|
53 |
'type': 'astakos_ui', |
54 |
'component': 'astakos', |
55 |
'prefix': 'ui', |
56 |
'public': False, |
57 |
'endpoints': [
|
58 |
{'versionId': '', |
59 |
'publicURL': None}, |
60 |
], |
61 |
}, |
62 |
|
63 |
'astakos_admin': {
|
64 |
'type': 'astakos_admin', |
65 |
'component': 'astakos', |
66 |
'prefix': 'admin', |
67 |
'public': False, |
68 |
'endpoints': [
|
69 |
{'versionId': '', |
70 |
'publicURL': None}, |
71 |
], |
72 |
'resources': {},
|
73 |
}, |
74 |
|
75 |
'astakos_oa2': {
|
76 |
'type': 'astakos_auth', |
77 |
'component': 'astakos', |
78 |
'prefix': 'oa2', |
79 |
'public': True, |
80 |
'endpoints': [
|
81 |
{'versionId': '', |
82 |
'publicURL': None}, |
83 |
], |
84 |
'resources': {},
|
85 |
} |
86 |
} |
87 |
|
88 |
cyclades_services = { |
89 |
'cyclades_compute': {
|
90 |
'type': 'compute', |
91 |
'component': 'cyclades', |
92 |
'prefix': 'compute', |
93 |
'public': True, |
94 |
'endpoints': [
|
95 |
{'versionId': 'v2.0', |
96 |
'publicURL': None}, |
97 |
], |
98 |
'resources': {
|
99 |
'vm': {
|
100 |
"name": "cyclades.vm", |
101 |
"desc": "Number of virtual machines", |
102 |
"service_type": "compute", |
103 |
"service_origin": "cyclades_compute", |
104 |
}, |
105 |
'total_cpu': {
|
106 |
"name": "cyclades.total_cpu", |
107 |
"desc": "Number of virtual machine processors", |
108 |
"service_type": "compute", |
109 |
"service_origin": "cyclades_compute", |
110 |
"ui_visible": False, |
111 |
"api_visible": False, |
112 |
}, |
113 |
'cpu': {
|
114 |
"name": "cyclades.cpu", |
115 |
"desc": "Number of virtual machine processors of running" |
116 |
" servers",
|
117 |
"service_type": "compute", |
118 |
"service_origin": "cyclades_compute", |
119 |
}, |
120 |
'total_ram': {
|
121 |
"name": "cyclades.total_ram", |
122 |
"desc": "Virtual machine memory size", |
123 |
"unit": "bytes", |
124 |
"service_type": "compute", |
125 |
"service_origin": "cyclades_compute", |
126 |
"ui_visible": False, |
127 |
"api_visible": False, |
128 |
}, |
129 |
'ram': {
|
130 |
"name": "cyclades.ram", |
131 |
"desc": "Virtual machine memory size of running servers", |
132 |
"unit": "bytes", |
133 |
"service_type": "compute", |
134 |
"service_origin": "cyclades_compute", |
135 |
}, |
136 |
'disk': {
|
137 |
"name": "cyclades.disk", |
138 |
"desc": "Virtual machine disk size", |
139 |
"unit": "bytes", |
140 |
"service_type": "compute", |
141 |
"service_origin": "cyclades_compute", |
142 |
}, |
143 |
}, |
144 |
}, |
145 |
|
146 |
'cyclades_plankton': {
|
147 |
'type': 'image', |
148 |
'component': 'cyclades', |
149 |
'prefix': 'image', |
150 |
'public': True, |
151 |
'endpoints': [
|
152 |
{'versionId': 'v1.0', |
153 |
'publicURL': None}, |
154 |
], |
155 |
'resources': {},
|
156 |
}, |
157 |
|
158 |
'cyclades_network': {
|
159 |
'type': 'network', |
160 |
'component': 'cyclades', |
161 |
'prefix': 'network', |
162 |
'public': True, |
163 |
'endpoints': [
|
164 |
{'versionId': 'v2.0', |
165 |
'publicURL': None}, |
166 |
], |
167 |
'resources': {
|
168 |
'network-private': {
|
169 |
"name": "cyclades.network.private", |
170 |
"desc": "Number of private networks", |
171 |
"service_type": "network", |
172 |
"service_origin": "cyclades_network", |
173 |
}, |
174 |
'floating_ip': {
|
175 |
"name": "cyclades.floating_ip", |
176 |
"desc": "Number of Floating IP addresses", |
177 |
"service_type": "network", |
178 |
"service_origin": "cyclades_network", |
179 |
}, |
180 |
}, |
181 |
}, |
182 |
|
183 |
'cyclades_vmapi': {
|
184 |
'type': 'vmapi', |
185 |
'component': 'cyclades', |
186 |
'prefix': 'vmapi', |
187 |
'public': True, |
188 |
'endpoints': [
|
189 |
{'versionId': 'v1.0', |
190 |
'publicURL': None}, |
191 |
], |
192 |
'resources': {},
|
193 |
}, |
194 |
|
195 |
'cyclades_helpdesk': {
|
196 |
'type': 'cyclades_helpdesk', |
197 |
'component': 'cyclades', |
198 |
'prefix': 'helpdesk', |
199 |
'public': False, |
200 |
'endpoints': [
|
201 |
{'versionId': '', |
202 |
'publicURL': None}, |
203 |
], |
204 |
}, |
205 |
|
206 |
'cyclades_userdata': {
|
207 |
'type': 'cyclades_userdata', |
208 |
'component': 'cyclades', |
209 |
'prefix': 'userdata', |
210 |
'public': False, |
211 |
'endpoints': [
|
212 |
{'versionId': '', |
213 |
'publicURL': None}, |
214 |
], |
215 |
'resources': {},
|
216 |
}, |
217 |
|
218 |
'cyclades_ui': {
|
219 |
'type': 'cyclades_ui', |
220 |
'component': 'cyclades', |
221 |
'prefix': 'ui', |
222 |
'public': False, |
223 |
'endpoints': [
|
224 |
{'versionId': '', |
225 |
'publicURL': None}, |
226 |
], |
227 |
'resources': {},
|
228 |
}, |
229 |
|
230 |
'cyclades_admin': {
|
231 |
'type': 'admin', |
232 |
'component': 'cyclades', |
233 |
'prefix': 'admin', |
234 |
'public': True, |
235 |
'endpoints': [
|
236 |
{'versionId': '', |
237 |
'publicURL': None}, |
238 |
], |
239 |
'resources': {},
|
240 |
}, |
241 |
} |
242 |
|
243 |
pithos_services = { |
244 |
'pithos_object-store': {
|
245 |
'type': 'object-store', |
246 |
'component': 'pithos', |
247 |
'prefix': 'object-store', |
248 |
'public': True, |
249 |
'endpoints': [
|
250 |
{'versionId': 'v1', |
251 |
'publicURL': None}, |
252 |
], |
253 |
'resources': {
|
254 |
'diskspace': {
|
255 |
"desc": "Pithos account diskspace", |
256 |
"name": "pithos.diskspace", |
257 |
"unit": "bytes", |
258 |
"service_type": "object-store", |
259 |
"service_origin": "pithos_object-store", |
260 |
}, |
261 |
}, |
262 |
}, |
263 |
|
264 |
'pithos_public': {
|
265 |
'type': 'pithos_public', |
266 |
'component': 'pithos', |
267 |
'prefix': 'public', |
268 |
'public': False, |
269 |
'endpoints': [
|
270 |
{'versionId': '', |
271 |
'publicURL': None}, |
272 |
], |
273 |
'resources': {},
|
274 |
}, |
275 |
|
276 |
'pithos_ui': {
|
277 |
'type': 'pithos_ui', |
278 |
'component': 'pithos', |
279 |
'prefix': 'ui', |
280 |
'public': False, |
281 |
'endpoints': [
|
282 |
{'versionId': '', |
283 |
'publicURL': None}, |
284 |
], |
285 |
'resources': {},
|
286 |
}, |
287 |
} |
288 |
|
289 |
|
290 |
definitions = { |
291 |
'astakos': astakos_services,
|
292 |
'cyclades': cyclades_services,
|
293 |
'pithos': pithos_services,
|
294 |
} |
295 |
|
296 |
|
297 |
def print_definitions(d, base_url): |
298 |
fill_endpoints(d, base_url) |
299 |
print json.dumps(filter_public(d), indent=4) |
300 |
|
301 |
|
302 |
usage = "usage: %prog <component_name> <base_url>"
|
303 |
parser = OptionParser(usage=usage) |
304 |
|
305 |
|
306 |
def main(): |
307 |
(options, args) = parser.parse_args() |
308 |
if len(args) != 2: |
309 |
parser.error("Wrong number of arguments.")
|
310 |
component = args[0]
|
311 |
try:
|
312 |
services = definitions[component] |
313 |
except KeyError: |
314 |
print "Unrecognized component %s" % component |
315 |
exit(1) |
316 |
base_url = args[1]
|
317 |
print_definitions(services, base_url) |
318 |
|
319 |
if __name__ == '__main__': |
320 |
main() |