mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 11:52:28 +01:00
VPC: unplugNic - release the nic in the DB only after the command is executed succesfully on the backend
Conflicts: api/src/com/cloud/agent/api/routing/SetStaticRouteCommand.java server/src/com/cloud/network/NetworkManagerImpl.java server/test/com/cloud/network/MockNetworkManagerImpl.java
This commit is contained in:
parent
f59b935da5
commit
697aa4589b
@ -16,7 +16,6 @@
|
||||
// under the License.
|
||||
package com.cloud.network;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -387,17 +386,6 @@ public interface NetworkManager extends NetworkService {
|
||||
InsufficientAddressCapacityException, ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException;
|
||||
|
||||
|
||||
/**
|
||||
* @param vmProfile
|
||||
* @param network
|
||||
* @return TODO
|
||||
* @throws ConcurrentOperationException
|
||||
* @throws ResourceUnavailableException
|
||||
*/
|
||||
NicProfile releaseNic(VirtualMachineProfile<? extends VMInstanceVO> vmProfile, NetworkVO network)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
|
||||
/**
|
||||
* @param vm
|
||||
* @param network
|
||||
@ -446,13 +434,11 @@ public interface NetworkManager extends NetworkService {
|
||||
|
||||
/**
|
||||
* @param vmProfile
|
||||
* @param network
|
||||
* @param broadcastUri
|
||||
* @return
|
||||
* @param nic TODO
|
||||
* @throws ConcurrentOperationException
|
||||
* @throws ResourceUnavailableException
|
||||
*/
|
||||
NicProfile releaseNic(VirtualMachineProfile<? extends VMInstanceVO> vmProfile, NetworkVO network, URI broadcastUri)
|
||||
void releaseNic(VirtualMachineProfile<? extends VMInstanceVO> vmProfile, Nic nic)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
|
||||
|
||||
@ -2264,37 +2264,20 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
ConcurrentOperationException, ResourceUnavailableException {
|
||||
List<NicVO> nics = _nicDao.listByVmId(vmProfile.getId());
|
||||
for (NicVO nic : nics) {
|
||||
NetworkVO network = _networksDao.findById(nic.getNetworkId());
|
||||
releaseNic(vmProfile, nic, network);
|
||||
releaseNic(vmProfile, nic);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NicProfile releaseNic(VirtualMachineProfile<? extends VMInstanceVO> vmProfile, NetworkVO network)
|
||||
public void releaseNic(VirtualMachineProfile<? extends VMInstanceVO> vmProfile, Nic nic)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
NicVO nic = _nicDao.findByInstanceIdAndNetworkId(network.getId(), vmProfile.getId());
|
||||
releaseNic(vmProfile, nic, network);
|
||||
|
||||
NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), null,
|
||||
isSecurityGroupSupportedInNetwork(network), getNetworkTag(vmProfile.getVirtualMachine().getHypervisorType(), network));
|
||||
return profile;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public NicProfile releaseNic(VirtualMachineProfile<? extends VMInstanceVO> vmProfile, NetworkVO network, URI broadcastUri)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
NicVO nic = _nicDao.findByInstanceIdNetworkIdAndBroadcastUri(network.getId(), vmProfile.getId(), broadcastUri.toString());
|
||||
releaseNic(vmProfile, nic, network);
|
||||
|
||||
NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), null,
|
||||
isSecurityGroupSupportedInNetwork(network), getNetworkTag(vmProfile.getVirtualMachine().getHypervisorType(), network));
|
||||
return profile;
|
||||
NicVO nicVO = _nicDao.findById(nic.getId());
|
||||
releaseNic(vmProfile, nicVO);
|
||||
}
|
||||
|
||||
|
||||
protected void releaseNic(VirtualMachineProfile<? extends VMInstanceVO> vmProfile, NicVO nic, NetworkVO network)
|
||||
protected void releaseNic(VirtualMachineProfile<? extends VMInstanceVO> vmProfile, NicVO nic)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
NetworkVO network = _networksDao.findById(nic.getNetworkId());
|
||||
if (nic.getState() == Nic.State.Reserved || nic.getState() == Nic.State.Reserving) {
|
||||
Nic.State originalState = nic.getState();
|
||||
if (nic.getReservationStrategy() == Nic.ReservationStrategy.Start) {
|
||||
|
||||
@ -2493,7 +2493,6 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
|
||||
@Override
|
||||
public boolean removeVmFromNetwork(VirtualMachine vm, Network network, URI broadcastUri) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
VMInstanceVO vmVO = _vmDao.findById(vm.getId());
|
||||
NetworkVO networkVO = _networkDao.findById(network.getId());
|
||||
ReservationContext context = new ReservationContextImpl(null, null, _accountMgr.getActiveUser(User.UID_SYSTEM),
|
||||
_accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM));
|
||||
|
||||
@ -2503,20 +2502,20 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
|
||||
DataCenter dc = _configMgr.getZone(network.getDataCenterId());
|
||||
Host host = _hostDao.findById(vm.getHostId());
|
||||
DeployDestination dest = new DeployDestination(dc, null, null, host);
|
||||
|
||||
//1) Release the nic
|
||||
NicProfile nic = _networkMgr.releaseNic(vmProfile, networkVO, broadcastUri);
|
||||
|
||||
//2) Convert vmProfile to vmTO
|
||||
VirtualMachineGuru<VMInstanceVO> vmGuru = getVmGuru(vmVO);
|
||||
HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vmProfile.getVirtualMachine().getHypervisorType());
|
||||
VirtualMachineTO vmTO = hvGuru.implement(vmProfile);
|
||||
|
||||
NicTO nicTO = toNicTO(nic, vmProfile.getVirtualMachine().getHypervisorType());
|
||||
Nic nic = _networkMgr.getNicInNetwork(vm.getId(), network.getId());
|
||||
NicProfile nicProfile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(),
|
||||
_networkMgr.getNetworkRate(network.getId(), vm.getId()),
|
||||
_networkMgr.isSecurityGroupSupportedInNetwork(network),
|
||||
_networkMgr.getNetworkTag(vmProfile.getVirtualMachine().getHypervisorType(), network));
|
||||
|
||||
//1) Unplug the nic
|
||||
NicTO nicTO = toNicTO(nicProfile, vmProfile.getVirtualMachine().getHypervisorType());
|
||||
s_logger.debug("Un-plugging nic for vm " + vm + " from network " + network);
|
||||
boolean result = vmGuru.unplugNic(network, nicTO, vmTO, context, dest);
|
||||
//4) Unplug the nic
|
||||
if (result) {
|
||||
s_logger.debug("Nic is unplugged successfully for vm " + vm + " in network " + network );
|
||||
} else {
|
||||
@ -2524,7 +2523,11 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
|
||||
return false;
|
||||
}
|
||||
|
||||
//6) Remove the nic
|
||||
//2) Release the nic
|
||||
_networkMgr.releaseNic(vmProfile, nic);
|
||||
s_logger.debug("Successfully released nic " + nic + "for vm " + vm);
|
||||
|
||||
//3) Remove the nic
|
||||
_networkMgr.removeNic(vmProfile, network);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
// under the License.
|
||||
package com.cloud.network;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -804,15 +803,6 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.NetworkManager#releaseNic(com.cloud.vm.VirtualMachineProfile, com.cloud.network.NetworkVO)
|
||||
*/
|
||||
@Override
|
||||
public NicProfile releaseNic(VirtualMachineProfile<? extends VMInstanceVO> vmProfile, NetworkVO network) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.NetworkManager#removeNic(com.cloud.vm.VirtualMachineProfile, com.cloud.network.Network)
|
||||
*/
|
||||
@ -962,8 +952,7 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
|
||||
* @see com.cloud.network.NetworkManager#allocateDirectIp(com.cloud.vm.NicProfile, com.cloud.dc.DataCenter, com.cloud.vm.VirtualMachineProfile, com.cloud.network.Network, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void allocateDirectIp(NicProfile nic, DataCenter dc, VirtualMachineProfile<? extends VirtualMachine> vm, Network network, String requestedIp) throws InsufficientVirtualNetworkCapcityException,
|
||||
InsufficientAddressCapacityException {
|
||||
public void releaseNic(VirtualMachineProfile<? extends VMInstanceVO> vmProfile, Nic nic) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@ -1066,15 +1055,6 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.NetworkManager#releaseNic(com.cloud.vm.VirtualMachineProfile, com.cloud.network.NetworkVO, java.net.URI)
|
||||
*/
|
||||
@Override
|
||||
public NicProfile releaseNic(VirtualMachineProfile<? extends VMInstanceVO> vmProfile, NetworkVO network, URI broadcastUri) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.NetworkManager#getPhysicalNtwksSupportingTrafficType(long, com.cloud.network.Networks.TrafficType)
|
||||
*/
|
||||
@ -1139,4 +1119,14 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.NetworkManager#allocateDirectIp(com.cloud.vm.NicProfile, com.cloud.dc.DataCenter, com.cloud.vm.VirtualMachineProfile, com.cloud.network.Network, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void allocateDirectIp(NicProfile nic, DataCenter dc, VirtualMachineProfile<? extends VirtualMachine> vm, Network network, String requestedIp) throws InsufficientVirtualNetworkCapcityException,
|
||||
InsufficientAddressCapacityException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user