Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (7.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
                'allow_in_projects': False},
25
        },
26
    },
27

    
28
    'astakos_identity': {
29
        'type': 'identity',
30
        'component': 'astakos',
31
        'prefix': 'identity',
32
        'public': True,
33
        'endpoints': [
34
            {'versionId': 'v2.0',
35
             'publicURL': None},
36
        ],
37
        'resources': {},
38
    },
39

    
40
    'astakos_weblogin': {
41
        'type': 'astakos_weblogin',
42
        'component': 'astakos',
43
        'prefix': 'weblogin',
44
        'public': True,
45
        'endpoints': [
46
            {'versionId': '',
47
             'publicURL': None},
48
        ],
49
    },
50

    
51
    'astakos_ui': {
52
        'type': 'astakos_ui',
53
        'component': 'astakos',
54
        'prefix': 'ui',
55
        'public': False,
56
        'endpoints': [
57
            {'versionId': '',
58
             'publicURL': None},
59
        ],
60
    },
61
}
62

    
63
cyclades_services = {
64
    'cyclades_compute': {
65
        'type': 'compute',
66
        'component': 'cyclades',
67
        'prefix': 'compute',
68
        'public': True,
69
        'endpoints': [
70
            {'versionId': 'v2.0',
71
             'publicURL': None},
72
        ],
73
        'resources': {
74
            'vm': {
75
                "name": "cyclades.vm",
76
                "desc": "Number of virtual machines",
77
                "service_type": "compute",
78
                "service_origin": "cyclades_compute",
79
            },
80
            'cpu': {
81
                "name": "cyclades.cpu",
82
                "desc": "Number of virtual machine processors",
83
                "service_type": "compute",
84
                "service_origin": "cyclades_compute",
85
            },
86
            'active_cpu': {
87
                "name": "cyclades.active_cpu",
88
                "desc": "Number of virtual machine processors of running"
89
                        " servers",
90
                "service_type": "compute",
91
                "service_origin": "cyclades_compute",
92
            },
93
            'ram': {
94
                "name": "cyclades.ram",
95
                "desc": "Virtual machine memory size",
96
                "unit": "bytes",
97
                "service_type": "compute",
98
                "service_origin": "cyclades_compute",
99
            },
100
            'active_ram': {
101
                "name": "cyclades.active_ram",
102
                "desc": "Virtual machine memory size of running servers",
103
                "unit": "bytes",
104
                "service_type": "compute",
105
                "service_origin": "cyclades_compute",
106
            },
107
            'disk': {
108
                "name": "cyclades.disk",
109
                "desc": "Virtual machine disk size",
110
                "unit": "bytes",
111
                "service_type": "compute",
112
                "service_origin": "cyclades_compute",
113
            },
114
            'network-private': {
115
                "name": "cyclades.network.private",
116
                "desc": "Number of private networks",
117
                "service_type": "compute",
118
                "service_origin": "cyclades_compute",
119
            },
120
            'floating_ip': {
121
                "name": "cyclades.floating_ip",
122
                "desc": "Number of Floating IP addresses",
123
                "service_type": "compute",
124
                "service_origin": "cyclades_compute",
125
            },
126
        },
127
    },
128

    
129
    'cyclades_plankton': {
130
        'type': 'image',
131
        'component': 'cyclades',
132
        'prefix': 'image',
133
        'public': True,
134
        'endpoints': [
135
            {'versionId': 'v1.0',
136
             'publicURL': None},
137
        ],
138
        'resources': {},
139
    },
140

    
141
    'cyclades_vmapi': {
142
        'type': 'vmapi',
143
        'component': 'cyclades',
144
        'prefix': 'vmapi',
145
        'public': True,
146
        'endpoints': [
147
            {'versionId': 'v1.0',
148
             'publicURL': None},
149
        ],
150
        'resources': {},
151
    },
152

    
153
    'cyclades_helpdesk': {
154
        'type': 'cyclades_helpdesk',
155
        'component': 'cyclades',
156
        'prefix': 'helpdesk',
157
        'public': False,
158
        'endpoints': [
159
            {'versionId': '',
160
             'publicURL': None},
161
        ],
162
    },
163

    
164
    'cyclades_userdata': {
165
        'type': 'cyclades_userdata',
166
        'component': 'cyclades',
167
        'prefix': 'userdata',
168
        'public': False,
169
        'endpoints': [
170
            {'versionId': '',
171
             'publicURL': None},
172
        ],
173
        'resources': {},
174
    },
175

    
176
    'cyclades_ui': {
177
        'type': 'cyclades_ui',
178
        'component': 'cyclades',
179
        'prefix': 'ui',
180
        'public': False,
181
        'endpoints': [
182
            {'versionId': '',
183
             'publicURL': None},
184
        ],
185
        'resources': {},
186
    },
187

    
188
    'cyclades_admin': {
189
        'type': 'admin',
190
        'component': 'cyclades',
191
        'prefix': 'admin',
192
        'public': True,
193
        'endpoints': [
194
            {'versionId': '',
195
             'publicURL': None},
196
        ],
197
        'resources': {},
198
    },
199
}
200

    
201
pithos_services = {
202
    'pithos_object-store': {
203
        'type': 'object-store',
204
        'component': 'pithos',
205
        'prefix': 'object-store',
206
        'public': True,
207
        'endpoints': [
208
            {'versionId': 'v1',
209
             'publicURL': None},
210
        ],
211
        'resources': {
212
            'diskspace': {
213
                "desc": "Pithos account diskspace",
214
                "name": "pithos.diskspace",
215
                "unit": "bytes",
216
                "service_type": "object-store",
217
                "service_origin": "pithos_object-store",
218
            },
219
        },
220
    },
221

    
222
    'pithos_public': {
223
        'type': 'public',
224
        'component': 'pithos',
225
        'prefix': 'public',
226
        'public': False,
227
        'endpoints': [
228
            {'versionId': 'v1.0',
229
             'publicURL': None},
230
        ],
231
        'resources': {},
232
    },
233

    
234
    'pithos_ui': {
235
        'type': 'pithos_ui',
236
        'component': 'pithos',
237
        'prefix': 'ui',
238
        'public': False,
239
        'endpoints': [
240
            {'versionId': '',
241
             'publicURL': None},
242
        ],
243
        'resources': {},
244
    },
245
}
246

    
247

    
248
definitions = {
249
    'astakos': astakos_services,
250
    'cyclades': cyclades_services,
251
    'pithos': pithos_services,
252
}
253

    
254

    
255
def print_definitions(d, base_url):
256
    fill_endpoints(d, base_url)
257
    print json.dumps(filter_public(d), indent=4)
258

    
259

    
260
usage = "usage: %prog <component_name> <base_url>"
261
parser = OptionParser(usage=usage)
262

    
263

    
264
def main():
265
    (options, args) = parser.parse_args()
266
    if len(args) != 2:
267
        parser.error("Wrong number of arguments.")
268
    component = args[0]
269
    try:
270
        services = definitions[component]
271
    except KeyError:
272
        print "Unrecognized component %s" % component
273
        exit(1)
274
    base_url = args[1]
275
    print_definitions(services, base_url)
276

    
277
if __name__ == '__main__':
278
    main()