mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
Removed unused code that was commented out previously.
This commit is contained in:
parent
0049c74a5e
commit
ec1749a3bc
@ -423,185 +423,6 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean releaseRouter(final long routerId) {
|
||||
// return destroyRouter(routerId);
|
||||
// }
|
||||
//
|
||||
// @Override @DB
|
||||
// public DomainRouterVO createRouter(final long accountId, final String publicIpAddress, final long dataCenterId,
|
||||
// String domain, final ServiceOfferingVO offering, long startEventId)
|
||||
// throws ConcurrentOperationException {
|
||||
// if (s_logger.isDebugEnabled()) {
|
||||
// s_logger.debug("Creating a router for account=" + accountId + "; publicIpAddress=" + publicIpAddress + "; dc=" + dataCenterId + "domain=" + domain);
|
||||
// }
|
||||
//
|
||||
// final AccountVO account = _accountDao.acquireInLockTable(accountId);
|
||||
// if (account == null) {
|
||||
// throw new ConcurrentOperationException("Unable to acquire account " + accountId);
|
||||
// }
|
||||
//
|
||||
// if(s_logger.isDebugEnabled()) {
|
||||
// s_logger.debug("lock on account " + accountId + " for createRouter is acquired");
|
||||
// }
|
||||
//
|
||||
// final Transaction txn = Transaction.currentTxn();
|
||||
// DomainRouterVO router = null;
|
||||
// boolean success = false;
|
||||
// try {
|
||||
// router = _routerDao.findBy(accountId, dataCenterId);
|
||||
// if (router != null && router.getState() != State.Creating) {
|
||||
// if (s_logger.isDebugEnabled()) {
|
||||
// s_logger.debug("Router " + router.toString() + " found for account " + accountId + " in data center " + dataCenterId);
|
||||
// }
|
||||
// success = true;
|
||||
// return router;
|
||||
// }
|
||||
// EventVO event = new EventVO();
|
||||
// event.setUserId(1L);
|
||||
// event.setAccountId(accountId);
|
||||
// event.setType(EventTypes.EVENT_ROUTER_CREATE);
|
||||
// event.setState(Event.State.Started);
|
||||
// event.setStartId(startEventId);
|
||||
// event.setDescription("Creating Router for account with Id: "+accountId);
|
||||
// event = _eventDao.persist(event);
|
||||
//
|
||||
// final DataCenterVO dc = _dcDao.findById(dataCenterId);
|
||||
// final VMTemplateVO template = _templateDao.findRoutingTemplate();
|
||||
//
|
||||
// String[] macAddresses = getMacAddressPair(dataCenterId);
|
||||
// String privateMacAddress = macAddresses[0];
|
||||
// String publicMacAddress = macAddresses[1];
|
||||
//
|
||||
// final long id = _routerDao.getNextInSequence(Long.class, "id");
|
||||
//
|
||||
// if (domain == null) {
|
||||
// domain = "v" + Long.toHexString(accountId) + "." + _domain;
|
||||
// }
|
||||
//
|
||||
// final String name = VirtualMachineName.getRouterName(id, _instance).intern();
|
||||
// long routerMacAddress = NetUtils.mac2Long(dc.getRouterMacAddress()) | ((dc.getId() & 0xff) << 32);
|
||||
//
|
||||
// //set the guestNetworkCidr from the dc obj
|
||||
// String guestNetworkCidr = dc.getGuestNetworkCidr();
|
||||
// String[] cidrTuple = guestNetworkCidr.split("\\/");
|
||||
// String guestIpAddress = NetUtils.getIpRangeStartIpFromCidr(cidrTuple[0], Long.parseLong(cidrTuple[1]));
|
||||
// String guestNetmask = NetUtils.getCidrNetmask(Long.parseLong(cidrTuple[1]));
|
||||
//
|
||||
//// String path = null;
|
||||
//// final int numVolumes = offering.isMirroredVolumes()?2:1;
|
||||
//// long routerId = 0;
|
||||
//
|
||||
// // Find the VLAN ID, VLAN gateway, and VLAN netmask for publicIpAddress
|
||||
// IPAddressVO ipVO = _ipAddressDao.findById(publicIpAddress);
|
||||
// VlanVO vlan = _vlanDao.findById(ipVO.getVlanId());
|
||||
// String vlanId = vlan.getVlanTag();
|
||||
// String vlanGateway = vlan.getVlanGateway();
|
||||
// String vlanNetmask = vlan.getVlanNetmask();
|
||||
//
|
||||
// Pair<HostPodVO, Long> pod = null;
|
||||
// Set<Long> avoids = new HashSet<Long>();
|
||||
// boolean found = false;
|
||||
// while ((pod = _agentMgr.findPod(template, offering, dc, accountId, avoids)) != null) {
|
||||
//
|
||||
// if (s_logger.isDebugEnabled()) {
|
||||
// s_logger.debug("Attempting to create in pod " + pod.first().getName());
|
||||
// }
|
||||
//
|
||||
// router = new DomainRouterVO(id,
|
||||
// _offering.getId(),
|
||||
// name,
|
||||
// privateMacAddress,
|
||||
// null,
|
||||
// null,
|
||||
// _routerTemplateId,
|
||||
// template.getGuestOSId(),
|
||||
// NetUtils.long2Mac(routerMacAddress),
|
||||
// guestIpAddress,
|
||||
// guestNetmask,
|
||||
// accountId,
|
||||
// account.getDomainId(),
|
||||
// publicMacAddress,
|
||||
// publicIpAddress,
|
||||
// vlanNetmask,
|
||||
// vlan.getId(),
|
||||
// vlanId,
|
||||
// pod.first().getId(),
|
||||
// dataCenterId,
|
||||
// _routerRamSize,
|
||||
// vlanGateway,
|
||||
// domain,
|
||||
// dc.getDns1(),
|
||||
// dc.getDns2());
|
||||
// router.setMirroredVols(offering.isMirrored());
|
||||
//
|
||||
// router.setLastHostId(pod.second());
|
||||
// router = _routerDao.persist(router);
|
||||
//
|
||||
// List<VolumeVO> vols = _storageMgr.create(account, router, template, dc, pod.first(), _offering, null,0);
|
||||
// if(vols != null) {
|
||||
// found = true;
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// _routerDao.expunge(router.getId());
|
||||
// if (s_logger.isDebugEnabled()) {
|
||||
// s_logger.debug("Unable to find storage host or pool in pod " + pod.first().getName() + " (id:" + pod.first().getId() + "), checking other pods");
|
||||
// }
|
||||
// avoids.add(pod.first().getId());
|
||||
// }
|
||||
//
|
||||
// if (!found) {
|
||||
// event.setDescription("failed to create Domain Router : " + name);
|
||||
// event.setLevel(EventVO.LEVEL_ERROR);
|
||||
// _eventDao.persist(event);
|
||||
// throw new ExecutionException("Unable to create DomainRouter");
|
||||
// }
|
||||
// _itMgr.stateTransitTo(router, VirtualMachine.Event.OperationSucceeded, null);
|
||||
//
|
||||
// s_logger.debug("Router created: id=" + router.getId() + "; name=" + router.getName());
|
||||
//
|
||||
// event = new EventVO();
|
||||
// event.setUserId(1L); // system user performed the action
|
||||
// event.setAccountId(accountId);
|
||||
// event.setType(EventTypes.EVENT_ROUTER_CREATE);
|
||||
// event.setStartId(startEventId);
|
||||
// event.setDescription("successfully created Domain Router : " + router.getName() + " with ip : " + publicIpAddress);
|
||||
// _eventDao.persist(event);
|
||||
// success = true;
|
||||
// return router;
|
||||
// } catch (final Throwable th) {
|
||||
// if (th instanceof ExecutionException) {
|
||||
// s_logger.error("Error while starting router due to " + th.getMessage());
|
||||
// } else {
|
||||
// s_logger.error("Unable to create router", th);
|
||||
// }
|
||||
// txn.rollback();
|
||||
//
|
||||
// if (router != null && router.getState() == State.Creating) {
|
||||
// _routerDao.expunge(router.getId());
|
||||
// }
|
||||
// return null;
|
||||
// } finally {
|
||||
// if (account != null) {
|
||||
// if(s_logger.isDebugEnabled()) {
|
||||
// s_logger.debug("Releasing lock on account " + account.getId() + " for createRouter");
|
||||
// }
|
||||
// _accountDao.releaseFromLockTable(account.getId());
|
||||
// }
|
||||
// if(!success){
|
||||
// EventVO event = new EventVO();
|
||||
// event.setUserId(1L); // system user performed the action
|
||||
// event.setAccountId(accountId);
|
||||
// event.setType(EventTypes.EVENT_ROUTER_CREATE);
|
||||
// event.setStartId(startEventId);
|
||||
// event.setLevel(EventVO.LEVEL_ERROR);
|
||||
// event.setDescription("Failed to create router for account " + accountId + " in data center " + dataCenterId);
|
||||
// _eventDao.persist(event);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
public boolean destroyRouter(final long routerId) {
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
|
||||
@ -1991,267 +1991,6 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
|
||||
return privateTemplate;
|
||||
}
|
||||
|
||||
// @DB
|
||||
// @Override
|
||||
// public UserVmVO createDirectlyAttachedVM(Long vmId, long userId, AccountVO account, DataCenterVO dc, ServiceOfferingVO offering, VMTemplateVO template, DiskOfferingVO diskOffering, String displayName, String userData, List<StoragePoolVO> a, List<NetworkGroupVO> networkGroups, long startEventId, long size) throws CloudRuntimeException, ResourceAllocationException {
|
||||
//
|
||||
// long accountId = account.getId();
|
||||
// long dataCenterId = dc.getId();
|
||||
// long serviceOfferingId = offering.getId();
|
||||
// long templateId = -1;
|
||||
// if (template != null) {
|
||||
// templateId = template.getId();
|
||||
// }
|
||||
//
|
||||
// if (s_logger.isDebugEnabled()) {
|
||||
// s_logger.debug("Creating directly attached vm for account id=" + account.getId() +
|
||||
// ", name="+ account.getAccountName() + "; dc=" + dc.getName() +
|
||||
// "; offering=" + offering.getId() + "; diskOffering=" + ((diskOffering != null) ? diskOffering.getName() : "none") +
|
||||
// "; template=" + templateId);
|
||||
// }
|
||||
//
|
||||
// // Determine the Guest OS Id
|
||||
// long guestOSId;
|
||||
// if (template != null) {
|
||||
// guestOSId = template.getGuestOSId();
|
||||
// } else {
|
||||
// throw new CloudRuntimeException("No template or ISO was specified for the VM.");
|
||||
// }
|
||||
//
|
||||
// Transaction txn = Transaction.currentTxn();
|
||||
// txn.start();
|
||||
//
|
||||
// account = _accountDao.lockRow(accountId, true);
|
||||
// if (account == null) {
|
||||
// throw new CloudRuntimeException("Unable to lock up the account: " + accountId);
|
||||
// }
|
||||
//
|
||||
// // First check that the maximum number of UserVMs for the given accountId will not be exceeded
|
||||
// if (_accountMgr.resourceLimitExceeded(account, ResourceType.user_vm)) {
|
||||
// ResourceAllocationException rae = new ResourceAllocationException("Maximum number of virtual machines for account: " + account.getAccountName() + " has been exceeded.");
|
||||
// rae.setResourceType("vm");
|
||||
// throw rae;
|
||||
// }
|
||||
// _accountMgr.incrementResourceCount(account.getId(), ResourceType.user_vm);
|
||||
// boolean isIso = Storage.ImageFormat.ISO.equals(template.getFormat());
|
||||
// long numVolumes = (isIso || (diskOffering == null)) ? 1 : 2;
|
||||
// _accountMgr.incrementResourceCount(account.getId(), ResourceType.volume, numVolumes);
|
||||
// txn.commit();
|
||||
//
|
||||
// try {
|
||||
// UserVmVO vm = null;
|
||||
//
|
||||
// final String name = VirtualMachineName.getVmName(vmId, accountId, _instance);
|
||||
//
|
||||
// final String[] macAddresses = _dcDao.getNextAvailableMacAddressPair(dc.getId());
|
||||
// long routerId = -1;
|
||||
// long poolId = 0;
|
||||
// Pair<HostPodVO, Long> pod = null;
|
||||
// DomainRouterVO router = null;
|
||||
// Set<Long> avoids = new HashSet<Long>();
|
||||
// VlanVO guestVlan = null;
|
||||
// List<VlanVO> vlansForAccount = _vlanDao.listVlansForAccountByType(dc.getId(), account.getId(), VlanType.DirectAttached);
|
||||
// List<VlanVO> vlansForPod = null;
|
||||
// List<VlanVO> zoneWideVlans = null;
|
||||
//
|
||||
// boolean forAccount = false;
|
||||
// boolean forZone = false;
|
||||
// if (vlansForAccount.size() > 0) {
|
||||
// forAccount = true;
|
||||
// guestVlan = vlansForAccount.get(0);//FIXME: iterate over all vlans
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //list zone wide vlans that are direct attached and tagged
|
||||
// //if exists pick random one
|
||||
// //set forZone = true
|
||||
//
|
||||
// //note the dao method below does a NEQ on vlan id, hence passing untagged
|
||||
// zoneWideVlans = _vlanDao.searchForZoneWideVlans(dc.getId(),VlanType.DirectAttached.toString(),"untagged");
|
||||
//
|
||||
// if(zoneWideVlans!=null && zoneWideVlans.size()>0){
|
||||
// forZone = true;
|
||||
// guestVlan = zoneWideVlans.get(0);//FIXME: iterate over all vlans
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// while ((pod = _agentMgr.findPod(template, offering, dc, account.getId(), avoids)) != null) {
|
||||
// if (s_logger.isDebugEnabled()) {
|
||||
// s_logger.debug("Attempting to create direct attached vm in pod " + pod.first().getName());
|
||||
// }
|
||||
// if (!forAccount && !forZone) {
|
||||
// vlansForPod = _vlanDao.listVlansForPodByType(pod.first().getId(), VlanType.DirectAttached);
|
||||
// if (vlansForPod.size() < 1) {
|
||||
// avoids.add(pod.first().getId());
|
||||
// if (s_logger.isDebugEnabled()) {
|
||||
// s_logger.debug("No direct attached vlans available in pod " + pod.first().getName() + " (id:" + pod.first().getId() + "), checking other pods");
|
||||
// }
|
||||
// continue;
|
||||
// }
|
||||
// guestVlan = vlansForPod.get(0);//FIXME: iterate over all vlans
|
||||
// }
|
||||
//
|
||||
// List<DomainRouterVO> rtrs = _routerDao.listByVlanDbId(guestVlan.getId());
|
||||
// assert rtrs.size() < 2 : "How did we get more than one router per vlan?";
|
||||
// if (rtrs.size() > 0) {
|
||||
// router = rtrs.get(0);
|
||||
// routerId = router.getId();
|
||||
// } else if (rtrs.size() == 0) {
|
||||
// router = _routerMgr.createDhcpServerForDirectlyAttachedGuests(userId, accountId, dc, pod.first(), pod.second(), guestVlan);
|
||||
// if (router == null) {
|
||||
// avoids.add(pod.first().getId());
|
||||
// if (s_logger.isDebugEnabled()) {
|
||||
// s_logger.debug("Unable to create DHCP server in vlan " + guestVlan.getVlanTag() + ", pod=" + pod.first().getName() + " (podid:" + pod.first().getId() + "), checking other pods");
|
||||
// }
|
||||
// continue;
|
||||
// }
|
||||
// routerId = router.getId();
|
||||
// }
|
||||
// String guestIp = null;
|
||||
//
|
||||
// if(forAccount)
|
||||
// {
|
||||
// for(VlanVO vlanForAcc : vlansForAccount)
|
||||
// {
|
||||
// guestIp = null;//_ipAddressDao.assignIpAddress(accountId, account.getDomainId(), vlanForAcc.getId(), false).getAddress();
|
||||
// if(guestIp!=null) {
|
||||
// break; //got an ip
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else if(!forAccount && !forZone)
|
||||
// {
|
||||
// //i.e. for pod
|
||||
// for(VlanVO vlanForPod : vlansForPod)
|
||||
// {
|
||||
// guestIp = null; // _ipAddressDao.assignIpAddress(accountId, account.getDomainId(), vlanForPod.getId(), false).getAddress();
|
||||
// if(guestIp!=null) {
|
||||
// break;//got an ip
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //for zone
|
||||
// for(VlanVO vlanForZone : zoneWideVlans)
|
||||
// {
|
||||
// guestIp = null;// _ipAddressDao.assignIpAddress(accountId, account.getDomainId(), vlanForZone.getId(), false).getAddress();
|
||||
// if(guestIp!=null) {
|
||||
// break;//found an ip
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (guestIp == null) {
|
||||
// s_logger.debug("No guest IP available in pod id=" + pod.first().getId());
|
||||
// avoids.add(pod.first().getId());
|
||||
// continue;
|
||||
// }
|
||||
// s_logger.debug("Acquired a guest IP, ip=" + guestIp);
|
||||
// String guestMacAddress = macAddresses[0];
|
||||
// String externalMacAddress = macAddresses[1];
|
||||
// Long externalVlanDbId = null;
|
||||
//
|
||||
// vm = new UserVmVO(vmId, name, templateId, guestOSId, accountId, account.getDomainId(),
|
||||
// serviceOfferingId, guestMacAddress, guestIp, guestVlan.getVlanNetmask(),
|
||||
// null, externalMacAddress, externalVlanDbId,
|
||||
// routerId, pod.first().getId(), dataCenterId,
|
||||
// offering.getOfferHA(), displayName, userData);
|
||||
//
|
||||
// if (diskOffering != null) {
|
||||
// vm.setMirroredVols(diskOffering.isMirrored());
|
||||
// }
|
||||
//
|
||||
// vm.setLastHostId(pod.second());
|
||||
// vm = _vmDao.persist(vm);
|
||||
// boolean addedToGroups = _networkGroupMgr.addInstanceToGroups(vmId, networkGroups);
|
||||
// if (!addedToGroups) {
|
||||
// s_logger.warn("Not all specified network groups can be found");
|
||||
// _vmDao.expunge(vm.getId());
|
||||
// throw new InvalidParameterValueException("Not all specified network groups can be found");
|
||||
// }
|
||||
//
|
||||
// vm = _vmDao.findById(vmId);
|
||||
// try {
|
||||
// poolId = _storageMgr.createUserVM(account, vm, template, dc, pod.first(), offering, diskOffering, a,size);
|
||||
// } catch (CloudRuntimeException e) {
|
||||
// _vmDao.expunge(vmId);
|
||||
// _ipAddressDao.unassignIpAddress(guestIp);
|
||||
// s_logger.debug("Released a guest ip address because we could not find storage: ip=" + guestIp);
|
||||
// guestIp = null;
|
||||
// if (s_logger.isDebugEnabled()) {
|
||||
// s_logger.debug("Unable to find storage host in pod " + pod.first().getName() + " (id:" + pod.first().getId() + "), checking other pods");
|
||||
// }
|
||||
// avoids.add(pod.first().getId());
|
||||
// continue; // didn't find a storage host in pod, go to the next pod
|
||||
// }
|
||||
//
|
||||
// EventVO event = new EventVO();
|
||||
// event.setUserId(userId);
|
||||
// event.setAccountId(accountId);
|
||||
// event.setType(EventTypes.EVENT_NET_IP_ASSIGN);
|
||||
// event.setParameters("guestIPaddress=" + guestIp + "\nvmName=" + vm.getName() + "\ndcId=" + vm.getDataCenterId());
|
||||
// event.setDescription("acquired a public ip: " + guestIp);
|
||||
// _eventDao.persist(event);
|
||||
//
|
||||
// break; // if we got here, we found a host and can stop searching the pods
|
||||
// }
|
||||
//
|
||||
// if (poolId == 0) {
|
||||
// if(vm != null && vm.getName()!=null && vm.getDisplayName() != null)
|
||||
// {
|
||||
// if(!vm.getName().equals(vm.getDisplayName())) {
|
||||
// s_logger.debug("failed to create VM instance : " + name+"("+vm.getInstanceName()+")");
|
||||
// } else {
|
||||
// s_logger.debug("failed to create VM instance : " + name);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// s_logger.debug("failed to create VM instance : " + name);
|
||||
// throw new CloudRuntimeException("We could not find a suitable pool for creating this directly attached vm");
|
||||
//
|
||||
// }
|
||||
// _accountMgr.decrementResourceCount(account.getId(), ResourceType.user_vm);
|
||||
// _accountMgr.decrementResourceCount(account.getId(), ResourceType.volume, numVolumes);
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// txn.start();
|
||||
// EventVO event = new EventVO();
|
||||
// event.setUserId(userId);
|
||||
// event.setAccountId(accountId);
|
||||
// event.setType(EventTypes.EVENT_VM_CREATE);
|
||||
// event.setStartId(startEventId);
|
||||
// event.setState(Event.State.Completed);
|
||||
// String diskOfferingIdentifier = (diskOffering != null) ? String.valueOf(diskOffering.getId()) : "-1";
|
||||
// String eventParams = "id=" + vm.getId() + "\nvmName=" + vm.getName() + "\nsoId=" + vm.getServiceOfferingId() + "\ndoId=" + diskOfferingIdentifier + "\ntId=" + vm.getTemplateId() + "\ndcId=" + vm.getDataCenterId();
|
||||
// event.setParameters(eventParams);
|
||||
// if(!vm.getName().equals(vm.getDisplayName())) {
|
||||
// event.setDescription("successfully created VM instance : " + vm.getName()+"("+vm.getInstanceName()+")");
|
||||
// } else {
|
||||
// event.setDescription("successfully created VM instance : " + vm.getName());
|
||||
// }
|
||||
// _eventDao.persist(event);
|
||||
//
|
||||
// _itMgr.stateTransitTo(vm, VirtualMachine.Event.OperationSucceeded, null);
|
||||
// if (s_logger.isDebugEnabled()) {
|
||||
// s_logger.debug("vm created " + vmId);
|
||||
// }
|
||||
// txn.commit();
|
||||
//
|
||||
// return _vmDao.findById(vmId);
|
||||
// } catch (Throwable th) {
|
||||
// _accountMgr.decrementResourceCount(account.getId(), ResourceType.user_vm);
|
||||
// _accountMgr.decrementResourceCount(account.getId(), ResourceType.volume, numVolumes);
|
||||
//
|
||||
// s_logger.error("Unable to create vm", th);
|
||||
// throw new CloudRuntimeException("Unable to create vm: "+th.getMessage(), th);
|
||||
// } finally{
|
||||
// updateVmStateForFailedVmCreation(vmId);
|
||||
// }
|
||||
// }
|
||||
|
||||
//used for vm transitioning to error state
|
||||
private void updateVmStateForFailedVmCreation(Long vmId) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user