From c3c6e4f57ad174cb87152055a3f528ee4b095f7d Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 9 Nov 2011 17:08:56 -0800 Subject: [PATCH] NaaS: Remove unused code --- .../VirtualNetworkApplianceManager.java | 2 - .../VirtualNetworkApplianceManagerImpl.java | 151 ------------------ 2 files changed, 153 deletions(-) diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java index 315318dc72f..3c5f279c389 100644 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java @@ -71,8 +71,6 @@ public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkA List deployVirtualRouter(Network guestNetwork, DeployDestination dest, Account owner, Map params, Provider provider) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException; - //List deployDhcp(Network guestNetwork, DeployDestination dest, Account owner, Map params) 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 6d1eb914982..60823140203 100755 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -1317,157 +1317,6 @@ 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) { - throw new ConcurrentOperationException("Unable to lock network " + guestNetwork.getId()); - } - - DataCenterDeployment plan = null; - DataCenter dc = dest.getDataCenter(); - long dcId = dc.getId(); - boolean isPodBased = (dc.getNetworkType() == NetworkType.Basic || _networkMgr.areServicesSupportedByNetworkOffering(guestNetwork.getNetworkOfferingId(), Service.SecurityGroup)) && guestNetwork.getTrafficType() == TrafficType.Guest; - DomainRouterVO router = null; - - List routers = null; - - try { - Long podId = dest.getPod().getId(); - - // In Basic zone and Guest network we have to start domR per pod, not per network - 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); - } - - if (!routers.isEmpty()) { - return routers; - } - - long id = _routerDao.getNextInSequence(Long.class, "id"); - if (s_logger.isDebugEnabled()) { - s_logger.debug("Creating the dhcp server " + id); - } - - List offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork); - NetworkOfferingVO controlOffering = offerings.get(0); - NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false, false).get(0); - - List> networks = new ArrayList>(3); - - String defaultNetworkStartIp = null; - if (guestNetwork.getCidr() != null) { - 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); - gatewayNic.setDefaultNic(true); - networks.add(new Pair((NetworkVO) guestNetwork, gatewayNic)); - networks.add(new Pair(controlConfig, null)); - - //Router is the network element, we don't know the hypervisor type yet. - //Try to allocate the domR twice using diff hypervisors, and when failed both times, throw the exception up - List supportedHypervisors = _resourceMgr.getSupportedHypervisorTypes(dest.getDataCenter().getId()); - Long offering_id = _networkOfferingDao.findById(guestNetwork.getNetworkOfferingId()).getServiceOfferingId(); - if (offering_id == null) { - offering_id = _offering.getId(); - } - ServiceOfferingVO routerOffering = _serviceOfferingDao.findById(offering_id); - int retry = 0; - for (HypervisorType hType : supportedHypervisors) { - try { - s_logger.debug("Allocating the domR with the hypervisor type " + hType); - VMTemplateVO template = _templateDao.findRoutingTemplate(hType); - - //physical network id can be null in Guest Network in Basic zone, so locate the physical network - Long physicalNetworkId = network.getPhysicalNetworkId(); - if (physicalNetworkId == null) { - physicalNetworkId = _networkMgr.findPhysicalNetworkId(network.getDataCenterId(), null); - } - VirtualRouterProviderType type = VirtualRouterProviderType.DhcpElement; - String typeString = "DhcpServer"; - PhysicalNetworkServiceProvider provider = _physicalProviderDao.findByServiceProvider(physicalNetworkId, typeString); - VirtualRouterProvider vrProvider = _vrProviderDao.findByNspIdAndType(provider.getId(), type); - - router = new DomainRouterVO(id, routerOffering.getId(), vrProvider.getId(), VirtualMachineName.getRouterName(id, _instance), template.getId(), template.getHypervisorType(), - template.getGuestOSId(), owner.getDomainId(), owner.getId(), guestNetwork.getId(), false, 0, false, RedundantState.UNKNOWN, routerOffering.getOfferHA(), false); - router.setRole(Role.DHCP_USERDATA); - router = _itMgr.allocate(router, template, routerOffering, networks, plan, null, owner); - break; - } catch (InsufficientCapacityException ex) { - if (retry < 2) { - s_logger.debug("Failed to allocate the domR with hypervisor type " + hType + ", retrying one more time"); - } else { - throw ex; - } - } finally { - retry++; - } - } - - routers.add(router); - - // Creating stats entry for router - UserStatisticsVO stats = _userStatsDao.findBy(owner.getId(), dcId, router.getNetworkId(), null, router.getId(), router.getType().toString()); - if (stats == null) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Creating user statistics for the account: " + owner.getId() + " Router Id: " + router.getId()); - } - stats = new UserStatisticsVO(owner.getId(), dcId, null, router.getId(), router.getType().toString(), guestNetwork.getId()); - _userStatsDao.persist(stats); - } - - } finally { - if (network != null) { - _networkDao.releaseFromLockTable(network.getId()); - } - } - - return routers; - } - - @Override - public List deployDhcp(Network guestNetwork, DeployDestination dest, Account owner, Map params) throws InsufficientCapacityException, StorageUnavailableException, - 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 dhcp server for " + guestNetwork + " in " + dest); - } - assert guestNetwork.getState() == Network.State.Implemented || guestNetwork.getState() == Network.State.Setup || guestNetwork.getState() == Network.State.Implementing : "Network is not yet fully implemented: " - + guestNetwork; - - List routers = findOrCreateDhcpServers(guestNetwork, dest, owner); - List runningRouters = null; - - if (routers != null) { - runningRouters = new ArrayList(); - } - - for (DomainRouterVO router : routers) { - State state = router.getState(); - if (state != State.Running) { - router = startVirtualRouter(router, _accountService.getSystemUser(), _accountService.getSystemAccount(), params); - } - runningRouters.add(router); - } - - return runningRouters; - } - */ - @Override public boolean finalizeVirtualMachineProfile(VirtualMachineProfile profile, DeployDestination dest, ReservationContext context) {