diff --git a/src/sunstone/public/app/opennebula/group.js b/src/sunstone/public/app/opennebula/group.js index 8ab61f02b7..ccad4ad0b0 100644 --- a/src/sunstone/public/app/opennebula/group.js +++ b/src/sunstone/public/app/opennebula/group.js @@ -49,6 +49,18 @@ define(function(require) { OpenNebulaAction.simple_action(params, RESOURCE, "set_quota", action_obj); }, "show" : function(params) { + var callback = params.success; + + // Before calling the true callback, we update the default quotas + // included in the .show response + params.success = function(request, response) { + QuotaDefaults.setDefaultGroupQuotas( + QuotaDefaults.default_quotas(response.GROUP.DEFAULT_GROUP_QUOTAS) + ); + + return callback ? callback(request, response) : null; + }; + OpenNebulaAction.show(params, RESOURCE); }, "accounting" : function(params) { diff --git a/src/sunstone/public/app/opennebula/user.js b/src/sunstone/public/app/opennebula/user.js index 839f08145e..f7e7f9bdf1 100644 --- a/src/sunstone/public/app/opennebula/user.js +++ b/src/sunstone/public/app/opennebula/user.js @@ -42,6 +42,18 @@ define(function(require) { }); }, "show" : function(params) { + var callback = params.success; + + // Before calling the true callback, we update the default quotas + // included in the .show response + params.success = function(request, response) { + QuotaDefaults.setDefaultUserQuotas( + QuotaDefaults.default_quotas(response.USER.DEFAULT_USER_QUOTAS) + ); + + return callback ? callback(request, response) : null; + }; + OpenNebulaAction.show(params, RESOURCE); }, "passwd": function(params) { diff --git a/src/sunstone/public/app/utils/quotas/quota-defaults.js b/src/sunstone/public/app/utils/quotas/quota-defaults.js index 7ec52c3b29..e3ee325bf4 100644 --- a/src/sunstone/public/app/utils/quotas/quota-defaults.js +++ b/src/sunstone/public/app/utils/quotas/quota-defaults.js @@ -1,7 +1,33 @@ define(function(require) { // The default quotas returned by the pool.list method are stored here - var _defaultUserQuotas; - var _defaultGroupQuotas; + var _defaultUserQuotas = { + "VM_QUOTA": { + "VM": { + "CPU": QUOTA_LIMIT_UNLIMITED, + "MEMORY": QUOTA_LIMIT_UNLIMITED, + "VMS": QUOTA_LIMIT_UNLIMITED, + "VOLATILE_SIZE": QUOTA_LIMIT_UNLIMITED, + } + }, + "DATASTORE_QUOTA": {}, + "IMAGE_QUOTA": {}, + "NETWORK_QUOTA": {} + }; + + var _defaultGroupQuotas = { + "VM_QUOTA": { + "VM": { + "CPU": QUOTA_LIMIT_UNLIMITED, + "MEMORY": QUOTA_LIMIT_UNLIMITED, + "VMS": QUOTA_LIMIT_UNLIMITED, + "VOLATILE_SIZE": QUOTA_LIMIT_UNLIMITED, + } + }, + "DATASTORE_QUOTA": {}, + "IMAGE_QUOTA": {}, + "NETWORK_QUOTA": {} + }; + var QuotaLimits = require('./quota-limits');