bug 9481: deployVm with Guest Virtual network - throw an exception when fail to acquire guest Ip address

status 9481: resolved fixed
This commit is contained in:
alena 2011-04-21 11:58:17 -07:00
parent c844655825
commit d7ec734b01
1 changed files with 11 additions and 3 deletions

View File

@ -186,7 +186,13 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
nic.setBroadcastUri(network.getBroadcastUri());
nic.setIsolationUri(network.getBroadcastUri());
nic.setGateway(network.getGateway());
nic.setIp4Address(acquireGuestIpAddress(network));
String guestIp = acquireGuestIpAddress(network);
if (guestIp == null) {
throw new InsufficientVirtualNetworkCapcityException("Unable to acquire guest IP address for network " + network, DataCenter.class, dc.getId());
}
nic.setIp4Address(guestIp);
nic.setNetmask(NetUtils.cidr2Netmask(network.getCidr()));
nic.setFormat(AddressFormat.Ip4);
@ -253,8 +259,10 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
@Override
public void shutdown(NetworkProfile profile, NetworkOffering offering) {
s_logger.debug("Releasing vnet for the network id=" + profile.getId());
_dcDao.releaseVnet(profile.getBroadcastUri().getHost(), profile.getDataCenterId(), profile.getAccountId(), profile.getReservationId());
profile.setBroadcastUri(null);
if (profile.getBroadcastUri() != null) {
_dcDao.releaseVnet(profile.getBroadcastUri().getHost(), profile.getDataCenterId(), profile.getAccountId(), profile.getReservationId());
profile.setBroadcastUri(null);
}
}
@Override