Commit df0a350d authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

Merge branch 'develop' into feature-quotas

parents 2373cc88 d255a830
......@@ -1801,7 +1801,7 @@ Edit ``/etc/default/vncauthproxy``:
.. code-block:: console
CHUID="www-data:nogroup"
CHUID="nobody:www-data"
We have now finished with the basic Cyclades and Plankton configuration.
......
......@@ -39,12 +39,12 @@ from django.utils.translation import ugettext as _
from django.contrib import messages
from django.template import RequestContext
from django.views.decorators.http import require_http_methods
from django.http import HttpResponseRedirect
from django.http import HttpResponseRedirect, urlencode
from django.core.urlresolvers import reverse
from django.core.exceptions import ImproperlyConfigured
from django.shortcuts import get_object_or_404
from urlparse import urlunsplit, urlsplit
from urlparse import urlunsplit, urlsplit, parse_qsl
from astakos.im.util import prepare_response, get_context, login_url
from astakos.im.views import requires_anonymous, render_response, \
......@@ -67,9 +67,9 @@ import oauth2 as oauth
import cgi
import urllib
request_token_url = 'http://twitter.com/oauth/request_token'
access_token_url = 'http://twitter.com/oauth/access_token'
authenticate_url = 'http://twitter.com/oauth/authenticate'
request_token_url = 'https://api.twitter.com/oauth/request_token'
access_token_url = 'https://api.twitter.com/oauth/access_token'
authenticate_url = 'https://api.twitter.com/oauth/authenticate'
@requires_auth_provider('twitter')
@require_http_methods(["GET", "POST"])
......@@ -125,7 +125,15 @@ def authenticated(
client = oauth.Client(consumer, token)
# Step 2. Request the authorized access token from Twitter.
resp, content = client.request(access_token_url, "GET")
parts = list(urlsplit(access_token_url))
params = dict(parse_qsl(parts[3], keep_blank_values=True))
oauth_verifier = request.GET.get('oauth_verifier')
params['oauth_verifier'] = oauth_verifier
parts[3] = urlencode(params)
parameterized_url = urlunsplit(parts)
resp, content = client.request(parameterized_url, "GET")
if resp['status'] != '200':
try:
del request.session['request_token']
......
......@@ -146,6 +146,7 @@ class Command(BaseCommand):
link = options['link']
mac_prefix = options['mac_prefix']
tags = options['tags']
userid = options["owner"]
if not name:
raise CommandError("Name is required")
......@@ -155,9 +156,8 @@ class Command(BaseCommand):
raise CommandError("Flavor is required")
if public and not backend_id:
raise CommandError("backend-id is required")
if backend_id and not public:
raise CommandError("Private networks must be created to"
" all backends")
if not userid and not public:
raise CommandError("'owner' is required for private networks")
if mac_prefix and flavor == "MAC_FILTERED":
raise CommandError("Can not override MAC_FILTERED mac-prefix")
......
......@@ -94,6 +94,8 @@ class Command(BaseCommand):
raise CommandError("user-id is mandatory")
if not password:
raise CommandError("password is mandatory")
if not flavor_id:
raise CommandError("flavor-id is mandatory")
# Get Flavor
if flavor_id:
......
......@@ -338,7 +338,7 @@ def create_server(serials, request):
# create this NIC, because if the hooks never run (e.g. building error)
# the VM's public IP address will never be released!
NetworkInterface.objects.create(machine=vm, network=network, index=0,
ipv4=address, state="Buidling")
ipv4=address, state="BUILDING")
log.info("Created entry in DB for VM '%s'", vm)
......
......@@ -59,7 +59,7 @@ from django.db.models import Q
from snf_django.lib.api import faults
from synnefo.db.models import (Flavor, VirtualMachine, VirtualMachineMetadata,
Network, BackendNetwork, NetworkInterface,
BridgePoolTable, MacPrefixPoolTable)
BridgePoolTable, MacPrefixPoolTable, Backend)
from synnefo.db.pools import EmptyPool
from snf_django.lib.astakos import get_user
......@@ -267,6 +267,12 @@ def get_public_ip(backend):
This method should run inside a transaction.
"""
# Guarantee exclusive access to backend, because accessing the IP pools of
# the backend networks may result in a deadlock with backend allocator
# which also checks that backend networks have a free IP.
backend = Backend.objects.select_for_update().get(id=backend.id)
address = None
if settings.PUBLIC_USE_POOL:
(network, address) = allocate_public_address(backend)
......
......@@ -35,6 +35,7 @@ from logging import getLogger
from django.utils import simplejson as json
from django.core.urlresolvers import reverse
from urlparse import urljoin
from synnefo.api.servers import server_created
from synnefo.vmapi import backend, get_key, get_uuid, settings
......@@ -49,10 +50,10 @@ def create_server_params(sender, created_vm_params, **kwargs):
log.info("Setting vmapi params with key %s for %s", key, sender)
backend.set(key, json_value)
config_url = urljoin(settings.BASE_URL, reverse("vmapi_server_params",
args=[uuid]))
# inject sender (vm) with its configuration url
setattr(sender, 'config_url', "%s%s" % (settings.BASE_URL,
reverse('vmapi_server_params',
args=[uuid])))
setattr(sender, 'config_url', config_url)
return uuid
server_created.connect(create_server_params)
......@@ -104,6 +104,8 @@ class ListCommand(BaseCommand):
# Default filters and excludes
filters = {}
excludes = {}
# Order results
order_by = None
# Fields used only with user_user_field
astakos_url = None
......@@ -240,6 +242,9 @@ class ListCommand(BaseCommand):
except Exception as e:
raise CommandError("Can not filter results: %s" % e)
order_key = self.order_by if self.order_by is not None else 'pk'
objects = objects.order_by(order_key)
# --display-mails option
display_mails = options.get("display_mails")
if display_mails:
......
import sys
from synnefo.webproject.management import util
from synnefo.webproject.management import utils
# Use backported unittest functionality if Python < 2.7
try:
......@@ -12,17 +12,20 @@ except ImportError:
class ParseFiltersTestCase(unittest.TestCase):
def test_parse_empty(self):
res = util.parse_filters("")
res = utils.parse_filters("")
self.assertEqual(res, ({}, {}))
def test_parse_one(self):
res = util.parse_filters("x=2")
res = utils.parse_filters("x=2")
self.assertEqual(res, ({"x": "2"}, {}))
res = util.parse_filters("x!=2")
res = utils.parse_filters("x!=2")
self.assertEqual(res, ({}, {"x": "2"}))
def test_parse_many(self):
res = util.parse_filters("x=2,x>=3,y!=4,z<3")
res = utils.parse_filters("x=2,x>=3,y!=4,z<3")
filters = {"x": "2", "x__gte": "3", "z__lt": "3"}
excludes = {"y": "4"}
self.assertEqual(res, (filters, excludes))
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment