commit 27738c439056b9b97f3cb77fcfe38db78df6b3a8
Author: Kostas Papadimitriou <kpap@grnet.gr>
Date:   Thu May 30 14:45:45 2013 +0300

    cyclades ui: Clean up ui url settings
    
    - Removed most url's from ui conf file. Default values are dynamically set based
      on other settings (CYCLADES_BASE_URL, ASTAKOS_BASE_URL etc.). We still do
      service lookups to be able to change urls in *extraordinary* deployments.
    - Moved url settings in ui.settings module

diff --git a/snf-cyclades-app/conf/20-snf-cyclades-app-ui.conf b/snf-cyclades-app/conf/20-snf-cyclades-app-ui.conf
index 5c2f979..d87be17 100644
--- a/snf-cyclades-app/conf/20-snf-cyclades-app-ui.conf
+++ b/snf-cyclades-app/conf/20-snf-cyclades-app-ui.conf
@@ -3,9 +3,6 @@
 ## UI settings
 ####################
 #
-## API URL
-#COMPUTE_API_URL = '/api/v1.1'
-#
 ## base url for ui static files
 ## if not set, defaults to MEDIA_URL + 'snf-<latest_ui_version>/'
 #UI_MEDIA_URL = '/static/ui/static/snf/'
@@ -39,12 +36,6 @@
 ## consecutive API calls (aligning changes-since attribute).
 #UI_CHANGES_SINCE_ALIGNMENT = 0
 #
-## URL to redirect not authenticated users
-#UI_LOGIN_URL = "/im/login"
-#
-## URL to redirect user to when he logs out from the ui
-#UI_LOGOUT_URL = "/im/logout"
-#
 ## Cookie name to retrieve authentication data from
 #UI_AUTH_COOKIE_NAME = '_pithos2_a'
 #
@@ -187,12 +178,8 @@
 ## UI EXTENSIONS
 ################
 #
-## Glance images API endpoint
-#UI_GLANCE_API_URL = '/plankton'
-#
 ## Whether or not UI should display images from the Glance API
-## set in UI_GLANCE_API_URL, if setting is set to False, ui will
-## request images from Compute API
+## If setting is set to False, ui will request images from Compute API
 #UI_ENABLE_GLANCE = True
 #
 ## a dict of image owner ids and their associate name
diff --git a/snf-cyclades-app/synnefo/app_settings/default/ui.py b/snf-cyclades-app/synnefo/app_settings/default/ui.py
index f029379..8ec5db5 100644
--- a/snf-cyclades-app/synnefo/app_settings/default/ui.py
+++ b/snf-cyclades-app/synnefo/app_settings/default/ui.py
@@ -43,12 +43,6 @@ UI_CHANGES_SINCE_ALIGNMENT = 0
 # How often to check for user usage changes
 UI_QUOTAS_UPDATE_INTERVAL = 10000
 
-# URL to redirect not authenticated users
-UI_LOGIN_URL = "/im/login"
-
-# URL to redirect user to when he logs out from the ui
-UI_LOGOUT_URL = "/im/logout"
-
 # Cookie name to retrieve authentication data from
 UI_AUTH_COOKIE_NAME = '_pithos2_a'
 
