NaaS: Remove unused code

This commit is contained in:
Sheng Yang 2011-11-09 17:08:56 -08:00
parent 9b8f96c06d
commit c3c6e4f57a
2 changed files with 0 additions and 153 deletions

View File

@ -71,8 +71,6 @@ public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkA
List<DomainRouterVO> deployVirtualRouter(Network guestNetwork, DeployDestination dest, Account owner, Map<VirtualMachineProfile.Param, Object> params, Provider provider) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException;
//List<DomainRouterVO> deployDhcp(Network guestNetwork, DeployDestination dest, Account owner, Map<VirtualMachineProfile.Param, Object> params) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException;
List<VirtualRouter> applyDhcpEntry(Network config, NicProfile nic, VirtualMachineProfile<UserVm> vm, DeployDestination dest, ReservationContext context, List<DomainRouterVO> routers) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException;
List<VirtualRouter> applyUserData(Network config, NicProfile nic, VirtualMachineProfile<UserVm> vm, DeployDestination dest, ReservationContext context, List<DomainRouterVO> routers) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException;

View File

@ -1317,157 +1317,6 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
return runningRouters;
}
/*
List<DomainRouterVO> 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<DomainRouterVO> 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<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork);
NetworkOfferingVO controlOffering = offerings.get(0);
NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false, false).get(0);
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>(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, NicProfile>((NetworkVO) guestNetwork, gatewayNic));
networks.add(new Pair<NetworkVO, NicProfile>(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<HypervisorType> 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<DomainRouterVO> deployDhcp(Network guestNetwork, DeployDestination dest, Account owner, Map<Param, Object> 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<DomainRouterVO> routers = findOrCreateDhcpServers(guestNetwork, dest, owner);
List<DomainRouterVO> runningRouters = null;
if (routers != null) {
runningRouters = new ArrayList<DomainRouterVO>();
}
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<DomainRouterVO> profile, DeployDestination dest, ReservationContext context) {