root / snf-astakos-app / astakos / scripts / snf_service_export.py @ 2f8a7c0e
History | View | Annotate | Download (8 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 |
} |
76 |
|
77 |
from astakos.oa2.services import oa2_services |
78 |
astakos_services.update(oa2_services) |
79 |
|
80 |
cyclades_services = { |
81 |
'cyclades_compute': {
|
82 |
'type': 'compute', |
83 |
'component': 'cyclades', |
84 |
'prefix': 'compute', |
85 |
'public': True, |
86 |
'endpoints': [
|
87 |
{'versionId': 'v2.0', |
88 |
'publicURL': None}, |
89 |
], |
90 |
'resources': {
|
91 |
'vm': {
|
92 |
"name": "cyclades.vm", |
93 |
"desc": "Number of virtual machines", |
94 |
"service_type": "compute", |
95 |
"service_origin": "cyclades_compute", |
96 |
}, |
97 |
'total_cpu': {
|
98 |
"name": "cyclades.total_cpu", |
99 |
"desc": "Number of virtual machine processors", |
100 |
"service_type": "compute", |
101 |
"service_origin": "cyclades_compute", |
102 |
"ui_visible": False, |
103 |
"api_visible": False, |
104 |
}, |
105 |
'cpu': {
|
106 |
"name": "cyclades.cpu", |
107 |
"desc": "Number of virtual machine processors of running" |
108 |
" servers",
|
109 |
"service_type": "compute", |
110 |
"service_origin": "cyclades_compute", |
111 |
}, |
112 |
'total_ram': {
|
113 |
"name": "cyclades.total_ram", |
114 |
"desc": "Virtual machine memory size", |
115 |
"unit": "bytes", |
116 |
"service_type": "compute", |
117 |
"service_origin": "cyclades_compute", |
118 |
"ui_visible": False, |
119 |
"api_visible": False, |
120 |
}, |
121 |
'ram': {
|
122 |
"name": "cyclades.ram", |
123 |
"desc": "Virtual machine memory size of running servers", |
124 |
"unit": "bytes", |
125 |
"service_type": "compute", |
126 |
"service_origin": "cyclades_compute", |
127 |
}, |
128 |
'disk': {
|
129 |
"name": "cyclades.disk", |
130 |
"desc": "Virtual machine disk size", |
131 |
"unit": "bytes", |
132 |
"service_type": "compute", |
133 |
"service_origin": "cyclades_compute", |
134 |
}, |
135 |
}, |
136 |
}, |
137 |
|
138 |
'cyclades_plankton': {
|
139 |
'type': 'image', |
140 |
'component': 'cyclades', |
141 |
'prefix': 'image', |
142 |
'public': True, |
143 |
'endpoints': [
|
144 |
{'versionId': 'v1.0', |
145 |
'publicURL': None}, |
146 |
], |
147 |
'resources': {},
|
148 |
}, |
149 |
|
150 |
'cyclades_network': {
|
151 |
'type': 'network', |
152 |
'component': 'cyclades', |
153 |
'prefix': 'network', |
154 |
'public': True, |
155 |
'endpoints': [
|
156 |
{'versionId': 'v2.0', |
157 |
'publicURL': None}, |
158 |
], |
159 |
'resources': {
|
160 |
'network-private': {
|
161 |
"name": "cyclades.network.private", |
162 |
"desc": "Number of private networks", |
163 |
"service_type": "network", |
164 |
"service_origin": "cyclades_network", |
165 |
}, |
166 |
'floating_ip': {
|
167 |
"name": "cyclades.floating_ip", |
168 |
"desc": "Number of Floating IP addresses", |
169 |
"service_type": "network", |
170 |
"service_origin": "cyclades_network", |
171 |
}, |
172 |
}, |
173 |
}, |
174 |
|
175 |
'cyclades_vmapi': {
|
176 |
'type': 'vmapi', |
177 |
'component': 'cyclades', |
178 |
'prefix': 'vmapi', |
179 |
'public': True, |
180 |
'endpoints': [
|
181 |
{'versionId': 'v1.0', |
182 |
'publicURL': None}, |
183 |
], |
184 |
'resources': {},
|
185 |
}, |
186 |
|
187 |
'cyclades_helpdesk': {
|
188 |
'type': 'cyclades_helpdesk', |
189 |
'component': 'cyclades', |
190 |
'prefix': 'helpdesk', |
191 |
'public': False, |
192 |
'endpoints': [
|
193 |
{'versionId': '', |
194 |
'publicURL': None}, |
195 |
], |
196 |
}, |
197 |
|
198 |
'cyclades_userdata': {
|
199 |
'type': 'cyclades_userdata', |
200 |
'component': 'cyclades', |
201 |
'prefix': 'userdata', |
202 |
'public': False, |
203 |
'endpoints': [
|
204 |
{'versionId': '', |
205 |
'publicURL': None}, |
206 |
], |
207 |
'resources': {},
|
208 |
}, |
209 |
|
210 |
'cyclades_ui': {
|
211 |
'type': 'cyclades_ui', |
212 |
'component': 'cyclades', |
213 |
'prefix': 'ui', |
214 |
'public': False, |
215 |
'endpoints': [
|
216 |
{'versionId': '', |
217 |
'publicURL': None}, |
218 |
], |
219 |
'resources': {},
|
220 |
}, |
221 |
|
222 |
'cyclades_admin': {
|
223 |
'type': 'admin', |
224 |
'component': 'cyclades', |
225 |
'prefix': 'admin', |
226 |
'public': True, |
227 |
'endpoints': [
|
228 |
{'versionId': '', |
229 |
'publicURL': None}, |
230 |
], |
231 |
'resources': {},
|
232 |
}, |
233 |
} |
234 |
|
235 |
pithos_services = { |
236 |
'pithos_object-store': {
|
237 |
'type': 'object-store', |
238 |
'component': 'pithos', |
239 |
'prefix': 'object-store', |
240 |
'public': True, |
241 |
'endpoints': [
|
242 |
{'versionId': 'v1', |
243 |
'publicURL': None}, |
244 |
], |
245 |
'resources': {
|
246 |
'diskspace': {
|
247 |
"desc": "Pithos account diskspace", |
248 |
"name": "pithos.diskspace", |
249 |
"unit": "bytes", |
250 |
"service_type": "object-store", |
251 |
"service_origin": "pithos_object-store", |
252 |
}, |
253 |
}, |
254 |
}, |
255 |
|
256 |
'pithos_public': {
|
257 |
'type': 'pithos_public', |
258 |
'component': 'pithos', |
259 |
'prefix': 'public', |
260 |
'public': False, |
261 |
'endpoints': [
|
262 |
{'versionId': '', |
263 |
'publicURL': None}, |
264 |
], |
265 |
'resources': {},
|
266 |
}, |
267 |
|
268 |
'pithos_ui': {
|
269 |
'type': 'pithos_ui', |
270 |
'component': 'pithos', |
271 |
'prefix': 'ui', |
272 |
'public': False, |
273 |
'endpoints': [
|
274 |
{'versionId': '', |
275 |
'publicURL': None}, |
276 |
], |
277 |
'resources': {},
|
278 |
}, |
279 |
} |
280 |
|
281 |
|
282 |
definitions = { |
283 |
'astakos': astakos_services,
|
284 |
'cyclades': cyclades_services,
|
285 |
'pithos': pithos_services,
|
286 |
} |
287 |
|
288 |
|
289 |
def print_definitions(d, base_url): |
290 |
fill_endpoints(d, base_url) |
291 |
print json.dumps(filter_public(d), indent=4) |
292 |
|
293 |
|
294 |
usage = "usage: %prog <component_name> <base_url>"
|
295 |
parser = OptionParser(usage=usage) |
296 |
|
297 |
|
298 |
def main(): |
299 |
(options, args) = parser.parse_args() |
300 |
if len(args) != 2: |
301 |
parser.error("Wrong number of arguments.")
|
302 |
component = args[0]
|
303 |
try:
|
304 |
services = definitions[component] |
305 |
except KeyError: |
306 |
print "Unrecognized component %s" % component |
307 |
exit(1) |
308 |
base_url = args[1]
|
309 |
print_definitions(services, base_url) |
310 |
|
311 |
if __name__ == '__main__': |
312 |
main() |