@@ -79,10 +73,12 @@ VM_CREATE_SUGGESTED_FLAVORS = {
 
 # A list of metadata keys to clone from image
 # to the virtual machine on its creation.
-VM_IMAGE_COMMON_METADATA = ["OS", "loginname", "logindomain", "users", "remote"]
+VM_IMAGE_COMMON_METADATA = ["OS", "loginname", "logindomain", "users",
+                            "remote"]
 
 # A list of suggested vm roles to display to user on create wizard
-VM_CREATE_SUGGESTED_ROLES = ["Database server", "File server", "Mail server", "Web server", "Proxy"]
+VM_CREATE_SUGGESTED_ROLES = ["Database server", "File server", "Mail server",
+                             "Web server", "Proxy"]
 
 # Template to be used for suggesting the user a default name for newly created
 # vms. {0} gets replaced by the image OS value
@@ -149,7 +145,7 @@ UI_SUPPORT_SSH_OS_LIST = ['debian', 'fedora', 'okeanos', 'ubuntu', 'kubuntu',
 
 # OS/username map to identify default user name for the specified os
 UI_OS_DEFAULT_USER_MAP = {
-    'debian':'root', 'fedora': 'root', 'okeanos': 'root',
+    'debian': 'root', 'fedora': 'root', 'okeanos': 'root',
     'ubuntu': 'root', 'kubuntu': 'root', 'centos': 'root',
     'windows': 'Administrator'
 }
@@ -162,8 +158,8 @@ UI_OS_DEFAULT_USER_MAP = {
 # If only one set, no select options will be displayed
 UI_NETWORK_AVAILABLE_NETWORK_TYPES = {'MAC_FILTERED': 'mac-filtering'}
 
-# Suggested private networks to let the user choose from when creating a private
-# network with dhcp enabled
+# Suggested private networks to let the user choose from when creating a
+# private network with dhcp enabled
 UI_NETWORK_AVAILABLE_SUBNETS = ['10.0.0.0/24', '192.168.0.0/24']
 
 # UI will use this setting to find an available network subnet if user requests
@@ -189,9 +185,6 @@ UI_GROUPED_PUBLIC_NETWORK_NAME = 'Internet'
 # UI EXTENSIONS
 ###############
 
-# Glance images API endpoint
-#UI_GLANCE_API_URL = '/plankton'
-
 # Whether or not UI should display images from the Glance API
 # set in UI_GLANCE_API_URL, if setting is set to False, ui will
 # request images from Compute API
diff --git a/snf-cyclades-app/synnefo/ui/settings.py b/snf-cyclades-app/synnefo/ui/settings.py
new file mode 100644
index 0000000..dc14d51
--- /dev/null
+++ b/snf-cyclades-app/synnefo/ui/settings.py
@@ -0,0 +1,68 @@
+# 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.
+#
+
+import synnefo.cyclades_settings as cyclades
+
+from synnefo.lib import join_urls
+from django.conf import settings
+
+
+ASTAKOS_VIEWS_URL = join_urls(cyclades.ASTAKOS_BASE_URL,
+                              cyclades.ASTAKOS_VIEWS_PREFIX)
+
+ASTAKOS_ACCOUNTS_URL = join_urls(cyclades.ASTAKOS_BASE_URL,
+                                 cyclades.ASTAKOS_ACCOUNTS_PREFIX)
+if cyclades.PROXY_USER_SERVICES:
+    ASTAKOS_ACCOUNTS_URL = join_urls(cyclades.BASE_ASTAKOS_PROXY_PATH,
+                                     cyclades.ASTAKOS_ACCOUNTS_PREFIX)
+
+
+ACCOUNTS_URL = getattr(settings, 'CYCLADES_UI_ACCOUNTS_URL',
+                       join_urls(ASTAKOS_ACCOUNTS_URL))
+USER_CATALOG_URL = getattr(settings, 'CYCLADES_UI_USER_CATALOG_URL',
+                           join_urls(ACCOUNTS_URL, 'user_catalogs'))
+FEEDBACK_URL = getattr(settings, 'CYCLADES_UI_FEEDBACK_URL',
+                       join_urls(ACCOUNTS_URL, 'feedback'))
+COMPUTE_URL = getattr(settings, 'CYCLADES_UI_COMPUTE_URL',
+                      join_urls(cyclades.BASE_PATH,
+                                cyclades.COMPUTE_PREFIX,
+                                'v1.1'))
+GLANCE_URL = getattr(settings, 'CYCLADES_UI_GLANCE_URL',
+                     join_urls(cyclades.BASE_PATH, cyclades.PLANKTON_PREFIX))
+USERDATA_URL = getattr(settings, 'CYCLADES_UI_USERDATA_URL',
+                       join_urls(cyclades.BASE_PATH, cyclades.USERDATA_PREFIX))
+LOGIN_URL = getattr(settings, 'CYCLADES_UI_LOGIN_URL',
+                    join_urls(cyclades.ASTAKOS_BASE_URL,
+                              cyclades.ASTAKOS_VIEWS_PREFIX, 'login'))
+LOGOUT_REDIRECT = getattr(settings, 'CYCLADES_UI_LOGOUT_REDIRECT', LOGIN_URL)
diff --git a/snf-cyclades-app/synnefo/ui/templates/home.html b/snf-cyclades-app/synnefo/ui/templates/home.html
index 17560e6..b7346ba 100644
--- a/snf-cyclades-app/synnefo/ui/templates/home.html
+++ b/snf-cyclades-app/synnefo/ui/templates/home.html
@@ -84,7 +84,7 @@
     <script>
         tmp_auth_client = new synnefo.auth.AstakosClient({
             cookie_name: '{{ auth_cookie_name }}',
-            login_url: '{{ login_redirect }}'
+            login_url: {{ login_redirect|safe }}
         });
         if (!tmp_auth_client.get_token()) { tmp_auth_client.redirect_to_login(); }
     </script>
@@ -637,8 +637,8 @@
             synnefo.config.os_created_users = {{ os_created_users|safe }};
             synnefo.config.feedback_post_url = {{ feedback_post_url|safe }};
             
-            synnefo.config.logout_redirect = '{{ logout_redirect }}';
-            synnefo.config.login_redirect = '{{ login_redirect }}';
+            synnefo.config.logout_redirect = {{ logout_redirect|safe }};
+            synnefo.config.login_redirect = {{ login_redirect|safe }};
             synnefo.config.auth_cookie_name = '{{ auth_cookie_name }}';
 
             synnefo.config.translate_uuids = {{ translate_uuids|safe }};
diff --git a/snf-cyclades-app/synnefo/ui/views.py b/snf-cyclades-app/synnefo/ui/views.py
index 3fb0240..f7a5345 100644
--- a/snf-cyclades-app/synnefo/ui/views.py
+++ b/snf-cyclades-app/synnefo/ui/views.py
@@ -52,30 +52,9 @@ from synnefo.lib import join_urls
 
 from snf_django.lib.astakos import get_user
 from synnefo import cyclades_settings
+from synnefo.ui import settings as uisettings
 
 SYNNEFO_JS_LIB_VERSION = get_component_version('app')
-PROXY_USER_SERVICES = getattr(settings, 'CYCLADES_PROXY_USER_SERVICES', True)
-
-
-# resolve astakos base url to be used by ui
-UI_ASTAKOS_BASE_HREF = cyclades_settings.ASTAKOS_BASE_URL
-if PROXY_USER_SERVICES:
-    UI_ASTAKOS_BASE_HREF = \
-        '/' + cyclades_settings.BASE_ASTAKOS_PROXY_PATH.lstrip('/')
-
-UI_ASTAKOS_ACCOUNTS_HREF = join_urls(UI_ASTAKOS_BASE_HREF,
-                                     cyclades_settings.ASTAKOS_ACCOUNTS_PREFIX)
-
-UI_ASTAKOS_VIEWS_HREF = join_urls(UI_ASTAKOS_BASE_HREF,
-                                  cyclades_settings.ASTAKOS_VIEWS_PREFIX)
-
-UI_ASTAKOS_KEYSTONE_HREF = join_urls(UI_ASTAKOS_BASE_HREF,
-                                     cyclades_settings.ASTAKOS_KEYSTONE_PREFIX)
-
-# api configuration
-api_path = join_urls(cyclades_settings.COMPUTE_PREFIX, 'v1.1').lstrip('/')
-api_path = '/' + join_urls(cyclades_settings.BASE_PATH, api_path).lstrip('/')
-COMPUTE_API_HREF = getattr(settings, 'COMPUTE_API_URL', api_path)
 
 # UI preferences settings
 TIMEOUT = getattr(settings, "TIMEOUT", 10000)
@@ -108,14 +87,6 @@ SUPPORT_SSH_OS_LIST = getattr(settings, "UI_SUPPORT_SSH_OS_LIST",)
 OS_CREATED_USERS = getattr(settings, "UI_OS_DEFAULT_USER_MAP")
 UNKNOWN_OS = getattr(settings, "UI_UNKNOWN_OS", "unknown")
 
-LOGOUT_PATH = join_urls(cyclades_settings.ASTAKOS_ACCOUNTS_PREFIX,
-                        getattr(settings, "UI_LOGOUT_PATH", 'authenticate'))
-LOGOUT_URL = join_urls(cyclades_settings.ASTAKOS_BASE_URL, LOGOUT_PATH)
-
-LOGIN_PATH = join_urls(cyclades_settings.ASTAKOS_VIEWS_PREFIX,
-                       getattr(settings, "UI_LOGIN_PATH", 'login'))
-LOGIN_URL = join_urls(cyclades_settings.ASTAKOS_BASE_URL, LOGIN_PATH)
-
 AUTH_COOKIE_NAME = getattr(settings, "UI_AUTH_COOKIE_NAME", 'synnefo_user')
 
 # UI behaviour settings
@@ -160,10 +131,6 @@ UI_SYNNEFO_JS_WEB_URL = \
 
 # extensions
 ENABLE_GLANCE = getattr(settings, 'UI_ENABLE_GLANCE', True)
-glance_path = join_urls(cyclades_settings.BASE_PATH,
-                        cyclades_settings.PLANKTON_PREFIX)
-glance_path = '/' + glance_path.lstrip('/')
-GLANCE_API_HREF = getattr(settings, 'UI_GLANCE_API_URL', glance_path)
 
 DIAGNOSTICS_UPDATE_INTERVAL = \
     getattr(settings, 'UI_DIAGNOSTICS_UPDATE_INTERVAL', 2000)
@@ -195,18 +162,6 @@ GROUP_PUBLIC_NETWORKS = getattr(settings, 'UI_GROUP_PUBLIC_NETWORKS', True)
 GROUPED_PUBLIC_NETWORK_NAME = \
     getattr(settings, 'UI_GROUPED_PUBLIC_NETWORK_NAME', 'Internet')
 
-USER_CATALOG_PATH = getattr(settings, 'UI_USER_CATALOG_PATH', 'user_catalogs')
-USER_CATALOG_HREF = join_urls(UI_ASTAKOS_ACCOUNTS_HREF, USER_CATALOG_PATH)
-
-FEEDBACK_POST_PATH = getattr(settings, 'UI_FEEDBACK_POST_PATH', 'feedback')
-FEEDBACK_POST_HREF = join_urls(UI_ASTAKOS_ACCOUNTS_HREF, FEEDBACK_POST_PATH)
-
-
-ACCOUNTS_API_VERSION = getattr(settings, 'UI_ACCOUNTS_API_VERSION', '')
-ACCOUNTS_API_HREF = join_urls(UI_ASTAKOS_ACCOUNTS_HREF, ACCOUNTS_API_VERSION)
-
-TRANSLATE_UUIDS = not getattr(settings, 'TRANSLATE_UUIDS', False)
-
 
 def template(name, request, context):
     template_path = os.path.join(os.path.dirname(__file__), "templates/")
@@ -231,11 +186,14 @@ def home(request):
                'project': '+nefo',
                'request': request,
                'current_lang': get_language() or 'en',
-               'compute_api_url': json.dumps(COMPUTE_API_HREF),
-               'user_catalog_url': json.dumps(USER_CATALOG_HREF),
-               'feedback_post_url': json.dumps(FEEDBACK_POST_HREF),
-               'accounts_api_url': json.dumps(ACCOUNTS_API_HREF),
-               'translate_uuids': json.dumps(TRANSLATE_UUIDS),
+               'compute_api_url': json.dumps(uisettings.COMPUTE_URL),
+               'user_catalog_url': json.dumps(uisettings.USER_CATALOG_URL),
+               'feedback_post_url': json.dumps(uisettings.FEEDBACK_URL),
+               'accounts_api_url': json.dumps(uisettings.ACCOUNTS_URL),
+               'logout_redirect': json.dumps(uisettings.LOGOUT_REDIRECT),
+               'login_redirect': json.dumps(uisettings.LOGIN_URL),
+               'glance_api_url': json.dumps(uisettings.GLANCE_URL),
+               'translate_uuids': json.dumps(True),
                # update interval settings
                'update_interval': UPDATE_INTERVAL,
                'update_interval_increase': UPDATE_INTERVAL_INCREASE,
@@ -245,8 +203,6 @@ def home(request):
                'update_interval_max': UPDATE_INTERVAL_MAX,
                'changes_since_alignment': CHANGES_SINCE_ALIGNMENT,
                'image_icons': IMAGE_ICONS,
-               'logout_redirect': LOGOUT_URL,
-               'login_redirect': LOGIN_URL,
                'auth_cookie_name': AUTH_COOKIE_NAME,
                'suggested_flavors': json.dumps(SUGGESTED_FLAVORS),
                'suggested_roles': json.dumps(SUGGESTED_ROLES),
@@ -264,7 +220,6 @@ def home(request):
                'os_created_users': json.dumps(OS_CREATED_USERS),
                'userdata_keys_limit': json.dumps(MAX_SSH_KEYS_PER_USER),
                'use_glance': json.dumps(ENABLE_GLANCE),
-               'glance_api_url': json.dumps(GLANCE_API_HREF),
                'system_images_owners': json.dumps(SYSTEM_IMAGES_OWNERS),
                'custom_image_help_url': CUSTOM_IMAGE_HELP_URL,
                'image_deleted_title': json.dumps(IMAGE_DELETED_TITLE),
