Statistics
| Branch: | Tag: | Revision:

root / snf-astakos-app / astakos / scripts / snf_service_export.py @ 50f74340

History | View | Annotate | Download (7.2 kB)

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