From d7ec734b01ab05da905356abbd542d68b5fa0e68 Mon Sep 17 00:00:00 2001 From: alena Date: Thu, 21 Apr 2011 11:58:17 -0700 Subject: [PATCH] bug 9481: deployVm with Guest Virtual network - throw an exception when fail to acquire guest Ip address status 9481: resolved fixed --- .../com/cloud/network/guru/GuestNetworkGuru.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/server/src/com/cloud/network/guru/GuestNetworkGuru.java b/server/src/com/cloud/network/guru/GuestNetworkGuru.java index b4993093a14..de9dd38cebd 100644 --- a/server/src/com/cloud/network/guru/GuestNetworkGuru.java +++ b/server/src/com/cloud/network/guru/GuestNetworkGuru.java @@ -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