From 61f3706255b5a658e77014fe7f20acab2707219a Mon Sep 17 00:00:00 2001 From: Wilder Rodrigues Date: Wed, 6 Jan 2016 09:08:21 +0100 Subject: [PATCH 1/5] CLOUDSTACK-9213 - Formatting the code --- .../api/routing/SetNetworkACLCommand.java | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/core/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java b/core/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java index 0cb1c3ec1ac..395ab5f0fb1 100644 --- a/core/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java +++ b/core/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java @@ -19,14 +19,14 @@ package com.cloud.agent.api.routing; -import com.cloud.agent.api.to.NetworkACLTO; -import com.cloud.agent.api.to.NicTO; - import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; +import com.cloud.agent.api.to.NetworkACLTO; +import com.cloud.agent.api.to.NicTO; + public class SetNetworkACLCommand extends NetworkElementCommand { NetworkACLTO[] rules; NicTO nic; @@ -34,7 +34,7 @@ public class SetNetworkACLCommand extends NetworkElementCommand { protected SetNetworkACLCommand() { } - public SetNetworkACLCommand(List rules, NicTO nic) { + public SetNetworkACLCommand(final List rules, final NicTO nic) { this.rules = rules.toArray(new NetworkACLTO[rules.size()]); this.nic = nic; } @@ -44,32 +44,32 @@ public class SetNetworkACLCommand extends NetworkElementCommand { } public String[][] generateFwRules() { - List aclList = Arrays.asList(rules); + final List aclList = Arrays.asList(rules); Collections.sort(aclList, new Comparator() { @Override - public int compare(NetworkACLTO acl1, NetworkACLTO acl2) { + public int compare(final NetworkACLTO acl1, final NetworkACLTO acl2) { return acl1.getNumber() < acl2.getNumber() ? 1 : -1; } }); - String[][] result = new String[2][aclList.size()]; + final String[][] result = new String[2][aclList.size()]; int i = 0; - for (NetworkACLTO aclTO : aclList) { + for (final NetworkACLTO aclTO : aclList) { /* example : Ingress:tcp:80:80:0.0.0.0/0:ACCEPT:,Egress:tcp:220:220:0.0.0.0/0:DROP:, * each entry format Ingress/Egress:protocol:start port: end port:scidrs:action: * reverted entry format Ingress/Egress:reverted:0:0:0: */ if (aclTO.revoked() == true) { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); /* This entry is added just to make sure atleast there will one entry in the list to get the ipaddress */ sb.append(aclTO.getTrafficType().toString()).append(":reverted:0:0:0:"); - String aclRuleEntry = sb.toString(); + final String aclRuleEntry = sb.toString(); result[0][i++] = aclRuleEntry; continue; } List cidr; - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(aclTO.getTrafficType().toString()).append(":").append(aclTO.getProtocol()).append(":"); if ("icmp".compareTo(aclTO.getProtocol()) == 0) { sb.append(aclTO.getIcmpType()).append(":").append(aclTO.getIcmpCode()).append(":"); @@ -81,15 +81,16 @@ public class SetNetworkACLCommand extends NetworkElementCommand { sb.append("0.0.0.0/0"); } else { Boolean firstEntry = true; - for (String tag : cidr) { - if (!firstEntry) + for (final String tag : cidr) { + if (!firstEntry) { sb.append("-"); + } sb.append(tag); firstEntry = false; } } sb.append(":").append(aclTO.getAction()).append(":"); - String aclRuleEntry = sb.toString(); + final String aclRuleEntry = sb.toString(); result[0][i++] = aclRuleEntry; } From 94c0dc5dfec1d8b20afcbc1e652eb7c9350b4946 Mon Sep 17 00:00:00 2001 From: Wilder Rodrigues Date: Wed, 6 Jan 2016 09:08:56 +0100 Subject: [PATCH 2/5] CLOUDSTACK-9213 - Split the ACL rules using comma instead of dash. - The router code no longer deals with parsing the ALC list again. It's not necessary if it's sent in the proper way. --- core/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java b/core/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java index 395ab5f0fb1..59ef6686ef0 100644 --- a/core/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java +++ b/core/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java @@ -83,7 +83,7 @@ public class SetNetworkACLCommand extends NetworkElementCommand { Boolean firstEntry = true; for (final String tag : cidr) { if (!firstEntry) { - sb.append("-"); + sb.append(","); } sb.append(tag); firstEntry = false; From 65d39d034694993827456d97ddd562d4803b2109 Mon Sep 17 00:00:00 2001 From: Anton Opgenoort Date: Wed, 6 Jan 2016 17:30:55 +0100 Subject: [PATCH 3/5] Fix mariadb related listCapacity bug (CLOUDSTACK-8966) type bigint(20) with type varchar does not work well on MariaDB So forcing it to type decimal --- .../cloud/capacity/dao/CapacityDaoImpl.java | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/engine/schema/src/com/cloud/capacity/dao/CapacityDaoImpl.java b/engine/schema/src/com/cloud/capacity/dao/CapacityDaoImpl.java index 69dc0146a22..bc992b0bb51 100644 --- a/engine/schema/src/com/cloud/capacity/dao/CapacityDaoImpl.java +++ b/engine/schema/src/com/cloud/capacity/dao/CapacityDaoImpl.java @@ -109,41 +109,42 @@ public class CapacityDaoImpl extends GenericDaoBase implements private static final String LIST_CAPACITY_GROUP_BY_ZONE_TYPE_PART1 = "SELECT sum(capacity.used_capacity), sum(capacity.reserved_capacity)," - + " (case capacity_type when 1 then (sum(total_capacity) * (select value from `cloud`.`cluster_details` where cluster_details.name= 'cpuOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id))" - + "when '0' then (sum(total_capacity) * (select value from `cloud`.`cluster_details` where cluster_details.name= 'memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id))" + + " (case capacity_type when 1 then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details` where cluster_details.name= 'cpuOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id) AS DECIMAL (10,4)))" + + "when '0' then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details` where cluster_details.name= 'memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id) AS DECIMAL (10,4)))" + "else sum(total_capacity) end)," - + "((sum(capacity.used_capacity) + sum(capacity.reserved_capacity)) / ( case capacity_type when 1 then (sum(total_capacity) * (select value from `cloud`.`cluster_details` where cluster_details.name= 'cpuOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id))" - + "when '0' then (sum(total_capacity) * (select value from `cloud`.`cluster_details` where cluster_details.name='memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id))else sum(total_capacity) end)) percent," + + "((sum(capacity.used_capacity) + sum(capacity.reserved_capacity)) / ( case capacity_type when 1 then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details` where cluster_details.name= 'cpuOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id) AS DECIMAL (10,4)))" + + "when '0' then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details` where cluster_details.name='memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id) AS DECIMAL (10,4)))else sum(total_capacity) end)) percent," + "capacity.capacity_type, capacity.data_center_id, pod_id, cluster_id FROM `cloud`.`op_host_capacity` capacity WHERE total_capacity > 0 AND data_center_id is not null AND capacity_state='Enabled'"; private static final String LIST_CAPACITY_GROUP_BY_ZONE_TYPE_PART2 = " GROUP BY data_center_id, capacity_type order by percent desc limit "; private static final String LIST_CAPACITY_GROUP_BY_POD_TYPE_PART1 = "SELECT sum(capacity.used_capacity), sum(capacity.reserved_capacity)," - + " (case capacity_type when 1 then (sum(total_capacity) * (select value from `cloud`.`cluster_details` where cluster_details.name= 'cpuOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id)) " - + "when '0' then (sum(total_capacity) * (select value from `cloud`.`cluster_details` where cluster_details.name= 'memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id))else sum(total_capacity) end)," - + "((sum(capacity.used_capacity) + sum(capacity.reserved_capacity)) / ( case capacity_type when 1 then (sum(total_capacity) * (select value from `cloud`.`cluster_details` where cluster_details.name= 'cpuOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id)) " - + "when '0' then (sum(total_capacity) * (select value from `cloud`.`cluster_details` where cluster_details.name= 'memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id))else sum(total_capacity) end)) percent," + + " (case capacity_type when 1 then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details` where cluster_details.name= 'cpuOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id) AS DECIMAL (10,4))) " + + "when '0' then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details` where cluster_details.name= 'memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id) AS DECIMAL (10,4)))else sum(total_capacity) end)," + + "((sum(capacity.used_capacity) + sum(capacity.reserved_capacity)) / ( case capacity_type when 1 then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details` where cluster_details.name= 'cpuOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id) AS DECIMAL (10,4))) " + + "when '0' then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details` where cluster_details.name= 'memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id) AS DECIMAL (10,4)))else sum(total_capacity) end)) percent," + "capacity.capacity_type, capacity.data_center_id, pod_id, cluster_id FROM `cloud`.`op_host_capacity` capacity WHERE total_capacity > 0 AND data_center_id is not null AND capacity_state='Enabled' "; private static final String LIST_CAPACITY_GROUP_BY_POD_TYPE_PART2 = " GROUP BY pod_id, capacity_type order by percent desc limit "; private static final String LIST_CAPACITY_GROUP_BY_CLUSTER_TYPE_PART1 = "SELECT sum(capacity.used_capacity), sum(capacity.reserved_capacity)," - + " (case capacity_type when 1 then (sum(total_capacity) * (select value from `cloud`.`cluster_details` where cluster_details.name= 'cpuOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id)) " - + "when '0' then (sum(total_capacity) * (select value from `cloud`.`cluster_details` where cluster_details.name= 'memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id))else sum(total_capacity) end)," - + "((sum(capacity.used_capacity) + sum(capacity.reserved_capacity)) / ( case capacity_type when 1 then (sum(total_capacity) * (select value from `cloud`.`cluster_details` where cluster_details.name= 'cpuOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id)) " - + "when '0' then (sum(total_capacity) * (select value from `cloud`.`cluster_details` where cluster_details.name= 'memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id))else sum(total_capacity) end)) percent," + + " (case capacity_type when 1 then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details` where cluster_details.name= 'cpuOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id) AS DECIMAL (10,4))) " + + "when '0' then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details` where cluster_details.name= 'memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id) AS DECIMAL (10,4)))else sum(total_capacity) end)," + + "((sum(capacity.used_capacity) + sum(capacity.reserved_capacity)) / ( case capacity_type when 1 then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details` where cluster_details.name= 'cpuOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id) AS DECIMAL (10,4))) " + + "when '0' then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details` where cluster_details.name= 'memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id) AS DECIMAL (10,4)))else sum(total_capacity) end)) percent," + "capacity.capacity_type, capacity.data_center_id, pod_id, cluster_id FROM `cloud`.`op_host_capacity` capacity WHERE total_capacity > 0 AND data_center_id is not null AND capacity_state='Enabled' "; private static final String LIST_CAPACITY_GROUP_BY_CLUSTER_TYPE_PART2 = " GROUP BY cluster_id, capacity_type, pod_id order by percent desc limit "; private static final String UPDATE_CAPACITY_STATE = "UPDATE `cloud`.`op_host_capacity` SET capacity_state = ? WHERE "; - private static final String LIST_CAPACITY_GROUP_BY_CAPACITY_PART1= "SELECT sum(capacity.used_capacity), sum(capacity.reserved_capacity)," + - " (case capacity_type when 1 then (sum(total_capacity) * (select value from `cloud`.`cluster_details` where cluster_details.name= 'cpuOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id)) " + - "when '0' then (sum(total_capacity) * (select value from `cloud`.`cluster_details` where cluster_details.name= 'memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id))else sum(total_capacity) end)," + - "((sum(capacity.used_capacity) + sum(capacity.reserved_capacity)) / ( case capacity_type when 1 then (sum(total_capacity) * (select value from `cloud`.`cluster_details` where cluster_details.name= 'cpuOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id)) " + - "when '0' then (sum(total_capacity) * (select value from `cloud`.`cluster_details` where cluster_details.name= 'memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id)) else sum(total_capacity) end)) percent," + - "capacity.capacity_type, capacity.data_center_id, pod_id, cluster_id FROM `cloud`.`op_host_capacity` capacity WHERE total_capacity > 0 AND data_center_id is not null AND capacity_state='Enabled' "; + private static final String LIST_CAPACITY_GROUP_BY_CAPACITY_PART1= + "SELECT sum(capacity.used_capacity), sum(capacity.reserved_capacity)," + + " (case capacity_type when 1 then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details` where cluster_details.name= 'cpuOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id) AS DECIMAL (10,4))) " + + "when '0' then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details` where cluster_details.name= 'memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id) AS DECIMAL(10,4)))else sum(total_capacity) end)," + + "((sum(capacity.used_capacity) + sum(capacity.reserved_capacity)) / ( case capacity_type when 1 then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details` where cluster_details.name= 'cpuOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id) AS DECIMAL(10,4))) " + + "when '0' then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details` where cluster_details.name= 'memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id) AS DECIMAL(10,4))) else sum(total_capacity) end)) percent," + + "capacity.capacity_type, capacity.data_center_id, pod_id, cluster_id FROM `cloud`.`op_host_capacity` capacity WHERE total_capacity > 0 AND data_center_id is not null AND capacity_state='Enabled' "; private static final String LIST_CAPACITY_GROUP_BY_CAPACITY_PART2 = " GROUP BY capacity_type"; private static final String LIST_CAPACITY_GROUP_BY_CAPACITY_DATA_CENTER_POD_CLUSTER = " GROUP BY data_center_id, pod_id, cluster_id, capacity_type"; From f1861819104c43b776fa1c4083112adece6a5cf5 Mon Sep 17 00:00:00 2001 From: Remi Bergsma Date: Fri, 8 Jan 2016 22:00:01 +0100 Subject: [PATCH 4/5] Admin cannot see VMs on port forwarding page On commir a902443708ee10acb9f68fff74af346a6a9fb370 the 'listAll=true' is removed. On some places the domainid and accountid are added but not on these. I added them now. It's either doing this, or readding listAll is true. I've seeing other folks doing that so let's see what performs best. --- ui/scripts/network.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui/scripts/network.js b/ui/scripts/network.js index 2831aa00099..cdfbcaa2d5a 100755 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -3526,6 +3526,8 @@ if ('vpc' in args.context) { var data = { //listAll: true, //do not pass listAll to listNetworks under VPC + domainid: args.context.vpc[0].domainid, + account: args.context.vpc[0].account, supportedservices: 'Lb' }; if (args.context.ipAddresses[0].associatednetworkid == null) { @@ -4158,6 +4160,8 @@ if ('vpc' in args.context) { var data = { //listAll: true, //do not pass listAll to listNetworks under VPC + domainid: args.context.vpc[0].domainid, + account: args.context.vpc[0].account, supportedservices: 'PortForwarding' }; if (args.context.ipAddresses[0].associatednetworkid == null) { From 93bbc1afb7986282d6f6ded7ecd373e558f519cc Mon Sep 17 00:00:00 2001 From: Remi Bergsma Date: Sat, 9 Jan 2016 21:02:38 +0100 Subject: [PATCH 5/5] CLOUDSTACK-9220 Sort list of domains on Domain tab in UI --- ui/scripts/domains.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ui/scripts/domains.js b/ui/scripts/domains.js index dcec93d53f4..9dc801bfc0a 100644 --- a/ui/scripts/domains.js +++ b/ui/scripts/domains.js @@ -722,6 +722,11 @@ async: false, success: function(json) { var domainObjs = json.listdomainsresponse.domain; + if (domainObjs != null && domainObjs.length > 0) { + domainObjs.sort(function(a, b) { + return a.name.localeCompare(b.name); + }); + } args.response.success({ actionFilter: domainActionfilter, data: domainObjs @@ -735,6 +740,11 @@ async: false, success: function(json) { var domainObjs = json.listdomainchildrenresponse.domain; + if (domainObjs != null && domainObjs.length > 0) { + domainObjs.sort(function(a, b) { + return a.name.localeCompare(b.name); + }); + } args.response.success({ actionFilter: domainActionfilter, data: domainObjs