diff --git a/api/src/com/cloud/api/commands/UpdateNetworkCmd.java b/api/src/com/cloud/api/commands/UpdateNetworkCmd.java index da7542ae214..8add07d7eba 100644 --- a/api/src/com/cloud/api/commands/UpdateNetworkCmd.java +++ b/api/src/com/cloud/api/commands/UpdateNetworkCmd.java @@ -27,6 +27,7 @@ import com.cloud.api.BaseCmd; import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; +import com.cloud.api.BaseCmd.CommandType; import com.cloud.api.response.NetworkResponse; import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.InsufficientCapacityException; @@ -55,6 +56,9 @@ public class UpdateNetworkCmd extends BaseCmd { @Parameter(name=ApiConstants.TAGS, type=CommandType.LIST, collectionType=CommandType.STRING, description="tags for the network") private List tags; + @Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="network domain") + private String networkDomain; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// @@ -76,6 +80,10 @@ public class UpdateNetworkCmd extends BaseCmd { return tags; } + private String getNetworkDomain() { + return networkDomain; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// @@ -99,7 +107,7 @@ public class UpdateNetworkCmd extends BaseCmd { @Override public void execute() throws InsufficientCapacityException, ConcurrentOperationException{ - Network result = _networkService.updateNetwork(getId(), getNetworkName(), getDisplayText(), tags, UserContext.current().getCaller()); + Network result = _networkService.updateNetwork(getId(), getNetworkName(), getDisplayText(), tags, UserContext.current().getCaller(), getNetworkDomain()); if (result != null) { NetworkResponse response = _responseGenerator.createNetworkResponse(result); response.setResponseName(getCommandName()); diff --git a/api/src/com/cloud/network/Network.java b/api/src/com/cloud/network/Network.java index ad6532cb19b..3287369ce53 100644 --- a/api/src/com/cloud/network/Network.java +++ b/api/src/com/cloud/network/Network.java @@ -47,7 +47,7 @@ public interface Network extends ControlledEntity { public static final Service Vpn = new Service("Vpn", Capability.SupportedVpnTypes); public static final Service Dhcp = new Service("Dhcp"); - public static final Service Dns = new Service("Dns"); + public static final Service Dns = new Service("Dns", Capability.AllowDnsSuffixModification); public static final Service Gateway = new Service("Gateway"); public static final Service Firewall = new Service("Firewall", Capability.PortForwarding, Capability.StaticNat, Capability.SupportedProtocols, Capability.MultipleIps, Capability.SupportedSourceNatTypes, Capability.TrafficStatistics); public static final Service Lb = new Service("Lb", Capability.SupportedLBAlgorithms, Capability.SupportedProtocols, Capability.TrafficStatistics, Capability.LoadBalancingSupportedIps); @@ -117,6 +117,7 @@ public interface Network extends ControlledEntity { public static final Capability SupportedVpnTypes = new Capability("SupportedVpnTypes"); public static final Capability TrafficStatistics = new Capability("TrafficStatistics"); public static final Capability LoadBalancingSupportedIps = new Capability("LoadBalancingSupportedIps"); + public static final Capability AllowDnsSuffixModification = new Capability("AllowDnsSuffixModification"); private String name; diff --git a/api/src/com/cloud/network/NetworkService.java b/api/src/com/cloud/network/NetworkService.java index e866eec9b83..4a14ce50d68 100644 --- a/api/src/com/cloud/network/NetworkService.java +++ b/api/src/com/cloud/network/NetworkService.java @@ -75,13 +75,13 @@ public interface NetworkService { Map> getZoneCapabilities(long zoneId); - Map> getNetworkCapabilities(long networkId); + Map> getNetworkCapabilities(long networkId, long zoneId); boolean isNetworkAvailableInDomain(long networkId, long domainId); Long getDedicatedNetworkDomain(long networkId); - Network updateNetwork(long networkId, String name, String displayText, List tags, Account caller); + Network updateNetwork(long networkId, String name, String displayText, List tags, Account caller, String domainSuffix); Integer getNetworkRate(long networkId, Long vmId); diff --git a/server/src/com/cloud/api/ApiDBUtils.java b/server/src/com/cloud/api/ApiDBUtils.java index bded506edee..9116a9960b0 100755 --- a/server/src/com/cloud/api/ApiDBUtils.java +++ b/server/src/com/cloud/api/ApiDBUtils.java @@ -533,8 +533,8 @@ public class ApiDBUtils { return _networkDao.findById(id); } - public static Map> getNetworkCapabilities(long networkId) { - return _networkMgr.getNetworkCapabilities(networkId); + public static Map> getNetworkCapabilities(long networkOfferingId, long zoneId) { + return _networkMgr.getNetworkCapabilities(networkOfferingId, zoneId); } public static long getPublicNetworkIdByZone(long zoneId) { diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index 160b7fc59fa..625154a6b54 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -2484,7 +2484,7 @@ public class ApiResponseHelper implements ResponseGenerator { response.setTags(network.getTags()); // populate capability - Map> serviceCapabilitiesMap = ApiDBUtils.getNetworkCapabilities(network.getId()); + Map> serviceCapabilitiesMap = ApiDBUtils.getNetworkCapabilities(networkOffering.getId(), network.getDataCenterId()); List serviceResponses = new ArrayList(); if (serviceCapabilitiesMap != null) { for (Service service : serviceCapabilitiesMap.keySet()) { diff --git a/server/src/com/cloud/network/NetworkManager.java b/server/src/com/cloud/network/NetworkManager.java index ddee026f3fb..c84e3d4b453 100644 --- a/server/src/com/cloud/network/NetworkManager.java +++ b/server/src/com/cloud/network/NetworkManager.java @@ -188,7 +188,7 @@ public interface NetworkManager extends NetworkService { boolean zoneIsConfiguredForExternalNetworking(long zoneId); - Map getServiceCapabilities(long zoneId, Service service); + Map getServiceCapabilities(long zoneId, Long networkOfferingId, Service service); boolean applyIpAssociations(Network network, boolean continueOnError) throws ResourceUnavailableException; diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index 1318abbafa6..d85135c92e7 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -133,6 +133,7 @@ import com.cloud.utils.db.Transaction; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.net.Ip; import com.cloud.utils.net.NetUtils; +import com.cloud.vm.DomainRouterVO; import com.cloud.vm.Nic; import com.cloud.vm.NicProfile; import com.cloud.vm.NicVO; @@ -143,6 +144,7 @@ import com.cloud.vm.VMInstanceVO; import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachine.Type; import com.cloud.vm.VirtualMachineProfile; +import com.cloud.vm.dao.DomainRouterDao; import com.cloud.vm.dao.NicDao; import com.cloud.vm.dao.UserVmDao; import com.cloud.vm.dao.VMInstanceDao; @@ -211,6 +213,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag NetworkDomainDao _networkDomainDao; @Inject VMInstanceDao _vmDao; + + @Inject DomainRouterDao _routerDao; private final HashMap _systemNetworks = new HashMap(5); @@ -903,7 +907,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } NetworkVO vo = new NetworkVO(id, network, offering.getId(), plan.getDataCenterId(), guru.getName(), owner.getDomainId(), owner.getId(), related, name, displayText, isShared, isDefault, - predefined.isSecurityGroupEnabled(), (domainId != null)); + predefined.isSecurityGroupEnabled(), (domainId != null), predefined.getNetworkDomain()); vo.setTags(tags); networks.add(_networksDao.persist(vo, vo.getGuestType() != null)); @@ -1675,14 +1679,22 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } // If networkDomain is not specified, take it from the global configuration - if (networkDomain == null) { - networkDomain = "cs" + Long.toHexString(owner.getId()) + _networkDomain; + Map dnsCapabilities = getServiceCapabilities(zoneId, networkOfferingId, Service.Dns); + String isUpdateDnsSupported = dnsCapabilities.get(Capability.AllowDnsSuffixModification); + if (isUpdateDnsSupported == null || !Boolean.valueOf(isUpdateDnsSupported)) { + if (networkDomain != null) { + throw new InvalidParameterValueException("Domain name change is not supported by network offering id=" + networkOfferingId + " in zone id=" + zoneId); + } } else { - // validate network domain - if (!NetUtils.verifyDomainName(networkDomain)) { - throw new InvalidParameterValueException( - "Invalid network domain. Total length shouldn't exceed 190 chars. Each domain label must be between 1 and 63 characters long, can contain ASCII letters 'a' through 'z', the digits '0' through '9', " - + "and the hyphen ('-'); can't start or end with \"-\""); + if (networkDomain == null) { + networkDomain = "cs" + Long.toHexString(owner.getId()) + _networkDomain; + } else { + // validate network domain + if (!NetUtils.verifyDomainName(networkDomain)) { + throw new InvalidParameterValueException( + "Invalid network domain. Total length shouldn't exceed 190 chars. Each domain label must be between 1 and 63 characters long, can contain ASCII letters 'a' through 'z', the digits '0' through '9', " + + "and the hyphen ('-'); can't start or end with \"-\""); + } } } @@ -2420,17 +2432,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } @Override - public Map> getNetworkCapabilities(long networkId) { - Network network = getNetwork(networkId); - if (network == null) { - throw new InvalidParameterValueException("Unable to find network by id " + networkId); - } + public Map> getNetworkCapabilities(long networkOfferingId, long zoneId) { - Map> zoneCapabilities = getZoneCapabilities(network.getDataCenterId()); + Map> zoneCapabilities = getZoneCapabilities(zoneId); Map> networkCapabilities = new HashMap>(); for (Service service : zoneCapabilities.keySet()) { - if (isServiceSupported(networkId, service)) { + if (isServiceSupported(networkOfferingId, service)) { networkCapabilities.put(service, zoneCapabilities.get(service)); } } @@ -2439,7 +2447,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } @Override - public Map getServiceCapabilities(long zoneId, Service service) { + public Map getServiceCapabilities(long zoneId, Long networkOfferingId, Service service) { + + if (!isServiceSupported(networkOfferingId, service)) { + throw new UnsupportedServiceException("Service " + service.getName() + " is not by the network offering id=" + networkOfferingId); + } + Map> networkCapabilities = getZoneCapabilities(zoneId); if (networkCapabilities.get(service) == null) { throw new UnsupportedServiceException("Service " + service.getName() + " is not supported in zone id=" + zoneId); @@ -2673,9 +2686,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } @Override - public boolean isServiceSupported(long networkId, Network.Service service) { - Network network = getNetwork(networkId); - NetworkOffering offering = _configMgr.getNetworkOffering(network.getNetworkOfferingId()); + public boolean isServiceSupported(long networkOfferingId, Network.Service service) { + NetworkOffering offering = _configMgr.getNetworkOffering(networkOfferingId); if (service == Service.Lb) { return offering.isLbService(); } else if (service == Service.Dhcp) { @@ -2761,7 +2773,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag NetworkOfferingVO no = _networkOfferingDao.findById(network.getNetworkOfferingId()); if (!no.isSystemOnly()) { if (network.getIsShared() || !_networksDao.listBy(accountId, network.getId()).isEmpty()) { - if ((guestType == null || guestType == network.getGuestType()) && (isDefault == null || isDefault == network.isDefault)) { + if ((guestType == null || guestType == network.getGuestType()) && (isDefault == null || isDefault.booleanValue() == network.isDefault)) { accountNetworks.add(network); } } @@ -2858,7 +2870,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag @Override @ActionEvent(eventType = EventTypes.EVENT_NETWORK_UPDATE, eventDescription = "updating network", async = false) - public Network updateNetwork(long networkId, String name, String displayText, List tags, Account caller) { + public Network updateNetwork(long networkId, String name, String displayText, List tags, Account caller, String domainSuffix) { // verify input parameters NetworkVO network = _networksDao.findById(networkId); @@ -2875,6 +2887,23 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (offering.isSystemOnly()) { throw new InvalidParameterValueException("Can't update system networks"); } + + //don't allow to modify network domain if the service is not supported + if (domainSuffix != null) { + Map dnsCapabilities = getServiceCapabilities(network.getDataCenterId(), network.getNetworkOfferingId(), Service.Dns); + String isUpdateDnsSupported = dnsCapabilities.get(Capability.AllowDnsSuffixModification); + if (isUpdateDnsSupported == null || !Boolean.valueOf(isUpdateDnsSupported)) { + throw new InvalidParameterValueException("Domain name change is not supported for network id=" + network.getNetworkOfferingId() + " in zone id=" + network.getDataCenterId()); + } + + List routers = _routerDao.listActive(networkId); + if (!routers.isEmpty()) { + throw new CloudRuntimeException("Unable to update network id=" + networkId + " with new network domain as the network has running network elements"); + } + + + network.setNetworkDomain(domainSuffix); + } _accountMgr.checkAccess(caller, network); diff --git a/server/src/com/cloud/network/NetworkVO.java b/server/src/com/cloud/network/NetworkVO.java index 4778f55dd7c..b98a188b49c 100644 --- a/server/src/com/cloud/network/NetworkVO.java +++ b/server/src/com/cloud/network/NetworkVO.java @@ -178,15 +178,14 @@ public class NetworkVO implements Network { this.guestType = guestType; } - public NetworkVO(long id, Network that, long offeringId, long dataCenterId, String guruName, long domainId, long accountId, long related, String name, String displayText, Boolean isShared, boolean isDefault, boolean isSecurityGroupEnabled, boolean isDomainSpecific) { - this(id, that.getTrafficType(), that.getGuestType(), that.getMode(), that.getBroadcastDomainType(), offeringId, dataCenterId, domainId, accountId, related, name, displayText, isShared, isDefault, isDomainSpecific); + public NetworkVO(long id, Network that, long offeringId, long dataCenterId, String guruName, long domainId, long accountId, long related, String name, String displayText, Boolean isShared, boolean isDefault, boolean isSecurityGroupEnabled, boolean isDomainSpecific, String networkDomain) { + this(id, that.getTrafficType(), that.getGuestType(), that.getMode(), that.getBroadcastDomainType(), offeringId, dataCenterId, domainId, accountId, related, name, displayText, isShared, isDefault, isDomainSpecific, networkDomain); this.gateway = that.getGateway(); this.cidr = that.getCidr(); this.broadcastUri = that.getBroadcastUri(); this.broadcastDomainType = that.getBroadcastDomainType(); this.guruName = guruName; this.state = that.getState(); - this.networkDomain = that.getNetworkDomain(); this.securityGroupEnabled = isSecurityGroupEnabled; if (state == null) { state = State.Allocated; @@ -207,8 +206,9 @@ public class NetworkVO implements Network { * @param isShared * @param isDefault * @param isDomainSpecific + * @param networkDomain */ - public NetworkVO(long id, TrafficType trafficType, GuestIpType guestType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long dataCenterId, long domainId, long accountId, long related, String name, String displayText, Boolean isShared, boolean isDefault, boolean isDomainSpecific) { + public NetworkVO(long id, TrafficType trafficType, GuestIpType guestType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long dataCenterId, long domainId, long accountId, long related, String name, String displayText, Boolean isShared, boolean isDefault, boolean isDomainSpecific, String networkDomain) { this(trafficType, guestType, mode, broadcastDomainType, networkOfferingId, dataCenterId, State.Allocated); this.domainId = domainId; this.accountId = accountId; @@ -219,6 +219,7 @@ public class NetworkVO implements Network { this.isShared = isShared; this.isDefault = isDefault; this.isDomainSpecific = isDomainSpecific; + this.networkDomain = networkDomain; } @Override diff --git a/server/src/com/cloud/network/element/DhcpElement.java b/server/src/com/cloud/network/element/DhcpElement.java index 216af9677ee..092f74588f2 100644 --- a/server/src/com/cloud/network/element/DhcpElement.java +++ b/server/src/com/cloud/network/element/DhcpElement.java @@ -179,7 +179,10 @@ public class DhcpElement extends AdapterBase implements NetworkElement, Password private static Map> setCapabilities() { Map> capabilities = new HashMap>(); - capabilities.put(Service.Dns, null); + Map dnsCapabilities = new HashMap(); + dnsCapabilities.put(Capability.AllowDnsSuffixModification, "true"); + capabilities.put(Service.Dns, dnsCapabilities); + capabilities.put(Service.UserData, null); capabilities.put(Service.Dhcp, null); diff --git a/server/src/com/cloud/network/element/VirtualRouterElement.java b/server/src/com/cloud/network/element/VirtualRouterElement.java index 304059d9b62..b31688b588a 100644 --- a/server/src/com/cloud/network/element/VirtualRouterElement.java +++ b/server/src/com/cloud/network/element/VirtualRouterElement.java @@ -257,9 +257,12 @@ public class VirtualRouterElement extends DhcpElement implements NetworkElement, //Set capabilities for vpn Map vpnCapabilities = new HashMap(); vpnCapabilities.put(Capability.SupportedVpnTypes, "pptp,l2tp,ipsec"); - capabilities.put(Service.Vpn, vpnCapabilities); - capabilities.put(Service.Dns, null); + + Map dnsCapabilities = new HashMap(); + dnsCapabilities.put(Capability.AllowDnsSuffixModification, "true"); + capabilities.put(Service.Dns, dnsCapabilities); + capabilities.put(Service.UserData, null); capabilities.put(Service.Dhcp, null); capabilities.put(Service.Gateway, null); diff --git a/server/src/com/cloud/network/guru/DirectNetworkGuru.java b/server/src/com/cloud/network/guru/DirectNetworkGuru.java index 980893b8655..0a47884ecde 100644 --- a/server/src/com/cloud/network/guru/DirectNetworkGuru.java +++ b/server/src/com/cloud/network/guru/DirectNetworkGuru.java @@ -122,6 +122,7 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru { if (userSpecified.getBroadcastDomainType() != null) { config.setBroadcastDomainType(userSpecified.getBroadcastDomainType()); } + } if (config.isSecurityGroupEnabled()) { diff --git a/server/src/com/cloud/network/guru/GuestNetworkGuru.java b/server/src/com/cloud/network/guru/GuestNetworkGuru.java index 3ff46314c13..186038b45fc 100644 --- a/server/src/com/cloud/network/guru/GuestNetworkGuru.java +++ b/server/src/com/cloud/network/guru/GuestNetworkGuru.java @@ -118,9 +118,6 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru { network.setBroadcastUri(userSpecified.getBroadcastUri()); network.setState(State.Setup); } - if (userSpecified.getNetworkDomain() != null) { - network.setNetworkDomain(userSpecified.getNetworkDomain()); - } } else { String guestNetworkCidr = dc.getGuestNetworkCidr(); diff --git a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java index 608900c3d9b..760a06fe657 100755 --- a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java +++ b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java @@ -49,6 +49,7 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.IPAddressVO; import com.cloud.network.LoadBalancerVMMapVO; import com.cloud.network.LoadBalancerVO; +import com.cloud.network.Network; import com.cloud.network.Network.Service; import com.cloud.network.NetworkManager; import com.cloud.network.dao.FirewallRulesDao; @@ -388,7 +389,8 @@ public class LoadBalancingRulesManagerImpl implements LoadBalancingRulesManager, _accountMgr.checkAccess(caller.getCaller(), ipAddr); // verify that lb service is supported by the network - if (!_networkMgr.isServiceSupported(networkId, Service.Lb)) { + Network network = _networkMgr.getNetwork(networkId); + if (!_networkMgr.isServiceSupported(network.getNetworkOfferingId(), Service.Lb)) { throw new InvalidParameterValueException("LB service is not supported in network id=" + networkId); } diff --git a/server/src/com/cloud/network/rules/RulesManagerImpl.java b/server/src/com/cloud/network/rules/RulesManagerImpl.java index bac109589ed..38c4a8c5727 100755 --- a/server/src/com/cloud/network/rules/RulesManagerImpl.java +++ b/server/src/com/cloud/network/rules/RulesManagerImpl.java @@ -233,13 +233,8 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager { Network network = _networkMgr.getNetwork(networkId); assert network != null : "Can't create port forwarding rule as network associated with public ip address is null...how is it possible?"; - // verify that firewall service is supported by the network - if (!_networkMgr.isServiceSupported(networkId, Service.Firewall)) { - throw new InvalidParameterValueException("Firewall service is not supported in network id=" + networkId); - } - // Verify that the network guru supports the protocol specified - Map firewallCapabilities = _networkMgr.getServiceCapabilities(network.getDataCenterId(), Service.Firewall); + Map firewallCapabilities = _networkMgr.getServiceCapabilities(network.getDataCenterId(), network.getNetworkOfferingId(), Service.Firewall); String supportedProtocols = firewallCapabilities.get(Capability.SupportedProtocols).toLowerCase(); if (!supportedProtocols.contains(rule.getProtocol().toLowerCase())) { throw new InvalidParameterValueException("Protocol " + rule.getProtocol() + " is not supported in zone " + network.getDataCenterId()); @@ -323,13 +318,8 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager { assert (guestNic != null && guestNic.getIp4Address() != null) : "Vm doesn't belong to network associated with ipAddress or ip4 address is null...how is it possible?"; String dstIp = guestNic.getIp4Address(); - // verify that firewall service is supported by the network - if (!_networkMgr.isServiceSupported(networkId, Service.Firewall)) { - throw new InvalidParameterValueException("Firewall service is not supported in network id=" + networkId); - } - // Verify that the network guru supports the protocol specified - Map firewallCapability = _networkMgr.getServiceCapabilities(network.getDataCenterId(), Service.Firewall); + Map firewallCapability = _networkMgr.getServiceCapabilities(network.getDataCenterId(), network.getNetworkOfferingId(), Service.Firewall); String supportedProtocols = firewallCapability.get(Capability.SupportedProtocols).toLowerCase(); if (!supportedProtocols.contains(rule.getProtocol().toLowerCase())) { throw new InvalidParameterValueException("Protocol " + rule.getProtocol() + " is not supported in zone " + network.getDataCenterId()); @@ -396,7 +386,8 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager { throw new InvalidParameterValueException("Vm doesn't belong to the network " + networkId); } - if (!_networkMgr.isServiceSupported(networkId, Service.Firewall)) { + Network network = _networkMgr.getNetwork(networkId); + if (!_networkMgr.isServiceSupported(network.getNetworkOfferingId(), Service.Firewall)) { throw new InvalidParameterValueException("Unable to create static nat rule; Firewall service is not supported in network id=" + networkId); } diff --git a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java index 7d91d7b08ba..c0c5add1ca3 100755 --- a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java +++ b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java @@ -131,7 +131,8 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag } //Verify that vpn service is enabled for the network - if (!_networkMgr.isServiceSupported(ipAddr.getAssociatedWithNetworkId(), Service.Vpn)) { + Network network = _networkMgr.getNetwork(ipAddr.getAssociatedWithNetworkId()); + if (!_networkMgr.isServiceSupported(network.getNetworkOfferingId(), Service.Vpn)) { throw new InvalidParameterValueException("Vpn service is not supported in network id=" + ipAddr.getAssociatedWithNetworkId()); } @@ -149,7 +150,6 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag throw new InvalidParameterValueException("Invalid ip range " + ipRange); } - Network network = _networkMgr.getNetwork(ipAddr.getAssociatedWithNetworkId()); Pair cidr = NetUtils.getCidr(network.getCidr()); // FIXME: This check won't work for the case where the guest ip range diff --git a/server/src/com/cloud/server/ConfigurationServerImpl.java b/server/src/com/cloud/server/ConfigurationServerImpl.java index 87712659d05..841adc08710 100644 --- a/server/src/com/cloud/server/ConfigurationServerImpl.java +++ b/server/src/com/cloud/server/ConfigurationServerImpl.java @@ -921,7 +921,7 @@ public class ConfigurationServerImpl implements ConfigurationServer { } if (broadcastDomainType != null) { - NetworkVO network = new NetworkVO(id, trafficType, null, mode, broadcastDomainType, networkOfferingId, zoneId, domainId, accountId, related, null, null, true, isNetworkDefault, false); + NetworkVO network = new NetworkVO(id, trafficType, null, mode, broadcastDomainType, networkOfferingId, zoneId, domainId, accountId, related, null, null, true, isNetworkDefault, false, null); network.setGuruName(guruNames.get(network.getTrafficType())); network.setDns1(zone.getDns1()); network.setDns2(zone.getDns2()); diff --git a/server/src/com/cloud/vm/dao/DomainRouterDao.java b/server/src/com/cloud/vm/dao/DomainRouterDao.java index 0709d1e514d..8f79c410232 100755 --- a/server/src/com/cloud/vm/dao/DomainRouterDao.java +++ b/server/src/com/cloud/vm/dao/DomainRouterDao.java @@ -81,4 +81,6 @@ public interface DomainRouterDao extends GenericDao { List findByNetwork(long networkId); List findByNetworkAndPod(long networkId, long podId); + + List listActive(long networkId); } diff --git a/server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java b/server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java index 6453c0f15ce..880d3ae8333 100755 --- a/server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java +++ b/server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java @@ -43,7 +43,7 @@ public class DomainRouterDaoImpl extends GenericDaoBase im private static final Logger s_logger = Logger.getLogger(DomainRouterDaoImpl.class); protected final SearchBuilder AllFieldsSearch; - protected final SearchBuilder IdStatesSearch; + protected final SearchBuilder IdNetworkIdStatesSearch; protected final SearchBuilder HostUpSearch; NetworkDaoImpl _networksDao = ComponentLocator.inject(NetworkDaoImpl.class); @@ -60,10 +60,11 @@ public class DomainRouterDaoImpl extends GenericDaoBase im AllFieldsSearch.and("podId", AllFieldsSearch.entity().getPodIdToDeployIn(), Op.EQ); AllFieldsSearch.done(); - IdStatesSearch = createSearchBuilder(); - IdStatesSearch.and("id", IdStatesSearch.entity().getId(), Op.EQ); - IdStatesSearch.and("states", IdStatesSearch.entity().getState(), Op.IN); - IdStatesSearch.done(); + IdNetworkIdStatesSearch = createSearchBuilder(); + IdNetworkIdStatesSearch.and("id", IdNetworkIdStatesSearch.entity().getId(), Op.EQ); + IdNetworkIdStatesSearch.and("network", IdNetworkIdStatesSearch.entity().getNetworkId(), Op.EQ); + IdNetworkIdStatesSearch.and("states", IdNetworkIdStatesSearch.entity().getState(), Op.IN); + IdNetworkIdStatesSearch.done(); HostUpSearch = createSearchBuilder(); HostUpSearch.and("host", HostUpSearch.entity().getHostId(), Op.EQ); @@ -72,7 +73,7 @@ public class DomainRouterDaoImpl extends GenericDaoBase im joinNetwork.and("guestType", joinNetwork.entity().getGuestType(), Op.EQ); HostUpSearch.join("network", joinNetwork, joinNetwork.entity().getId(), HostUpSearch.entity().getNetworkId(), JoinType.INNER); HostUpSearch.done(); - + } @Override @@ -105,7 +106,7 @@ public class DomainRouterDaoImpl extends GenericDaoBase im sc.setParameters("role", Role.DHCP_FIREWALL_LB_PASSWD_USERDATA); return listBy(sc); } - + @Override public List findBy(long accountId, long dcId, Role role) { SearchCriteria sc = AllFieldsSearch.create(); @@ -128,11 +129,11 @@ public class DomainRouterDaoImpl extends GenericDaoBase im sc.setParameters("host", hostId); return listBy(sc); } - + @Override public List listVirtualUpByHostId(Long hostId) { SearchCriteria sc = HostUpSearch.create(); - if(hostId != null){ + if (hostId != null) { sc.setParameters("host", hostId); } sc.setParameters("states", State.Destroyed, State.Stopped, State.Expunging); @@ -153,10 +154,10 @@ public class DomainRouterDaoImpl extends GenericDaoBase im sc.setParameters("network", networkId); return listBy(sc); } - - @Override - public List listByLastHostId(Long hostId) { - SearchCriteria sc = AllFieldsSearch.create(); + + @Override + public List listByLastHostId(Long hostId) { + SearchCriteria sc = AllFieldsSearch.create(); sc.setParameters("lastHost", hostId); sc.setParameters("state", State.Stopped); return listBy(sc); @@ -169,4 +170,12 @@ public class DomainRouterDaoImpl extends GenericDaoBase im sc.setParameters("podId", podId); return listBy(sc); } + + @Override + public List listActive(long networkId) { + SearchCriteria sc = IdNetworkIdStatesSearch.create(); + sc.setParameters("network", networkId); + sc.setParameters("states", State.Running, State.Migrating, State.Stopping, State.Starting); + return listBy(sc); + } }