|
37 | 37 | import javax.naming.ConfigurationException; |
38 | 38 |
|
39 | 39 | import com.cloud.dc.dao.VlanDao; |
40 | | -import com.cloud.network.Networks; |
41 | 40 | import com.cloud.network.dao.IPAddressDao; |
42 | | -import com.cloud.network.dao.IPAddressVO; |
43 | | -import com.cloud.network.element.DhcpServiceProvider; |
44 | | -import com.cloud.vm.dao.NicIpAliasDao; |
45 | | -import com.cloud.vm.dao.NicIpAliasVO; |
46 | 41 | import org.apache.log4j.Logger; |
47 | 42 |
|
48 | 43 | import com.cloud.agent.AgentManager; |
|
185 | 180 | import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory; |
186 | 181 | import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; |
187 | 182 | import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; |
188 | | -import org.apache.log4j.Logger; |
189 | 183 |
|
190 | 184 | import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao; |
191 | | -import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; |
192 | | -import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator; |
193 | | -import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory; |
194 | | -import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; |
195 | | -import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; |
196 | 185 |
|
197 | 186 | @Local(value = VirtualMachineManager.class) |
198 | 187 | public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMachineManager, Listener { |
@@ -280,8 +269,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac |
280 | 269 | protected IPAddressDao _publicIpAddressDao; |
281 | 270 | @Inject |
282 | 271 | protected VlanDao _vlanDao; |
283 | | - @Inject |
284 | | - protected NicIpAliasDao _nicIpAliasDao; |
285 | 272 |
|
286 | 273 | protected List<DeploymentPlanner> _planners; |
287 | 274 | public List<DeploymentPlanner> getPlanners() { |
@@ -475,10 +462,6 @@ public <T extends VMInstanceVO> boolean advanceExpunge(T vm, User caller, Accoun |
475 | 462 | s_logger.debug("Destroying vm " + vm); |
476 | 463 | } |
477 | 464 |
|
478 | | - if (vm.getType() == VirtualMachine.Type.User) { |
479 | | - removeDhcpServiceInsubnet(vm); |
480 | | - } |
481 | | - |
482 | 465 | VirtualMachineProfile<T> profile = new VirtualMachineProfileImpl<T>(vm); |
483 | 466 |
|
484 | 467 | HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vm.getHypervisorType()); |
@@ -536,40 +519,7 @@ public <T extends VMInstanceVO> boolean advanceExpunge(T vm, User caller, Accoun |
536 | 519 | return true; |
537 | 520 | } |
538 | 521 |
|
539 | | - @DB |
540 | | - private void removeDhcpServiceInsubnet(VirtualMachine vm) { |
541 | | - //list all the nics which belong to this vm and are the last nics in the subnets. |
542 | | - //we are using the info in these nics to remove the dhcp sercvice for these subnets. |
543 | | - List<NicVO> nicList = listLastNicsInSubnet(vm); |
544 | | - |
545 | | - if(nicList != null && nicList.size() != 0) { |
546 | | - for (NicVO nic : nicList) { |
547 | | - //free the ipalias on the routers corresponding to each of the nics. |
548 | | - Network network = _networkDao.findById(nic.getNetworkId()); |
549 | | - DhcpServiceProvider dhcpServiceProvider = _networkMgr.getDhcpServiceProvider(network); |
550 | | - try { |
551 | | - NicIpAliasVO ipAlias = _nicIpAliasDao.findByGatewayAndNetworkIdAndState(nic.getGateway(), network.getId(), NicIpAlias.state.active); |
552 | | - if (ipAlias != null) { |
553 | | - ipAlias.setState(NicIpAlias.state.revoked); |
554 | | - Transaction txn = Transaction.currentTxn(); |
555 | | - txn.start(); |
556 | | - _nicIpAliasDao.update(ipAlias.getId(),ipAlias); |
557 | | - IPAddressVO aliasIpaddressVo = _publicIpAddressDao.findByIpAndSourceNetworkId(ipAlias.getNetworkId(), ipAlias.getIp4Address()); |
558 | | - _publicIpAddressDao.unassignIpAddress(aliasIpaddressVo.getId()); |
559 | | - txn.commit(); |
560 | | - if (!dhcpServiceProvider.removeDhcpSupportForSubnet(network)) { |
561 | | - s_logger.warn("Failed to remove the ip alias on the router, marking it as removed in db and freed the allocated ip " + ipAlias.getIp4Address()); |
562 | | - } |
563 | | - } |
564 | | - } |
565 | | - catch (ResourceUnavailableException e) { |
566 | | - //failed to remove the dhcpconfig on the router. |
567 | | - s_logger.info ("Unable to delete the ip alias due to unable to contact the virtualrouter."); |
568 | | - } |
569 | 522 |
|
570 | | - } |
571 | | - } |
572 | | - } |
573 | 523 |
|
574 | 524 | @Override |
575 | 525 | public boolean start() { |
@@ -1413,27 +1363,6 @@ public <T extends VMInstanceVO> boolean destroy(T vm, User user, Account caller) |
1413 | 1363 | return true; |
1414 | 1364 | } |
1415 | 1365 |
|
1416 | | - //list all the nics which belong to this vm and are the last nics in the subnets. |
1417 | | - //we are using the info in these nics to remove the dhcp sercvice for these subnets. |
1418 | | - private List<NicVO> listLastNicsInSubnet(VirtualMachine vm) { |
1419 | | - List<NicVO> nicList = _nicsDao.listByVmId(vm.getId()); |
1420 | | - List<NicVO> copyOfnicList = new ArrayList<NicVO>(nicList); |
1421 | | - for (NicVO nic : nicList) { |
1422 | | - Network network = _networkDao.findById(nic.getNetworkId()); |
1423 | | - DhcpServiceProvider dhcpServiceProvider = _networkMgr.getDhcpServiceProvider(network); |
1424 | | - Map <Network.Capability, String> capabilities = dhcpServiceProvider.getCapabilities().get(Network.Service.Dhcp); |
1425 | | - String supportsMultipleSubnets = capabilities.get(Network.Capability.DhcpAccrossMultipleSubnets); |
1426 | | - if ((supportsMultipleSubnets != null && Boolean.valueOf(supportsMultipleSubnets) && network.getTrafficType() == Networks.TrafficType.Guest && network.getGuestType() == Network.GuestType.Shared)) { |
1427 | | - //including the ip of the vm and the ipAlias |
1428 | | - if (_nicsDao.listByNetworkIdTypeAndGatewayAndBroadcastUri(nic.getNetworkId(), VirtualMachine.Type.User, nic.getGateway(), nic.getBroadcastUri()).size() > 1) { |
1429 | | - copyOfnicList.remove(nic); |
1430 | | - } |
1431 | | - } else { |
1432 | | - copyOfnicList.remove(nic); |
1433 | | - } |
1434 | | - } |
1435 | | - return copyOfnicList; |
1436 | | - } |
1437 | 1366 |
|
1438 | 1367 | protected boolean checkVmOnHost(VirtualMachine vm, long hostId) throws AgentUnavailableException, OperationTimedoutException { |
1439 | 1368 | CheckVirtualMachineAnswer answer = (CheckVirtualMachineAnswer) _agentMgr.send(hostId, new CheckVirtualMachineCommand(vm.getInstanceName())); |
@@ -3037,11 +2966,6 @@ public boolean removeNicFromVm(VirtualMachine vm, NicVO nic) throws ConcurrentOp |
3037 | 2966 | _networkModel.isSecurityGroupSupportedInNetwork(network), |
3038 | 2967 | _networkModel.getNetworkTag(vmProfile.getVirtualMachine().getHypervisorType(), network)); |
3039 | 2968 |
|
3040 | | - // Adding this to the dhcpservice config if this is the last nic in subnet. |
3041 | | - if (vm.getType() == VirtualMachine.Type.User) { |
3042 | | - removeDhcpServiceInsubnet(vm); |
3043 | | - } |
3044 | | - |
3045 | 2969 | //1) Unplug the nic |
3046 | 2970 | if (vm.getState() == State.Running) { |
3047 | 2971 | NicTO nicTO = toNicTO(nicProfile, vmProfile.getVirtualMachine().getHypervisorType()); |
|
0 commit comments