cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject [18/25] git commit: updated refs/heads/bvt to 5727bd0
Date Fri, 29 Mar 2013 12:46:20 GMT
CLOUDSTACK-1592:[UI] Add support to limit newly added resourcetypes


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/2c176ab9
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/2c176ab9
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/2c176ab9

Branch: refs/heads/bvt
Commit: 2c176ab9ea6216b7c9da25ce0b0d2b34cbc2a776
Parents: d13c185
Author: Sanjay Tripathi <sanjay.tripathi@citrix.com>
Authored: Fri Mar 29 14:18:14 2013 +0530
Committer: Pranav Saxena <pranav.saxena@citrix.com>
Committed: Fri Mar 29 14:18:14 2013 +0530

----------------------------------------------------------------------
 .../WEB-INF/classes/resources/messages.properties  |    8 +
 ui/dictionary.jsp                                  |    8 +
 ui/scripts/accounts.js                             |  137 ++++++++++++++-
 ui/scripts/domains.js                              |   92 ++++++++++
 ui/scripts/projects.js                             |   20 ++-
 5 files changed, 254 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2c176ab9/client/WEB-INF/classes/resources/messages.properties
----------------------------------------------------------------------
diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties
index 66b32ac..da224eb 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

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2c176ab9/ui/dictionary.jsp
----------------------------------------------------------------------
diff --git a/ui/dictionary.jsp b/ui/dictionary.jsp
index cd8d732..d4f9078 100644
--- a/ui/dictionary.jsp
+++ b/ui/dictionary.jsp
@@ -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"/>',

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2c176ab9/ui/scripts/accounts.js
----------------------------------------------------------------------
diff --git a/ui/scripts/accounts.js b/ui/scripts/accounts.js
index 3403337..8353d70 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 
 														}
-													);							
+													);
 												}
-											});											
+											});
 										}
-									});		
+									});
                 }
               }
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2c176ab9/ui/scripts/domains.js
----------------------------------------------------------------------
diff --git a/ui/scripts/domains.js b/ui/scripts/domains.js
index 991e37d..8ee0ee6 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;
                       }
                     }
                   }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2c176ab9/ui/scripts/projects.js
----------------------------------------------------------------------
diff --git a/ui/scripts/projects.js b/ui/scripts/projects.js
index b62dcb4..4004709 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 {


Mime
View raw message