diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties
index 66b32acfc6c..da224eb3a7a 100644
--- a/client/WEB-INF/classes/resources/messages.properties
+++ b/client/WEB-INF/classes/resources/messages.properties
@@ -19,6 +19,14 @@
#new labels (begin) **********************************************************************************************
message.redirecting.region=Redirecting to region...
label.use.vm.ip=Use VM IP:
+label.cpu.limits=CPU limits
+label.memory.limits=Memory limits (MiB)
+label.primary.storage.limits=Primary Storage limits (GiB)
+label.secondary.storage.limits=Secondary Storage limits (GiB)
+label.max.cpus=Max. CPU cores
+label.max.memory=Max. memory (MiB)
+label.max.primary.storage=Max. primary (GiB)
+label.max.secondary.storage=Max. secondary (GiB)
label.menu.regions=Regions
label.region=Region
label.add.region=Add Region
diff --git a/ui/dictionary.jsp b/ui/dictionary.jsp
index cd8d7323300..d4f9078907b 100644
--- a/ui/dictionary.jsp
+++ b/ui/dictionary.jsp
@@ -27,6 +27,14 @@ under the License.
dictionary = {
'message.redirecting.region': '',
'label.use.vm.ip': '',
+'label.cpu.limits': '',
+'label.memory.limits': '',
+'label.primary.storage.limits': '',
+'label.secondary.storage.limits': '',
+'label.max.cpus': '',
+'label.max.memory': '',
+'label.max.primary.storage': '',
+'label.max.secondary.storage': '',
'label.add.region': '',
'label.remove.region': '',
'message.remove.region': '',
diff --git a/ui/scripts/accounts.js b/ui/scripts/accounts.js
index 3403337a834..8353d70536e 100644
--- a/ui/scripts/accounts.js
+++ b/ui/scripts/accounts.js
@@ -409,6 +409,77 @@
});
}
+ if(args.data.cpuLimit != null) {
+ var data = {
+ resourceType: 8,
+ max: args.data.cpuLimit,
+ domainid: accountObj.domainid,
+ account: accountObj.name
+ };
+
+ $.ajax({
+ url: createURL('updateResourceLimit'),
+ data: data,
+ async: false,
+ success: function(json) {
+ accountObj["cpuLimit"] = args.data.cpuLimit;
+ }
+ });
+ }
+
+ if(args.data.memoryLimit != null) {
+ var data = {
+ resourceType: 9,
+ max: args.data.memoryLimit,
+ domainid: accountObj.domainid,
+ account: accountObj.name
+ };
+
+ $.ajax({
+ url: createURL('updateResourceLimit'),
+ data: data,
+ async: false,
+ success: function(json) {
+ accountObj["memoryLimit"] = args.data.memoryLimit;
+ }
+ });
+ }
+
+ if(args.data.primaryStorageLimit != null) {
+ var data = {
+ resourceType: 10,
+ max: args.data.primaryStorageLimit,
+ domainid: accountObj.domainid,
+ account: accountObj.name
+ };
+
+ $.ajax({
+ url: createURL('updateResourceLimit'),
+ data: data,
+ async: false,
+ success: function(json) {
+ accountObj["primaryStorageLimit"] = args.data.primaryStorageLimit;
+ }
+ });
+ }
+
+ if(args.data.secondaryStorageLimit != null) {
+ var data = {
+ resourceType: 11,
+ max: args.data.secondaryStorageLimit,
+ domainid: accountObj.domainid,
+ account: accountObj.name
+ };
+
+ $.ajax({
+ url: createURL('updateResourceLimit'),
+ data: data,
+ async: false,
+ success: function(json) {
+ accountObj["secondaryStorageLimit"] = args.data.secondaryStorageLimit;
+ }
+ });
+ }
args.response.success({data: accountObj});
}
},
@@ -698,6 +769,42 @@
return false;
}
},
+ cpuLimit: {
+ label: 'label.cpu.limits',
+ isEditable: function(context) {
+ if (context.accounts[0].accounttype == roleTypeUser || context.accounts[0].accounttype == roleTypeDomainAdmin) //updateResourceLimits is only allowed on account whose type is user or domain-admin
+ return true;
+ else
+ return false;
+ }
+ },
+ memoryLimit: {
+ label: 'label.memory.limits',
+ isEditable: function(context) {
+ if (context.accounts[0].accounttype == roleTypeUser || context.accounts[0].accounttype == roleTypeDomainAdmin) //updateResourceLimits is only allowed on account whose type is user or domain-admin
+ return true;
+ else
+ return false;
+ }
+ },
+ primaryStorageLimit: {
+ label: 'label.primary.storage.limits',
+ isEditable: function(context) {
+ if (context.accounts[0].accounttype == roleTypeUser || context.accounts[0].accounttype == roleTypeDomainAdmin) //updateResourceLimits is only allowed on account whose type is user or domain-admin
+ return true;
+ else
+ return false;
+ }
+ },
+ secondaryStorageLimit: {
+ label: 'label.secondary.storage.limits',
+ isEditable: function(context) {
+ if (context.accounts[0].accounttype == roleTypeUser || context.accounts[0].accounttype == roleTypeDomainAdmin) //updateResourceLimits is only allowed on account whose type is user or domain-admin
+ return true;
+ else
+ return false;
+ }
+ },
vmtotal: { label: 'label.total.of.vm' },
iptotal: { label: 'label.total.of.ip' },
@@ -725,11 +832,11 @@
dataProvider: function(args) {
var data = {
id: args.context.accounts[0].id
- };
+ };
$.ajax({
url: createURL('listAccounts'),
- data: data,
- success: function(json) {
+ data: data,
+ success: function(json) {
var accountObj = json.listaccountsresponse.account[0];
var data = {
domainid: accountObj.domainid,
@@ -737,7 +844,7 @@
};
$.ajax({
url: createURL('listResourceLimits'),
- data: data,
+ data: data,
success: function(json) {
var limits = json.listresourcelimitsresponse.resourcelimit;
if (limits != null) {
@@ -759,22 +866,34 @@
case "4":
accountObj["templateLimit"] = limit.max;
break;
- case "7":
+ case "7":
accountObj["vpcLimit"] = limit.max;
break;
+ case "8":
+ accountObj["cpuLimit"] = limit.max;
+ break;
+ case "9":
+ accountObj["memoryLimit"] = limit.max;
+ break;
+ case "10":
+ accountObj["primaryStorageLimit"] = limit.max;
+ break;
+ case "11":
+ accountObj["secondaryStorageLimit"] = limit.max;
+ break;
}
}
- }
+ }
args.response.success(
{
actionFilter: accountActionfilter,
data: accountObj
}
- );
+ );
}
- });
+ });
}
- });
+ });
}
}
}
diff --git a/ui/scripts/domains.js b/ui/scripts/domains.js
index 991e37d7324..8ee0ee6816a 100644
--- a/ui/scripts/domains.js
+++ b/ui/scripts/domains.js
@@ -184,6 +184,50 @@
});
}
+ if(args.data.cpuLimit != null) {
+ $.ajax({
+ url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=8&max=" + args.data.cpuLimit),
+ dataType: "json",
+ async: false,
+ success: function(json) {
+ domainObj["cpuLimit"] = args.data.cpuLimit;
+ }
+ });
+ }
+
+ if(args.data.memoryLimit != null) {
+ $.ajax({
+ url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=9&max=" + args.data.memoryLimit),
+ dataType: "json",
+ async: false,
+ success: function(json) {
+ domainObj["memoryLimit"] = args.data.memoryLimit;
+ }
+ });
+ }
+
+ if(args.data.primaryStorageLimit != null) {
+ $.ajax({
+ url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=10&max=" + args.data.primaryStorageLimit),
+ dataType: "json",
+ async: false,
+ success: function(json) {
+ domainObj["primaryStorageLimit"] = args.data.primaryStorageLimit;
+ }
+ });
+ }
+
+ if(args.data.secondaryStorageLimit != null) {
+ $.ajax({
+ url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=11&max=" + args.data.secondaryStorageLimit),
+ dataType: "json",
+ async: false,
+ success: function(json) {
+ domainObj["secondaryStorageLimit"] = args.data.secondaryStorageLimit;
+ }
+ });
+ }
+
args.response.success({data: domainObj});
}
},
@@ -348,6 +392,42 @@
return false;
}
},
+ cpuLimit: {
+ label: 'label.cpu.limits',
+ isEditable: function(context) {
+ if(context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits
+ return true;
+ else
+ return false;
+ }
+ },
+ memoryLimit: {
+ label: 'label.memory.limits',
+ isEditable: function(context) {
+ if(context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits
+ return true;
+ else
+ return false;
+ }
+ },
+ primaryStorageLimit: {
+ label: 'label.primary.storage.limits',
+ isEditable: function(context) {
+ if(context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits
+ return true;
+ else
+ return false;
+ }
+ },
+ secondaryStorageLimit: {
+ label: 'label.secondary.storage.limits',
+ isEditable: function(context) {
+ if(context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits
+ return true;
+ else
+ return false;
+ }
+ },
accountTotal: { label: 'label.accounts' },
vmTotal: { label: 'label.instances' },
volumeTotal: { label: 'label.volumes' }
@@ -441,6 +521,18 @@
case "7":
domainObj["vpcLimit"] = limit.max;
break;
+ case "8":
+ domainObj["cpuLimit"] = limit.max;
+ break;
+ case "9":
+ domainObj["memoryLimit"] = limit.max;
+ break;
+ case "10":
+ domainObj["primaryStorageLimit"] = limit.max;
+ break;
+ case "7":
+ domainObj["secondaryStorageLimit"] = limit.max;
+ break;
}
}
}
diff --git a/ui/scripts/projects.js b/ui/scripts/projects.js
index b62dcb4c6a2..4004709a75d 100644
--- a/ui/scripts/projects.js
+++ b/ui/scripts/projects.js
@@ -71,7 +71,7 @@
var resourceLimits = $.grep(
json.listresourcelimitsresponse.resourcelimit,
function(resourceLimit) {
- return resourceLimit.resourcetype != 5 && resourceLimit.resourcetype != 8;
+ return resourceLimit.resourcetype != 5 && resourceLimit.resourcetype != 12;
}
);
@@ -111,7 +111,23 @@
7: {
id: 'vpc',
label: 'label.max.vpcs'
- }
+ },
+ 8: {
+ id: 'cpu',
+ label: 'label.max.cpus'
+ },
+ 9: {
+ id: 'memory',
+ label: 'label.max.memory'
+ },
+ 10: {
+ id: 'primary_storage',
+ label: 'label.max.primary.storage'
+ },
+ 11: {
+ id: 'secondary_storage',
+ label: 'label.max.secondary.storage'
+ }
};
return {