mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-1592:[UI] Add support to limit newly added resourcetypes
This commit is contained in:
parent
d13c18516a
commit
2c176ab9ea
@ -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
|
||||
|
||||
@ -27,6 +27,14 @@ under the License.
|
||||
dictionary = {
|
||||
'message.redirecting.region': '<fmt:message key="message.redirecting.region"/>',
|
||||
'label.use.vm.ip': '<fmt:message key="label.use.vm.ip"/>',
|
||||
'label.cpu.limits': '<fmt:message key="label.cpu.limits"/>',
|
||||
'label.memory.limits': '<fmt:message key="label.memory.limits"/>',
|
||||
'label.primary.storage.limits': '<fmt:message key="label.primary.storage.limits"/>',
|
||||
'label.secondary.storage.limits': '<fmt:message key="label.secondary.storage.limits"/>',
|
||||
'label.max.cpus': '<fmt:message key="label.max.cpus"/>',
|
||||
'label.max.memory': '<fmt:message key="label.max.memory"/>',
|
||||
'label.max.primary.storage': '<fmt:message key="label.max.primary.storage"/>',
|
||||
'label.max.secondary.storage': '<fmt:message key="label.max.secondary.storage"/>',
|
||||
'label.add.region': '<fmt:message key="label.add.region"/>',
|
||||
'label.remove.region': '<fmt:message key="label.remove.region"/>',
|
||||
'message.remove.region': '<fmt:message key="message.remove.region"/>',
|
||||
|
||||
@ -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
|
||||
}
|
||||
);
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user