Skip to content

Commit b1034ed

Browse files
committed
Merge release branch 4.7 to master
* 4.7: CLOUDSTACK-9220 Sort list of domains on Domain tab in UI Admin cannot see VMs on port forwarding page Fix mariadb related listCapacity bug (CLOUDSTACK-8966) CLOUDSTACK-9213 - Split the ACL rules using comma instead of dash. CLOUDSTACK-9213 - Formatting the code
2 parents 4014169 + 80703ca commit b1034ed

4 files changed

Lines changed: 49 additions & 33 deletions

File tree

core/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@
1919

2020
package com.cloud.agent.api.routing;
2121

22-
import com.cloud.agent.api.to.NetworkACLTO;
23-
import com.cloud.agent.api.to.NicTO;
24-
2522
import java.util.Arrays;
2623
import java.util.Collections;
2724
import java.util.Comparator;
2825
import java.util.List;
2926

27+
import com.cloud.agent.api.to.NetworkACLTO;
28+
import com.cloud.agent.api.to.NicTO;
29+
3030
public class SetNetworkACLCommand extends NetworkElementCommand {
3131
NetworkACLTO[] rules;
3232
NicTO nic;
3333

3434
protected SetNetworkACLCommand() {
3535
}
3636

37-
public SetNetworkACLCommand(List<NetworkACLTO> rules, NicTO nic) {
37+
public SetNetworkACLCommand(final List<NetworkACLTO> rules, final NicTO nic) {
3838
this.rules = rules.toArray(new NetworkACLTO[rules.size()]);
3939
this.nic = nic;
4040
}
@@ -44,32 +44,32 @@ public NetworkACLTO[] getRules() {
4444
}
4545

4646
public String[][] generateFwRules() {
47-
List<NetworkACLTO> aclList = Arrays.asList(rules);
47+
final List<NetworkACLTO> aclList = Arrays.asList(rules);
4848
Collections.sort(aclList, new Comparator<NetworkACLTO>() {
4949
@Override
50-
public int compare(NetworkACLTO acl1, NetworkACLTO acl2) {
50+
public int compare(final NetworkACLTO acl1, final NetworkACLTO acl2) {
5151
return acl1.getNumber() < acl2.getNumber() ? 1 : -1;
5252
}
5353
});
5454

55-
String[][] result = new String[2][aclList.size()];
55+
final String[][] result = new String[2][aclList.size()];
5656
int i = 0;
57-
for (NetworkACLTO aclTO : aclList) {
57+
for (final NetworkACLTO aclTO : aclList) {
5858
/* example : Ingress:tcp:80:80:0.0.0.0/0:ACCEPT:,Egress:tcp:220:220:0.0.0.0/0:DROP:,
5959
* each entry format Ingress/Egress:protocol:start port: end port:scidrs:action:
6060
* reverted entry format Ingress/Egress:reverted:0:0:0:
6161
*/
6262
if (aclTO.revoked() == true) {
63-
StringBuilder sb = new StringBuilder();
63+
final StringBuilder sb = new StringBuilder();
6464
/* This entry is added just to make sure atleast there will one entry in the list to get the ipaddress */
6565
sb.append(aclTO.getTrafficType().toString()).append(":reverted:0:0:0:");
66-
String aclRuleEntry = sb.toString();
66+
final String aclRuleEntry = sb.toString();
6767
result[0][i++] = aclRuleEntry;
6868
continue;
6969
}
7070

7171
List<String> cidr;
72-
StringBuilder sb = new StringBuilder();
72+
final StringBuilder sb = new StringBuilder();
7373
sb.append(aclTO.getTrafficType().toString()).append(":").append(aclTO.getProtocol()).append(":");
7474
if ("icmp".compareTo(aclTO.getProtocol()) == 0) {
7575
sb.append(aclTO.getIcmpType()).append(":").append(aclTO.getIcmpCode()).append(":");
@@ -81,15 +81,16 @@ public int compare(NetworkACLTO acl1, NetworkACLTO acl2) {
8181
sb.append("0.0.0.0/0");
8282
} else {
8383
Boolean firstEntry = true;
84-
for (String tag : cidr) {
85-
if (!firstEntry)
86-
sb.append("-");
84+
for (final String tag : cidr) {
85+
if (!firstEntry) {
86+
sb.append(",");
87+
}
8788
sb.append(tag);
8889
firstEntry = false;
8990
}
9091
}
9192
sb.append(":").append(aclTO.getAction()).append(":");
92-
String aclRuleEntry = sb.toString();
93+
final String aclRuleEntry = sb.toString();
9394
result[0][i++] = aclRuleEntry;
9495
}
9596

engine/schema/src/com/cloud/capacity/dao/CapacityDaoImpl.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -109,41 +109,42 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
109109

110110
private static final String LIST_CAPACITY_GROUP_BY_ZONE_TYPE_PART1 =
111111
"SELECT sum(capacity.used_capacity), sum(capacity.reserved_capacity),"
112-
+ " (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))"
113-
+ "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))"
112+
+ " (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)))"
113+
+ "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)))"
114114
+ "else sum(total_capacity) end),"
115-
+ "((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))"
116-
+ "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,"
115+
+ "((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)))"
116+
+ "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,"
117117
+ "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'";
118118

119119
private static final String LIST_CAPACITY_GROUP_BY_ZONE_TYPE_PART2 = " GROUP BY data_center_id, capacity_type order by percent desc limit ";
120120
private static final String LIST_CAPACITY_GROUP_BY_POD_TYPE_PART1 =
121121
"SELECT sum(capacity.used_capacity), sum(capacity.reserved_capacity),"
122-
+ " (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)) "
123-
+ "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),"
124-
+ "((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)) "
125-
+ "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,"
122+
+ " (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))) "
123+
+ "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),"
124+
+ "((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))) "
125+
+ "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,"
126126
+ "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' ";
127127

128128
private static final String LIST_CAPACITY_GROUP_BY_POD_TYPE_PART2 = " GROUP BY pod_id, capacity_type order by percent desc limit ";
129129

130130
private static final String LIST_CAPACITY_GROUP_BY_CLUSTER_TYPE_PART1 =
131131
"SELECT sum(capacity.used_capacity), sum(capacity.reserved_capacity),"
132-
+ " (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)) "
133-
+ "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),"
134-
+ "((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)) "
135-
+ "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,"
132+
+ " (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))) "
133+
+ "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),"
134+
+ "((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))) "
135+
+ "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,"
136136
+ "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' ";
137137

138138
private static final String LIST_CAPACITY_GROUP_BY_CLUSTER_TYPE_PART2 = " GROUP BY cluster_id, capacity_type, pod_id order by percent desc limit ";
139139
private static final String UPDATE_CAPACITY_STATE = "UPDATE `cloud`.`op_host_capacity` SET capacity_state = ? WHERE ";
140140

141-
private static final String LIST_CAPACITY_GROUP_BY_CAPACITY_PART1= "SELECT sum(capacity.used_capacity), sum(capacity.reserved_capacity)," +
142-
" (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)) " +
143-
"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)," +
144-
"((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)) " +
145-
"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," +
146-
"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' ";
141+
private static final String LIST_CAPACITY_GROUP_BY_CAPACITY_PART1=
142+
"SELECT sum(capacity.used_capacity), sum(capacity.reserved_capacity),"
143+
+ " (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))) "
144+
+ "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),"
145+
+ "((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))) "
146+
+ "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,"
147+
+ "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' ";
147148

148149
private static final String LIST_CAPACITY_GROUP_BY_CAPACITY_PART2 = " GROUP BY capacity_type";
149150
private static final String LIST_CAPACITY_GROUP_BY_CAPACITY_DATA_CENTER_POD_CLUSTER = " GROUP BY data_center_id, pod_id, cluster_id, capacity_type";

ui/scripts/domains.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,11 @@
722722
async: false,
723723
success: function(json) {
724724
var domainObjs = json.listdomainsresponse.domain;
725+
if (domainObjs != null && domainObjs.length > 0) {
726+
domainObjs.sort(function(a, b) {
727+
return a.name.localeCompare(b.name);
728+
});
729+
}
725730
args.response.success({
726731
actionFilter: domainActionfilter,
727732
data: domainObjs
@@ -735,6 +740,11 @@
735740
async: false,
736741
success: function(json) {
737742
var domainObjs = json.listdomainchildrenresponse.domain;
743+
if (domainObjs != null && domainObjs.length > 0) {
744+
domainObjs.sort(function(a, b) {
745+
return a.name.localeCompare(b.name);
746+
});
747+
}
738748
args.response.success({
739749
actionFilter: domainActionfilter,
740750
data: domainObjs

ui/scripts/network.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3526,6 +3526,8 @@
35263526
if ('vpc' in args.context) {
35273527
var data = {
35283528
//listAll: true, //do not pass listAll to listNetworks under VPC
3529+
domainid: args.context.vpc[0].domainid,
3530+
account: args.context.vpc[0].account,
35293531
supportedservices: 'Lb'
35303532
};
35313533
if (args.context.ipAddresses[0].associatednetworkid == null) {
@@ -4158,6 +4160,8 @@
41584160
if ('vpc' in args.context) {
41594161
var data = {
41604162
//listAll: true, //do not pass listAll to listNetworks under VPC
4163+
domainid: args.context.vpc[0].domainid,
4164+
account: args.context.vpc[0].account,
41614165
supportedservices: 'PortForwarding'
41624166
};
41634167
if (args.context.ipAddresses[0].associatednetworkid == null) {

0 commit comments

Comments
 (0)