cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sate...@apache.org
Subject [02/50] [abbrv] git commit: updated refs/heads/vmware-datamodel to 6a8c2bd
Date Fri, 31 May 2013 07:49:00 GMT
CLOUDSTACK-2719: Additional public IP is getting acquired during Cisco VNMc provider Guest
Network restart (cleanup=true)
An extra public ip is acquired while implementing the vnmc element as there is a limitation
where in the source nat cannot be used as asa outside ip.
As a result of this when the network gets re-implemented an additional ip is acquired every
time. The fix involves checking for existing public ips
in the network and reuse it in case it is not a source nat ip for assigning to asa outside
interface.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/84d904ab
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/84d904ab
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/84d904ab

Branch: refs/heads/vmware-datamodel
Commit: 84d904abf2e6e0616a47b338e588276530094d4e
Parents: 7fb6eaa
Author: Koushik Das <koushik.das@citrix.com>
Authored: Wed May 29 14:20:21 2013 +0530
Committer: Koushik Das <koushik.das@citrix.com>
Committed: Wed May 29 14:20:21 2013 +0530

----------------------------------------------------------------------
 .../cloud/network/element/CiscoVnmcElement.java    |   45 ++++++++++-----
 1 files changed, 30 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/84d904ab/plugins/network-elements/cisco-vnmc/src/com/cloud/network/element/CiscoVnmcElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/cisco-vnmc/src/com/cloud/network/element/CiscoVnmcElement.java
b/plugins/network-elements/cisco-vnmc/src/com/cloud/network/element/CiscoVnmcElement.java
index b335edb..9118bad 100644
--- a/plugins/network-elements/cisco-vnmc/src/com/cloud/network/element/CiscoVnmcElement.java
+++ b/plugins/network-elements/cisco-vnmc/src/com/cloud/network/element/CiscoVnmcElement.java
@@ -98,6 +98,8 @@ import com.cloud.network.cisco.NetworkAsa1000vMapVO;
 import com.cloud.network.dao.CiscoAsa1000vDao;
 import com.cloud.network.dao.CiscoNexusVSMDeviceDao;
 import com.cloud.network.dao.CiscoVnmcDao;
+import com.cloud.network.dao.IPAddressDao;
+import com.cloud.network.dao.IPAddressVO;
 import com.cloud.network.dao.NetworkAsa1000vMapDao;
 import com.cloud.network.dao.NetworkDao;
 import com.cloud.network.dao.PhysicalNetworkDao;
@@ -148,7 +150,9 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
     PhysicalNetworkDao _physicalNetworkDao;
     @Inject
     PhysicalNetworkServiceProviderDao _physicalNetworkServiceProviderDao;
-    @Inject 
+    @Inject
+    IPAddressDao _ipAddressDao;
+    @Inject
     HostDetailsDao _hostDetailsDao;
     @Inject
     HostDao _hostDao;
@@ -342,22 +346,33 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
             }
 
             // due to VNMC limitation of not allowing source NAT ip as the outside ip of
firewall,
-            // an additional public ip needs to acquired for assigning as firewall outside
ip
+            // an additional public ip needs to acquired for assigning as firewall outside
ip.
+            // In case there are already additional ip addresses available (network restart)
use one
+            // of them such that it is not the source NAT ip
             IpAddress outsideIp = null;
-            try {
-                Account caller = UserContext.current().getCaller();
-                long callerUserId = UserContext.current().getCallerUserId();
-                outsideIp = _networkMgr.allocateIp(owner, false, caller, callerUserId, zone);
-            } catch (ResourceAllocationException e) {
-                s_logger.error("Unable to allocate additional public Ip address. Exception
details " + e);
-                return false;
+            List<IPAddressVO> publicIps = _ipAddressDao.listByAssociatedNetwork(network.getId(),
null);
+            for (IPAddressVO ip : publicIps) {
+                if (!ip.isSourceNat()) {
+                    outsideIp = ip;
+                    break;
+                }
             }
-
-            try {
-                outsideIp = _networkMgr.associateIPToGuestNetwork(outsideIp.getId(), network.getId(),
true);
-            } catch (ResourceAllocationException e) {
-                s_logger.error("Unable to assign allocated additional public Ip " + outsideIp.getAddress().addr()
+ " to network with vlan " + vlanId + ". Exception details " + e);
-                return false;
+            if (outsideIp == null) { // none available, acquire one
+                try {
+                    Account caller = UserContext.current().getCaller();
+                    long callerUserId = UserContext.current().getCallerUserId();
+                    outsideIp = _networkMgr.allocateIp(owner, false, caller, callerUserId,
zone);
+                } catch (ResourceAllocationException e) {
+                    s_logger.error("Unable to allocate additional public Ip address. Exception
details " + e);
+                    return false;
+                }
+
+                try {
+                    outsideIp = _networkMgr.associateIPToGuestNetwork(outsideIp.getId(),
network.getId(), true);
+                } catch (ResourceAllocationException e) {
+                    s_logger.error("Unable to assign allocated additional public Ip " + outsideIp.getAddress().addr()
+ " to network with vlan " + vlanId + ". Exception details " + e);
+                    return false;
+                }
             }
 
             // create logical edge firewall in VNMC


Mime
View raw message