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