root / snf-cyclades-app / synnefo / admin / api.py @ c1d11f96
History | View | Annotate | Download (1.9 kB)
1 | 1081c1a0 | Giorgos Verigakis | # Copyright 2011 GRNET S.A. All rights reserved.
|
---|---|---|---|
2 | 1081c1a0 | Giorgos Verigakis | #
|
3 | 1081c1a0 | Giorgos Verigakis | # Redistribution and use in source and binary forms, with or
|
4 | 1081c1a0 | Giorgos Verigakis | # without modification, are permitted provided that the following
|
5 | 1081c1a0 | Giorgos Verigakis | # conditions are met:
|
6 | 1081c1a0 | Giorgos Verigakis | #
|
7 | 1081c1a0 | Giorgos Verigakis | # 1. Redistributions of source code must retain the above
|
8 | 1081c1a0 | Giorgos Verigakis | # copyright notice, this list of conditions and the following
|
9 | 1081c1a0 | Giorgos Verigakis | # disclaimer.
|
10 | 1081c1a0 | Giorgos Verigakis | #
|
11 | 1081c1a0 | Giorgos Verigakis | # 2. Redistributions in binary form must reproduce the above
|
12 | 1081c1a0 | Giorgos Verigakis | # copyright notice, this list of conditions and the following
|
13 | 1081c1a0 | Giorgos Verigakis | # disclaimer in the documentation and/or other materials
|
14 | 1081c1a0 | Giorgos Verigakis | # provided with the distribution.
|
15 | 1081c1a0 | Giorgos Verigakis | #
|
16 | 1081c1a0 | Giorgos Verigakis | # THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
17 | 1081c1a0 | Giorgos Verigakis | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18 | 1081c1a0 | Giorgos Verigakis | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19 | 1081c1a0 | Giorgos Verigakis | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
20 | 1081c1a0 | Giorgos Verigakis | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 | 1081c1a0 | Giorgos Verigakis | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 | 1081c1a0 | Giorgos Verigakis | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23 | 1081c1a0 | Giorgos Verigakis | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24 | 1081c1a0 | Giorgos Verigakis | # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 | 1081c1a0 | Giorgos Verigakis | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26 | 1081c1a0 | Giorgos Verigakis | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 | 1081c1a0 | Giorgos Verigakis | # POSSIBILITY OF SUCH DAMAGE.
|
28 | 1081c1a0 | Giorgos Verigakis | #
|
29 | 1081c1a0 | Giorgos Verigakis | # The views and conclusions contained in the software and
|
30 | 1081c1a0 | Giorgos Verigakis | # documentation are those of the authors and should not be
|
31 | 1081c1a0 | Giorgos Verigakis | # interpreted as representing official policies, either expressed
|
32 | 1081c1a0 | Giorgos Verigakis | # or implied, of GRNET S.A.
|
33 | 1081c1a0 | Giorgos Verigakis | |
34 | 811a68f5 | Giorgos Verigakis | import json |
35 | 811a68f5 | Giorgos Verigakis | |
36 | 811a68f5 | Giorgos Verigakis | from django.core.urlresolvers import reverse |
37 | 811a68f5 | Giorgos Verigakis | from django.http import HttpResponse |
38 | 811a68f5 | Giorgos Verigakis | |
39 | 811a68f5 | Giorgos Verigakis | from synnefo.admin.views import requires_admin |
40 | 244c552b | Giorgos Verigakis | from synnefo.db.models import VirtualMachine |
41 | 811a68f5 | Giorgos Verigakis | |
42 | 811a68f5 | Giorgos Verigakis | |
43 | 811a68f5 | Giorgos Verigakis | @requires_admin
|
44 | 811a68f5 | Giorgos Verigakis | def servers_info(request, server_id): |
45 | 244c552b | Giorgos Verigakis | server = VirtualMachine.objects.get(id=server_id) |
46 | 811a68f5 | Giorgos Verigakis | reply = { |
47 | 811a68f5 | Giorgos Verigakis | 'name': server.name,
|
48 | 811a68f5 | Giorgos Verigakis | 'ref': '#'} |
49 | 811a68f5 | Giorgos Verigakis | return HttpResponse(json.dumps(reply), content_type='application/json') |