Commit a3250f82 authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

cyclades ui: Configurable userdata api url

PublicKey collections used hardcoded urls to access the ssh public keys
api. A new dummy view added (to serve '/ui/userdata/') to be able to use
django reverse mechanism for the base url of userdata api.
parent a28098f8
......@@ -54,7 +54,11 @@
// get url helper
var getUrl = function(baseurl) {
var baseurl = baseurl || snf.config.api_urls[this.api_type];
return baseurl + "/" + this.path;
var append = "/";
if (baseurl.split("").reverse()[0] == "/") {
append = "";
}
return baseurl + append + this.path;
}
var NIC_REGEX = /^nic-([0-9]+)-([0-9]+)$/
......@@ -2304,7 +2308,7 @@
models.PublicKey = models.Model.extend({
path: 'keys',
base_url: '/ui/userdata',
api_type: 'userdata',
details: false,
noUpdate: true,
......@@ -2331,7 +2335,7 @@
model: models.PublicKey,
details: false,
path: 'keys',
base_url: '/ui/userdata',
api_type: 'userdata',
noUpdate: true,
generate_new: function(success, error) {
......
......@@ -610,13 +610,13 @@
// TODO: make it dynamic
synnefo.config.api_urls = {
'userdata': '{% url ui_userdata %}',
'compute': {{ compute_api_url|safe }},
'glance': {{ glance_api_url|safe }},
'accounts': {{ accounts_api_url|safe }},
};
// TODO: configurable userdata urls in models.js
synnefo.config.userdata_url = '/ui/userdata';
synnefo.config.userdata_keys_url = '{% url ui_keys_collection %}';
synnefo.config.userdata_keys_limit = {{ userdata_keys_limit }};
......
......@@ -34,13 +34,22 @@
from django.conf.urls.defaults import *
from synnefo.ui.userdata import views
from django.http import Http404
def index(request):
raise Http404
urlpatterns = patterns('',
url(r'^keys$', views.PublicKeyPairCollectionView.as_view('ui_keys_resource'),
url(r'^$', index, name='ui_userdata'),
url(r'^keys$',
views.PublicKeyPairCollectionView.as_view('ui_keys_resource'),
name='ui_keys_collection'),
url(r'^keys/(?P<id>\d+)',
views.PublicKeyPairResourceView.as_view('ui_keys_resource'),
name="ui_keys_resource"),
url(r'keys/generate', views.generate_key_pair, name="ui_generate_public_key"),
url(r'keys/download', views.download_private_key, name="ui_download_public_key")
url(r'keys/generate', views.generate_key_pair,
name="ui_generate_public_key"),
url(r'keys/download', views.download_private_key,
name="ui_download_public_key")
)
......@@ -46,6 +46,7 @@ from django.template import RequestContext
from synnefo_branding import settings as snf_settings
from synnefo.util.version import get_component_version
from synnefo.lib import join_urls
from snf_django.lib.astakos import get_user
......@@ -154,15 +155,21 @@ NETWORK_ALLOW_MULTIPLE_DESTROY = \
'UI_NETWORK_ALLOW_MULTIPLE_DESTROY', False)
AUTOMATIC_NETWORK_RANGE_FORMAT = getattr(settings,
'UI_AUTOMATIC_NETWORK_RANGE_FORMAT',
"192.168.%d.0/24").replace("%d", "{0}")
"192.168.%d.0/24").replace("%d",
"{0}")
GROUP_PUBLIC_NETWORKS = getattr(settings, 'UI_GROUP_PUBLIC_NETWORKS', True)
GROUPED_PUBLIC_NETWORK_NAME = \
getattr(settings, 'UI_GROUPED_PUBLIC_NETWORK_NAME', 'Internet')
USER_CATALOG_URL = getattr(settings, 'UI_USER_CATALOG_URL', '/astakos/api/user_catalogs')
FEEDBACK_POST_URL = getattr(settings, 'UI_FEEDBACK_POST_URL', '/astakos/api/feedback')
ASTAKOS_BASE_URL = '/'
ASTAKOS_API_URL = join_urls(ASTAKOS_BASE_URL, 'astakos/api')
USER_CATALOG_URL = getattr(settings, 'UI_USER_CATALOG_URL',
join_urls(ASTAKOS_API_URL, 'user_catalogs'))
FEEDBACK_POST_URL = getattr(settings, 'UI_FEEDBACK_POST_URL',
join_urls(ASTAKOS_API_URL, 'feedback'))
ACCOUNTS_API_URL = getattr(settings, 'UI_ACCOUNTS_API_URL', ASTAKOS_API_URL)
TRANSLATE_UUIDS = not getattr(settings, 'TRANSLATE_UUIDS', False)
ACCOUNTS_API_URL = getattr(settings, 'UI_ACCOUNTS_API_URL', '/astakos/api')
def template(name, request, context):
......
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