Commit c8ada5c2 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki

astakos: move get_services back to astakos im services

parent f3c0e4ce
......@@ -18,7 +18,6 @@ Synnefo-wide
------------
* Create 'snf_django' Python package to hold common code for all Synnefo
components.
* CLOUDBAR_SERVICES_URL should point to /astakos/api/get_services
Astakos
-------
......
......@@ -35,7 +35,7 @@ Returns a json formatted list containing information about the supported cloud s
============================= ========= ==================
Uri Method Description
============================= ========= ==================
``/astakos/api/get_services`` GET Get cloud services
``/im/get_services`` GET Get cloud services
============================= ========= ==================
Example reply:
......@@ -46,9 +46,6 @@ Example reply:
{"url": "/okeanos.html", "name": "~okeanos", "id": "2"},
{"url": "/ui/", "name": "pithos+", "id": "3"}]
.. warning:: The service is also available under ``/im/get_services``.
It will be removed in the next version.
Get Menu
^^^^^^^^
......
......@@ -610,7 +610,7 @@ Then edit ``/etc/synnefo/20-snf-astakos-app-cloudbar.conf`` :
CLOUDBAR_LOCATION = 'https://node1.example.com/static/im/cloudbar/'
CLOUDBAR_SERVICES_URL = 'https://node1.example.com/astakos/api/get_services'
CLOUDBAR_SERVICES_URL = 'https://node1.example.com/im/get_services'
CLOUDBAR_MENU_URL = 'https://node1.example.com/im/get_menu'
......@@ -912,7 +912,7 @@ pithos+ web UI with the astakos web UI (through the top cloudbar):
CLOUDBAR_LOCATION = 'https://node1.example.com/static/im/cloudbar/'
PITHOS_UI_CLOUDBAR_ACTIVE_SERVICE = '3'
CLOUDBAR_SERVICES_URL = 'https://node1.example.com/astakos/api/get_services'
CLOUDBAR_SERVICES_URL = 'https://node1.example.com/im/get_services'
CLOUDBAR_MENU_URL = 'https://node1.example.com/im/get_menu'
The ``CLOUDBAR_LOCATION`` tells the client where to find the astakos common
......@@ -1722,7 +1722,7 @@ Edit ``/etc/synnefo/20-snf-cyclades-app-cloudbar.conf``:
CLOUDBAR_LOCATION = 'https://node1.example.com/static/im/cloudbar/'
CLOUDBAR_ACTIVE_SERVICE = '2'
CLOUDBAR_SERVICES_URL = 'https://node1.example.com/astakos/api/get_services'
CLOUDBAR_SERVICES_URL = 'https://node1.example.com/im/get_services'
CLOUDBAR_MENU_URL = 'https://account.node1.example.com/im/get_menu'
``CLOUDBAR_LOCATION`` tells the client where to find the Astakos common
......
......@@ -39,7 +39,7 @@ In `/etc/synnefo/astakos.conf` add:
.. code-block:: console
CLOUDBAR_LOCATION = 'https://accounts.example.com/static/im/cloudbar/'
CLOUDBAR_SERVICES_URL = 'https://accounts.example.com/astakos/api/get_services'
CLOUDBAR_SERVICES_URL = 'https://accounts.example.com/im/get_services'
CLOUDBAR_MENU_URL = 'https://accounts.example.com/im/get_menu'
ASTAKOS_IM_MODULES = ['local']
......
......@@ -42,7 +42,7 @@ In `/etc/synnefo/cloudcms.conf` add:
CLOUDBAR_ACTIVE = True
CLOUDBAR_LOCATION = 'https://accounts.example.com/static/im/cloudbar/'
CLOUDBAR_SERVICES_URL = 'https://accounts.example.com/astakos/api/get_services'
CLOUDBAR_SERVICES_URL = 'https://accounts.example.com/im/get_services'
CLOUDBAR_MENU_URL = 'https://accounts.example.com/im/get_menu'
WEBPROJECT_SERVE_STATIC = True
......
......@@ -64,7 +64,7 @@ In `/etc/synnefo/cyclades.conf` add:
GANETI_USE_HOTPLUG = True
CLOUDBAR_LOCATION = 'https://accounts.example.com/static/im/cloudbar/'
CLOUDBAR_ACTIVE_SERVICE = '2'
CLOUDBAR_SERVICES_URL = 'https://accounts.example.com/astakos/api/get_services'
CLOUDBAR_SERVICES_URL = 'https://accounts.example.com/im/get_services'
CLOUDBAR_MENU_URL = 'https://accounts.example.com/im/get_menu'
BACKEND_DB_CONNECTION = 'postgresql://synnefo:example_passw0rd@db.example.com:5432/snf_pithos'
BACKEND_BLOCK_PATH = '/srv/pithos/data/'
......
......@@ -85,7 +85,7 @@ In `/etc/synnefo/webclient.conf` add:
.. code-block:: console
CLOUDBAR_LOCATION = 'https://accounts.example.com/static/im/cloudbar/'
CLOUDBAR_SERVICES_URL = 'https://accounts.example.com/astakos/api/get_services'
CLOUDBAR_SERVICES_URL = 'https://accounts.example.com/im/get_services'
CLOUDBAR_MENU_URL = 'https://accounts.example.com/im/get_menu'
PITHOS_UI_CLOUDBAR_ACTIVE_SERVICE = 'XXXXXXXX'
......
......@@ -74,49 +74,3 @@ Finally, Astakos needs to inform the quota system for the current number
of pending applications per user::
astakos-host$ snf-manage reconcile-resources-astakos --fix
4 Change Astakos URIs in settings
=================================
In astakos-host edit ``/etc/synnefo/20-snf-astakos-app-cloudbar.conf`` and replace
the following line:
.. code-block:: console
CLOUDBAR_SERVICES_URL = 'https://node1.example.com/im/get_services'
with:
.. code-block:: console
CLOUDBAR_SERVICES_URL = 'https://node1.example.com/astakos/api/get_services'
|
Also in pithos-host edit ``/etc/synnefo/20-snf-pithos-webclient-cloudbar.conf``
and the following line:
.. code-block:: console
CLOUDBAR_SERVICES_URL = 'https://node1.example.com/im/get_services'
with:
.. code-block:: console
CLOUDBAR_SERVICES_URL = 'https://node1.example.com/astakos/api/get_services'
|
Finally in cyclades-node edit ``/etc/synnefo/20-snf-cyclades-app-cloudbar.conf``
and replace the following line:
.. code-block:: console
CLOUDBAR_SERVICES_URL = 'https://node1.example.com/im/get_services'
with:
.. code-block:: console
CLOUDBAR_SERVICES_URL = 'https://node1.example.com/astakos/api/get_services'
# Copyright 2013 GRNET S.A. All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
#
# 1. Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
# Decorator for API methods, using common utils.api_method decorator.
# It is used for 'get_services' and 'get_menu' methods that do not
# require any sort of authentication
from functools import partial
from django.http import HttpResponse
from django.utils import simplejson as json
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext as _
from django.contrib import messages
from django.contrib.auth.models import User
from snf_django.lib import api
from astakos.im.models import Service
from astakos.im import settings
import logging
logger = logging.getLogger(__name__)
absolute = lambda request, url: request.build_absolute_uri(url)
api_method = partial(api.api_method, user_required=False,
token_required=False, logger=logger)
@api_method(http_method=None)
def get_services(request):
callback = request.GET.get('callback', None)
mimetype = 'application/json'
data = json.dumps(Service.catalog().values())
if callback:
# Consume session messages. When get_services is loaded from an astakos
# page, messages should have already been consumed in the html
# response. When get_services is loaded from another domain/service we
# consume them here so that no stale messages to appear if user visits
# an astakos view later on.
# TODO: messages could be served to other services/sites in the dict
# response of get_services and/or get_menu. Services could handle those
# messages respectively.
messages_list = list(messages.get_messages(request))
mimetype = 'application/javascript'
data = '%s(%s)' % (callback, data)
return HttpResponse(content=data, mimetype=mimetype)
......@@ -33,12 +33,8 @@
from django.conf.urls.defaults import patterns, url
urlpatterns = patterns(
'astakos.api',
url(r'^get_services/?$', 'get_services'),
)
urlpatterns += patterns(
urlpatterns = patterns(
'astakos.api.quotas',
url(r'^quotas/?$', 'quotas', name="astakos-api-quotas"),
url(r'^service_quotas/?$', 'service_quotas'),
......
......@@ -146,7 +146,8 @@ if 'linkedin' in settings.IM_MODULES:
urlpatterns += patterns(
'astakos.im.views',
url(r'^get_menu/?$', 'get_menu'))
url(r'^get_menu/?$', 'get_menu'),
url(r'^get_services/?$', 'get_services'))
urlpatterns += patterns(
'astakos.api.user',
......
......@@ -903,3 +903,24 @@ class MenuItem(dict):
super(MenuItem, self).__setattribute__(name, value)
if name == 'current_path':
self.__set_is_active__()
def get_services(request):
callback = request.GET.get('callback', None)
mimetype = 'application/json'
data = json.dumps(Service.catalog().values())
if callback:
# Consume session messages. When get_services is loaded from an astakos
# page, messages should have already been consumed in the html
# response. When get_services is loaded from another domain/service we
# consume them here so that no stale messages to appear if user visits
# an astakos view later on.
# TODO: messages could be served to other services/sites in the dict
# response of get_services and/or get_menu. Services could handle those
# messages respectively.
messages_list = list(messages.get_messages(request))
mimetype = 'application/javascript'
data = '%s(%s)' % (callback, data)
return HttpResponse(content=data, mimetype=mimetype)
#CLOUDBAR_ACTIVE = True
#CLOUDBAR_LOCATION = 'https://accounts.example.synnefo.org/static/im/cloudbar/'
#CLOUDBAR_COOKIE_NAME = '_pithos2_a'
#CLOUDBAR_SERVICES_URL = 'https://accounts.example.synnefo.org/astakos/api/get_services'
#CLOUDBAR_SERVICES_URL = 'https://accounts.example.synnefo.org/im/get_services'
#CLOUDBAR_MENU_URL = 'https://accounts.example.synnefo.org/im/get_menu'
......@@ -37,7 +37,7 @@ def cloudbar(request):
CB_ACTIVE_SERVICE = getattr(settings, 'CLOUDBAR_ACTIVE_SERVICE',
'cloud')
CB_SERVICES_URL = getattr(settings, 'CLOUDBAR_SERVICES_URL',
'https://accounts.okeanos.grnet.gr/astakos/api/get_services')
'https://accounts.okeanos.grnet.gr/im/get_services')
CB_MENU_URL = getattr(settings, 'CLOUDBAR_MENU_URL',
'https://accounts.okeanos.grnet.gr/im/get_menu')
CB_HEIGHT = getattr(settings, 'CLOUDBAR_HEIGHT',
......
......@@ -2,6 +2,6 @@
#CLOUDBAR_LOCATION = 'https://accounts.synnefo.org/static/im/cloudbar/'
#CLOUDBAR_COOKIE_NAME = '_pithos2_a'
#CLOUDBAR_ACTIVE_SERVICE = 'cloud'
#CLOUDBAR_SERVICES_URL = 'https://accounts.synnefo.org/astakos/api/get_services'
#CLOUDBAR_MENU_URL = 'https://accounts.synnefo.org/im/get_menu'
#CLOUDBAR_SERVICES_URL = 'https://accounts.okeanos.grnet.gr/im/get_services'
#CLOUDBAR_MENU_URL = 'https://accounts.okeanos.grnet.gr/im/get_menu'
#
......@@ -2,6 +2,6 @@ CLOUDBAR_ACTIVE = True
CLOUDBAR_LOCATION = 'https://accounts.synnefo.org/static/im/cloudbar/'
CLOUDBAR_COOKIE_NAME = '_pithos2_a'
CLOUDBAR_ACTIVE_SERVICE = 'cloud'
CLOUDBAR_SERVICES_URL = 'https://accounts.synnefo.org/astakos/api/get_services'
CLOUDBAR_SERVICES_URL = 'https://accounts.synnefo.org/im/get_services'
CLOUDBAR_MENU_URL = 'https://accounts.synnefo.org/im/get_menu'
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