Commit 0d347a43 authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

Improved owners of system images configuration, Refs #1748

- allow multiple system owners
- allow custom owner aliases (displayed in UI)
parent 61b07ab9
......@@ -93,6 +93,7 @@ UI_FLAVORS_DISK_TEMPLATES_INFO = {
'description': 'DRBD storage.'},
}
#######################
# UI BEHAVIOUR SETTINGS
#######################
......@@ -133,3 +134,11 @@ UI_GLANCE_API_URL = '/plankton'
# set in UI_GLANCE_API_URL, 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
# to be displayed on images list
UI_SYSTEM_IMAGES_OWNERS = {
'admin@synnefo.gr': 'system',
'images@synnefo.gr': 'system'
}
......@@ -27,7 +27,17 @@
display_size: function() {
return this.get_readable_size();
},
display_owner: function() {
var owner = this.get_owner();
if (_.include(_.keys(synnefo.config.system_images_owners)), owner) {
return synnefo.config.system_images_owners[owner];
} else {
return owner;
}
}
})
models.GlanceImages = snf.models.Images.extend({
......@@ -87,11 +97,16 @@
},
get_system_images: function() {
return _.filter(this.active(), function(i){ return i.get_owner() == snf.config.system_images_owner })
return _.filter(this.active(), function(i) {
return _.include(_.keys(snf.config.system_images_owners),
i.get_owner());
})
},
get_personal_images: function() {
return _.filter(this.active(), function(i) { return i.get_owner() == snf.user.username });
return _.filter(this.active(), function(i) {
return i.get_owner() == snf.user.username
});
},
get_public_images: function() {
......@@ -99,9 +114,12 @@
},
get_shared_images: function() {
return _.filter(this.active(), function(i){ return i.get_owner() != snf.config.system_images_owner &&
return _.filter(this.active(), function(i){
return !_.include(_.keys(snf.config.system_images_owners),
i.get_owner()) &&
i.get_owner() != snf.user.username &&
!i.is_public() })
!i.is_public();
});
}
})
......
......@@ -229,7 +229,7 @@
},
get_owner: function() {
return this.get('owner') || synnefo.config.system_images_owner;
return this.get('owner') || _.keys(synnefo.config.system_images_owners)[0];
},
get_readable_size: function() {
......
......@@ -363,7 +363,7 @@
var value;
var method = 'get_' + key.toLowerCase();
var display_method = 'display_' + key.toLowerCase();
if (image[display_method]) {
value = image[display_method]();
} else if (image[method]) {
......@@ -425,7 +425,7 @@
snf.ui.helpers.os_icon_tag(img.escape("OS")),
_.escape(img.get_readable_size()),
util.truncate(img.escape("description"), 35),
_.escape(img.get_owner())));
_.escape(img.display_owner())));
image.data("image", img);
image.data("image_id", img.id);
this.images_list.append(image);
......
......@@ -587,7 +587,7 @@ We welcome any suggestions, questions and bug reports you may have.{% endblocktr
synnefo.user.username = '{{ request.user.uniq }}';
synnefo.user.token = $.cookie("X-Auth-Token");
// images config
synnefo.config.system_images_owner = {{ system_images_owner|safe }};
synnefo.config.system_images_owners = {{ system_images_owners|safe }};
synnefo.ui.init();
synnefo.ui.main.bind("initial", function(){
});
......
......@@ -88,7 +88,7 @@ SKIP_TIMEOUTS = getattr(settings, "UI_SKIP_TIMEOUTS", 1)
VM_NAME_TEMPLATE = getattr(settings, "VM_CREATE_NAME_TPL", "My {0} server")
MAX_SSH_KEYS_PER_USER = getattr(settings, "USERDATA_MAX_SSH_KEYS_PER_USER")
FLAVORS_DISK_TEMPLATES_INFO = getattr(settings, "UI_FLAVORS_DISK_TEMPLATES_INFO", {})
SYSTEM_IMAGES_OWNER = getattr(settings, "UI_SYSTEM_IMAGES_OWNER", 'synnefo')
SYSTEM_IMAGES_OWNERS = getattr(settings, "UI_SYSTEM_IMAGES_OWNERS", {})
# MEDIA PATHS
UI_MEDIA_URL = getattr(settings, "UI_MEDIA_URL",
......@@ -158,9 +158,9 @@ def home(request):
'support_ssh_os_list': json.dumps(SUPPORT_SSH_OS_LIST),
'os_created_users': json.dumps(OS_CREATED_USERS),
'userdata_keys_limit': json.dumps(MAX_SSH_KEYS_PER_USER),
'system_images_owner': json.dumps(SYSTEM_IMAGES_OWNER),
'use_glance': json.dumps(ENABLE_GLANCE),
'glance_api_url': json.dumps(GLANCE_API_URL)
'glance_api_url': json.dumps(GLANCE_API_URL),
'system_images_owners': json.dumps(SYSTEM_IMAGES_OWNERS)
}
return template('home', 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