You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by Daan Hoogland <da...@gmail.com> on 2014/05/08 23:34:41 UTC

create gateway network without reference to vpc

Jayapal,

I am trying to create the vpc gateway network so that the external
gateway ip won't be assigned to the gateway interface on the vpc
router. the simplest way caused a regression I am sure you are aware
of. Another way is to set the vpc on the network to null after
creation. This doesn't seem right to me either. the third option is to
create a lot of code to mimic the network creation code. This in turn
is a lot of code duplication so not really the way to go either. Here
is what I came up with tonight:

diff --git a/engine/schema/src/com/cloud/network/dao/NetworkVO.java
b/engine/schema/src/com/cloud/network/dao/NetworkVO.java
index 6bb3902..3194345 100644
--- a/engine/schema/src/com/cloud/network/dao/NetworkVO.java
+++ b/engine/schema/src/com/cloud/network/dao/NetworkVO.java
@@ -600,4 +600,8 @@ public class NetworkVO implements Network {
     public void setStrechedL2Network(boolean strechedL2Network) {
         this.strechedL2Network = strechedL2Network;
     }
+
+    public void setVpcId(long vpcId) {
+        this.vpcId = vpcId;
+    }
 }
diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
index 29e621a..35b787e 100644
--- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
@@ -1626,6 +1626,14 @@ public class VpcManagerImpl extends ManagerBase
implements VpcManager, VpcProvis
             networkAclId = aclId;
         }

+        {   // experimental block
+            // set vpc id in network to null
+            // might be needed for all types of networks
+            NetworkVO gatewaynet = _ntwkDao.findById(privateNtwk.getId());
+            gatewaynet.setVpcId(vpcId);
+            _ntwkDao.persist(gatewaynet);
+        }
+
         //2) create gateway entry
                     VpcGatewayVO gatewayVO =
                         new VpcGatewayVO(ipAddress,
VpcGateway.Type.Private, vpcId, privateNtwk.getDataCenterId(),
privateNtwk.getId(), broadcastUri, gateway, netmask,

I think it stinks so if anyone can please give me directions to an
alternative? The privategateway network of a vpc should not be
associated with the vpc as it is not one of its guest networks. It is
a network the vpc is guest to.

-- 
Daan