Commit 15ef3c3a authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

Periodic update of user usage quotas

parent 316ad059
......@@ -39,6 +39,9 @@ UI_UPDATE_INTERVAL_FAST = UI_UPDATE_INTERVAL / 2
# consecutive API calls (aligning changes-since attribute).
UI_CHANGES_SINCE_ALIGNMENT = 0
# How often to check for user usage changes
UI_QUOTAS_UPDATE_INTERVAL = 10000
# List of emails used for sending the feedback messages to (following the ADMINS format)
FEEDBACK_CONTACTS = (
# ('Contact Name', 'contact_email@domain.com'),
......
......@@ -768,6 +768,8 @@
}
},
quota_handlers_initialized: false,
load_user_quotas: function() {
var main_view = this;
snf.api.sync('read', undefined, {
......@@ -776,7 +778,21 @@
snf.user.quotas = {};
snf.user.quotas['vms'] = d.vms_quota;
snf.user.quotas['networks'] = d.networks_quota;
main_view.init_quotas_handlers(['vms','networks']);
if (!main_view.quota_handlers_initialized) {
main_view.init_quotas_handlers(['vms','networks']);
main_view.quota_handlers_initialized = true;
}
try {
main_view.check_quotas('vms');
main_view.check_quotas('networks');
} catch (err) {
console.error(err);
}
},
complete: function() {
setTimeout(function(){
main_view.load_user_quotas();
}, synnefo.config.quotas_update_interval || 10000);
}
});
},
......
......@@ -638,6 +638,7 @@
synnefo.config.automatic_network_range_format = {{ automatic_network_range_format|safe }};
synnefo.config.quota_url = '{% url synnefo.ui.views.user_quota %}';
synnefo.config.custom_image_help_url = '{{ custom_image_help_url|safe }}';
synnefo.config.quotas_update_interval = {{ quotas_update_interval }};
synnefo.auth_client = new synnefo.auth.AstakosClient({
login_url: synnefo.config.login_redirect,
......
......@@ -66,6 +66,7 @@ UPDATE_INTERVAL_INCREASE_AFTER_CALLS_COUNT = getattr(settings,
3)
UPDATE_INTERVAL_FAST = getattr(settings, "UI_UPDATE_INTERVAL_FAST", 2500)
UPDATE_INTERVAL_MAX = getattr(settings, "UI_UPDATE_INTERVAL_MAX", 10000)
QUOTAS_UPDATE_INTERVAL = getattr(settings, "UI_QUOTAS_UPDATE_INTERVAL", 10000)
# predefined values settings
VM_IMAGE_COMMON_METADATA = getattr(settings, "UI_VM_IMAGE_COMMON_METADATA", ["OS", "users"])
......@@ -179,6 +180,7 @@ def home(request):
'update_interval_fast': UPDATE_INTERVAL_FAST,
'update_interval_max': UPDATE_INTERVAL_MAX,
'changes_since_alignment': CHANGES_SINCE_ALIGNMENT,
'quotas_update_interval': QUOTAS_UPDATE_INTERVAL,
# additional settings
'image_icons': IMAGE_ICONS,
'logout_redirect': LOGOUT_URL,
......
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