mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug 10954: when start a vm, always check if it's being started in original pod; if not - release old ip address, and allocate the new one from the new pod
status 10954: resolved fixed
This commit is contained in:
parent
a680f192ab
commit
dfd0d7730e
@ -1326,7 +1326,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
NetworkGuru guru = _networkGurus.get(network.getGuruName());
|
||||
nic.setState(Nic.State.Releasing);
|
||||
_nicDao.update(nic.getId(), nic);
|
||||
NicProfile profile = new NicProfile(nic, network, null, null, null);
|
||||
NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), null);
|
||||
if (guru.release(profile, vmProfile, nic.getReservationId())) {
|
||||
applyProfileToNicForRelease(nic, profile);
|
||||
nic.setState(Nic.State.Allocated);
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
package com.cloud.network.guru;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
@ -29,14 +30,17 @@ import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.Pod;
|
||||
import com.cloud.dc.PodVlanMapVO;
|
||||
import com.cloud.dc.Vlan;
|
||||
import com.cloud.dc.Vlan.VlanType;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.dc.dao.PodVlanMapDao;
|
||||
import com.cloud.dc.dao.VlanDao;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||
import com.cloud.network.IPAddressVO;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.Networks.AddressFormat;
|
||||
@ -68,6 +72,8 @@ public class DirectPodBasedNetworkGuru extends DirectNetworkGuru {
|
||||
IPAddressDao _ipAddressDao;
|
||||
@Inject
|
||||
NetworkOfferingDao _networkOfferingDao;
|
||||
@Inject
|
||||
PodVlanMapDao _podVlanDao;
|
||||
|
||||
@Override
|
||||
protected boolean canHandle(NetworkOffering offering, DataCenter dc) {
|
||||
@ -108,6 +114,7 @@ public class DirectPodBasedNetworkGuru extends DirectNetworkGuru {
|
||||
} else {
|
||||
nic.setStrategy(ReservationStrategy.Create);
|
||||
}
|
||||
|
||||
if (rsStrategy == ReservationStrategy.Create) {
|
||||
String mac = _networkMgr.getNextAvailableMacAddressInNetwork(network.getId());
|
||||
nic.setMacAddress(mac);
|
||||
@ -118,9 +125,31 @@ public class DirectPodBasedNetworkGuru extends DirectNetworkGuru {
|
||||
@Override
|
||||
public void reserve(NicProfile nic, Network network, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context)
|
||||
throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException {
|
||||
if (nic.getIp4Address() == null) {
|
||||
|
||||
String oldIp = nic.getIp4Address();
|
||||
boolean getNewIp = false;
|
||||
|
||||
if (oldIp == null) {
|
||||
getNewIp = true;
|
||||
} else {
|
||||
// we need to get a new ip address if we try to deploy a vm in a different pod
|
||||
IPAddressVO ipVO = _ipAddressDao.findByIpAndSourceNetworkId(network.getId(), oldIp);
|
||||
if (ipVO != null) {
|
||||
List<PodVlanMapVO> mapVO = _podVlanDao.listPodVlanMapsByVlan(ipVO.getVlanId());
|
||||
if (mapVO.get(0).getPodId() != dest.getPod().getId()) {
|
||||
//release the old ip here
|
||||
_networkMgr.markIpAsUnavailable(ipVO.getId());
|
||||
_ipAddressDao.unassignIpAddress(ipVO.getId());
|
||||
|
||||
nic.setIp4Address(null);
|
||||
getNewIp = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getNewIp) {
|
||||
//we don't set reservationStrategy to Create because we need this method to be called again for the case when vm fails to deploy in Pod1, and we try to redeploy it in Pod2
|
||||
getIp(nic, dest.getPod(), vm, network);
|
||||
nic.setStrategy(ReservationStrategy.Create);
|
||||
}
|
||||
|
||||
DataCenter dc = _dcDao.findById(network.getDataCenterId());
|
||||
@ -148,5 +177,5 @@ public class DirectPodBasedNetworkGuru extends DirectNetworkGuru {
|
||||
nic.setDns1(dc.getDns1());
|
||||
nic.setDns2(dc.getDns2());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -54,3 +54,4 @@ INSERT IGNORE INTO configuration VALUES ('Network', 'DEFAULT', 'management-serve
|
||||
INSERT IGNORE INTO configuration VALUES ('Network', 'DEFAULT', 'management-server', 'network.loadbalancer.haproxy.stats.auth','admin1:AdMiN123','Load Balancer(haproxy) authetication string in the format username:password');
|
||||
INSERT IGNORE INTO configuration VALUES ('Network', 'DEFAULT', 'management-server', 'network.loadbalancer.haproxy.stats.port','8081','Load Balancer(haproxy) stats port number.');
|
||||
|
||||
UPDATE `cloud`.`nics` SET strategy='Start' where reserver_name='DirectPodBasedNetworkGuru';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user