diff --git a/api/src/com/cloud/api/commands/ConfigureRedundantVirtualRouterElementCmd.java b/api/src/com/cloud/api/commands/ConfigureRedundantVirtualRouterElementCmd.java deleted file mode 100644 index e383fbcaf69..00000000000 --- a/api/src/com/cloud/api/commands/ConfigureRedundantVirtualRouterElementCmd.java +++ /dev/null @@ -1,128 +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.network.element.RedundantVirtualRouterElementService; -import com.cloud.async.AsyncJob; -import com.cloud.event.EventTypes; -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 redundant virtual router element.") -public class ConfigureRedundantVirtualRouterElementCmd extends BaseAsyncCmd { - public static final Logger s_logger = Logger.getLogger(ConfigureRedundantVirtualRouterElementCmd.class.getName()); - private static final String s_name = "configureredundantvirtualrouterelementresponse"; - - @PlugService - private RedundantVirtualRouterElementService _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 redundant virtual router element: " + _service.getIdByNspId(nspId); - } - - public AsyncJob.Type getInstanceType() { - return AsyncJob.Type.None; - } - - public Long getInstanceId() { - return _service.getIdByNspId(getNspId()); - } - - @Override - public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{ - UserContext.current().setEventDetails("Redundant virtual router 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 redundant virtual router element"); - } - } -} diff --git a/api/src/com/cloud/api/commands/CreateRedundantVirtualRouterElementCmd.java b/api/src/com/cloud/api/commands/CreateRedundantVirtualRouterElementCmd.java deleted file mode 100644 index 22771304d41..00000000000 --- a/api/src/com/cloud/api/commands/CreateRedundantVirtualRouterElementCmd.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.RedundantVirtualRouterElementService; -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 redundant virtual router element.") -public class CreateRedundantVirtualRouterElementCmd extends BaseAsyncCreateCmd { - public static final Logger s_logger = Logger.getLogger(CreateVirtualRouterElementCmd.class.getName()); - private static final String s_name = "createredundantvirtualrouterelementresponse"; - - @PlugService - private RedundantVirtualRouterElementService _service; - - ///////////////////////////////////////////////////// - //////////////// API parameters ///////////////////// - ///////////////////////////////////////////////////// - - @Parameter(name=ApiConstants.NETWORK_SERVICE_PROVIDER_ID, type=CommandType.LONG, required=true, description="the network service provider ID of the redundant virtual router 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("Redundant Virtual Router 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 redundant virtual router: " + getEntityId(); - } -} diff --git a/api/src/com/cloud/network/element/RedundantVirtualRouterElementService.java b/api/src/com/cloud/network/element/RedundantVirtualRouterElementService.java deleted file mode 100644 index 1b4d8a2cf66..00000000000 --- a/api/src/com/cloud/network/element/RedundantVirtualRouterElementService.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.cloud.network.element; - -import com.cloud.api.commands.ConfigureRedundantVirtualRouterElementCmd; - -public interface RedundantVirtualRouterElementService extends VirtualRouterElementService { - boolean configure(ConfigureRedundantVirtualRouterElementCmd cmd); -} diff --git a/client/tomcatconf/components-premium.xml.in b/client/tomcatconf/components-premium.xml.in index 9a69e09920c..5c5be12fbf2 100755 --- a/client/tomcatconf/components-premium.xml.in +++ b/client/tomcatconf/components-premium.xml.in @@ -24,7 +24,6 @@ - diff --git a/client/tomcatconf/components.xml.in b/client/tomcatconf/components.xml.in index 030c0b8d59e..7ff731ec25c 100755 --- a/client/tomcatconf/components.xml.in +++ b/client/tomcatconf/components.xml.in @@ -107,7 +107,6 @@ - diff --git a/client/tomcatconf/virtualrouter_commands.properties.in b/client/tomcatconf/virtualrouter_commands.properties.in index c906ab51b84..6e46872ab2e 100644 --- a/client/tomcatconf/virtualrouter_commands.properties.in +++ b/client/tomcatconf/virtualrouter_commands.properties.in @@ -3,6 +3,4 @@ #### router commands createVirtualRouterElement=com.cloud.api.commands.CreateVirtualRouterElementCmd;7 -createRedundantVirtualRouterElement=com.cloud.api.commands.CreateRedundantVirtualRouterElementCmd;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 6a5b4106d85..2f88819a2c4 100755 --- a/server/src/com/cloud/configuration/DefaultComponentLibrary.java +++ b/server/src/com/cloud/configuration/DefaultComponentLibrary.java @@ -90,8 +90,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.RedundantVirtualRouterElement; -import com.cloud.network.element.RedundantVirtualRouterElementService; import com.cloud.network.element.VirtualRouterElement; import com.cloud.network.element.VirtualRouterElementService; import com.cloud.network.firewall.FirewallManagerImpl; @@ -391,7 +389,6 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com protected void populateServices() { addService("VirtualRouterElementService", VirtualRouterElementService.class, VirtualRouterElement.class); - addService("RedundantVirtualRouterElementService", RedundantVirtualRouterElementService.class, RedundantVirtualRouterElement.class); } @Override diff --git a/server/src/com/cloud/network/element/RedundantVirtualRouterElement.java b/server/src/com/cloud/network/element/RedundantVirtualRouterElement.java deleted file mode 100644 index 4fd6c3575df..00000000000 --- a/server/src/com/cloud/network/element/RedundantVirtualRouterElement.java +++ /dev/null @@ -1,149 +0,0 @@ -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.ConfigureRedundantVirtualRouterElementCmd; -import com.cloud.deploy.DeployDestination; -import com.cloud.exception.ConcurrentOperationException; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.ResourceUnavailableException; -import com.cloud.network.Network; -import com.cloud.network.Network.Provider; -import com.cloud.network.Network.Service; -import com.cloud.network.NetworkManager; -import com.cloud.network.PhysicalNetworkServiceProvider; -import com.cloud.network.VirtualRouterProvider; -import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType; -import com.cloud.network.dao.VirtualRouterProviderDao; -import com.cloud.network.router.VirtualRouter; -import com.cloud.offering.NetworkOffering; -import com.cloud.offerings.NetworkOfferingVO; -import com.cloud.uservm.UserVm; -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.VirtualMachine; -import com.cloud.vm.VirtualMachineProfile; - -@Local(value=NetworkElement.class) -public class RedundantVirtualRouterElement extends VirtualRouterElement implements RedundantVirtualRouterElementService { - private static final Logger s_logger = Logger.getLogger(RedundantVirtualRouterElement.class); - - @Inject NetworkManager _networkMgr; - @Inject VirtualRouterProviderDao _vrElementsDao; - - @Override - public Provider getProvider() { - return Provider.RedundantVirtualRouter; - } - - @Override - public boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException { - if (offering.isSystemOnly()) { - return false; - } - if (!_networkMgr.isProviderAvailable(_networkMgr.getPhysicalNetworkId(network), "RedundantVirtualRouter")) { - return false; - } - - Map params = new HashMap(1); - params.put(VirtualMachineProfile.Param.ReProgramNetwork, true); - - _routerMgr.deployVirtualRouter(network, dest, _accountMgr.getAccount(network.getAccountId()), params, getProvider()); - - return true; - } - - - @Override - public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException { - NetworkOfferingVO offering = _networkOfferingDao.findById(network.getNetworkOfferingId()); - if (offering.isSystemOnly()) { - return false; - } - if (!_networkMgr.isProviderAvailable(_networkMgr.getPhysicalNetworkId(network), "RedundantVirtualRouter")) { - return false; - } - - if (vm.getType() != VirtualMachine.Type.User) { - return false; - } - - @SuppressWarnings("unchecked") - VirtualMachineProfile uservm = (VirtualMachineProfile)vm; - List routers = _routerMgr.deployVirtualRouter(network, dest, _accountMgr.getAccount(network.getAccountId()), uservm.getParameters(), getProvider()); - if ((routers == null) || (routers.size() == 0)) { - throw new ResourceUnavailableException("Can't find at least one running router!", this.getClass(), 0); - } - return true; - } - - @Override - public String getPropertiesFile() { - return "virtualrouter_commands.properties"; - } - - @Override - public boolean configure(ConfigureRedundantVirtualRouterElementCmd cmd) { - VirtualRouterProviderVO element = _vrElementsDao.findByNspIdAndType(cmd.getNspId(), VirtualRouterProviderType.RedundantVirtualRouter); - if (element == null) { - s_logger.trace("Can't find element with UUID " + cmd.getNspId()); - return false; - } - element.setEnabled(cmd.getEnabled()); - _vrElementsDao.persist(element); - - return true; - } - - @Override - public VirtualRouterProvider addElement(Long nspId) { - VirtualRouterProviderVO element = _vrElementsDao.findByNspIdAndType(nspId, VirtualRouterProviderType.RedundantVirtualRouter); - if (element != null) { - s_logger.trace("There is already a redundant virtual router element with service provider id " + nspId); - return null; - } - element = new VirtualRouterProviderVO(nspId, null, VirtualRouterProviderType.RedundantVirtualRouter); - _vrElementsDao.persist(element); - return element; - } - - @Override - public boolean isReady(PhysicalNetworkServiceProvider provider) { - VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(provider.getId(), VirtualRouterProviderType.RedundantVirtualRouter); - if (element == null) { - return false; - } - return element.isEnabled(); - } - - @Override - public Long getIdByNspId(Long nspId) { - VirtualRouterProviderVO vr = _vrElementsDao.findByNspIdAndType(nspId, VirtualRouterProviderType.RedundantVirtualRouter); - return vr.getId(); - } - - @Override - public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException, - ResourceUnavailableException { - VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(provider.getId(), VirtualRouterProviderType.RedundantVirtualRouter); - if (element == null) { - return true; - } - //Find domain routers - long elementId = element.getId(); - List routers = _routerDao.listByElementId(elementId); - boolean result = true; - for (DomainRouterVO router : routers) { - result = result && (_routerMgr.destroyRouter(router.getId()) != null); - } - return result; - } -} diff --git a/server/src/com/cloud/network/element/VirtualRouterElement.java b/server/src/com/cloud/network/element/VirtualRouterElement.java index dd3f83b890c..c89ee5329bf 100644 --- a/server/src/com/cloud/network/element/VirtualRouterElement.java +++ b/server/src/com/cloud/network/element/VirtualRouterElement.java @@ -125,7 +125,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl Map params = new HashMap(1); params.put(VirtualMachineProfile.Param.ReProgramNetwork, true); - _routerMgr.deployVirtualRouter(network, dest, _accountMgr.getAccount(network.getAccountId()), params, getProvider()); + _routerMgr.deployVirtualRouter(network, dest, _accountMgr.getAccount(network.getAccountId()), params, false); return true; } @@ -147,7 +147,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl @SuppressWarnings("unchecked") VirtualMachineProfile uservm = (VirtualMachineProfile)vm; - List routers = _routerMgr.deployVirtualRouter(network, dest, _accountMgr.getAccount(network.getAccountId()), uservm.getParameters(), getProvider()); + List routers = _routerMgr.deployVirtualRouter(network, dest, _accountMgr.getAccount(network.getAccountId()), uservm.getParameters(), false); if ((routers == null) || (routers.size() == 0)) { throw new ResourceUnavailableException("Can't find at least one running router!", this.getClass(), 0); } diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java index 3c5f279c389..875b79b497f 100644 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java @@ -69,7 +69,7 @@ public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkA List getRouters(long accountId, long zoneId); - List deployVirtualRouter(Network guestNetwork, DeployDestination dest, Account owner, Map params, Provider provider) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException; + List deployVirtualRouter(Network guestNetwork, DeployDestination dest, Account owner, Map params, boolean isRedundant) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException; List applyDhcpEntry(Network config, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context, List routers) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException; List applyUserData(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 60823140203..1ec13b9e706 100755 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -1275,7 +1275,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian } @Override - public List deployVirtualRouter(Network guestNetwork, DeployDestination dest, Account owner, Map params, Provider provider) throws InsufficientCapacityException, + public List deployVirtualRouter(Network guestNetwork, DeployDestination dest, Account owner, Map params, boolean isRedundant) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException { if (_networkMgr.isNetworkSystem(guestNetwork) || guestNetwork.getGuestType() == Network.GuestType.Shared) { owner = _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM); @@ -1289,7 +1289,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian + guestNetwork; assert guestNetwork.getTrafficType() == TrafficType.Guest; - List routers = findOrCreateVirtualRouters(guestNetwork, dest, owner, provider == Provider.RedundantVirtualRouter); + List routers = findOrCreateVirtualRouters(guestNetwork, dest, owner, isRedundant); List runningRouters = null; if (routers != null) {