cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prachida...@apache.org
Subject [09/50] [abbrv] git commit: updated refs/heads/planner_reserve to 9b86516
Date Sun, 05 May 2013 07:59:34 GMT
CLOUDSTACK-1828 Source Nat on private gateway feature


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

Branch: refs/heads/planner_reserve
Commit: 1f1467974f77901bcde0c1c52ac4286185dcc333
Parents: 101d89c
Author: Jayapal <jayapalreddy.uradi@citrix.com>
Authored: Thu May 2 15:24:21 2013 +0530
Committer: Murali Reddy <murali.reddy@citrix.com>
Committed: Thu May 2 15:40:15 2013 +0530

----------------------------------------------------------------------
 api/src/com/cloud/network/NetworkService.java      |    4 ++-
 api/src/com/cloud/network/vpc/PrivateIp.java       |    1 +
 api/src/com/cloud/network/vpc/VpcGateway.java      |    4 +++
 api/src/com/cloud/network/vpc/VpcService.java      |    4 ++-
 .../command/admin/vpc/CreatePrivateGatewayCmd.java |   14 ++++++++++-
 .../api/response/PrivateGatewayResponse.java       |   10 ++++++++
 .../virtualnetwork/VirtualRoutingResource.java     |   15 +++++++++++-
 .../config/opt/cloud/bin/vpc_privateGateway.sh     |    2 +-
 .../kvm/resource/LibvirtComputingResource.java     |    2 +-
 .../hypervisor/vmware/resource/VmwareResource.java |   19 +++++++++++++++
 .../xen/resource/CitrixResourceBase.java           |   14 +++++++++++
 server/src/com/cloud/api/ApiResponseHelper.java    |    1 +
 .../src/com/cloud/network/NetworkServiceImpl.java  |    6 ++--
 .../VpcVirtualNetworkApplianceManagerImpl.java     |    4 +-
 .../cloud/network/vpc/PrivateGatewayProfile.java   |    5 ++++
 .../com/cloud/network/vpc/PrivateIpAddress.java    |    7 +++++
 server/src/com/cloud/network/vpc/PrivateIpVO.java  |   12 ++++++++-
 server/src/com/cloud/network/vpc/VpcGatewayVO.java |   16 ++++++++++--
 .../src/com/cloud/network/vpc/VpcManagerImpl.java  |    8 +++---
 .../com/cloud/network/MockNetworkManagerImpl.java  |   12 +--------
 .../test/com/cloud/vpc/MockNetworkManagerImpl.java |   12 +--------
 server/test/com/cloud/vpc/MockVpcManagerImpl.java  |    2 +-
 setup/db/db/schema-410to420.sql                    |    3 ++
 23 files changed, 136 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f146797/api/src/com/cloud/network/NetworkService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/NetworkService.java b/api/src/com/cloud/network/NetworkService.java
