From 482d0fd85ef0ce5f15873fb48f6b41b849085b76 Mon Sep 17 00:00:00 2001 From: dahn Date: Fri, 20 Dec 2019 16:43:09 +0100 Subject: [PATCH] 4.13 (#3782) * create template from snapshot regression (partly reverted) (#3767) * Once again allow a VM to be on multiple networks from VPCs (#3754) to once again allow a VM to be on multiple networks from VPCs * convert protocal names to be found as labels (#3747) * convert protocal names to be found as labels * format * filter hosts to query on zone wide storage (#3733) * config: add isdynamic flag in configuration response (#3729) Co-authored-by: Wei Zhou --- .../apache/cloudstack/api/ApiConstants.java | 1 + .../api/response/ConfigurationResponse.java | 13 +++++++++++ .../java/com/cloud/api/ApiResponseHelper.java | 1 + .../java/com/cloud/vm/UserVmManagerImpl.java | 23 ++++++++++--------- ui/scripts/globalSettings.js | 4 ++-- ui/scripts/network.js | 3 ++- 6 files changed, 31 insertions(+), 14 deletions(-) diff --git a/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java b/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java index e5d96713f68..e810760314c 100644 --- a/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java +++ b/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java @@ -188,6 +188,7 @@ public class ApiConstants { public static final String IP_LIMIT = "iplimit"; public static final String IP_TOTAL = "iptotal"; public static final String IS_CLEANUP_REQUIRED = "iscleanuprequired"; + public static final String IS_DYNAMIC = "isdynamic"; public static final String IS_EXTRACTABLE = "isextractable"; public static final String IS_FEATURED = "isfeatured"; public static final String IS_PORTABLE = "isportable"; diff --git a/api/src/main/java/org/apache/cloudstack/api/response/ConfigurationResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/ConfigurationResponse.java index 2d815deb286..c42307c265a 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/ConfigurationResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/ConfigurationResponse.java @@ -48,6 +48,10 @@ public class ConfigurationResponse extends BaseResponse { @Param(description = "the description of the configuration") private String description; + @SerializedName(ApiConstants.IS_DYNAMIC) + @Param(description = "true if the configuration is dynamic") + private boolean isDynamic; + public String getCategory() { return category; } @@ -87,4 +91,13 @@ public class ConfigurationResponse extends BaseResponse { public void setScope(String scope) { this.scope = scope; } + + public boolean isDynamic() { + return isDynamic; + } + + public void setIsDynamic(boolean isDynamic) { + this.isDynamic = isDynamic; + } + } diff --git a/server/src/main/java/com/cloud/api/ApiResponseHelper.java b/server/src/main/java/com/cloud/api/ApiResponseHelper.java index 8e6731dd20d..b8e60325ea2 100644 --- a/server/src/main/java/com/cloud/api/ApiResponseHelper.java +++ b/server/src/main/java/com/cloud/api/ApiResponseHelper.java @@ -491,6 +491,7 @@ public class ApiResponseHelper implements ResponseGenerator { } else { cfgResponse.setValue(cfg.getValue()); } + cfgResponse.setIsDynamic(cfg.isDynamic()); cfgResponse.setObjectName("configuration"); return cfgResponse; diff --git a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java index 11c1effe951..b05135e9f78 100644 --- a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java @@ -40,6 +40,7 @@ import java.util.stream.Stream; import javax.inject.Inject; import javax.naming.ConfigurationException; +import com.cloud.storage.ScopeType; import org.apache.cloudstack.acl.ControlledEntity.ACLType; import org.apache.cloudstack.acl.SecurityChecker.AccessType; import org.apache.cloudstack.affinity.AffinityGroupService; @@ -1941,14 +1942,23 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir @Override public HashMap getVolumeStatistics(long clusterId, String poolUuid, StoragePoolType poolType, List volumeLocators, int timeout) { List neighbors = _resourceMgr.listHostsInClusterByStatus(clusterId, Status.Up); - StoragePool storagePool = _storagePoolDao.findPoolByUUID(poolUuid); + StoragePoolVO storagePool = _storagePoolDao.findPoolByUUID(poolUuid); for (HostVO neighbor : neighbors) { - if (storagePool.isManaged()) { + // apply filters: + // - managed storage + // - local storage + if (storagePool.isManaged() || storagePool.isLocal()) { volumeLocators = getVolumesByHost(neighbor, storagePool); } + // - zone wide storage for specific hypervisortypes + if (ScopeType.ZONE.equals(storagePool.getScope()) && storagePool.getHypervisor() != neighbor.getHypervisorType()) { + // skip this neighbour if their hypervisor type is not the same as that of the store + continue; + } + GetVolumeStatsCommand cmd = new GetVolumeStatsCommand(poolType, poolUuid, volumeLocators); if (timeout > 0) { @@ -3612,7 +3622,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir short defaultNetworkNumber = 0; boolean securityGroupEnabled = false; - boolean vpcNetwork = false; for (NetworkVO network : networkList) { if ((network.getDataCenterId() != zone.getId())) { if (!network.isStrechedL2Network()) { @@ -3683,14 +3692,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir securityGroupEnabled = true; } - // vm can't be a part of more than 1 VPC network - if (network.getVpcId() != null) { - if (vpcNetwork) { - throw new InvalidParameterValueException("Vm can't be a part of more than 1 VPC network"); - } - vpcNetwork = true; - } - networkNicMap.put(network.getUuid(), profile); } diff --git a/ui/scripts/globalSettings.js b/ui/scripts/globalSettings.js index 3e926ea678f..5d34982de29 100644 --- a/ui/scripts/globalSettings.js +++ b/ui/scripts/globalSettings.js @@ -41,11 +41,11 @@ data: data, success: function(json) { var item = json.updateconfigurationresponse.configuration; - if (item.category == "Usage") + if (item.category == "Usage" && item.isdynamic == false) cloudStack.dialog.notice({ message: _l('message.restart.mgmt.usage.server') }); - else + else if (item.isdynamic == false) cloudStack.dialog.notice({ message: _l('message.restart.mgmt.server') }); diff --git a/ui/scripts/network.js b/ui/scripts/network.js index 7e5f554d08a..aa6af96afd4 100644 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -6843,7 +6843,8 @@ return []; } - var protocols = protocolCapabilities.value.split(','); + // make sure protocols are found in a script compatible way: i.e. "tcp,udp,tcp.proxy" , no minus sign or spaces + var protocols = protocolCapabilities.value.replace(/\s/g,'').replace('-','.').split(','); if (!protocols) { return [];