mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
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
This commit is contained in:
commit
b1034ed624
@ -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<NetworkACLTO> rules, NicTO nic) {
|
||||
public SetNetworkACLCommand(final List<NetworkACLTO> 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<NetworkACLTO> aclList = Arrays.asList(rules);
|
||||
final List<NetworkACLTO> aclList = Arrays.asList(rules);
|
||||
Collections.sort(aclList, new Comparator<NetworkACLTO>() {
|
||||
@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<String> 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)
|
||||
sb.append("-");
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@ -109,41 +109,42 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> 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";
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user