1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-20 10:50:08 +03:00

Feature #3748: User and group list use the cache

This commit is contained in:
Carlos Martín 2015-06-18 13:25:08 +02:00
parent c3e6d81d88
commit f231418c4a
3 changed files with 42 additions and 70 deletions

View File

@ -97,7 +97,7 @@ define(function(require) {
});
},
"list": function(params, resource, path) {
"list": function(params, resource, path, process) {
var callback = params.success;
var callbackError = params.error;
var timeout = params.timeout || false;
@ -153,7 +153,13 @@ define(function(require) {
data: {timeout: timeout},
dataType: "json",
success: function(response) {
var list = OpenNebulaHelper.pool(resource, response)
var list;
if (process){
list = process(response);
} else {
list = OpenNebulaHelper.pool(resource, response);
}
listCache[cache_name] = {
timestamp : new Date().getTime(),

View File

@ -16,45 +16,28 @@ define(function(require) {
OpenNebulaAction.del(params, RESOURCE);
},
"list": function(params) {
var req_path = RESOURCE.toLowerCase();
var callback = params.success;
var callback_error = params.error;
var timeout = params.timeout || false;
var request = OpenNebulaHelper.request(RESOURCE, "list");
OpenNebulaAction.list(params, RESOURCE, null, function(response) {
var list = OpenNebulaHelper.pool(RESOURCE, response);
$.ajax({
url: req_path,
type: "GET",
data: {timeout: timeout},
dataType: "json",
success: function(response) {
var list = OpenNebulaHelper.pool(RESOURCE, response);
QuotaDefaults.setDefaultGroupQuotas(
QuotaDefaults.default_quotas(response.GROUP_POOL.DEFAULT_GROUP_QUOTAS)
);
QuotaDefaults.setDefaultGroupQuotas(
QuotaDefaults.default_quotas(response.GROUP_POOL.DEFAULT_GROUP_QUOTAS)
);
// Inject the VM quota. This info is returned separately in the
// pool info call, but the elementArray expects it inside the GROUP,
// as it is returned by the individual info call
var quotas_hash = OpenNebulaHelper.pool_hash_processing(
'GROUP_POOL', 'QUOTAS', response);
// Inject the VM quota. This info is returned separately in the
// pool info call, but the elementArray expects it inside the GROUP,
// as it is returned by the individual info call
var quotas_hash = OpenNebulaHelper.pool_hash_processing(
'GROUP_POOL', 'QUOTAS', response);
$.each(list,function(){
var q = quotas_hash[this[RESOURCE].ID];
$.each(list,function(){
var q = quotas_hash[this[RESOURCE].ID];
if (q != undefined) {
this[RESOURCE].VM_QUOTA = q.QUOTAS.VM_QUOTA;
}
});
if (q != undefined) {
this[RESOURCE].VM_QUOTA = q.QUOTAS.VM_QUOTA;
}
});
return callback ?
callback(request, list, quotas_hash) : null;
},
error: function(response) {
return callback_error ?
callback_error(request, OpenNebulaError(response)) : null;
}
return list;
});
},
"update": function(params) {

View File

@ -17,45 +17,28 @@ define(function(require) {
OpenNebulaAction.del(params, RESOURCE);
},
"list": function(params) {
var req_path = RESOURCE.toLowerCase();
var callback = params.success;
var callback_error = params.error;
var timeout = params.timeout || false;
var request = OpenNebulaHelper.request(RESOURCE, "list");
OpenNebulaAction.list(params, RESOURCE, null, function(response) {
var list = OpenNebulaHelper.pool(RESOURCE, response);
$.ajax({
url: req_path,
type: "GET",
data: {timeout: timeout},
dataType: "json",
success: function(response) {
var list = OpenNebulaHelper.pool(RESOURCE, response);
QuotaDefaults.setDefaultUserQuotas(
QuotaDefaults.default_quotas(response.USER_POOL.DEFAULT_USER_QUOTAS)
);
QuotaDefaults.setDefaultUserQuotas(
QuotaDefaults.default_quotas(response.USER_POOL.DEFAULT_USER_QUOTAS)
);
// Inject the VM user quota. This info is returned separately in the
// pool info call, but the userElementArray expects it inside the USER,
// as it is returned by the individual info call
var quotas_hash = OpenNebulaHelper.pool_hash_processing(
'USER_POOL', 'QUOTAS', response);
// Inject the VM user quota. This info is returned separately in the
// pool info call, but the userElementArray expects it inside the USER,
// as it is returned by the individual info call
var quotas_hash = OpenNebulaHelper.pool_hash_processing(
'USER_POOL', 'QUOTAS', response);
$.each(list,function(){
var q = quotas_hash[this[RESOURCE].ID];
$.each(list,function(){
var q = quotas_hash[this[RESOURCE].ID];
if (q != undefined) {
this[RESOURCE].VM_QUOTA = q.QUOTAS.VM_QUOTA;
}
});
if (q != undefined) {
this[RESOURCE].VM_QUOTA = q.QUOTAS.VM_QUOTA;
}
});
return callback ?
callback(request, list, quotas_hash) : null;
},
error: function(response) {
return callback_error ?
callback_error(request, OpenNebulaError(response)) : null;
}
return list;
});
},
"show" : function(params) {