diff --git a/api/src/com/cloud/api/commands/ConfigureDhcpElementCmd.java b/api/src/com/cloud/api/commands/ConfigureDhcpElementCmd.java
deleted file mode 100644
index 6cf1ac402dd..00000000000
--- a/api/src/com/cloud/api/commands/ConfigureDhcpElementCmd.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/**
- * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
- *
- * This software is licensed under the GNU General Public License v3 or later.
- *
- * It is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-package com.cloud.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseAsyncCmd;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.PlugService;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.network.element.DhcpElementService;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(responseObject=SuccessResponse.class, description="Configures a dhcp element.")
-public class ConfigureDhcpElementCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(ConfigureDhcpElementCmd.class.getName());
- private static final String s_name = "configuredhcpelementresponse";
-
- @PlugService
- private DhcpElementService _service;
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the network service provider ID of the virtual router element")
- private Long nspId;
-
- @Parameter(name=ApiConstants.ENABLED, type=CommandType.BOOLEAN, required=true, description="Enabled/Disabled the service provider")
- private Boolean enabled;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public void setNspId(Long nspId) {
- this.nspId = nspId;
- }
-
- public Long getNspId() {
- return nspId;
- }
-
- public void setEnabled(Boolean enabled) {
- this.enabled = enabled;
- }
-
- public Boolean getEnabled() {
- return enabled;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- public static String getResultObjectName() {
- return "boolean";
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_NETWORK_ELEMENT_CONFIGURE;
- }
-
- @Override
- public String getEventDescription() {
- return "configuring dhcp element: " + _service.getIdByNspId(nspId);
- }
-
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.None;
- }
-
- public Long getInstanceId() {
- return _service.getIdByNspId(nspId);
- }
-
- @Override
- public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
- UserContext.current().setEventDetails("Dhcp element: " + _service.getIdByNspId(nspId));
- Boolean result = _service.configure(this);
- if (result){
- SuccessResponse response = new SuccessResponse();
- response.setResponseName(getCommandName());
- response.setSuccess(result);
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to configure the dhcp element");
- }
- }
-}
diff --git a/api/src/com/cloud/api/commands/CreateDhcpElementCmd.java b/api/src/com/cloud/api/commands/CreateDhcpElementCmd.java
deleted file mode 100644
index 9243b06fb71..00000000000
--- a/api/src/com/cloud/api/commands/CreateDhcpElementCmd.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/**
- * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
- *
- * This software is licensed under the GNU General Public License v3 or later.
- *
- * It is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-package com.cloud.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseAsyncCreateCmd;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.PlugService;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.network.VirtualRouterProvider;
-import com.cloud.network.element.DhcpElementService;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(responseObject=SuccessResponse.class, description="Create a dhcp element.")
-public class CreateDhcpElementCmd extends BaseAsyncCreateCmd {
- public static final Logger s_logger = Logger.getLogger(CreateDhcpElementCmd.class.getName());
- private static final String s_name = "createdhcpelementresponse";
-
- @PlugService
- private DhcpElementService _service;
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @Parameter(name=ApiConstants.NETWORK_SERVICE_PROVIDER_ID, type=CommandType.LONG, required=true, description="the network service provider ID of the dhcp element")
- private Long nspId;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public void setNspId(Long nspId) {
- this.nspId = nspId;
- }
-
- public Long getNspId() {
- return nspId;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- @Override
- public void execute(){
- UserContext.current().setEventDetails("DHCP element Id: "+getEntityId());
- VirtualRouterProvider result = _service.getCreatedElement(getEntityId());
- if (result != null) {
- SuccessResponse response = new SuccessResponse();
- response.setResponseName(getCommandName());
- response.setSuccess(true);
- this.setResponseObject(response);
- }else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add Virtual Router entity to physical network");
- }
- }
-
- @Override
- public void create() throws ResourceAllocationException {
- VirtualRouterProvider result = _service.addElement(getNspId());
- if (result != null) {
- setEntityId(result.getId());
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add Virtual Router entity to physical network");
- }
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_SERVICE_PROVIDER_CREATE;
- }
-
- @Override
- public String getEventDescription() {
- return "Adding physical network ServiceProvider Dhcp server: " + getEntityId();
- }
-}
diff --git a/api/src/com/cloud/network/Network.java b/api/src/com/cloud/network/Network.java
index a04918dc6ad..e362ac8ca09 100644
--- a/api/src/com/cloud/network/Network.java
+++ b/api/src/com/cloud/network/Network.java
@@ -113,7 +113,6 @@ public interface Network extends ControlledEntity {
public static final Provider VirtualRouter = new Provider("VirtualRouter", false);
- public static final Provider DhcpServer = new Provider("DhcpServer", false);
public static final Provider JuniperSRX = new Provider("JuniperSRX", true);
public static final Provider F5BigIp = new Provider("F5BigIp", true);
public static final Provider Netscaler = new Provider("Netscaler", true);
diff --git a/api/src/com/cloud/network/VirtualRouterProvider.java b/api/src/com/cloud/network/VirtualRouterProvider.java
index 96740ca602a..461b765746e 100644
--- a/api/src/com/cloud/network/VirtualRouterProvider.java
+++ b/api/src/com/cloud/network/VirtualRouterProvider.java
@@ -20,7 +20,6 @@ package com.cloud.network;
public interface VirtualRouterProvider {
public enum VirtualRouterProviderType {
- DhcpElement,
VirtualRouterElement,
RedundantVirtualRouterElement,
}
diff --git a/api/src/com/cloud/network/element/DhcpElementService.java b/api/src/com/cloud/network/element/DhcpElementService.java
deleted file mode 100644
index 0490b6a8507..00000000000
--- a/api/src/com/cloud/network/element/DhcpElementService.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.cloud.network.element;
-
-import com.cloud.api.commands.ConfigureDhcpElementCmd;
-import com.cloud.network.VirtualRouterProvider;
-import com.cloud.utils.component.PluggableService;
-
-public interface DhcpElementService extends PluggableService{
- boolean configure(ConfigureDhcpElementCmd cmd);
- VirtualRouterProvider addElement(Long nspId);
- Long getIdByNspId(Long nspId);
- VirtualRouterProvider getCreatedElement(long id);
-}
diff --git a/api/src/com/cloud/network/element/VirtualRouterElementService.java b/api/src/com/cloud/network/element/VirtualRouterElementService.java
index a5ca60335c0..9100d7493a8 100644
--- a/api/src/com/cloud/network/element/VirtualRouterElementService.java
+++ b/api/src/com/cloud/network/element/VirtualRouterElementService.java
@@ -1,7 +1,12 @@
package com.cloud.network.element;
import com.cloud.api.commands.ConfigureVirtualRouterElementCmd;
+import com.cloud.network.VirtualRouterProvider;
+import com.cloud.utils.component.PluggableService;
-public interface VirtualRouterElementService extends DhcpElementService {
+public interface VirtualRouterElementService extends PluggableService{
boolean configure(ConfigureVirtualRouterElementCmd cmd);
+ VirtualRouterProvider addElement(Long nspId);
+ Long getIdByNspId(Long nspId);
+ VirtualRouterProvider getCreatedElement(long id);
}
diff --git a/client/tomcatconf/components-premium.xml.in b/client/tomcatconf/components-premium.xml.in
index 1aa7352521f..9a69e09920c 100755
--- a/client/tomcatconf/components-premium.xml.in
+++ b/client/tomcatconf/components-premium.xml.in
@@ -25,7 +25,6 @@
-
diff --git a/client/tomcatconf/components.xml.in b/client/tomcatconf/components.xml.in
index 8a305f93d97..030c0b8d59e 100755
--- a/client/tomcatconf/components.xml.in
+++ b/client/tomcatconf/components.xml.in
@@ -95,7 +95,6 @@
-
@@ -107,7 +106,6 @@
-
diff --git a/client/tomcatconf/virtualrouter_commands.properties.in b/client/tomcatconf/virtualrouter_commands.properties.in
index e88194910b5..c906ab51b84 100644
--- a/client/tomcatconf/virtualrouter_commands.properties.in
+++ b/client/tomcatconf/virtualrouter_commands.properties.in
@@ -3,8 +3,6 @@
#### router commands
createVirtualRouterElement=com.cloud.api.commands.CreateVirtualRouterElementCmd;7
-createDhcpElement=com.cloud.api.commands.CreateDhcpElementCmd;7
createRedundantVirtualRouterElement=com.cloud.api.commands.CreateRedundantVirtualRouterElementCmd;7
-configureDhcpElement=com.cloud.api.commands.ConfigureDhcpElementCmd;7
configureVirtualRouterElement=com.cloud.api.commands.ConfigureVirtualRouterElementCmd;7
configureRedundantVirtualRouterElement=com.cloud.api.commands.ConfigureRedundantVirtualRouterElementCmd;7
diff --git a/server/src/com/cloud/configuration/DefaultComponentLibrary.java b/server/src/com/cloud/configuration/DefaultComponentLibrary.java
index 5ec3d822c3a..5aea73c3fdb 100755
--- a/server/src/com/cloud/configuration/DefaultComponentLibrary.java
+++ b/server/src/com/cloud/configuration/DefaultComponentLibrary.java
@@ -89,8 +89,6 @@ import com.cloud.network.dao.PhysicalNetworkTrafficTypeDaoImpl;
import com.cloud.network.dao.RemoteAccessVpnDaoImpl;
import com.cloud.network.dao.VirtualRouterProviderDaoImpl;
import com.cloud.network.dao.VpnUserDaoImpl;
-import com.cloud.network.element.DhcpElement;
-import com.cloud.network.element.DhcpElementService;
import com.cloud.network.element.RedundantVirtualRouterElement;
import com.cloud.network.element.RedundantVirtualRouterElementService;
import com.cloud.network.element.VirtualRouterElement;
@@ -390,7 +388,6 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com
}
protected void populateServices() {
- addService("DhcpElementService", DhcpElementService.class, DhcpElement.class);
addService("VirtualRouterElementService", VirtualRouterElementService.class, VirtualRouterElement.class);
addService("RedundantVirtualRouterElementService", RedundantVirtualRouterElementService.class, RedundantVirtualRouterElement.class);
}
diff --git a/server/src/com/cloud/dc/DataCenterVO.java b/server/src/com/cloud/dc/DataCenterVO.java
index 19b69193043..1e61de0a528 100644
--- a/server/src/com/cloud/dc/DataCenterVO.java
+++ b/server/src/com/cloud/dc/DataCenterVO.java
@@ -199,9 +199,9 @@ public class DataCenterVO implements DataCenter {
vpnProvider = Provider.VirtualRouter.getName();
userDataProvider = Provider.VirtualRouter.getName();
} else if (zoneType == NetworkType.Basic){
- dhcpProvider = Provider.DhcpServer.getName();
- dnsProvider = Provider.DhcpServer.getName();
- userDataProvider = Provider.DhcpServer.getName();
+ dhcpProvider = Provider.VirtualRouter.getName();
+ dnsProvider = Provider.VirtualRouter.getName();
+ userDataProvider = Provider.VirtualRouter.getName();
loadBalancerProvider = Provider.ElasticLoadBalancerVm.getName();
}
diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java
index 9836980c1ba..72b7980abde 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -854,7 +854,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
//populate providers
Map> defaultDirectNetworkOfferingProviders = new HashMap>();
Set defaultProviders = new HashSet();
- defaultProviders.add(Network.Provider.DhcpServer);
+ defaultProviders.add(Network.Provider.VirtualRouter);
defaultDirectNetworkOfferingProviders.put(Service.Dhcp, defaultProviders);
defaultDirectNetworkOfferingProviders.put(Service.Dns, defaultProviders);
defaultDirectNetworkOfferingProviders.put(Service.UserData, defaultProviders);
diff --git a/server/src/com/cloud/network/element/DhcpElement.java b/server/src/com/cloud/network/element/DhcpElement.java
deleted file mode 100644
index a066d664fa5..00000000000
--- a/server/src/com/cloud/network/element/DhcpElement.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/**
- * Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
- *
- * This software is licensed under the GNU General Public License v3 or later.
- *
- * It is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-package com.cloud.network.element;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.ejb.Local;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.commands.ConfigureDhcpElementCmd;
-import com.cloud.configuration.ConfigurationManager;
-import com.cloud.dc.DataCenter;
-import com.cloud.dc.DataCenter.NetworkType;
-import com.cloud.dc.dao.HostPodDao;
-import com.cloud.deploy.DeployDestination;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.host.dao.HostDao;
-import com.cloud.network.Network;
-import com.cloud.network.VirtualRouterProvider;
-import com.cloud.network.Network.Capability;
-import com.cloud.network.Network.GuestType;
-import com.cloud.network.Network.Provider;
-import com.cloud.network.Network.Service;
-import com.cloud.network.NetworkManager;
-import com.cloud.network.Networks.TrafficType;
-import com.cloud.network.PhysicalNetworkServiceProvider;
-import com.cloud.network.dao.NetworkDao;
-import com.cloud.network.dao.VirtualRouterProviderDao;
-import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
-import com.cloud.network.router.VirtualNetworkApplianceManager;
-import com.cloud.network.router.VirtualRouter;
-import com.cloud.network.router.VirtualRouter.Role;
-import com.cloud.offering.NetworkOffering;
-import com.cloud.user.AccountManager;
-import com.cloud.uservm.UserVm;
-import com.cloud.utils.component.AdapterBase;
-import com.cloud.utils.component.Inject;
-import com.cloud.vm.DomainRouterVO;
-import com.cloud.vm.NicProfile;
-import com.cloud.vm.ReservationContext;
-import com.cloud.vm.UserVmManager;
-import com.cloud.vm.VirtualMachine;
-import com.cloud.vm.VirtualMachine.State;
-import com.cloud.vm.VirtualMachineProfile;
-import com.cloud.vm.dao.DomainRouterDao;
-import com.cloud.vm.dao.UserVmDao;
-
-
-@Local(value=NetworkElement.class)
-public class DhcpElement extends AdapterBase implements DhcpElementService, UserDataServiceProvider {
- private static final Logger s_logger = Logger.getLogger(DhcpElement.class);
-
- private static final Map> capabilities = setCapabilities();
-
- @Inject NetworkDao _networkConfigDao;
- @Inject NetworkManager _networkMgr;
- @Inject VirtualNetworkApplianceManager _routerMgr;
- @Inject UserVmManager _userVmMgr;
- @Inject UserVmDao _userVmDao;
- @Inject DomainRouterDao _routerDao;
- @Inject ConfigurationManager _configMgr;
- @Inject HostPodDao _podDao;
- @Inject AccountManager _accountMgr;
- @Inject HostDao _hostDao;
- @Inject VirtualRouterProviderDao _vrProviderDao;
-
- private boolean canHandle(DeployDestination dest, TrafficType trafficType, GuestType networkType, long offeringId) {
- if (_networkMgr.isProviderSupported(offeringId, Service.Gateway, Provider.JuniperSRX) && networkType == Network.GuestType.Isolated) {
- return true;
- } else if (dest.getPod() != null && dest.getPod().getExternalDhcp()){
- //This pod is using external DHCP server
- return false;
- } else {
- return (networkType == Network.GuestType.Shared);
- }
- }
-
- @Override
- public boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException {
- if (!canHandle(dest, offering.getTrafficType(), network.getGuestType(), network.getNetworkOfferingId())) {
- return false;
- }
-
- Map params = new HashMap(1);
- params.put(VirtualMachineProfile.Param.ReProgramNetwork, true);
- _routerMgr.deployDhcp(network, dest, _accountMgr.getAccount(network.getAccountId()), params);
- return true;
- }
-
- @Override
- public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
- if (canHandle(dest, network.getTrafficType(), network.getGuestType(), network.getNetworkOfferingId())) {
-
- if (vm.getType() != VirtualMachine.Type.User) {
- return false;
- }
-
- @SuppressWarnings("unchecked")
- VirtualMachineProfile uservm = (VirtualMachineProfile)vm;
- Map params = new HashMap(1);
- params.put(VirtualMachineProfile.Param.ReProgramNetwork, true);
-
- List routers = _routerMgr.deployDhcp(network, dest, _accountMgr.getAccount(network.getAccountId()), uservm.getParameters());
-
- //for Basic zone, add all Running routers - we have to send Dhcp/vmData/password info to them when network.dns.basiczone.updates is set to "all"
- Long podId = dest.getPod().getId();
- DataCenter dc = dest.getDataCenter();
- boolean isPodBased = (dc.getNetworkType() == NetworkType.Basic || _networkMgr.isSecurityGroupSupportedInNetwork(network)) && network.getTrafficType() == TrafficType.Guest;
- if (isPodBased && _routerMgr.getDnsBasicZoneUpdate().equalsIgnoreCase("all")) {
- List allRunningRoutersOutsideThePod = _routerDao.findByNetworkOutsideThePod(network.getId(), podId, State.Running, Role.DHCP_USERDATA);
- routers.addAll(allRunningRoutersOutsideThePod);
- }
-
- List rets = _routerMgr.addVirtualMachineIntoNetwork(network, nic, uservm, dest, context, routers);
- return (rets != null) && (!rets.isEmpty());
- } else {
- return false;
- }
- }
-
- @Override
- public boolean release(Network network, NicProfile nic, VirtualMachineProfile extends VirtualMachine> vm, ReservationContext context) {
- return true;
- }
-
- @Override
- public boolean shutdown(Network network, ReservationContext context, boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException {
- List routers = _routerDao.listByNetworkAndRole(network.getId(), Role.DHCP_USERDATA);
- if (routers == null || routers.isEmpty()) {
- return true;
- }
- boolean result = true;
- for (DomainRouterVO router : routers) {
- result = result && _routerMgr.stop(router, false, context.getCaller(), context.getAccount()) != null;
- }
- return result;
- }
-
- @Override
- public boolean destroy(Network config) throws ConcurrentOperationException, ResourceUnavailableException{
- List routers = _routerDao.listByNetworkAndRole(config.getId(), Role.DHCP_USERDATA);
- if (routers == null || routers.isEmpty()) {
- return true;
- }
- boolean result = true;
- for (DomainRouterVO router : routers) {
- result = result && (_routerMgr.destroyRouter(router.getId()) != null);
- }
- return result;
- }
-
- @Override
- public Provider getProvider() {
- return Provider.DhcpServer;
- }
-
- @Override
- public Map> getCapabilities() {
- return capabilities;
- }
-
- private static Map> setCapabilities() {
- Map> capabilities = new HashMap>();
-
- Map dnsCapabilities = new HashMap();
- dnsCapabilities.put(Capability.AllowDnsSuffixModification, "true");
- capabilities.put(Service.Dns, dnsCapabilities);
-
- capabilities.put(Service.UserData, null);
- capabilities.put(Service.Dhcp, null);
-
- return capabilities;
- }
-
- @Override
- public boolean savePassword(Network network, NicProfile nic, VirtualMachineProfile extends VirtualMachine> vm) throws ResourceUnavailableException{
-
- List routers = _routerDao.listByNetworkAndRole(network.getId(), Role.DHCP_USERDATA);
- if (routers == null || routers.isEmpty()) {
- s_logger.trace("Can't find dhcp element in network " + network.getId());
- return true;
- }
-
- @SuppressWarnings("unchecked")
- VirtualMachineProfile uservm = (VirtualMachineProfile)vm;
-
- return _routerMgr.savePasswordToRouter(network, nic, uservm, routers);
- }
-
- @Override
- public String getPropertiesFile() {
- return "virtualrouter_commands.properties";
- }
-
- @Override
- public boolean configure(ConfigureDhcpElementCmd cmd) {
- VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(cmd.getNspId(), VirtualRouterProviderType.DhcpElement);
- if (element == null) {
- s_logger.trace("Can't find element with network service provider ID " + cmd.getNspId());
- return false;
- }
- element.setEnabled(cmd.getEnabled());
-
- _vrProviderDao.persist(element);
-
- return true;
- }
-
- @Override
- public VirtualRouterProvider addElement(Long nspId) {
- long serviceOfferingId = _routerMgr.getDefaultVirtualRouterServiceOfferingId();
- if (serviceOfferingId == 0) {
- return null;
- }
- VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(nspId, VirtualRouterProviderType.DhcpElement);
- if (element != null) {
- s_logger.trace("There is already a dhcp element with service provider id " + nspId);
- return null;
- }
- element = new VirtualRouterProviderVO(nspId, null, VirtualRouterProviderType.DhcpElement);
- _vrProviderDao.persist(element);
- return element;
- }
-
- @Override
- public Long getIdByNspId(Long nspId) {
- VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(nspId, VirtualRouterProviderType.DhcpElement);
- return element.getId();
- }
-
- @Override
- public boolean isReady(PhysicalNetworkServiceProvider provider) {
- VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(provider.getId(), VirtualRouterProviderType.DhcpElement);
- if (element == null) {
- return false;
- }
- return element.isEnabled();
- }
-
- @Override
- public VirtualRouterProvider getCreatedElement(long id) {
- return _vrProviderDao.findById(id);
- }
-
- @Override
- public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context, boolean forceShutdown) throws ConcurrentOperationException,
- ResourceUnavailableException {
- VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(provider.getId(), VirtualRouterProviderType.DhcpElement);
- if (element == null) {
- return true;
- }
- //Find domain routers
- long elementId = element.getId();
- List routers = _routerDao.listByElementId(elementId);
- boolean result = true;
- for (DomainRouterVO router : routers) {
- if (forceShutdown) {
- result = result && (_routerMgr.stopRouter(router.getId(), true) != null);
- }
- result = result && (_routerMgr.destroyRouter(router.getId()) != null);
- }
- return result;
- }
-
- @Override
- public boolean canEnableIndividualServices() {
- return false;
- }
-}
diff --git a/server/src/com/cloud/network/element/RedundantVirtualRouterElement.java b/server/src/com/cloud/network/element/RedundantVirtualRouterElement.java
index 498b801131d..e244c12011f 100644
--- a/server/src/com/cloud/network/element/RedundantVirtualRouterElement.java
+++ b/server/src/com/cloud/network/element/RedundantVirtualRouterElement.java
@@ -50,6 +50,7 @@ public class RedundantVirtualRouterElement extends VirtualRouterElement implemen
}
Map params = new HashMap(1);
+ params.put(VirtualMachineProfile.Param.ReProgramNetwork, true);
_routerMgr.deployVirtualRouter(guestConfig, dest, _accountMgr.getAccount(guestConfig.getAccountId()), params, true);
diff --git a/server/src/com/cloud/network/element/VirtualRouterElement.java b/server/src/com/cloud/network/element/VirtualRouterElement.java
index 0308f1df829..f213be1321c 100644
--- a/server/src/com/cloud/network/element/VirtualRouterElement.java
+++ b/server/src/com/cloud/network/element/VirtualRouterElement.java
@@ -22,12 +22,15 @@ import java.util.List;
import java.util.Map;
import javax.ejb.Local;
+import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import com.cloud.api.commands.ConfigureVirtualRouterElementCmd;
import com.cloud.configuration.ConfigurationManager;
import com.cloud.configuration.dao.ConfigurationDao;
+import com.cloud.dc.DataCenter;
+import com.cloud.dc.DataCenter.NetworkType;
import com.cloud.deploy.DeployDestination;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
@@ -38,6 +41,7 @@ import com.cloud.network.Network.Capability;
import com.cloud.network.Network.GuestType;
import com.cloud.network.Network.Provider;
import com.cloud.network.Network.Service;
+import com.cloud.network.Networks.TrafficType;
import com.cloud.network.NetworkManager;
import com.cloud.network.PhysicalNetworkServiceProvider;
import com.cloud.network.PublicIpAddress;
@@ -59,7 +63,9 @@ import com.cloud.network.rules.RulesManager;
import com.cloud.network.rules.StaticNat;
import com.cloud.offering.NetworkOffering;
import com.cloud.offerings.dao.NetworkOfferingDao;
+import com.cloud.user.AccountManager;
import com.cloud.uservm.UserVm;
+import com.cloud.utils.component.AdapterBase;
import com.cloud.utils.component.Inject;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.DomainRouterVO;
@@ -68,12 +74,13 @@ import com.cloud.vm.ReservationContext;
import com.cloud.vm.UserVmManager;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineProfile;
+import com.cloud.vm.VirtualMachine.State;
import com.cloud.vm.dao.DomainRouterDao;
import com.cloud.vm.dao.UserVmDao;
@Local(value=NetworkElement.class)
-public class VirtualRouterElement extends DhcpElement implements VirtualRouterElementService, SourceNatServiceProvider, StaticNatServiceProvider, FirewallServiceProvider, LoadBalancingServiceProvider, PortForwardingServiceProvider, RemoteAccessVPNServiceProvider {
+public class VirtualRouterElement extends AdapterBase implements VirtualRouterElementService, UserDataServiceProvider, SourceNatServiceProvider, StaticNatServiceProvider, FirewallServiceProvider, LoadBalancingServiceProvider, PortForwardingServiceProvider, RemoteAccessVPNServiceProvider {
private static final Logger s_logger = Logger.getLogger(VirtualRouterElement.class);
private static final Map> capabilities = setCapabilities();
@@ -90,11 +97,17 @@ public class VirtualRouterElement extends DhcpElement implements VirtualRouterEl
@Inject DomainRouterDao _routerDao;
@Inject LoadBalancerDao _lbDao;
@Inject HostDao _hostDao;
+ @Inject AccountManager _accountMgr;
@Inject ConfigurationDao _configDao;
@Inject VirtualRouterProviderDao _vrProviderDao;
protected boolean canHandle(GuestType networkType, long offeringId, Service service) {
- boolean result = (networkType == Network.GuestType.Isolated && _networkMgr.isProviderSupported(offeringId, service, getProvider()));
+ boolean result = false;
+
+ if (_networkMgr.isProviderSupported(offeringId, service, getProvider())) {
+ result = true;
+ }
+
if (!result) {
s_logger.trace("Virtual router element only takes care of type " + Network.GuestType.Isolated + " for provider " + getProvider().getName());
}
@@ -108,6 +121,7 @@ public class VirtualRouterElement extends DhcpElement implements VirtualRouterEl
}
Map params = new HashMap(1);
+ params.put(VirtualMachineProfile.Param.ReProgramNetwork, true);
_routerMgr.deployVirtualRouter(guestConfig, dest, _accountMgr.getAccount(guestConfig.getAccountId()), params, false);
@@ -117,7 +131,7 @@ public class VirtualRouterElement extends DhcpElement implements VirtualRouterEl
@Override
public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
- if (canHandle(network.getGuestType(), network.getNetworkOfferingId(), Service.Gateway)) {
+ if (canHandle(network.getGuestType(), network.getNetworkOfferingId(), Service.Dhcp)) {
if (vm.getType() != VirtualMachine.Type.User) {
return false;
}
@@ -128,6 +142,16 @@ public class VirtualRouterElement extends DhcpElement implements VirtualRouterEl
if ((routers == null) || (routers.size() == 0)) {
throw new ResourceUnavailableException("Can't find at least one running router!", this.getClass(), 0);
}
+
+ //for Basic zone, add all Running routers - we have to send Dhcp/vmData/password info to them when network.dns.basiczone.updates is set to "all"
+ Long podId = dest.getPod().getId();
+ DataCenter dc = dest.getDataCenter();
+ boolean isPodBased = (dc.getNetworkType() == NetworkType.Basic || _networkMgr.isSecurityGroupSupportedInNetwork(network)) && network.getTrafficType() == TrafficType.Guest;
+ if (isPodBased && _routerMgr.getDnsBasicZoneUpdate().equalsIgnoreCase("all")) {
+ List allRunningRoutersOutsideThePod = _routerDao.findByNetworkOutsideThePod(network.getId(), podId, State.Running, Role.DHCP_USERDATA);
+ routers.addAll(allRunningRoutersOutsideThePod);
+ }
+
List rets = _routerMgr.addVirtualMachineIntoNetwork(network, nic, uservm, dest, context, routers);
return (rets != null) && (!rets.isEmpty());
} else {
@@ -444,4 +468,15 @@ public class VirtualRouterElement extends DhcpElement implements VirtualRouterEl
VirtualRouterProviderVO vr = _vrProviderDao.findByNspIdAndType(nspId, VirtualRouterProviderType.VirtualRouterElement);
return vr.getId();
}
+
+ @Override
+ public VirtualRouterProvider getCreatedElement(long id) {
+ return _vrProviderDao.findById(id);
+ }
+
+ @Override
+ public boolean release(Network network, NicProfile nic, VirtualMachineProfile extends VirtualMachine> vm, ReservationContext context) throws ConcurrentOperationException,
+ ResourceUnavailableException {
+ return true;
+ }
}
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java
index f72c88779d0..ce18d80fb37 100644
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java
@@ -70,7 +70,7 @@ public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkA
List deployVirtualRouter(Network guestNetwork, DeployDestination dest, Account owner, Map params, boolean isRedundant) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException;
- List deployDhcp(Network guestNetwork, DeployDestination dest, Account owner, Map params) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException;
+ //List deployDhcp(Network guestNetwork, DeployDestination dest, Account owner, Map params) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException;
List addVirtualMachineIntoNetwork(Network config, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context, List routers) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException;
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index d33ab633f33..c2288ffb1dd 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -1031,8 +1031,28 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
long dcId = dest.getDataCenter().getId();
DataCenterDeployment plan = new DataCenterDeployment(dcId);
-
- List routers = _routerDao.listByNetworkAndRole(guestNetwork.getId(), Role.DHCP_FIREWALL_LB_PASSWD_USERDATA);
+ boolean isPodBased = (dest.getDataCenter().getNetworkType() == NetworkType.Basic || _networkMgr.isServiceSupportedByNetworkOffering(guestNetwork.getNetworkOfferingId(), Service.SecurityGroup)) && guestNetwork.getTrafficType() == TrafficType.Guest;
+ boolean publicNetwork = false;
+ if (_networkMgr.isServiceSupportedByNetworkOffering(guestNetwork.getNetworkOfferingId(), Service.SourceNat)) {
+ publicNetwork = true;
+ }
+ if (isRedundant && !publicNetwork) {
+ s_logger.error("Didn't support redundant virtual router without public network!");
+ return null;
+ }
+ List routers;
+ if (publicNetwork) {
+ routers = _routerDao.listByNetworkAndRole(guestNetwork.getId(), Role.DHCP_FIREWALL_LB_PASSWD_USERDATA);
+ } else {
+ Long podId = dest.getPod().getId();
+ if (isPodBased) {
+ routers = _routerDao.listByNetworkAndPodAndRole(guestNetwork.getId(), podId, Role.DHCP_USERDATA);
+ plan = new DataCenterDeployment(dcId, podId, null, null, null, null);
+ } else {
+ routers = _routerDao.listByNetworkAndRole(guestNetwork.getId(), Role.DHCP_USERDATA);
+ plan = new DataCenterDeployment(dcId);
+ }
+ }
try {
int routerCount = 1;
@@ -1058,7 +1078,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
NicProfile defaultNic = new NicProfile();
//if source nat service is supported by the network, get the source nat ip address
- if (_networkMgr.isServiceSupportedByNetworkOffering(guestNetwork.getNetworkOfferingId(), Service.SourceNat)) {
+ if (publicNetwork) {
PublicIp sourceNatIp = _networkMgr.assignSourceNatIpAddress(owner, guestNetwork, _accountService.getSystemUser().getId());
defaultNic.setDefaultNic(true);
defaultNic.setIp4Address(sourceNatIp.getAddress().addr());
@@ -1086,21 +1106,38 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false, false).get(0);
List> networks = new ArrayList>(3);
- NetworkOfferingVO publicOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemPublicNetwork).get(0);
- List publicNetworks = _networkMgr.setupNetwork(_systemAcct, publicOffering, plan, null, null, false, false);
- networks.add(new Pair(publicNetworks.get(0), defaultNic));
- NicProfile gatewayNic = new NicProfile();
- if (isRedundant) {
- gatewayNic.setIp4Address(_networkMgr.acquireGuestIpAddress(guestNetwork, null));
- } else {
- gatewayNic.setIp4Address(guestNetwork.getGateway());
+ if (publicNetwork) {
+ NetworkOfferingVO publicOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemPublicNetwork).get(0);
+ List publicNetworks = _networkMgr.setupNetwork(_systemAcct, publicOffering, plan, null, null, false, false);
+ networks.add(new Pair(publicNetworks.get(0), defaultNic));
+ }
+
+ String defaultNetworkStartIp = null;
+ if (guestNetwork.getCidr() != null && !publicNetwork) {
+ String startIp = _networkMgr.getStartIpAddress(guestNetwork.getId());
+ if (startIp != null && _ipAddressDao.findByIpAndSourceNetworkId(guestNetwork.getId(), startIp).getAllocatedTime() == null) {
+ defaultNetworkStartIp = startIp;
+ } else if (s_logger.isDebugEnabled()){
+ s_logger.debug("First ip " + startIp + " in network id=" + guestNetwork.getId() + " is already allocated, can't use it for domain router; will get random ip address from the range");
+ }
+ }
+
+ NicProfile gatewayNic = new NicProfile(defaultNetworkStartIp);
+ if (publicNetwork) {
+ if (isRedundant) {
+ gatewayNic.setIp4Address(_networkMgr.acquireGuestIpAddress(guestNetwork, null));
+ } else {
+ gatewayNic.setIp4Address(guestNetwork.getGateway());
+ }
+ gatewayNic.setBroadcastUri(guestNetwork.getBroadcastUri());
+ gatewayNic.setBroadcastType(guestNetwork.getBroadcastDomainType());
+ gatewayNic.setIsolationUri(guestNetwork.getBroadcastUri());
+ gatewayNic.setMode(guestNetwork.getMode());
+ String gatewayCidr = guestNetwork.getCidr();
+ gatewayNic.setNetmask(NetUtils.getCidrNetmask(gatewayCidr));
+ } else {
+ gatewayNic.setDefaultNic(true);
}
- gatewayNic.setBroadcastUri(guestNetwork.getBroadcastUri());
- gatewayNic.setBroadcastType(guestNetwork.getBroadcastDomainType());
- gatewayNic.setIsolationUri(guestNetwork.getBroadcastUri());
- gatewayNic.setMode(guestNetwork.getMode());
- String gatewayCidr = guestNetwork.getCidr();
- gatewayNic.setNetmask(NetUtils.getCidrNetmask(gatewayCidr));
networks.add(new Pair((NetworkVO) guestNetwork, gatewayNic));
networks.add(new Pair(controlConfig, null));
@@ -1135,6 +1172,9 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
router = new DomainRouterVO(id, routerOffering.getId(), vrProvider.getId(), VirtualMachineName.getRouterName(id, _instance), template.getId(), template.getHypervisorType(),
template.getGuestOSId(), owner.getDomainId(), owner.getId(), guestNetwork.getId(), isRedundant, 0, false, RedundantState.UNKNOWN, routerOffering.getOfferHA(), false);
+ if (!publicNetwork) {
+ router.setRole(Role.DHCP_USERDATA);
+ }
router = _itMgr.allocate(router, template, routerOffering, networks, plan, null, owner);
break;
} catch (InsufficientCapacityException ex) {
@@ -1236,6 +1276,11 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
@Override
public List deployVirtualRouter(Network guestNetwork, DeployDestination dest, Account owner, Map params, boolean isRedundant) throws InsufficientCapacityException,
ConcurrentOperationException, ResourceUnavailableException {
+ NetworkOffering offering = _networkOfferingDao.findByIdIncludingRemoved(guestNetwork.getNetworkOfferingId());
+ if (offering.isSystemOnly() || guestNetwork.getGuestType() == Network.GuestType.Shared) {
+ owner = _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM);
+ }
+
if (s_logger.isDebugEnabled()) {
s_logger.debug("Starting a router for " + guestNetwork + " in " + dest);
}
@@ -1272,6 +1317,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
return runningRouters;
}
+ /*
List findOrCreateDhcpServers(Network guestNetwork, DeployDestination dest, Account owner) throws ConcurrentOperationException, InsufficientCapacityException {
Network network = _networkDao.acquireInLockTable(guestNetwork.getId());
if (network == null) {
@@ -1340,7 +1386,6 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
for (HypervisorType hType : supportedHypervisors) {
try {
s_logger.debug("Allocating the domR with the hypervisor type " + hType);
- /* Before starting router, already know the hypervisor type */
VMTemplateVO template = _templateDao.findRoutingTemplate(hType);
//physical network id can be null in Guest Network in Basic zone, so locate the physical network
@@ -1421,6 +1466,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
return runningRouters;
}
+ */
@Override
public boolean finalizeVirtualMachineProfile(VirtualMachineProfile profile, DeployDestination dest, ReservationContext context) {
diff --git a/server/src/com/cloud/server/ConfigurationServerImpl.java b/server/src/com/cloud/server/ConfigurationServerImpl.java
index 50ee240fdfc..9d4d8228673 100644
--- a/server/src/com/cloud/server/ConfigurationServerImpl.java
+++ b/server/src/com/cloud/server/ConfigurationServerImpl.java
@@ -834,14 +834,14 @@ public class ConfigurationServerImpl implements ConfigurationServer {
//populate providers
Map defaultSharedNetworkOfferingProviders = new HashMap();
- defaultSharedNetworkOfferingProviders.put(Service.Dhcp, Provider.DhcpServer);
- defaultSharedNetworkOfferingProviders.put(Service.Dns, Provider.DhcpServer);
- defaultSharedNetworkOfferingProviders.put(Service.UserData, Provider.DhcpServer);
+ defaultSharedNetworkOfferingProviders.put(Service.Dhcp, Provider.VirtualRouter);
+ defaultSharedNetworkOfferingProviders.put(Service.Dns, Provider.VirtualRouter);
+ defaultSharedNetworkOfferingProviders.put(Service.UserData, Provider.VirtualRouter);
Map defaultSharedSGNetworkOfferingProviders = new HashMap();
- defaultSharedSGNetworkOfferingProviders.put(Service.Dhcp, Provider.DhcpServer);
- defaultSharedSGNetworkOfferingProviders.put(Service.Dns, Provider.DhcpServer);
- defaultSharedSGNetworkOfferingProviders.put(Service.UserData, Provider.DhcpServer);
+ defaultSharedSGNetworkOfferingProviders.put(Service.Dhcp, Provider.VirtualRouter);
+ defaultSharedSGNetworkOfferingProviders.put(Service.Dns, Provider.VirtualRouter);
+ defaultSharedSGNetworkOfferingProviders.put(Service.UserData, Provider.VirtualRouter);
defaultSharedSGNetworkOfferingProviders.put(Service.SecurityGroup, Provider.SecurityGroupProvider);
Map defaultIsolatedNetworkOfferingProviders = new HashMap();