index 6c9bebc..bea92dc 100755
--- a/api/src/com/cloud/network/NetworkService.java
+++ b/api/src/com/cloud/network/NetworkService.java
@@ -138,6 +138,7 @@ public interface NetworkService {
         ResourceAllocationException, ResourceUnavailableException, ConcurrentOperationException;
 
     /**
+     *
      * @param networkName
      * @param displayText
      * @param physicalNetworkId
@@ -148,13 +149,14 @@ public interface NetworkService {
      * @param netmask
      * @param networkOwnerId
      * @param vpcId TODO
+     * @param sourceNat
      * @return
      * @throws InsufficientCapacityException
      * @throws ConcurrentOperationException
      * @throws ResourceAllocationException
      */
     Network createPrivateNetwork(String networkName, String displayText, long physicalNetworkId,
String vlan,
-            String startIp, String endIP, String gateway, String netmask, long networkOwnerId,
Long vpcId)
+                                 String startIp, String endIP, String gateway, String netmask,
long networkOwnerId, Long vpcId, Boolean sourceNat)
                     throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException;
 
     /* Requests an IP address for the guest nic */

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f146797/api/src/com/cloud/network/vpc/PrivateIp.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/vpc/PrivateIp.java b/api/src/com/cloud/network/vpc/PrivateIp.java
index 857fc22..eb68433 100644
--- a/api/src/com/cloud/network/vpc/PrivateIp.java
+++ b/api/src/com/cloud/network/vpc/PrivateIp.java
@@ -44,5 +44,6 @@ public interface PrivateIp {
     String getMacAddress();
 
     long getNetworkId();
+    boolean getSourceNat();
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f146797/api/src/com/cloud/network/vpc/VpcGateway.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/vpc/VpcGateway.java b/api/src/com/cloud/network/vpc/VpcGateway.java
index 1756616..e3530d0 100644
--- a/api/src/com/cloud/network/vpc/VpcGateway.java
+++ b/api/src/com/cloud/network/vpc/VpcGateway.java
@@ -77,4 +77,8 @@ public interface VpcGateway extends Identity, ControlledEntity, InternalIdentity
      * @return
      */
     State getState();
+    /**
+     * @return
+     */
+    boolean getSourceNat();
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f146797/api/src/com/cloud/network/vpc/VpcService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/vpc/VpcService.java b/api/src/com/cloud/network/vpc/VpcService.java
index 07ce89b..23e2764 100644
--- a/api/src/com/cloud/network/vpc/VpcService.java
+++ b/api/src/com/cloud/network/vpc/VpcService.java
@@ -163,6 +163,7 @@ public interface VpcService {
     /**
      * Persists VPC private gateway in the Database.
      * 
+     *
      * @param vpcId TODO
      * @param physicalNetworkId
      * @param vlan
@@ -170,13 +171,14 @@ public interface VpcService {
      * @param gateway
      * @param netmask
      * @param gatewayOwnerId
+     * @param isSourceNat
      * @return
      * @throws InsufficientCapacityException
      * @throws ConcurrentOperationException
      * @throws ResourceAllocationException
      */
     public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId, String
vlan, String ipAddress,
-            String gateway, String netmask, long gatewayOwnerId) throws ResourceAllocationException,
+                                                  String gateway, String netmask, long gatewayOwnerId,
Boolean isSourceNat) throws ResourceAllocationException,
             ConcurrentOperationException, InsufficientCapacityException;
 
     /**

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f146797/api/src/org/apache/cloudstack/api/command/admin/vpc/CreatePrivateGatewayCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/vpc/CreatePrivateGatewayCmd.java
b/api/src/org/apache/cloudstack/api/command/admin/vpc/CreatePrivateGatewayCmd.java
index 9fd736f..2055695 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/vpc/CreatePrivateGatewayCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/vpc/CreatePrivateGatewayCmd.java
@@ -69,6 +69,11 @@ public class CreatePrivateGatewayCmd extends BaseAsyncCreateCmd {
             required=true, description="the VPC network belongs to")
     private Long vpcId;
 
+    @Parameter(name=ApiConstants.SOURCE_NAT_SUPPORTED, type=CommandType.BOOLEAN, required=false,
+            description="source NAT supported value. Default value false. If 'true' source
NAT is enabled on the private gateway" +
+                    " 'false': sourcenat is not supported")
+    private Boolean isSourceNat;
+
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
@@ -97,6 +102,13 @@ public class CreatePrivateGatewayCmd extends BaseAsyncCreateCmd {
         return vpcId;
     }
 
+    public Boolean getIsSourceNat () {
+        if (isSourceNat == null) {
+            return false;
+        }
+        return true;
+    }
+
     /////////////////////////////////////////////////////
     /////////////// API Implementation///////////////////
     /////////////////////////////////////////////////////
@@ -111,7 +123,7 @@ public class CreatePrivateGatewayCmd extends BaseAsyncCreateCmd {
         PrivateGateway result = null;
         try {
             result = _vpcService.createVpcPrivateGateway(getVpcId(), getPhysicalNetworkId(),
-                    getVlan(), getStartIp(), getGateway(), getNetmask(), getEntityOwnerId());
+                    getVlan(), getStartIp(), getGateway(), getNetmask(), getEntityOwnerId(),
getIsSourceNat());
         } catch (InsufficientCapacityException ex){
             s_logger.info(ex);
             s_logger.trace(ex);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f146797/api/src/org/apache/cloudstack/api/response/PrivateGatewayResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/PrivateGatewayResponse.java b/api/src/org/apache/cloudstack/api/response/PrivateGatewayResponse.java
index 4123477..ca76062 100644
--- a/api/src/org/apache/cloudstack/api/response/PrivateGatewayResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/PrivateGatewayResponse.java
@@ -76,6 +76,10 @@ public class PrivateGatewayResponse extends BaseResponse implements ControlledEn
     private String state;
 
 
+    @SerializedName(ApiConstants.SOURCE_NAT_SUPPORTED) @Param(description = "Souce Nat enable
status")
+    private Boolean sourceNat;
+
+
     @Override
     public String getObjectId() {
         return this.id;
@@ -145,5 +149,11 @@ public class PrivateGatewayResponse extends BaseResponse implements ControlledEn
     public void setState(String state) {
         this.state = state;
     }
+
+    public void setSourceNat(Boolean sourceNat) {
+        this.sourceNat = sourceNat;
+    }
+
+
 }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f146797/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
index 7148e07..b9bda4d 100755
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -863,13 +863,16 @@ public class VirtualRoutingResource implements Manager {
     }
 
     public void assignVpcIpToRouter(final String routerIP, final boolean add, final String
pubIP,
-            final String nicname, final String gateway, final String netmask, final String
subnet) throws InternalErrorException {
+                                    final String nicname, final String gateway, final String
netmask, final String subnet, boolean sourceNat) throws InternalErrorException {
         String args = "";
+        String snatArgs = "";
 
         if (add) {
             args += " -A ";
+            snatArgs += " -A ";
         } else {
             args += " -D ";
+            snatArgs += " -D ";
         }
 
         args += " -l ";
@@ -887,6 +890,16 @@ public class VirtualRoutingResource implements Manager {
         if (result != null) {
             throw new InternalErrorException("KVM plugin \"vpc_ipassoc\" failed:"+result);
         }
+        if (sourceNat) {
+            snatArgs += " -l " + pubIP;
+            snatArgs += " -c " + nicname;
+
+            result = routerProxy("vpc_privateGateway.sh", routerIP, snatArgs);
+            if (result != null) {
+                throw new InternalErrorException("KVM plugin \"vpc_privateGateway\" failed:"+result);
+            }
+
+        }
     }
 
     private SetStaticRouteAnswer execute(SetStaticRouteCommand cmd) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f146797/patches/systemvm/debian/config/opt/cloud/bin/vpc_privateGateway.sh
----------------------------------------------------------------------
diff --git a/patches/systemvm/debian/config/opt/cloud/bin/vpc_privateGateway.sh b/patches/systemvm/debian/config/opt/cloud/bin/vpc_privateGateway.sh
index a09d8f7..3635e1c 100755
--- a/patches/systemvm/debian/config/opt/cloud/bin/vpc_privateGateway.sh
+++ b/patches/systemvm/debian/config/opt/cloud/bin/vpc_privateGateway.sh
@@ -91,7 +91,7 @@ fi
 
 if [ "$Dflag" == "1" ]
 then
-  remove_sat  $publicIp
+  remove_snat  $publicIp
   unlock_exit $? $lock $locked
 fi
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f146797/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index 0064edf..8fe8c88 100755
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -1756,7 +1756,7 @@ ServerResource {
                 String netmask = Long.toString(NetUtils.getCidrSize(ip.getVlanNetmask()));
                 String subnet = NetUtils.getSubNet(ip.getPublicIp(), ip.getVlanNetmask());
                 _virtRouterResource.assignVpcIpToRouter(routerIP, ip.isAdd(), ip.getPublicIp(),
-                        nicName, ip.getVlanGateway(), netmask, subnet);
+                        nicName, ip.getVlanGateway(), netmask, subnet, ip.isSourceNat());
                 results[i++] = ip.getPublicIp() + " - success";
             }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f146797/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index 38c9f86..28a54e1 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -1441,10 +1441,14 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
         }
 
         String args = "";
+        String snatArgs = "";
+
         if (ip.isAdd()) {
             args += " -A ";
+            snatArgs += " -A ";
         } else {
             args += " -D ";
+            snatArgs += " -D ";
         }
 
         args += " -l ";
@@ -1468,6 +1472,21 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
         if (!result.first()) {
             throw new InternalErrorException("Unable to assign public IP address");
         }
+
+        if (ip.isSourceNat()) {
+            snatArgs += " -l ";
+            snatArgs += ip.getPublicIp();
+            snatArgs += " -c ";
+            snatArgs += "eth" + ethDeviceNum;
+
+            Pair<Boolean, String> result = SshHelper.sshExecute(routerIp, DEFAULT_DOMR_SSHPORT,
"root", mgr.getSystemVMKeyFile(), null,
+                    "/opt/cloud/bin/vpc_privateGateway.sh " + args);
+
+            if (!result.first()) {
+                throw new InternalErrorException("Unable to assign public IP address");
+            }
+
+        }
     }
 
     protected void assignPublicIpAddress(VirtualMachineMO vmMo, final String vmName, final
String privateIpAddress, final String publicIpAddress, final boolean add, final boolean firstIP,

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f146797/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
index 46ae35a..bac361d 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
@@ -2217,11 +2217,14 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
             }           
 
             String args = "vpc_ipassoc.sh " + routerIp;
+            String snatArgs = "vpc_privateGateway.sh " + routerIp;
 
             if (ip.isAdd()) {
                 args += " -A ";
+                snatArgs += " -A ";
             } else {
                 args += " -D ";
+                snatArgs+= " -D ";
             }
 
             args += " -l ";
@@ -2244,6 +2247,17 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
             if (result == null || result.isEmpty()) {
                 throw new InternalErrorException("Xen plugin \"vpc_ipassoc\" failed.");
             }
+
+            if (ip.isSourceNat()) {
+                snatArgs += " -l " + ip.getPublicIp();
+                snatArgs += " -c " + "eth" + correctVif.getDevice(conn);
+
+                result = callHostPlugin(conn, "vmops", "routerProxy", "args", snatArgs);
+                if (result == null || result.isEmpty()) {
+                    throw new InternalErrorException("Xen plugin \"vcp_privateGateway\" failed.");
+                }
+            }
+
         } catch (Exception e) {
             String msg = "Unable to assign public IP address due to " + e.toString();
             s_logger.warn(msg, e);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f146797/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index 6090ff0..790c366 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -3120,6 +3120,7 @@ public class ApiResponseHelper implements ResponseGenerator {
         populateAccount(response, result.getAccountId());
         populateDomain(response, result.getDomainId());
         response.setState(result.getState().toString());
+        response.setSourceNat(result.getSourceNat());
 
         response.setObjectName("privategateway");
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f146797/server/src/com/cloud/network/NetworkServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java
index ae0e421..b2db06c 100755
--- a/server/src/com/cloud/network/NetworkServiceImpl.java
+++ b/server/src/com/cloud/network/NetworkServiceImpl.java
@@ -3308,8 +3308,8 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService
{
     
 
     @Override @DB
-    public Network createPrivateNetwork(String networkName, String displayText, long physicalNetworkId,

-            String vlan, String startIp, String endIp, String gateway, String netmask, long
networkOwnerId, Long vpcId) 
+    public Network createPrivateNetwork(String networkName, String displayText, long physicalNetworkId,
+                                        String vlan, String startIp, String endIp, String
gateway, String netmask, long networkOwnerId, Long vpcId, Boolean sourceNat)
                     throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException
{
         
         Account owner = _accountMgr.getAccount(networkOwnerId);
@@ -3377,7 +3377,7 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService
{
         Long nextMac = mac + 1;
         dc.setMacAddress(nextMac);
 
-        privateIp = new PrivateIpVO(startIp, privateNetwork.getId(), nextMac, vpcId);
+        privateIp = new PrivateIpVO(startIp, privateNetwork.getId(), nextMac, vpcId, sourceNat);
         _privateIpDao.persist(privateIp);
         
         _dcDao.update(dc.getId(), dc);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f146797/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
index bdfac06..ebf2d42 100644
--- a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
@@ -1178,8 +1178,8 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
 
             for (final PrivateIpAddress ipAddr : ipAddrList) {
                 Network network = _networkModel.getNetwork(ipAddr.getNetworkId());
-                IpAddressTO ip = new IpAddressTO(Account.ACCOUNT_ID_SYSTEM, ipAddr.getIpAddress(),
add, false, 
-                        false, ipAddr.getVlanTag(), ipAddr.getGateway(), ipAddr.getNetmask(),
ipAddr.getMacAddress(),
+                IpAddressTO ip = new IpAddressTO(Account.ACCOUNT_ID_SYSTEM, ipAddr.getIpAddress(),
add, false,
+                        ipAddr.getSourceNat(), ipAddr.getVlanTag(), ipAddr.getGateway(),
ipAddr.getNetmask(), ipAddr.getMacAddress(),
                         null, false);
 
                 ip.setTrafficType(network.getTrafficType());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f146797/server/src/com/cloud/network/vpc/PrivateGatewayProfile.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/PrivateGatewayProfile.java b/server/src/com/cloud/network/vpc/PrivateGatewayProfile.java
index 2595a6a..20947db 100644
--- a/server/src/com/cloud/network/vpc/PrivateGatewayProfile.java
+++ b/server/src/com/cloud/network/vpc/PrivateGatewayProfile.java
@@ -100,4 +100,9 @@ public class PrivateGatewayProfile implements PrivateGateway {
     public State getState() {
         return vpcGateway.getState();
     }
+
+    @Override
+    public boolean getSourceNat() {
+        return vpcGateway.getSourceNat();
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f146797/server/src/com/cloud/network/vpc/PrivateIpAddress.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/PrivateIpAddress.java b/server/src/com/cloud/network/vpc/PrivateIpAddress.java
index 826bea2..2f3cf53 100644
--- a/server/src/com/cloud/network/vpc/PrivateIpAddress.java
+++ b/server/src/com/cloud/network/vpc/PrivateIpAddress.java
@@ -25,6 +25,7 @@ public class PrivateIpAddress implements PrivateIp{
     String ipAddress;
     String macAddress;
     long networkId;
+    boolean sourceNat;
     
     /**
      * @param privateIp
@@ -42,6 +43,7 @@ public class PrivateIpAddress implements PrivateIp{
         this.netmask = netmask;
         this.macAddress = macAddress;
         this.networkId = privateIp.getNetworkId();
+        this.sourceNat = privateIp.getSourceNat();
     }
 
     @Override
@@ -73,4 +75,9 @@ public class PrivateIpAddress implements PrivateIp{
     public long getNetworkId() {
         return networkId;
     }
+
+    @Override
+    public boolean getSourceNat() {
+        return sourceNat;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f146797/server/src/com/cloud/network/vpc/PrivateIpVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/PrivateIpVO.java b/server/src/com/cloud/network/vpc/PrivateIpVO.java
index e6616ae..952a0c2 100644
--- a/server/src/com/cloud/network/vpc/PrivateIpVO.java
+++ b/server/src/com/cloud/network/vpc/PrivateIpVO.java
@@ -54,15 +54,19 @@ public class PrivateIpVO implements InternalIdentity {
     
     @Column(name="vpc_id")
     private Long vpcId;
+
+    @Column(name="source_nat")
+    private boolean sourceNat;
     
     public PrivateIpVO() {
-    } 
+    }
 
-    public PrivateIpVO(String ipAddress, long networkId, long macAddress, long vpcId) {
+    public PrivateIpVO(String ipAddress, long networkId, long macAddress, long vpcId, boolean
sourceNat) {
         this.ipAddress = ipAddress;
         this.networkId = networkId;
         this.macAddress = macAddress;
         this.vpcId = vpcId;
+        this.sourceNat = sourceNat;
     }
     
     public void setTakenAt(Date takenDate) {
@@ -92,4 +96,8 @@ public class PrivateIpVO implements InternalIdentity {
     public Long getVpcId() {
         return vpcId;
     }
+    public boolean getSourceNat() {
+        return sourceNat;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f146797/server/src/com/cloud/network/vpc/VpcGatewayVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/VpcGatewayVO.java b/server/src/com/cloud/network/vpc/VpcGatewayVO.java
index 718e4df..e8dcb46 100644
--- a/server/src/com/cloud/network/vpc/VpcGatewayVO.java
+++ b/server/src/com/cloud/network/vpc/VpcGatewayVO.java
@@ -29,7 +29,6 @@ import javax.persistence.Id;
 import javax.persistence.Table;
 
 import com.cloud.utils.db.GenericDao;
-import org.apache.cloudstack.api.InternalIdentity;
 
 
 @Entity
@@ -84,7 +83,10 @@ public class VpcGatewayVO implements VpcGateway {
     @Column(name="state")
     @Enumerated(value=EnumType.STRING)
     State state;
-    
+
+    @Column(name="source_nat")
+    boolean sourceNat;
+
     protected VpcGatewayVO(){
         this.uuid = UUID.randomUUID().toString();
     }
@@ -101,9 +103,10 @@ public class VpcGatewayVO implements VpcGateway {
      * @param accountId TODO
      * @param domainId TODO
      * @param account_id
+     * @param sourceNat
      */
     public VpcGatewayVO(String ip4Address, Type type, Long vpcId, long zoneId, Long networkId,
String vlanTag, 
-            String gateway, String netmask, long accountId, long domainId) {
+            String gateway, String netmask, long accountId, long domainId, boolean sourceNat)
{
         this.ip4Address = ip4Address;
         this.type = type;
         this.vpcId = vpcId;
@@ -116,6 +119,7 @@ public class VpcGatewayVO implements VpcGateway {
         this.accountId = accountId;
         this.domainId = domainId;
         this.state = State.Creating;
+        this.sourceNat = sourceNat;
     }
 
     @Override
@@ -193,4 +197,10 @@ public class VpcGatewayVO implements VpcGateway {
     public void setState(State state) {
         this.state = state;
     }
+
+    @Override
+    public boolean getSourceNat() {
+        return this.sourceNat;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f146797/server/src/com/cloud/network/vpc/VpcManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
index bc7bb0c..a7f06e9 100644
--- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
@@ -1285,8 +1285,8 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
     @Override
     @DB
     @ActionEvent(eventType = EventTypes.EVENT_PRIVATE_GATEWAY_CREATE, eventDescription =
"creating vpc private gateway", create=true)
-    public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId, String
vlan, String ipAddress, 
-            String gateway, String netmask, long gatewayOwnerId) throws ResourceAllocationException,

+    public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId, String
vlan, String ipAddress,
+                                                  String gateway, String netmask, long gatewayOwnerId,
Boolean isSourceNat) throws ResourceAllocationException,
             ConcurrentOperationException, InsufficientCapacityException {
         
         //Validate parameters
@@ -1312,11 +1312,11 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
         //1) create private network
         String networkName = "vpc-" + vpc.getName() + "-privateNetwork";
         Network privateNtwk = _ntwkSvc.createPrivateNetwork(networkName, networkName, physicalNetworkId,

-                vlan, ipAddress, null, gateway, netmask, gatewayOwnerId, vpcId);
+                vlan, ipAddress, null, gateway, netmask, gatewayOwnerId, vpcId, isSourceNat);
         
         //2) create gateway entry
         VpcGatewayVO gatewayVO = new VpcGatewayVO(ipAddress, VpcGateway.Type.Private, vpcId,
privateNtwk.getDataCenterId(),
-                privateNtwk.getId(), vlan, gateway, netmask, vpc.getAccountId(), vpc.getDomainId());
+                privateNtwk.getId(), vlan, gateway, netmask, vpc.getAccountId(), vpc.getDomainId(),
isSourceNat);
         _vpcGatewayDao.persist(gatewayVO);
         
         s_logger.debug("Created vpc gateway entry " + gatewayVO);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f146797/server/test/com/cloud/network/MockNetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/network/MockNetworkManagerImpl.java b/server/test/com/cloud/network/MockNetworkManagerImpl.java
