Revision 32e4e343
b/snf-cyclades-app/synnefo/admin/urls.py | ||
---|---|---|
39 | 39 |
def index(request): |
40 | 40 |
raise Http404 |
41 | 41 |
|
42 |
urlpatterns = patterns('', |
|
42 |
urlpatterns = patterns( |
|
43 |
'', |
|
43 | 44 |
url(r'^$', index), |
44 | 45 |
url(r'^stats$', views.get_stats), |
45 | 46 |
) |
b/snf-cyclades-app/synnefo/api/floating_ips.py | ||
---|---|---|
142 | 142 |
else: |
143 | 143 |
try: |
144 | 144 |
network_id = int(pool) |
145 |
except ValueErrorx:
|
|
145 |
except ValueError: |
|
146 | 146 |
raise faults.BadRequest("Invalid pool ID.") |
147 |
network = next((n for n in net_objects if n.id==pool), None) |
|
147 |
network = next((n for n in net_objects if n.id == network_id), |
|
148 |
None) |
|
148 | 149 |
if network is None: |
149 | 150 |
raise faults.ItemNotFound("Pool '%s' does not exist." % pool) |
150 | 151 |
if address is None: |
... | ... | |
169 | 170 |
# If address is not available, check that it belongs to the |
170 | 171 |
# same user |
171 | 172 |
elif not network.nics.filter(ipv4=address, |
172 |
machine__userid=userid).exists(): |
|
173 |
machine__userid=userid).exists():
|
|
173 | 174 |
msg = "Address '%s' is already in use" % address |
174 | 175 |
raise faults.Conflict(msg) |
175 | 176 |
floating_ip = FloatingIP.objects.create(ipv4=address, network=network, |
b/snf-cyclades-app/synnefo/api/management/commands/network-create.py | ||
---|---|---|
194 | 194 |
raise CommandError("Can not create network." |
195 | 195 |
" No connectivity link or mode") |
196 | 196 |
netinfo = { |
197 |
"name": name, |
|
198 |
"userid": options["owner"], |
|
199 |
"subnet": subnet, |
|
200 |
"gateway": gateway, |
|
201 |
"gateway6": gateway6, |
|
202 |
"subnet6": subnet6, |
|
203 |
"dhcp": options["dhcp"], |
|
204 |
"flavor": flavor, |
|
205 |
"public": public, |
|
206 |
"mode": mode, |
|
207 |
"link": link, |
|
208 |
"mac_prefix": mac_prefix, |
|
209 |
"tags": tags, |
|
210 |
"floating_ip_pool": floating_ip_pool, |
|
211 |
"state": "ACTIVE"} |
|
197 |
"name": name,
|
|
198 |
"userid": options["owner"],
|
|
199 |
"subnet": subnet,
|
|
200 |
"gateway": gateway,
|
|
201 |
"gateway6": gateway6,
|
|
202 |
"subnet6": subnet6,
|
|
203 |
"dhcp": options["dhcp"],
|
|
204 |
"flavor": flavor,
|
|
205 |
"public": public,
|
|
206 |
"mode": mode,
|
|
207 |
"link": link,
|
|
208 |
"mac_prefix": mac_prefix,
|
|
209 |
"tags": tags,
|
|
210 |
"floating_ip_pool": floating_ip_pool,
|
|
211 |
"state": "ACTIVE"}
|
|
212 | 212 |
|
213 | 213 |
if dry_run: |
214 | 214 |
self.stdout.write("Creating network:\n") |
... | ... | |
232 | 232 |
self.stdout.write("Trying to connect network to backend '%s'\n" % |
233 | 233 |
backend) |
234 | 234 |
jobs = create_network(network=network, backend=backend, |
235 |
connect=True)
|
|
235 |
connect=True) |
|
236 | 236 |
self.stdout.write("Successfully issued jobs: %s\n" % |
237 | 237 |
",".join(jobs)) |
b/snf-cyclades-app/synnefo/api/util.py | ||
---|---|---|
31 | 31 |
# interpreted as representing official policies, either expressed |
32 | 32 |
# or implied, of GRNET S.A. |
33 | 33 |
|
34 |
import datetime |
|
35 | 34 |
import ipaddr |
36 | 35 |
|
37 | 36 |
from base64 import b64encode, b64decode |
38 |
from datetime import timedelta, tzinfo |
|
39 |
from functools import wraps |
|
40 | 37 |
from hashlib import sha256 |
41 | 38 |
from logging import getLogger |
42 | 39 |
from random import choice |
43 | 40 |
from string import digits, lowercase, uppercase |
44 |
from time import time |
|
45 |
from traceback import format_exc |
|
46 |
from wsgiref.handlers import format_date_time |
|
47 |
|
|
48 |
import dateutil.parser |
|
49 | 41 |
|
50 | 42 |
from Crypto.Cipher import AES |
51 | 43 |
|
... | ... | |
53 | 45 |
from django.http import HttpResponse |
54 | 46 |
from django.template.loader import render_to_string |
55 | 47 |
from django.utils import simplejson as json |
56 |
from django.utils.cache import add_never_cache_headers |
|
57 | 48 |
from django.db.models import Q |
58 | 49 |
|
59 | 50 |
from snf_django.lib.api import faults |
... | ... | |
63 | 54 |
FloatingIP) |
64 | 55 |
from synnefo.db.pools import EmptyPool |
65 | 56 |
|
66 |
from snf_django.lib.astakos import get_user |
|
67 | 57 |
from synnefo.plankton.utils import image_backend |
68 | 58 |
from synnefo.settings import MAX_CIDR_BLOCK |
69 | 59 |
|
... | ... | |
251 | 241 |
# Check that network size is allowed! |
252 | 242 |
if not validate_network_size(network.prefixlen): |
253 | 243 |
raise faults.OverLimit(message="Unsupported network size", |
254 |
details="Network mask must be in range (%s, 29]" %
|
|
255 |
MAX_CIDR_BLOCK) |
|
244 |
details="Network mask must be in range"
|
|
245 |
" (%s, 29]" % MAX_CIDR_BLOCK)
|
|
256 | 246 |
|
257 | 247 |
# Check that gateway belongs to network |
258 | 248 |
if gateway: |
... | ... | |
366 | 356 |
|
367 | 357 |
def render_meta(request, meta, status=200): |
368 | 358 |
if request.serialization == 'xml': |
359 |
key, val = meta.items()[0] |
|
369 | 360 |
data = render_to_string('meta.xml', dict(key=key, val=val)) |
370 | 361 |
else: |
371 | 362 |
data = json.dumps(dict(meta=meta)) |
... | ... | |
380 | 371 |
"""Verify that a a list of personalities is well formed""" |
381 | 372 |
if len(personality) > settings.MAX_PERSONALITY: |
382 | 373 |
raise faults.OverLimit("Maximum number of personalities" |
383 |
" exceeded") |
|
374 |
" exceeded")
|
|
384 | 375 |
for p in personality: |
385 | 376 |
# Verify that personalities are well-formed |
386 | 377 |
try: |
... | ... | |
490 | 481 |
"href": join_urls(IMAGES_PLANKTON_URL, str(image_id))}) |
491 | 482 |
return links |
492 | 483 |
|
484 |
|
|
493 | 485 |
def start_action(vm, action, jobId): |
494 | 486 |
vm.action = action |
495 | 487 |
vm.backendjobid = jobId |
b/snf-cyclades-app/synnefo/api/versions.py | ||
---|---|---|
33 | 33 |
|
34 | 34 |
from logging import getLogger |
35 | 35 |
|
36 |
from django.conf import settings |
|
37 | 36 |
from django.http import HttpResponse |
38 | 37 |
from django.template.loader import render_to_string |
39 | 38 |
from django.utils import simplejson as json |
... | ... | |
46 | 45 |
|
47 | 46 |
|
48 | 47 |
VERSION_2_0 = { |
49 |
"id" : "v2.0",
|
|
50 |
"status" : "CURRENT",
|
|
51 |
"updated" : "2011-01-21T11:33:21-06:00",
|
|
48 |
"id": "v2.0", |
|
49 |
"status": "CURRENT", |
|
50 |
"updated": "2011-01-21T11:33:21-06:00", |
|
52 | 51 |
"links": [ |
53 | 52 |
{ |
54 |
"rel" : "self",
|
|
55 |
"href" : COMPUTE_ROOT_URL,
|
|
53 |
"rel": "self", |
|
54 |
"href": COMPUTE_ROOT_URL, |
|
56 | 55 |
}, |
57 | 56 |
], |
58 | 57 |
} |
... | ... | |
61 | 60 |
|
62 | 61 |
MEDIA_TYPES = [ |
63 | 62 |
{ |
64 |
"base" : "application/xml",
|
|
65 |
"type" : "application/vnd.openstack.compute.v2+xml"
|
|
63 |
"base": "application/xml", |
|
64 |
"type": "application/vnd.openstack.compute.v2+xml" |
|
66 | 65 |
}, |
67 | 66 |
{ |
68 |
"base" : "application/json",
|
|
69 |
"type" : "application/vnd.openstack.compute.v2+json"
|
|
67 |
"base": "application/json", |
|
68 |
"type": "application/vnd.openstack.compute.v2+json" |
|
70 | 69 |
} |
71 | 70 |
] |
72 | 71 |
|
73 | 72 |
DESCRIBED_BY = [ |
74 | 73 |
{ |
75 |
"rel" : "describedby", |
|
76 |
"type" : "application/pdf", |
|
77 |
"href" : "http://docs.rackspacecloud.com/servers/api/v2/cs-devguide-20110125.pdf" |
|
74 |
"rel": "describedby", |
|
75 |
"type": "application/pdf", |
|
76 |
"href": "http://docs.rackspacecloud.com/servers/api/v2/" |
|
77 |
"cs-devguide-20110125.pdf" |
|
78 | 78 |
}, |
79 | 79 |
{ |
80 |
"rel" : "describedby", |
|
81 |
"type" : "application/vnd.sun.wadl+xml", |
|
82 |
"href" : "http://docs.rackspacecloud.com/servers/api/v2/application.wadl" |
|
80 |
"rel": "describedby", |
|
81 |
"type": "application/vnd.sun.wadl+xml", |
|
82 |
"href": "http://docs.rackspacecloud.com/servers/api/v2/" |
|
83 |
"application.wadl" |
|
83 | 84 |
} |
84 | 85 |
] |
85 | 86 |
|
b/snf-cyclades-app/synnefo/app_settings/default/reconciliation.py | ||
---|---|---|
5 | 5 |
|
6 | 6 |
# Minutes between reconciliations |
7 | 7 |
RECONCILIATION_MIN = 30 |
8 |
|
b/snf-cyclades-app/synnefo/app_settings/urls.py | ||
---|---|---|
50 | 50 |
astakos_proxy = partial(proxy, proxy_base=BASE_ASTAKOS_PROXY_PATH, |
51 | 51 |
target_base=ASTAKOS_BASE_URL) |
52 | 52 |
|
53 |
cyclades_patterns = api_patterns('', |
|
53 |
cyclades_patterns = api_patterns( |
|
54 |
'', |
|
54 | 55 |
(prefix_pattern(VMAPI_PREFIX), include('synnefo.vmapi.urls')), |
55 | 56 |
(prefix_pattern(PLANKTON_PREFIX), include('synnefo.plankton.urls')), |
56 | 57 |
(prefix_pattern(COMPUTE_PREFIX), include('synnefo.api.urls')), |
... | ... | |
58 | 59 |
(prefix_pattern(ADMIN_PREFIX), include('synnefo.admin.urls')), |
59 | 60 |
) |
60 | 61 |
|
61 |
cyclades_patterns += patterns('', |
|
62 |
cyclades_patterns += patterns( |
|
63 |
'', |
|
62 | 64 |
(prefix_pattern(UI_PREFIX), include('synnefo.ui.urls')), |
63 | 65 |
(prefix_pattern(HELPDESK_PREFIX), include('synnefo.helpdesk.urls')), |
64 | 66 |
) |
... | ... | |
72 | 74 |
astakos_proxy = partial(proxy, proxy_base=BASE_ASTAKOS_PROXY_PATH, |
73 | 75 |
target_base=ASTAKOS_BASE_URL) |
74 | 76 |
|
75 |
proxy_patterns = patterns('', |
|
77 |
proxy_patterns = patterns( |
|
78 |
'', |
|
76 | 79 |
(prefix_pattern(ASTAKOS_VIEWS_PREFIX), astakos_proxy), |
77 | 80 |
) |
78 | 81 |
proxy_patterns += api_patterns( |
b/snf-cyclades-app/synnefo/cyclades_settings.py | ||
---|---|---|
73 | 73 |
# Patch astakosclient directly, otherwise it will not see any customization |
74 | 74 |
#astakos_services = deepcopy(vanilla_astakos_services) |
75 | 75 |
CUSTOMIZE_ASTAKOS_SERVICES = \ |
76 |
getattr(settings, 'CYCLADES_CUSTOMIZE_ASTAKOS_SERVICES', ())
|
|
76 |
getattr(settings, 'CYCLADES_CUSTOMIZE_ASTAKOS_SERVICES', ()) |
|
77 | 77 |
|
78 | 78 |
astakos_services = deepcopy(vanilla_astakos_services) |
79 | 79 |
fill_endpoints(astakos_services, ASTAKOS_BASE_URL) |
b/snf-cyclades-app/synnefo/quotas/util.py | ||
---|---|---|
57 | 57 |
disk=Sum("flavor__disk")) |
58 | 58 |
vm_active_resources = \ |
59 | 59 |
vms.values("userid")\ |
60 |
.filter(Q(operstate="STARTED") | Q(operstate="BUILD") |\
|
|
60 |
.filter(Q(operstate="STARTED") | Q(operstate="BUILD") | |
|
61 | 61 |
Q(operstate="ERROR"))\ |
62 | 62 |
.annotate(active_ram=Sum("flavor__ram"), |
63 | 63 |
active_cpu=Sum("flavor__cpu")) |
b/snf-cyclades-app/synnefo/versions/__init__.py | ||
---|---|---|
38 | 38 |
except ImportError: |
39 | 39 |
import pkgutil |
40 | 40 |
__path__ = pkgutil.extend_path(__path__, __name__) |
41 |
|
b/snf-django-lib/snf_django/lib/api/utils.py | ||
---|---|---|
104 | 104 |
except ValueError: |
105 | 105 |
raise faults.BadRequest("Invalid JSON data") |
106 | 106 |
else: |
107 |
raise faults.BadRequest("Unsupported Content-type: '%s'" % content_type) |
|
107 |
raise faults.BadRequest("Unsupported Content-type: '%s'" % |
|
108 |
content_type) |
|
108 | 109 |
|
109 | 110 |
|
110 | 111 |
def prefix_pattern(prefix): |
Also available in: Unified diff