From e9093551c56df34fde54a9684f41701e5d2fd91e Mon Sep 17 00:00:00 2001 From: Daan Hoogland Date: Tue, 12 May 2015 11:25:37 +0200 Subject: [PATCH] backport of CLOUDSTACK-8197 create MinVRVersion config item Conflicts: api/src/com/cloud/network/VirtualNetworkApplianceService.java engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java --- .../cloud/network/VirtualNetworkApplianceService.java | 2 -- .../service/NetworkOrchestrationService.java | 7 ++++++- .../engine/orchestration/NetworkOrchestrator.java | 8 +++++--- .../src/com/cloud/agent/manager/MockVmManagerImpl.java | 5 ++--- .../com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java | 9 ++++----- .../router/VirtualNetworkApplianceManagerImpl.java | 6 ++++-- 6 files changed, 21 insertions(+), 16 deletions(-) diff --git a/api/src/com/cloud/network/VirtualNetworkApplianceService.java b/api/src/com/cloud/network/VirtualNetworkApplianceService.java index 2984e3fa34e0..815ae4d6ae31 100644 --- a/api/src/com/cloud/network/VirtualNetworkApplianceService.java +++ b/api/src/com/cloud/network/VirtualNetworkApplianceService.java @@ -68,6 +68,4 @@ public interface VirtualNetworkApplianceService { VirtualRouter findRouter(long routerId); List upgradeRouterTemplate(UpgradeRouterTemplateCmd cmd); - - public static final String MinVRVersion = "4.5.0"; } diff --git a/engine/api/src/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java b/engine/api/src/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java index 5412ee4ce1fa..62aec8f28a2a 100755 --- a/engine/api/src/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java +++ b/engine/api/src/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java @@ -22,6 +22,7 @@ import org.apache.cloudstack.acl.ControlledEntity.ACLType; import org.apache.cloudstack.framework.config.ConfigKey; +import org.apache.cloudstack.framework.config.ConfigKey.Scope; import com.cloud.deploy.DataCenterDeployment; import com.cloud.deploy.DeployDestination; @@ -62,9 +63,13 @@ public interface NetworkOrchestrationService { static final String NetworkLockTimeoutCK = "network.lock.timeout"; static final String GuestDomainSuffixCK = "guest.domain.suffix"; static final String NetworkThrottlingRateCK = "network.throttling.rate"; + static final String MinVRVersionCK = "minreq.sysvmtemplate.version"; + + static final ConfigKey MinVRVersion = new ConfigKey(String.class, MinVRVersionCK, "Advanced", "4.5.0", + "What version should the Virtual Routers report", true, ConfigKey.Scope.Zone, null); static final ConfigKey NetworkLockTimeout = new ConfigKey(Integer.class, NetworkLockTimeoutCK, "Network", "600", - "Lock wait timeout (seconds) while implementing network", true); + "Lock wait timeout (seconds) while implementing network", true, Scope.Global, null); static final ConfigKey GuestDomainSuffix = new ConfigKey(String.class, GuestDomainSuffixCK, "Network", "cloud.internal", "Default domain name for vms inside virtualized networks fronted by router", true, ConfigKey.Scope.Zone, null); static final ConfigKey NetworkThrottlingRate = new ConfigKey("Network", Integer.class, NetworkThrottlingRateCK, "200", diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java index 244ce472da0f..093f11382155 100755 --- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java @@ -46,6 +46,7 @@ import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; import org.apache.cloudstack.framework.config.ConfigDepot; import org.apache.cloudstack.framework.config.ConfigKey; +import org.apache.cloudstack.framework.config.ConfigKey.Scope; import org.apache.cloudstack.framework.config.Configurable; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.framework.messagebus.MessageBus; @@ -3328,12 +3329,13 @@ public String getConfigComponentName() { } public static final ConfigKey NetworkGcWait = new ConfigKey(Integer.class, "network.gc.wait", "Advanced", "600", - "Time (in seconds) to wait before shutting down a network that's not in used", false); + "Time (in seconds) to wait before shutting down a network that's not in used", false, Scope.Global, null); public static final ConfigKey NetworkGcInterval = new ConfigKey(Integer.class, "network.gc.interval", "Advanced", "600", - "Seconds to wait before checking for networks to shutdown", true); + "Seconds to wait before checking for networks to shutdown", true, Scope.Global, null); @Override public ConfigKey[] getConfigKeys() { - return new ConfigKey[] {NetworkGcWait, NetworkGcInterval, NetworkLockTimeout, GuestDomainSuffix, NetworkThrottlingRate}; + return new ConfigKey[] {NetworkGcWait, NetworkGcInterval, NetworkLockTimeout, GuestDomainSuffix, NetworkThrottlingRate, MinVRVersion}; } + } diff --git a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java index 00cd1089901f..f77e12b4f6b4 100644 --- a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java +++ b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java @@ -26,8 +26,7 @@ import javax.inject.Inject; import javax.naming.ConfigurationException; -import com.cloud.network.VirtualNetworkApplianceService; - +import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; import org.apache.log4j.Logger; import org.springframework.stereotype.Component; @@ -551,7 +550,7 @@ public Answer WatchConsoleProxyLoad(WatchConsoleProxyLoadCommand cmd) { @Override public GetDomRVersionAnswer getDomRVersion(GetDomRVersionCmd cmd) { - String template_version = "CloudStack Release "+ VirtualNetworkApplianceService.MinVRVersion.toString(); + String template_version = "CloudStack Release "+ NetworkOrchestrationService.MinVRVersion.defaultValue(); return new GetDomRVersionAnswer(cmd, null, template_version, UUID.randomUUID().toString()); } diff --git a/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java index b054b0e185d0..6f7ef43048c5 100644 --- a/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java +++ b/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java @@ -22,18 +22,17 @@ import javax.ejb.Local; import javax.inject.Inject; -import org.apache.log4j.Logger; -import org.springframework.stereotype.Component; - import org.apache.cloudstack.api.response.DomainRouterResponse; import org.apache.cloudstack.api.response.NicResponse; +import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; +import org.apache.log4j.Logger; +import org.springframework.stereotype.Component; import com.cloud.api.ApiResponseHelper; import com.cloud.api.query.vo.DomainRouterJoinVO; import com.cloud.maint.Version; import com.cloud.network.Networks.TrafficType; -import com.cloud.network.VirtualNetworkApplianceService; import com.cloud.network.router.VirtualRouter; import com.cloud.network.router.VirtualRouter.Role; import com.cloud.user.Account; @@ -83,7 +82,7 @@ public DomainRouterResponse newDomainRouterResponse(DomainRouterJoinVO router, A if (router.getTemplateVersion() != null) { String routerVersion = Version.trimRouterVersion(router.getTemplateVersion()); routerResponse.setVersion(routerVersion); - routerResponse.setRequiresUpgrade((Version.compare(routerVersion, VirtualNetworkApplianceService.MinVRVersion) < 0)); + routerResponse.setRequiresUpgrade((Version.compare(routerVersion, NetworkOrchestrationService.MinVRVersion.valueIn(router.getDataCenterId())) < 0)); } else { routerResponse.setVersion("UNKNOWN"); routerResponse.setRequiresUpgrade(true); diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index c09634fd77b5..46463cdf66e6 100755 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -3792,7 +3792,7 @@ private void createDhcpEntryCommandsForVMs(final DomainRouterVO router, final Co protected boolean sendCommandsToRouter(final VirtualRouter router, final Commands cmds) throws AgentUnavailableException { if(!checkRouterVersion(router)){ s_logger.debug("Router requires upgrade. Unable to send command to router:" + router.getId() + ", router template version : " + router.getTemplateVersion() - + ", minimal required version : " + MinVRVersion); + + ", minimal required version : " + NetworkOrchestrationService.MinVRVersion.valueIn(router.getDataCenterId())); throw new CloudRuntimeException("Unable to send command. Upgrade in progress. Please contact administrator."); } Answer[] answers = null; @@ -4427,8 +4427,10 @@ protected boolean checkRouterVersion(final VirtualRouter router) { if(router.getTemplateVersion() == null){ return false; } + long dcid = router.getDataCenterId(); + final String dcVersion = NetworkOrchestrationService.MinVRVersion.valueIn(dcid); final String trimmedVersion = Version.trimRouterVersion(router.getTemplateVersion()); - return (Version.compare(trimmedVersion, MinVRVersion) >= 0); + return (Version.compare(trimmedVersion, dcVersion) >= 0); } private List rebootRouters(List routers){