From 81e7b25217f1655fb2983e5454745237582faf8f Mon Sep 17 00:00:00 2001 From: alena Date: Wed, 27 Apr 2011 11:15:30 -0700 Subject: [PATCH] Fixed ipAssoc in Basic zone (elastic IP) --- server/src/com/cloud/network/NetworkManagerImpl.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index 905204f5f4a..37d217b7133 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -501,8 +501,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag _accountMgr.checkAccess(caller, ipOwner); + DataCenterVO zone = null; if (zoneId != null) { - DataCenterVO zone = _dcDao.findById(zoneId); + zone = _dcDao.findById(zoneId); if (zone == null) { throw new InvalidParameterValueException("Can't find zone by id " + zoneId); } @@ -521,8 +522,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } } - // Check that network belongs to IP owner - if (network.getAccountId() != ipOwner.getId()) { + // Check that network belongs to IP owner - skip this check for Basic zone as there is just one guest network, and it + // belongs to the system + if (zone.getNetworkType() != NetworkType.Basic && network.getAccountId() != ipOwner.getId()) { throw new InvalidParameterValueException("The owner of the network is not the same as owner of the IP"); } @@ -555,10 +557,10 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag boolean isSourceNat = false; txn.start(); - // First IP address should be source nat + // First IP address should be source nat when it's being associated with Guest Virtual network List addrs = listPublicIpAddressesInVirtualNetwork(ownerId, zoneId, true, networkId); - if (addrs.isEmpty()) { + if (addrs.isEmpty() && network.getGuestType() == GuestIpType.Virtual) { isSourceNat = true; }