index e9987bd..45562c6 100755
--- a/server/test/com/cloud/network/MockNetworkManagerImpl.java
+++ b/server/test/com/cloud/network/MockNetworkManagerImpl.java
@@ -43,16 +43,8 @@ import com.cloud.user.Account;
 import com.cloud.user.User;
 import com.cloud.utils.Pair;
 import com.cloud.utils.component.ManagerBase;
-import com.cloud.vm.Nic;
-import com.cloud.vm.NicProfile;
-import com.cloud.vm.NicSecondaryIp;
-import com.cloud.vm.NicVO;
-import com.cloud.vm.ReservationContext;
-import com.cloud.vm.VMInstanceVO;
-import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.*;
 import com.cloud.vm.VirtualMachine.Type;
-import com.cloud.vm.VirtualMachineProfile;
-import com.cloud.vm.VirtualMachineProfileImpl;
 import org.apache.cloudstack.acl.ControlledEntity.ACLType;
 import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
 import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd;
@@ -604,7 +596,7 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkManage
      */
     @Override
     public Network createPrivateNetwork(String networkName, String displayText, long physicalNetworkId,
String vlan,
-            String startIp, String endIP, String gateway, String netmask, long networkOwnerId,
Long vpcId)
+                                        String startIp, String endIP, String gateway, String
netmask, long networkOwnerId, Long vpcId, Boolean sourceNat)
                     throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException
{
         // TODO Auto-generated method stub
         return null;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f146797/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
index 9b18358..6689357 100644
--- a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
+++ b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
@@ -47,16 +47,8 @@ import com.cloud.user.Account;
 import com.cloud.user.User;
 import com.cloud.utils.Pair;
 import com.cloud.utils.component.ManagerBase;
-import com.cloud.vm.Nic;
-import com.cloud.vm.NicProfile;
-import com.cloud.vm.NicSecondaryIp;
-import com.cloud.vm.NicVO;
-import com.cloud.vm.ReservationContext;
-import com.cloud.vm.VMInstanceVO;
-import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.*;
 import com.cloud.vm.VirtualMachine.Type;
-import com.cloud.vm.VirtualMachineProfile;
-import com.cloud.vm.VirtualMachineProfileImpl;
 import org.apache.cloudstack.acl.ControlledEntity.ACLType;
 import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
 import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd;
@@ -609,7 +601,7 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkManage
      */
     @Override
     public Network createPrivateNetwork(String networkName, String displayText, long physicalNetworkId,
String vlan,
-            String startIp, String endIP, String gateway, String netmask, long networkOwnerId,
Long vpcId)
+                                        String startIp, String endIP, String gateway, String
netmask, long networkOwnerId, Long vpcId, Boolean sourceNat)
             throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException
{
         // TODO Auto-generated method stub
         return null;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f146797/server/test/com/cloud/vpc/MockVpcManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/MockVpcManagerImpl.java b/server/test/com/cloud/vpc/MockVpcManagerImpl.java
index 0f26928..baccbd0 100644
--- a/server/test/com/cloud/vpc/MockVpcManagerImpl.java
+++ b/server/test/com/cloud/vpc/MockVpcManagerImpl.java
@@ -164,7 +164,7 @@ public class MockVpcManagerImpl extends ManagerBase implements VpcManager
{
      * @see com.cloud.network.vpc.VpcService#createVpcPrivateGateway(long, java.lang.Long,
java.lang.String, java.lang.String, java.lang.String, java.lang.String, long)
      */
     @Override
-    public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId, String
vlan, String ipAddress, String gateway, String netmask, long gatewayOwnerId) throws ResourceAllocationException,
+    public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId, String
vlan, String ipAddress, String gateway, String netmask, long gatewayOwnerId, Boolean isSourceNat)
throws ResourceAllocationException,
     ConcurrentOperationException, InsufficientCapacityException {
         // TODO Auto-generated method stub
         return null;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f146797/setup/db/db/schema-410to420.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql
index 69bf886..99b476d 100644
--- a/setup/db/db/schema-410to420.sql
+++ b/setup/db/db/schema-410to420.sql
@@ -1123,3 +1123,6 @@ ALTER TABLE `cloud`.`account_details` MODIFY value varchar(255);
 
 INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server',
'midonet.apiserver.address', 'http://localhost:8081', 'Specify the address at which the Midonet
API server can be contacted (if using Midonet)');
 INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server',
'midonet.providerrouter.id', 'd7c5e6a3-e2f4-426b-b728-b7ce6a0448e5', 'Specifies the UUID of
the Midonet provider router (if using Midonet)');
+
+alter table cloud.vpc_gateways add column source_nat boolean default false;
+alter table cloud.private_ip_address add column source_nat boolean default false;


Mime
View raw message