Revision 32e4e343 snf-cyclades-app/synnefo/api/util.py
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 |
Also available in: Unified diff