You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by al...@apache.org on 2012/08/12 22:20:34 UTC

[40/50] [abbrv] git commit: Name change for vpc/Dao package (dao is lowercased now)

Name change for vpc/Dao package (dao is lowercased now)


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

Branch: refs/heads/master
Commit: 057d6ccbb8ee3c5bc999448114756722e995cfc4
Parents: a5f99a2
Author: Alena Prokharchyk <al...@citrix.com>
Authored: Wed Aug 8 14:51:51 2012 -0700
Committer: Alena Prokharchyk <al...@citrix.com>
Committed: Wed Aug 8 14:51:51 2012 -0700

----------------------------------------------------------------------
 api/src/com/cloud/vm/PluggableNics.java            |   21 --
 awsapi.log.2012-07-25.gz                           |  Bin 1037 -> 0 bytes
 .../configuration/DefaultComponentLibrary.java     |   12 +-
 .../src/com/cloud/network/NetworkManagerImpl.java  |    2 +-
 .../com/cloud/network/RouterNetworkDaoImpl.java    |   60 ------
 .../cloud/network/dao/RouterNetworkDaoImpl.java    |   61 ++++++
 .../com/cloud/network/guru/PrivateNetworkGuru.java |    2 +-
 .../VpcVirtualNetworkApplianceManagerImpl.java     |    8 +-
 .../com/cloud/network/vpc/Dao/PrivateIpDao.java    |   75 -------
 .../cloud/network/vpc/Dao/PrivateIpDaoImpl.java    |  152 --------------
 .../com/cloud/network/vpc/Dao/StaticRouteDao.java  |   35 ----
 .../cloud/network/vpc/Dao/StaticRouteDaoImpl.java  |  115 -----------
 server/src/com/cloud/network/vpc/Dao/VpcDao.java   |   42 ----
 .../src/com/cloud/network/vpc/Dao/VpcDaoImpl.java  |  121 -----------
 .../com/cloud/network/vpc/Dao/VpcGatewayDao.java   |   26 ---
 .../cloud/network/vpc/Dao/VpcGatewayDaoImpl.java   |   60 ------
 .../com/cloud/network/vpc/Dao/VpcOfferingDao.java  |   32 ---
 .../cloud/network/vpc/Dao/VpcOfferingDaoImpl.java  |   69 -------
 .../network/vpc/Dao/VpcOfferingServiceMapDao.java  |   41 ----
 .../vpc/Dao/VpcOfferingServiceMapDaoImpl.java      |  117 -----------
 .../src/com/cloud/network/vpc/VpcManagerImpl.java  |   12 +-
 .../com/cloud/network/vpc/dao/PrivateIpDao.java    |   75 +++++++
 .../cloud/network/vpc/dao/PrivateIpDaoImpl.java    |  155 +++++++++++++++
 .../com/cloud/network/vpc/dao/StaticRouteDao.java  |   35 ++++
 .../cloud/network/vpc/dao/StaticRouteDaoImpl.java  |  115 +++++++++++
 server/src/com/cloud/network/vpc/dao/VpcDao.java   |   42 ++++
 .../src/com/cloud/network/vpc/dao/VpcDaoImpl.java  |  121 +++++++++++
 .../com/cloud/network/vpc/dao/VpcGatewayDao.java   |   26 +++
 .../cloud/network/vpc/dao/VpcGatewayDaoImpl.java   |   60 ++++++
 .../com/cloud/network/vpc/dao/VpcOfferingDao.java  |   32 +++
 .../cloud/network/vpc/dao/VpcOfferingDaoImpl.java  |   69 +++++++
 .../network/vpc/dao/VpcOfferingServiceMapDao.java  |   41 ++++
 .../vpc/dao/VpcOfferingServiceMapDaoImpl.java      |  117 +++++++++++
 .../cloud/network/vpn/Site2SiteVpnManagerImpl.java |    6 +-
 .../resourcelimit/ResourceLimitManagerImpl.java    |    2 +-
 .../com/cloud/tags/TaggedResourceManagerImpl.java  |    4 +-
 .../src/com/cloud/vm/dao/DomainRouterDaoImpl.java  |    2 +-
 37 files changed, 972 insertions(+), 993 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/api/src/com/cloud/vm/PluggableNics.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/vm/PluggableNics.java b/api/src/com/cloud/vm/PluggableNics.java
deleted file mode 100644
index d346230..0000000
--- a/api/src/com/cloud/vm/PluggableNics.java
+++ /dev/null
@@ -1,21 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.vm;
-
-public interface PluggableNics {
-    boolean canPlugNics();
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/awsapi.log.2012-07-25.gz
----------------------------------------------------------------------
diff --git a/awsapi.log.2012-07-25.gz b/awsapi.log.2012-07-25.gz
deleted file mode 100644
index 02fd067..0000000
Binary files a/awsapi.log.2012-07-25.gz and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/server/src/com/cloud/configuration/DefaultComponentLibrary.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/DefaultComponentLibrary.java b/server/src/com/cloud/configuration/DefaultComponentLibrary.java
index ecc7cee..4edd402 100755
--- a/server/src/com/cloud/configuration/DefaultComponentLibrary.java
+++ b/server/src/com/cloud/configuration/DefaultComponentLibrary.java
@@ -116,12 +116,12 @@ import com.cloud.network.security.dao.SecurityGroupWorkDaoImpl;
 import com.cloud.network.security.dao.VmRulesetLogDaoImpl;
 import com.cloud.network.vpc.NetworkACLManagerImpl;
 import com.cloud.network.vpc.VpcManagerImpl;
-import com.cloud.network.vpc.Dao.PrivateIpDaoImpl;
-import com.cloud.network.vpc.Dao.StaticRouteDaoImpl;
-import com.cloud.network.vpc.Dao.VpcDaoImpl;
-import com.cloud.network.vpc.Dao.VpcGatewayDaoImpl;
-import com.cloud.network.vpc.Dao.VpcOfferingDaoImpl;
-import com.cloud.network.vpc.Dao.VpcOfferingServiceMapDaoImpl;
+import com.cloud.network.vpc.dao.PrivateIpDaoImpl;
+import com.cloud.network.vpc.dao.StaticRouteDaoImpl;
+import com.cloud.network.vpc.dao.VpcDaoImpl;
+import com.cloud.network.vpc.dao.VpcGatewayDaoImpl;
+import com.cloud.network.vpc.dao.VpcOfferingDaoImpl;
+import com.cloud.network.vpc.dao.VpcOfferingServiceMapDaoImpl;
 import com.cloud.network.vpn.RemoteAccessVpnManagerImpl;
 import com.cloud.network.vpn.Site2SiteVpnManagerImpl;
 import com.cloud.offerings.dao.NetworkOfferingDaoImpl;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/server/src/com/cloud/network/NetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java
index 94c7738..58ef30c 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -161,7 +161,7 @@ import com.cloud.network.rules.dao.PortForwardingRulesDao;
 import com.cloud.network.vpc.NetworkACLManager;
 import com.cloud.network.vpc.PrivateIpVO;
 import com.cloud.network.vpc.VpcManager;
-import com.cloud.network.vpc.Dao.PrivateIpDao;
+import com.cloud.network.vpc.dao.PrivateIpDao;
 import com.cloud.network.vpn.RemoteAccessVpnService;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.offering.NetworkOffering.Availability;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/server/src/com/cloud/network/RouterNetworkDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/RouterNetworkDaoImpl.java b/server/src/com/cloud/network/RouterNetworkDaoImpl.java
deleted file mode 100644
index 0210ae9..0000000
--- a/server/src/com/cloud/network/RouterNetworkDaoImpl.java
+++ /dev/null
@@ -1,60 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network;
-
-import java.util.List;
-
-import com.cloud.utils.db.GenericDao;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.GenericSearchBuilder;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.SearchCriteria.Op;
-
-
-public class RouterNetworkDaoImpl extends GenericDaoBase<RouterNetworkVO, Long> implements GenericDao<RouterNetworkVO, Long>{
-    protected final GenericSearchBuilder<RouterNetworkVO, Long> RouterNetworksSearch;
-    protected final SearchBuilder<RouterNetworkVO> AllFieldsSearch;
-
-    public RouterNetworkDaoImpl() {
-        super();
-
-        RouterNetworksSearch = createSearchBuilder(Long.class);
-        RouterNetworksSearch.selectField(RouterNetworksSearch.entity().getNetworkId());
-        RouterNetworksSearch.and("routerId", RouterNetworksSearch.entity().getRouterId(), Op.EQ);
-        RouterNetworksSearch.done();
-        
-        AllFieldsSearch = createSearchBuilder();
-        AllFieldsSearch.and("routerId", AllFieldsSearch.entity().getRouterId(), Op.EQ);
-        AllFieldsSearch.and("networkId", AllFieldsSearch.entity().getNetworkId(), Op.EQ);
-        AllFieldsSearch.done();
-    }
-    
-    public List<Long> getRouterNetworks(long routerId) {
-        SearchCriteria<Long> sc = RouterNetworksSearch.create();
-        sc.setParameters("routerId", routerId);
-        return customSearch(sc, null);
-    }
-    
-    public RouterNetworkVO findByRouterAndNetwork (long routerId, long networkId) {
-        SearchCriteria<RouterNetworkVO> sc = AllFieldsSearch.create();
-        sc.setParameters("routerId", routerId);
-        sc.setParameters("networkId", networkId);
-        return findOneBy(sc);
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/server/src/com/cloud/network/dao/RouterNetworkDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/RouterNetworkDaoImpl.java b/server/src/com/cloud/network/dao/RouterNetworkDaoImpl.java
new file mode 100644
index 0000000..e1eed28
--- /dev/null
+++ b/server/src/com/cloud/network/dao/RouterNetworkDaoImpl.java
@@ -0,0 +1,61 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.network.dao;
+
+import java.util.List;
+
+import com.cloud.network.RouterNetworkVO;
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.GenericSearchBuilder;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria.Op;
+
+
+public class RouterNetworkDaoImpl extends GenericDaoBase<RouterNetworkVO, Long> implements GenericDao<RouterNetworkVO, Long>{
+    protected final GenericSearchBuilder<RouterNetworkVO, Long> RouterNetworksSearch;
+    protected final SearchBuilder<RouterNetworkVO> AllFieldsSearch;
+
+    public RouterNetworkDaoImpl() {
+        super();
+
+        RouterNetworksSearch = createSearchBuilder(Long.class);
+        RouterNetworksSearch.selectField(RouterNetworksSearch.entity().getNetworkId());
+        RouterNetworksSearch.and("routerId", RouterNetworksSearch.entity().getRouterId(), Op.EQ);
+        RouterNetworksSearch.done();
+        
+        AllFieldsSearch = createSearchBuilder();
+        AllFieldsSearch.and("routerId", AllFieldsSearch.entity().getRouterId(), Op.EQ);
+        AllFieldsSearch.and("networkId", AllFieldsSearch.entity().getNetworkId(), Op.EQ);
+        AllFieldsSearch.done();
+    }
+    
+    public List<Long> getRouterNetworks(long routerId) {
+        SearchCriteria<Long> sc = RouterNetworksSearch.create();
+        sc.setParameters("routerId", routerId);
+        return customSearch(sc, null);
+    }
+    
+    public RouterNetworkVO findByRouterAndNetwork (long routerId, long networkId) {
+        SearchCriteria<RouterNetworkVO> sc = AllFieldsSearch.create();
+        sc.setParameters("routerId", routerId);
+        sc.setParameters("networkId", networkId);
+        return findOneBy(sc);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/server/src/com/cloud/network/guru/PrivateNetworkGuru.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/guru/PrivateNetworkGuru.java b/server/src/com/cloud/network/guru/PrivateNetworkGuru.java
index 25502d4..9d4c9c3 100644
--- a/server/src/com/cloud/network/guru/PrivateNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/PrivateNetworkGuru.java
@@ -41,7 +41,7 @@ import com.cloud.network.Networks.Mode;
 import com.cloud.network.Networks.TrafficType;
 import com.cloud.network.vpc.PrivateIpAddress;
 import com.cloud.network.vpc.PrivateIpVO;
-import com.cloud.network.vpc.Dao.PrivateIpDao;
+import com.cloud.network.vpc.dao.PrivateIpDao;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.user.Account;
 import com.cloud.utils.component.AdapterBase;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/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 761b138..b1176a5 100644
--- a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
@@ -96,10 +96,10 @@ import com.cloud.network.vpc.StaticRouteProfile;
 import com.cloud.network.vpc.Vpc;
 import com.cloud.network.vpc.VpcGateway;
 import com.cloud.network.vpc.VpcManager;
-import com.cloud.network.vpc.Dao.PrivateIpDao;
-import com.cloud.network.vpc.Dao.StaticRouteDao;
-import com.cloud.network.vpc.Dao.VpcDao;
-import com.cloud.network.vpc.Dao.VpcOfferingDao;
+import com.cloud.network.vpc.dao.PrivateIpDao;
+import com.cloud.network.vpc.dao.StaticRouteDao;
+import com.cloud.network.vpc.dao.VpcDao;
+import com.cloud.network.vpc.dao.VpcOfferingDao;
 import com.cloud.network.vpn.Site2SiteVpnManager;
 import com.cloud.offerings.NetworkOfferingVO;
 import com.cloud.user.Account;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/server/src/com/cloud/network/vpc/Dao/PrivateIpDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/Dao/PrivateIpDao.java b/server/src/com/cloud/network/vpc/Dao/PrivateIpDao.java
deleted file mode 100644
index c58f68e..0000000
--- a/server/src/com/cloud/network/vpc/Dao/PrivateIpDao.java
+++ /dev/null
@@ -1,75 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.vpc.Dao;
-
-import java.util.List;
-
-import com.cloud.network.vpc.PrivateIpVO;
-import com.cloud.utils.db.GenericDao;
-
-public interface PrivateIpDao extends GenericDao<PrivateIpVO, Long>{
-
-    /**
-     * @param dcId
-     * @param networkId
-     * @param requestedIp TODO
-     * @return
-     */
-    PrivateIpVO allocateIpAddress(long dcId, long networkId, String requestedIp);
-
-    /**
-     * @param ipAddress
-     * @param networkId
-     */
-    void releaseIpAddress(String ipAddress, long networkId);
-
-    /**
-     * @param networkId
-     * @param ip4Address
-     * @return
-     */
-    PrivateIpVO findByIpAndSourceNetworkId(long networkId, String ip4Address);
-
-    /**
-     * @param networkId
-     * @return
-     */
-    List<PrivateIpVO> listByNetworkId(long networkId);
-
-    /**
-     * @param ntwkId
-     * @return
-     */
-    int countAllocatedByNetworkId(long ntwkId);
-
-    /**
-     * @param networkId
-     */
-    void deleteByNetworkId(long networkId);
-    
-    int countByNetworkId(long ntwkId);
-
-    /**
-     * @param vpcId
-     * @param ip4Address
-     * @return
-     */
-    PrivateIpVO findByIpAndVpcId(long vpcId, String ip4Address);
-
-    
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/server/src/com/cloud/network/vpc/Dao/PrivateIpDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/Dao/PrivateIpDaoImpl.java b/server/src/com/cloud/network/vpc/Dao/PrivateIpDaoImpl.java
deleted file mode 100644
index 6c13700..0000000
--- a/server/src/com/cloud/network/vpc/Dao/PrivateIpDaoImpl.java
+++ /dev/null
@@ -1,152 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.vpc.Dao;
-
-import java.util.Date;
-import java.util.List;
-import javax.ejb.Local;
-import org.apache.log4j.Logger;
-import com.cloud.network.vpc.PrivateIpVO;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.GenericSearchBuilder;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.SearchCriteria.Func;
-import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.Transaction;
-
-
-@Local(value = PrivateIpDao.class)
-@DB(txn = false)
-public class PrivateIpDaoImpl extends GenericDaoBase<PrivateIpVO, Long> implements PrivateIpDao {
-    private static final Logger s_logger = Logger.getLogger(PrivateIpDaoImpl.class);
-
-    private final SearchBuilder<PrivateIpVO> AllFieldsSearch;
-    private final GenericSearchBuilder<PrivateIpVO, Integer> CountAllocatedByNetworkId;
-    private final GenericSearchBuilder<PrivateIpVO, Integer> CountByNetworkId;
-
-    
-    protected PrivateIpDaoImpl() {
-        super();
-        
-        AllFieldsSearch = createSearchBuilder();
-        AllFieldsSearch.and("ip", AllFieldsSearch.entity().getIpAddress(), SearchCriteria.Op.EQ);
-        AllFieldsSearch.and("networkId", AllFieldsSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
-        AllFieldsSearch.and("ipAddress", AllFieldsSearch.entity().getIpAddress(), SearchCriteria.Op.EQ);
-        AllFieldsSearch.and("taken", AllFieldsSearch.entity().getTakenAt(), SearchCriteria.Op.EQ);
-        AllFieldsSearch.and("vpcId", AllFieldsSearch.entity().getVpcId(), SearchCriteria.Op.EQ);
-        AllFieldsSearch.done();
-        
-        CountAllocatedByNetworkId = createSearchBuilder(Integer.class);
-        CountAllocatedByNetworkId.select(null, Func.COUNT, CountAllocatedByNetworkId.entity().getId());
-        CountAllocatedByNetworkId.and("networkId", CountAllocatedByNetworkId.entity().getNetworkId(), Op.EQ);
-        CountAllocatedByNetworkId.and("taken", CountAllocatedByNetworkId.entity().getTakenAt(), Op.NNULL);
-        CountAllocatedByNetworkId.done();
-        
-        CountByNetworkId = createSearchBuilder(Integer.class);
-        CountByNetworkId.select(null, Func.COUNT, CountByNetworkId.entity().getId());
-        CountByNetworkId.and("networkId", CountByNetworkId.entity().getNetworkId(), Op.EQ);
-        CountByNetworkId.done();
-    }
-    
-    @Override
-    public PrivateIpVO allocateIpAddress(long dcId, long networkId, String requestedIp) {
-        SearchCriteria<PrivateIpVO> sc = AllFieldsSearch.create();
-        sc.setParameters("networkId", networkId);
-        sc.setParameters("taken", (Date)null);
-        
-        if (requestedIp != null) {
-            sc.setParameters("ipAddress", requestedIp);
-        }
-        
-        Transaction txn = Transaction.currentTxn();
-        txn.start();
-        PrivateIpVO  vo = lockOneRandomRow(sc, true);
-        if (vo == null) {
-            txn.rollback();
-            return null;
-        }
-        vo.setTakenAt(new Date());
-        update(vo.getId(), vo);
-        txn.commit();
-        return vo;
-    }
-    
-    @Override
-    public void releaseIpAddress(String ipAddress, long networkId) {
-        if (s_logger.isDebugEnabled()) {
-            s_logger.debug("Releasing private ip address: " + ipAddress + " network id " + networkId);
-        }
-        SearchCriteria<PrivateIpVO> sc = AllFieldsSearch.create();
-        sc.setParameters("ip", ipAddress);
-        sc.setParameters("networkId", networkId);
-
-        PrivateIpVO vo = createForUpdate();
-        
-        vo.setTakenAt(null);
-        update(vo, sc);
-    }
-
-
-    @Override
-    public PrivateIpVO findByIpAndSourceNetworkId(long networkId, String ip4Address) {
-        SearchCriteria<PrivateIpVO> sc = AllFieldsSearch.create();
-        sc.setParameters("ip", ip4Address);
-        sc.setParameters("networkId", networkId);
-        return findOneBy(sc);
-    }
-    
-    @Override
-    public PrivateIpVO findByIpAndVpcId(long vpcId, String ip4Address) {
-        SearchCriteria<PrivateIpVO> sc = AllFieldsSearch.create();
-        sc.setParameters("ip", ip4Address);
-        sc.setParameters("vpcId", vpcId);
-        return findOneBy(sc);
-    }
-    
-    @Override
-    public List<PrivateIpVO> listByNetworkId(long networkId) {
-        SearchCriteria<PrivateIpVO> sc = AllFieldsSearch.create();
-        sc.setParameters("networkId", networkId);
-        return listBy(sc);
-    }
-    
-    @Override
-    public int countAllocatedByNetworkId(long ntwkId) {
-        SearchCriteria<Integer> sc = CountAllocatedByNetworkId.create();
-        sc.setParameters("networkId", ntwkId);
-        List<Integer> results = customSearch(sc, null);
-        return results.get(0);
-    }
-    
-    
-    @Override
-    public void deleteByNetworkId(long networkId) {
-        SearchCriteria<PrivateIpVO> sc = AllFieldsSearch.create();
-        sc.setParameters("networkId", networkId);
-        remove(sc);
-    }
-
-    @Override
-    public int countByNetworkId(long ntwkId) {
-        SearchCriteria<Integer> sc = CountByNetworkId.create();
-        sc.setParameters("networkId", ntwkId);
-        List<Integer> results = customSearch(sc, null);
-        return results.get(0);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/server/src/com/cloud/network/vpc/Dao/StaticRouteDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/Dao/StaticRouteDao.java b/server/src/com/cloud/network/vpc/Dao/StaticRouteDao.java
deleted file mode 100644
index 55efa1a..0000000
--- a/server/src/com/cloud/network/vpc/Dao/StaticRouteDao.java
+++ /dev/null
@@ -1,35 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.vpc.Dao;
-
-import java.util.List;
-
-import com.cloud.network.vpc.StaticRoute;
-import com.cloud.network.vpc.StaticRouteVO;
-import com.cloud.utils.db.GenericDao;
-
-public interface StaticRouteDao extends GenericDao<StaticRouteVO, Long>{
-    
-    boolean setStateToAdd(StaticRouteVO rule);
-
-    List<? extends StaticRoute> listByGatewayIdAndNotRevoked(long gatewayId);
-    
-    List<StaticRouteVO> listByVpcId(long vpcId);
-    
-    long countRoutesByGateway(long gatewayId);
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/server/src/com/cloud/network/vpc/Dao/StaticRouteDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/Dao/StaticRouteDaoImpl.java b/server/src/com/cloud/network/vpc/Dao/StaticRouteDaoImpl.java
deleted file mode 100644
index b55016d..0000000
--- a/server/src/com/cloud/network/vpc/Dao/StaticRouteDaoImpl.java
+++ /dev/null
@@ -1,115 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.vpc.Dao;
-
-import java.util.List;
-
-import javax.ejb.Local;
-
-import com.cloud.network.vpc.StaticRoute;
-import com.cloud.network.vpc.StaticRouteVO;
-import com.cloud.server.ResourceTag.TaggedResourceType;
-import com.cloud.tags.dao.ResourceTagsDaoImpl;
-import com.cloud.utils.component.ComponentLocator;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.GenericSearchBuilder;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.SearchCriteria.Func;
-import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.Transaction;
-
-
-@Local(value = StaticRouteDao.class)
-@DB(txn = false)
-public class StaticRouteDaoImpl extends GenericDaoBase<StaticRouteVO, Long> implements StaticRouteDao{
-    protected final SearchBuilder<StaticRouteVO> AllFieldsSearch;
-    protected final SearchBuilder<StaticRouteVO> NotRevokedSearch;
-    protected final GenericSearchBuilder<StaticRouteVO, Long> RoutesByGatewayCount;
-    ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class);
-    
-    protected StaticRouteDaoImpl() {
-        super();
-
-        AllFieldsSearch = createSearchBuilder();
-        AllFieldsSearch.and("gatewayId", AllFieldsSearch.entity().getVpcGatewayId(), Op.EQ);
-        AllFieldsSearch.and("vpcId", AllFieldsSearch.entity().getVpcId(), Op.EQ);
-        AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.EQ);
-        AllFieldsSearch.and("id", AllFieldsSearch.entity().getId(), Op.EQ);
-        AllFieldsSearch.done();
-        
-        NotRevokedSearch = createSearchBuilder();
-        NotRevokedSearch.and("gatewayId", NotRevokedSearch.entity().getVpcGatewayId(), Op.EQ);
-        NotRevokedSearch.and("state", NotRevokedSearch.entity().getState(), Op.NEQ);
-        NotRevokedSearch.done();
-        
-        RoutesByGatewayCount = createSearchBuilder(Long.class);
-        RoutesByGatewayCount.select(null, Func.COUNT, RoutesByGatewayCount.entity().getId());
-        RoutesByGatewayCount.and("gatewayId", RoutesByGatewayCount.entity().getVpcGatewayId(), Op.EQ);
-        RoutesByGatewayCount.done();
-    }
-
-    
-    @Override
-    public boolean setStateToAdd(StaticRouteVO rule) {
-        SearchCriteria<StaticRouteVO> sc = AllFieldsSearch.create();
-        sc.setParameters("id", rule.getId());
-        sc.setParameters("state", StaticRoute.State.Staged);
-
-        rule.setState(StaticRoute.State.Add);
-
-        return update(rule, sc) > 0;
-    }
-
-
-    @Override
-    public List<? extends StaticRoute> listByGatewayIdAndNotRevoked(long gatewayId) {
-        SearchCriteria<StaticRouteVO> sc = NotRevokedSearch.create();
-        sc.setParameters("gatewayId", gatewayId);
-        sc.setParameters("state", StaticRoute.State.Revoke);
-        return listBy(sc);
-    }
-
-    @Override
-    public List<StaticRouteVO> listByVpcId(long vpcId) {
-        SearchCriteria<StaticRouteVO> sc = AllFieldsSearch.create();
-        sc.setParameters("vpcId", vpcId);
-        return listBy(sc);
-    }
-
-    @Override
-    public long countRoutesByGateway(long gatewayId) {
-        SearchCriteria<Long> sc = RoutesByGatewayCount.create();
-        sc.setParameters("gatewayId", gatewayId);
-        return customSearch(sc, null).get(0);
-    }
-    
-    @Override
-    @DB
-    public boolean remove(Long id) {
-        Transaction txn = Transaction.currentTxn();
-        txn.start();
-        StaticRouteVO entry = findById(id);
-        if (entry != null) {
-            _tagsDao.removeByIdAndType(id, TaggedResourceType.StaticRoute);
-        }
-        boolean result = super.remove(id);
-        txn.commit();
-        return result;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/server/src/com/cloud/network/vpc/Dao/VpcDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/Dao/VpcDao.java b/server/src/com/cloud/network/vpc/Dao/VpcDao.java
deleted file mode 100644
index 73aa27e..0000000
--- a/server/src/com/cloud/network/vpc/Dao/VpcDao.java
+++ /dev/null
@@ -1,42 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.vpc.Dao;
-
-import java.util.List;
-
-import com.cloud.network.vpc.Vpc;
-import com.cloud.network.vpc.VpcVO;
-import com.cloud.utils.db.GenericDao;
-
-
-public interface VpcDao extends GenericDao<VpcVO, Long>{
-
-    /**
-     * @param offId
-     * @return
-     */
-    int getVpcCountByOfferingId(long offId);
-    
-    Vpc getActiveVpcById(long vpcId);
-    
-    List<? extends Vpc> listByAccountId(long accountId);
-    
-    List<VpcVO> listInactiveVpcs();
-    
-    long countByAccountId(long accountId);
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/server/src/com/cloud/network/vpc/Dao/VpcDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/Dao/VpcDaoImpl.java b/server/src/com/cloud/network/vpc/Dao/VpcDaoImpl.java
deleted file mode 100644
index 773d6ad..0000000
--- a/server/src/com/cloud/network/vpc/Dao/VpcDaoImpl.java
+++ /dev/null
@@ -1,121 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.vpc.Dao;
-
-import java.util.List;
-
-import javax.ejb.Local;
-
-import com.cloud.network.vpc.Vpc;
-import com.cloud.network.vpc.VpcVO;
-import com.cloud.server.ResourceTag.TaggedResourceType;
-import com.cloud.tags.dao.ResourceTagsDaoImpl;
-import com.cloud.utils.component.ComponentLocator;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.GenericSearchBuilder;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.SearchCriteria.Func;
-import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.Transaction;
-
-
-@Local(value = VpcDao.class)
-@DB(txn = false)
-public class VpcDaoImpl extends GenericDaoBase<VpcVO, Long> implements VpcDao{
-    final GenericSearchBuilder<VpcVO, Integer> CountByOfferingId;
-    final SearchBuilder<VpcVO> AllFieldsSearch;
-    final GenericSearchBuilder<VpcVO, Long> CountByAccountId;
-    ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class);
-
-    protected VpcDaoImpl() {
-        super();
-        
-        CountByOfferingId = createSearchBuilder(Integer.class);
-        CountByOfferingId.select(null, Func.COUNT, CountByOfferingId.entity().getId());
-        CountByOfferingId.and("offeringId", CountByOfferingId.entity().getVpcOfferingId(), Op.EQ);
-        CountByOfferingId.and("removed", CountByOfferingId.entity().getRemoved(), Op.NULL);
-        CountByOfferingId.done();
-        
-        AllFieldsSearch = createSearchBuilder();
-        AllFieldsSearch.and("id", AllFieldsSearch.entity().getId(), Op.EQ);
-        AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.EQ);
-        AllFieldsSearch.and("accountId", AllFieldsSearch.entity().getAccountId(), Op.EQ);
-        AllFieldsSearch.done();
-        
-        CountByAccountId = createSearchBuilder(Long.class);
-        CountByAccountId.select(null, Func.COUNT, CountByAccountId.entity().getId());
-        CountByAccountId.and("offeringId", CountByAccountId.entity().getAccountId(), Op.EQ);
-        CountByAccountId.and("removed", CountByAccountId.entity().getRemoved(), Op.NULL);
-        CountByAccountId.done();
-    }
-    
-    
-    @Override
-    public int getVpcCountByOfferingId(long offId) {
-        SearchCriteria<Integer> sc = CountByOfferingId.create();
-        sc.setParameters("offeringId", offId);
-        List<Integer> results = customSearch(sc, null);
-        return results.get(0);
-    }
-    
-    @Override
-    public Vpc getActiveVpcById(long vpcId) {
-        SearchCriteria<VpcVO> sc = AllFieldsSearch.create();
-        sc.setParameters("id", vpcId);
-        sc.setParameters("state", Vpc.State.Enabled);
-        return findOneBy(sc);
-    }
-    
-    @Override
-    public List<? extends Vpc> listByAccountId(long accountId) {
-        SearchCriteria<VpcVO> sc = AllFieldsSearch.create();
-        sc.setParameters("accountId", accountId);
-        return listBy(sc, null);
-    }
-    
-    @Override
-    public List<VpcVO> listInactiveVpcs() {
-        SearchCriteria<VpcVO> sc = AllFieldsSearch.create();
-        sc.setParameters("state", Vpc.State.Inactive);
-        return listBy(sc, null);
-    }
-    
-    @Override
-    @DB
-    public boolean remove(Long id) {
-        Transaction txn = Transaction.currentTxn();
-        txn.start();
-        VpcVO entry = findById(id);
-        if (entry != null) {
-            _tagsDao.removeByIdAndType(id, TaggedResourceType.Vpc);
-        }
-        boolean result = super.remove(id);
-        txn.commit();
-        return result;
-    }
-    
-    @Override
-    public long countByAccountId(long accountId) {
-        SearchCriteria<Long> sc = CountByAccountId.create();
-        sc.setParameters("accountId", accountId);
-        List<Long> results = customSearch(sc, null);
-        return results.get(0);
-    }
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/server/src/com/cloud/network/vpc/Dao/VpcGatewayDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/Dao/VpcGatewayDao.java b/server/src/com/cloud/network/vpc/Dao/VpcGatewayDao.java
deleted file mode 100644
index d91bc9c..0000000
--- a/server/src/com/cloud/network/vpc/Dao/VpcGatewayDao.java
+++ /dev/null
@@ -1,26 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.vpc.Dao;
-
-import com.cloud.network.vpc.VpcGatewayVO;
-import com.cloud.utils.db.GenericDao;
-
-
-public interface VpcGatewayDao extends GenericDao<VpcGatewayVO, Long>{
-    VpcGatewayVO getPrivateGatewayForVpc(long vpcId);
-    VpcGatewayVO getVpnGatewayForVpc(long vpcId);
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/server/src/com/cloud/network/vpc/Dao/VpcGatewayDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/Dao/VpcGatewayDaoImpl.java b/server/src/com/cloud/network/vpc/Dao/VpcGatewayDaoImpl.java
deleted file mode 100644
index f579ac0..0000000
--- a/server/src/com/cloud/network/vpc/Dao/VpcGatewayDaoImpl.java
+++ /dev/null
@@ -1,60 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.vpc.Dao;
-
-import javax.ejb.Local;
-
-import com.cloud.network.vpc.VpcGateway;
-import com.cloud.network.vpc.VpcGatewayVO;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-
-
-@Local(value = VpcGatewayDao.class)
-@DB(txn = false)
-public class VpcGatewayDaoImpl extends GenericDaoBase<VpcGatewayVO, Long> implements VpcGatewayDao{
-    protected final SearchBuilder<VpcGatewayVO> AllFieldsSearch;
-    
-    protected VpcGatewayDaoImpl() {
-        AllFieldsSearch = createSearchBuilder();
-        AllFieldsSearch.and("vpcId", AllFieldsSearch.entity().getVpcId(), SearchCriteria.Op.EQ);
-        AllFieldsSearch.and("type", AllFieldsSearch.entity().getType(), SearchCriteria.Op.EQ);
-        AllFieldsSearch.done();
-    }
-
-
-    @Override
-    public VpcGatewayVO getPrivateGatewayForVpc(long vpcId) {
-        SearchCriteria<VpcGatewayVO> sc = AllFieldsSearch.create();
-        sc.setParameters("vpcId", vpcId);
-        sc.setParameters("type", VpcGateway.Type.Private);
-
-        return findOneBy(sc);
-    }
-
-    @Override
-    public VpcGatewayVO getVpnGatewayForVpc(long vpcId) {
-        SearchCriteria<VpcGatewayVO> sc = AllFieldsSearch.create();
-        sc.setParameters("vpcId", vpcId);
-        sc.setParameters("type", VpcGateway.Type.Vpn);
-
-        return findOneBy(sc);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/server/src/com/cloud/network/vpc/Dao/VpcOfferingDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/Dao/VpcOfferingDao.java b/server/src/com/cloud/network/vpc/Dao/VpcOfferingDao.java
deleted file mode 100644
index bcb3a4a..0000000
--- a/server/src/com/cloud/network/vpc/Dao/VpcOfferingDao.java
+++ /dev/null
@@ -1,32 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.vpc.Dao;
-
-import com.cloud.network.vpc.VpcOfferingVO;
-import com.cloud.utils.db.GenericDao;
-
-
-public interface VpcOfferingDao extends GenericDao<VpcOfferingVO, Long>{
-    /**
-     * Returns the VPC offering that matches the unique name.
-     * 
-     * @param uniqueName
-     *            name
-     * @return VpcOfferingVO
-     */
-    VpcOfferingVO findByUniqueName(String uniqueName);
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/server/src/com/cloud/network/vpc/Dao/VpcOfferingDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/Dao/VpcOfferingDaoImpl.java b/server/src/com/cloud/network/vpc/Dao/VpcOfferingDaoImpl.java
deleted file mode 100644
index c7767ec..0000000
--- a/server/src/com/cloud/network/vpc/Dao/VpcOfferingDaoImpl.java
+++ /dev/null
@@ -1,69 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.vpc.Dao;
-
-import javax.ejb.Local;
-
-import com.cloud.network.vpc.VpcOfferingVO;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.Transaction;
-
-
-@Local(value = VpcOfferingDao.class)
-@DB(txn = false)
-public class VpcOfferingDaoImpl extends GenericDaoBase<VpcOfferingVO, Long> implements VpcOfferingDao{
-    final SearchBuilder<VpcOfferingVO> AllFieldsSearch;
-
-    protected VpcOfferingDaoImpl() {
-        super();
-        
-        AllFieldsSearch = createSearchBuilder();
-        AllFieldsSearch.and("id", AllFieldsSearch.entity().getId(), Op.EQ);
-        AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.EQ);
-        AllFieldsSearch.and("name", AllFieldsSearch.entity().getName(), Op.EQ);
-        AllFieldsSearch.and("uName", AllFieldsSearch.entity().getUniqueName(), Op.EQ);
-        AllFieldsSearch.and("displayText", AllFieldsSearch.entity().getDisplayText(), Op.EQ);
-        AllFieldsSearch.and("svcOffId", AllFieldsSearch.entity().getServiceOfferingId(), Op.EQ);
-        AllFieldsSearch.done();
-        
-    }
-
-    @Override
-    @DB
-    public boolean remove(Long vpcOffId) {
-        Transaction txn = Transaction.currentTxn();
-        txn.start();
-        VpcOfferingVO offering = findById(vpcOffId);
-        offering.setUniqueName(null);
-        update(vpcOffId, offering);
-        boolean result = super.remove(vpcOffId);
-        txn.commit();
-        return result;
-    }
-
-
-    @Override
-    public VpcOfferingVO findByUniqueName(String uniqueName) {
-        SearchCriteria<VpcOfferingVO> sc = AllFieldsSearch.create();
-        sc.setParameters("uName", uniqueName);
-        return findOneBy(sc);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/server/src/com/cloud/network/vpc/Dao/VpcOfferingServiceMapDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/Dao/VpcOfferingServiceMapDao.java b/server/src/com/cloud/network/vpc/Dao/VpcOfferingServiceMapDao.java
deleted file mode 100644
index 08b1855..0000000
--- a/server/src/com/cloud/network/vpc/Dao/VpcOfferingServiceMapDao.java
+++ /dev/null
@@ -1,41 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.vpc.Dao;
-
-import java.util.List;
-
-import com.cloud.network.Network.Service;
-import com.cloud.network.vpc.VpcOfferingServiceMapVO;
-import com.cloud.utils.db.GenericDao;
-
-
-public interface VpcOfferingServiceMapDao extends GenericDao<VpcOfferingServiceMapVO, Long>{
-    
-    List<VpcOfferingServiceMapVO> listByVpcOffId(long vpcOffId);
-
-    /**
-     * @param networkOfferingId
-     * @param services
-     * @return
-     */
-    boolean areServicesSupportedByNetworkOffering(long networkOfferingId, Service[] services);
-    
-    List<String> listServicesForVpcOffering(long vpcOfferingId);
-    
-    VpcOfferingServiceMapVO findByServiceProviderAndOfferingId(String service, String provider, long vpcOfferingId);
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/server/src/com/cloud/network/vpc/Dao/VpcOfferingServiceMapDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/Dao/VpcOfferingServiceMapDaoImpl.java b/server/src/com/cloud/network/vpc/Dao/VpcOfferingServiceMapDaoImpl.java
deleted file mode 100644
index f623e2b..0000000
--- a/server/src/com/cloud/network/vpc/Dao/VpcOfferingServiceMapDaoImpl.java
+++ /dev/null
@@ -1,117 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.vpc.Dao;
-
-import java.util.List;
-
-import javax.ejb.Local;
-
-import com.cloud.network.Network.Service;
-import com.cloud.network.vpc.VpcOfferingServiceMapVO;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.GenericSearchBuilder;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.SearchCriteria.Func;
-
-
-@Local(value = VpcOfferingServiceMapDao.class)
-@DB(txn = false)
-public class VpcOfferingServiceMapDaoImpl extends GenericDaoBase<VpcOfferingServiceMapVO, Long> implements VpcOfferingServiceMapDao{
-    final SearchBuilder<VpcOfferingServiceMapVO> AllFieldsSearch;
-    final SearchBuilder<VpcOfferingServiceMapVO> MultipleServicesSearch;
-    final GenericSearchBuilder<VpcOfferingServiceMapVO, String> ServicesSearch;
-
-    
-    protected VpcOfferingServiceMapDaoImpl() {
-        super();
-        AllFieldsSearch = createSearchBuilder();
-        AllFieldsSearch.and("vpcOffId", AllFieldsSearch.entity().getVpcOfferingId(), SearchCriteria.Op.EQ);
-        AllFieldsSearch.and("service", AllFieldsSearch.entity().getService(), SearchCriteria.Op.EQ);
-        AllFieldsSearch.and("provider", AllFieldsSearch.entity().getProvider(), SearchCriteria.Op.EQ);
-        AllFieldsSearch.done();
-        
-        
-        MultipleServicesSearch = createSearchBuilder();
-        MultipleServicesSearch.and("vpcOffId", MultipleServicesSearch.entity().getVpcOfferingId(), SearchCriteria.Op.EQ);
-        MultipleServicesSearch.and("service", MultipleServicesSearch.entity().getService(), SearchCriteria.Op.IN);
-        MultipleServicesSearch.and("provider", MultipleServicesSearch.entity().getProvider(), SearchCriteria.Op.EQ);
-        MultipleServicesSearch.done();
-        
-        ServicesSearch = createSearchBuilder(String.class);
-        ServicesSearch.and("offeringId", ServicesSearch.entity().getVpcOfferingId(), SearchCriteria.Op.EQ);
-        ServicesSearch.select(null, Func.DISTINCT, ServicesSearch.entity().getService());
-        ServicesSearch.done();
-    }
-    
-    @Override
-    public List<VpcOfferingServiceMapVO> listByVpcOffId(long vpcOffId) {
-        SearchCriteria<VpcOfferingServiceMapVO> sc = AllFieldsSearch.create();
-        sc.setParameters("vpcOffId", vpcOffId);
-        return listBy(sc);
-    }
-    
-    
-    @Override
-    public boolean areServicesSupportedByNetworkOffering(long networkOfferingId, Service... services) {
-        SearchCriteria<VpcOfferingServiceMapVO> sc = MultipleServicesSearch.create();
-        sc.setParameters("vpcOffId", networkOfferingId);
-        
-        if (services != null) {
-            String[] servicesStr = new String[services.length];
-            
-            int i = 0;
-            for (Service service : services) {
-                servicesStr[i] = service.getName();
-                i++;
-            }
-            
-            sc.setParameters("service", (Object[])servicesStr);
-        }
-        
-        List<VpcOfferingServiceMapVO> offeringServices = listBy(sc);
-        
-        if (services != null) {
-            if (offeringServices.size() == services.length) {
-                return true;
-            }
-        } else if (!offeringServices.isEmpty()) {
-            return true;
-        }
-        
-        return false;
-    }
-
-    @Override
-    public List<String> listServicesForVpcOffering(long offId) {
-        SearchCriteria<String> sc = ServicesSearch.create();;
-        sc.setParameters("offeringId", offId);
-        return customSearch(sc, null);
-    }
-
-
-    @Override
-    public VpcOfferingServiceMapVO findByServiceProviderAndOfferingId(String service, String provider, long vpcOfferingId) {
-        SearchCriteria<VpcOfferingServiceMapVO> sc = AllFieldsSearch.create();
-        sc.setParameters("vpcOffId", vpcOfferingId);
-        sc.setParameters("service", service);
-        sc.setParameters("provider", provider);
-        
-        return findOneBy(sc);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/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 32659b0..0612e65 100644
--- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
@@ -73,12 +73,12 @@ import com.cloud.network.dao.PhysicalNetworkDao;
 import com.cloud.network.dao.Site2SiteVpnGatewayDao;
 import com.cloud.network.element.VpcProvider;
 import com.cloud.network.vpc.VpcOffering.State;
-import com.cloud.network.vpc.Dao.PrivateIpDao;
-import com.cloud.network.vpc.Dao.StaticRouteDao;
-import com.cloud.network.vpc.Dao.VpcDao;
-import com.cloud.network.vpc.Dao.VpcGatewayDao;
-import com.cloud.network.vpc.Dao.VpcOfferingDao;
-import com.cloud.network.vpc.Dao.VpcOfferingServiceMapDao;
+import com.cloud.network.vpc.dao.PrivateIpDao;
+import com.cloud.network.vpc.dao.StaticRouteDao;
+import com.cloud.network.vpc.dao.VpcDao;
+import com.cloud.network.vpc.dao.VpcGatewayDao;
+import com.cloud.network.vpc.dao.VpcOfferingDao;
+import com.cloud.network.vpc.dao.VpcOfferingServiceMapDao;
 import com.cloud.network.vpn.Site2SiteVpnManager;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.offerings.NetworkOfferingServiceMapVO;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/server/src/com/cloud/network/vpc/dao/PrivateIpDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/dao/PrivateIpDao.java b/server/src/com/cloud/network/vpc/dao/PrivateIpDao.java
new file mode 100644
index 0000000..02df92e
--- /dev/null
+++ b/server/src/com/cloud/network/vpc/dao/PrivateIpDao.java
@@ -0,0 +1,75 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.network.vpc.dao;
+
+import java.util.List;
+
+import com.cloud.network.vpc.PrivateIpVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface PrivateIpDao extends GenericDao<PrivateIpVO, Long>{
+
+    /**
+     * @param dcId
+     * @param networkId
+     * @param requestedIp TODO
+     * @return
+     */
+    PrivateIpVO allocateIpAddress(long dcId, long networkId, String requestedIp);
+
+    /**
+     * @param ipAddress
+     * @param networkId
+     */
+    void releaseIpAddress(String ipAddress, long networkId);
+
+    /**
+     * @param networkId
+     * @param ip4Address
+     * @return
+     */
+    PrivateIpVO findByIpAndSourceNetworkId(long networkId, String ip4Address);
+
+    /**
+     * @param networkId
+     * @return
+     */
+    List<PrivateIpVO> listByNetworkId(long networkId);
+
+    /**
+     * @param ntwkId
+     * @return
+     */
+    int countAllocatedByNetworkId(long ntwkId);
+
+    /**
+     * @param networkId
+     */
+    void deleteByNetworkId(long networkId);
+    
+    int countByNetworkId(long ntwkId);
+
+    /**
+     * @param vpcId
+     * @param ip4Address
+     * @return
+     */
+    PrivateIpVO findByIpAndVpcId(long vpcId, String ip4Address);
+
+    
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/server/src/com/cloud/network/vpc/dao/PrivateIpDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/dao/PrivateIpDaoImpl.java b/server/src/com/cloud/network/vpc/dao/PrivateIpDaoImpl.java
new file mode 100644
index 0000000..35b81a8
--- /dev/null
+++ b/server/src/com/cloud/network/vpc/dao/PrivateIpDaoImpl.java
@@ -0,0 +1,155 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.network.vpc.dao;
+
+import java.util.Date;
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.network.vpc.PrivateIpVO;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.GenericSearchBuilder;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria.Func;
+import com.cloud.utils.db.SearchCriteria.Op;
+import com.cloud.utils.db.Transaction;
+
+
+@Local(value = PrivateIpDao.class)
+@DB(txn = false)
+public class PrivateIpDaoImpl extends GenericDaoBase<PrivateIpVO, Long> implements PrivateIpDao {
+    private static final Logger s_logger = Logger.getLogger(PrivateIpDaoImpl.class);
+
+    private final SearchBuilder<PrivateIpVO> AllFieldsSearch;
+    private final GenericSearchBuilder<PrivateIpVO, Integer> CountAllocatedByNetworkId;
+    private final GenericSearchBuilder<PrivateIpVO, Integer> CountByNetworkId;
+
+    
+    protected PrivateIpDaoImpl() {
+        super();
+        
+        AllFieldsSearch = createSearchBuilder();
+        AllFieldsSearch.and("ip", AllFieldsSearch.entity().getIpAddress(), SearchCriteria.Op.EQ);
+        AllFieldsSearch.and("networkId", AllFieldsSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
+        AllFieldsSearch.and("ipAddress", AllFieldsSearch.entity().getIpAddress(), SearchCriteria.Op.EQ);
+        AllFieldsSearch.and("taken", AllFieldsSearch.entity().getTakenAt(), SearchCriteria.Op.EQ);
+        AllFieldsSearch.and("vpcId", AllFieldsSearch.entity().getVpcId(), SearchCriteria.Op.EQ);
+        AllFieldsSearch.done();
+        
+        CountAllocatedByNetworkId = createSearchBuilder(Integer.class);
+        CountAllocatedByNetworkId.select(null, Func.COUNT, CountAllocatedByNetworkId.entity().getId());
+        CountAllocatedByNetworkId.and("networkId", CountAllocatedByNetworkId.entity().getNetworkId(), Op.EQ);
+        CountAllocatedByNetworkId.and("taken", CountAllocatedByNetworkId.entity().getTakenAt(), Op.NNULL);
+        CountAllocatedByNetworkId.done();
+        
+        CountByNetworkId = createSearchBuilder(Integer.class);
+        CountByNetworkId.select(null, Func.COUNT, CountByNetworkId.entity().getId());
+        CountByNetworkId.and("networkId", CountByNetworkId.entity().getNetworkId(), Op.EQ);
+        CountByNetworkId.done();
+    }
+    
+    @Override
+    public PrivateIpVO allocateIpAddress(long dcId, long networkId, String requestedIp) {
+        SearchCriteria<PrivateIpVO> sc = AllFieldsSearch.create();
+        sc.setParameters("networkId", networkId);
+        sc.setParameters("taken", (Date)null);
+        
+        if (requestedIp != null) {
+            sc.setParameters("ipAddress", requestedIp);
+        }
+        
+        Transaction txn = Transaction.currentTxn();
+        txn.start();
+        PrivateIpVO  vo = lockOneRandomRow(sc, true);
+        if (vo == null) {
+            txn.rollback();
+            return null;
+        }
+        vo.setTakenAt(new Date());
+        update(vo.getId(), vo);
+        txn.commit();
+        return vo;
+    }
+    
+    @Override
+    public void releaseIpAddress(String ipAddress, long networkId) {
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Releasing private ip address: " + ipAddress + " network id " + networkId);
+        }
+        SearchCriteria<PrivateIpVO> sc = AllFieldsSearch.create();
+        sc.setParameters("ip", ipAddress);
+        sc.setParameters("networkId", networkId);
+
+        PrivateIpVO vo = createForUpdate();
+        
+        vo.setTakenAt(null);
+        update(vo, sc);
+    }
+
+
+    @Override
+    public PrivateIpVO findByIpAndSourceNetworkId(long networkId, String ip4Address) {
+        SearchCriteria<PrivateIpVO> sc = AllFieldsSearch.create();
+        sc.setParameters("ip", ip4Address);
+        sc.setParameters("networkId", networkId);
+        return findOneBy(sc);
+    }
+    
+    @Override
+    public PrivateIpVO findByIpAndVpcId(long vpcId, String ip4Address) {
+        SearchCriteria<PrivateIpVO> sc = AllFieldsSearch.create();
+        sc.setParameters("ip", ip4Address);
+        sc.setParameters("vpcId", vpcId);
+        return findOneBy(sc);
+    }
+    
+    @Override
+    public List<PrivateIpVO> listByNetworkId(long networkId) {
+        SearchCriteria<PrivateIpVO> sc = AllFieldsSearch.create();
+        sc.setParameters("networkId", networkId);
+        return listBy(sc);
+    }
+    
+    @Override
+    public int countAllocatedByNetworkId(long ntwkId) {
+        SearchCriteria<Integer> sc = CountAllocatedByNetworkId.create();
+        sc.setParameters("networkId", ntwkId);
+        List<Integer> results = customSearch(sc, null);
+        return results.get(0);
+    }
+    
+    
+    @Override
+    public void deleteByNetworkId(long networkId) {
+        SearchCriteria<PrivateIpVO> sc = AllFieldsSearch.create();
+        sc.setParameters("networkId", networkId);
+        remove(sc);
+    }
+
+    @Override
+    public int countByNetworkId(long ntwkId) {
+        SearchCriteria<Integer> sc = CountByNetworkId.create();
+        sc.setParameters("networkId", ntwkId);
+        List<Integer> results = customSearch(sc, null);
+        return results.get(0);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/server/src/com/cloud/network/vpc/dao/StaticRouteDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/dao/StaticRouteDao.java b/server/src/com/cloud/network/vpc/dao/StaticRouteDao.java
new file mode 100644
index 0000000..a8fbc09
--- /dev/null
+++ b/server/src/com/cloud/network/vpc/dao/StaticRouteDao.java
@@ -0,0 +1,35 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.network.vpc.dao;
+
+import java.util.List;
+
+import com.cloud.network.vpc.StaticRoute;
+import com.cloud.network.vpc.StaticRouteVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface StaticRouteDao extends GenericDao<StaticRouteVO, Long>{
+    
+    boolean setStateToAdd(StaticRouteVO rule);
+
+    List<? extends StaticRoute> listByGatewayIdAndNotRevoked(long gatewayId);
+    
+    List<StaticRouteVO> listByVpcId(long vpcId);
+    
+    long countRoutesByGateway(long gatewayId);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/server/src/com/cloud/network/vpc/dao/StaticRouteDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/dao/StaticRouteDaoImpl.java b/server/src/com/cloud/network/vpc/dao/StaticRouteDaoImpl.java
new file mode 100644
index 0000000..b3077e7
--- /dev/null
+++ b/server/src/com/cloud/network/vpc/dao/StaticRouteDaoImpl.java
@@ -0,0 +1,115 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.network.vpc.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import com.cloud.network.vpc.StaticRoute;
+import com.cloud.network.vpc.StaticRouteVO;
+import com.cloud.server.ResourceTag.TaggedResourceType;
+import com.cloud.tags.dao.ResourceTagsDaoImpl;
+import com.cloud.utils.component.ComponentLocator;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.GenericSearchBuilder;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria.Func;
+import com.cloud.utils.db.SearchCriteria.Op;
+import com.cloud.utils.db.Transaction;
+
+
+@Local(value = StaticRouteDao.class)
+@DB(txn = false)
+public class StaticRouteDaoImpl extends GenericDaoBase<StaticRouteVO, Long> implements StaticRouteDao{
+    protected final SearchBuilder<StaticRouteVO> AllFieldsSearch;
+    protected final SearchBuilder<StaticRouteVO> NotRevokedSearch;
+    protected final GenericSearchBuilder<StaticRouteVO, Long> RoutesByGatewayCount;
+    ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class);
+    
+    protected StaticRouteDaoImpl() {
+        super();
+
+        AllFieldsSearch = createSearchBuilder();
+        AllFieldsSearch.and("gatewayId", AllFieldsSearch.entity().getVpcGatewayId(), Op.EQ);
+        AllFieldsSearch.and("vpcId", AllFieldsSearch.entity().getVpcId(), Op.EQ);
+        AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.EQ);
+        AllFieldsSearch.and("id", AllFieldsSearch.entity().getId(), Op.EQ);
+        AllFieldsSearch.done();
+        
+        NotRevokedSearch = createSearchBuilder();
+        NotRevokedSearch.and("gatewayId", NotRevokedSearch.entity().getVpcGatewayId(), Op.EQ);
+        NotRevokedSearch.and("state", NotRevokedSearch.entity().getState(), Op.NEQ);
+        NotRevokedSearch.done();
+        
+        RoutesByGatewayCount = createSearchBuilder(Long.class);
+        RoutesByGatewayCount.select(null, Func.COUNT, RoutesByGatewayCount.entity().getId());
+        RoutesByGatewayCount.and("gatewayId", RoutesByGatewayCount.entity().getVpcGatewayId(), Op.EQ);
+        RoutesByGatewayCount.done();
+    }
+
+    
+    @Override
+    public boolean setStateToAdd(StaticRouteVO rule) {
+        SearchCriteria<StaticRouteVO> sc = AllFieldsSearch.create();
+        sc.setParameters("id", rule.getId());
+        sc.setParameters("state", StaticRoute.State.Staged);
+
+        rule.setState(StaticRoute.State.Add);
+
+        return update(rule, sc) > 0;
+    }
+
+
+    @Override
+    public List<? extends StaticRoute> listByGatewayIdAndNotRevoked(long gatewayId) {
+        SearchCriteria<StaticRouteVO> sc = NotRevokedSearch.create();
+        sc.setParameters("gatewayId", gatewayId);
+        sc.setParameters("state", StaticRoute.State.Revoke);
+        return listBy(sc);
+    }
+
+    @Override
+    public List<StaticRouteVO> listByVpcId(long vpcId) {
+        SearchCriteria<StaticRouteVO> sc = AllFieldsSearch.create();
+        sc.setParameters("vpcId", vpcId);
+        return listBy(sc);
+    }
+
+    @Override
+    public long countRoutesByGateway(long gatewayId) {
+        SearchCriteria<Long> sc = RoutesByGatewayCount.create();
+        sc.setParameters("gatewayId", gatewayId);
+        return customSearch(sc, null).get(0);
+    }
+    
+    @Override
+    @DB
+    public boolean remove(Long id) {
+        Transaction txn = Transaction.currentTxn();
+        txn.start();
+        StaticRouteVO entry = findById(id);
+        if (entry != null) {
+            _tagsDao.removeByIdAndType(id, TaggedResourceType.StaticRoute);
+        }
+        boolean result = super.remove(id);
+        txn.commit();
+        return result;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/server/src/com/cloud/network/vpc/dao/VpcDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/dao/VpcDao.java b/server/src/com/cloud/network/vpc/dao/VpcDao.java
new file mode 100644
index 0000000..80e5e15
--- /dev/null
+++ b/server/src/com/cloud/network/vpc/dao/VpcDao.java
@@ -0,0 +1,42 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.network.vpc.dao;
+
+import java.util.List;
+
+import com.cloud.network.vpc.Vpc;
+import com.cloud.network.vpc.VpcVO;
+import com.cloud.utils.db.GenericDao;
+
+
+public interface VpcDao extends GenericDao<VpcVO, Long>{
+
+    /**
+     * @param offId
+     * @return
+     */
+    int getVpcCountByOfferingId(long offId);
+    
+    Vpc getActiveVpcById(long vpcId);
+    
+    List<? extends Vpc> listByAccountId(long accountId);
+    
+    List<VpcVO> listInactiveVpcs();
+    
+    long countByAccountId(long accountId);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/server/src/com/cloud/network/vpc/dao/VpcDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/dao/VpcDaoImpl.java b/server/src/com/cloud/network/vpc/dao/VpcDaoImpl.java
new file mode 100644
index 0000000..ffc3542
--- /dev/null
+++ b/server/src/com/cloud/network/vpc/dao/VpcDaoImpl.java
@@ -0,0 +1,121 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.network.vpc.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import com.cloud.network.vpc.Vpc;
+import com.cloud.network.vpc.VpcVO;
+import com.cloud.server.ResourceTag.TaggedResourceType;
+import com.cloud.tags.dao.ResourceTagsDaoImpl;
+import com.cloud.utils.component.ComponentLocator;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.GenericSearchBuilder;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria.Func;
+import com.cloud.utils.db.SearchCriteria.Op;
+import com.cloud.utils.db.Transaction;
+
+
+@Local(value = VpcDao.class)
+@DB(txn = false)
+public class VpcDaoImpl extends GenericDaoBase<VpcVO, Long> implements VpcDao{
+    final GenericSearchBuilder<VpcVO, Integer> CountByOfferingId;
+    final SearchBuilder<VpcVO> AllFieldsSearch;
+    final GenericSearchBuilder<VpcVO, Long> CountByAccountId;
+    ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class);
+
+    protected VpcDaoImpl() {
+        super();
+        
+        CountByOfferingId = createSearchBuilder(Integer.class);
+        CountByOfferingId.select(null, Func.COUNT, CountByOfferingId.entity().getId());
+        CountByOfferingId.and("offeringId", CountByOfferingId.entity().getVpcOfferingId(), Op.EQ);
+        CountByOfferingId.and("removed", CountByOfferingId.entity().getRemoved(), Op.NULL);
+        CountByOfferingId.done();
+        
+        AllFieldsSearch = createSearchBuilder();
+        AllFieldsSearch.and("id", AllFieldsSearch.entity().getId(), Op.EQ);
+        AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.EQ);
+        AllFieldsSearch.and("accountId", AllFieldsSearch.entity().getAccountId(), Op.EQ);
+        AllFieldsSearch.done();
+        
+        CountByAccountId = createSearchBuilder(Long.class);
+        CountByAccountId.select(null, Func.COUNT, CountByAccountId.entity().getId());
+        CountByAccountId.and("offeringId", CountByAccountId.entity().getAccountId(), Op.EQ);
+        CountByAccountId.and("removed", CountByAccountId.entity().getRemoved(), Op.NULL);
+        CountByAccountId.done();
+    }
+    
+    
+    @Override
+    public int getVpcCountByOfferingId(long offId) {
+        SearchCriteria<Integer> sc = CountByOfferingId.create();
+        sc.setParameters("offeringId", offId);
+        List<Integer> results = customSearch(sc, null);
+        return results.get(0);
+    }
+    
+    @Override
+    public Vpc getActiveVpcById(long vpcId) {
+        SearchCriteria<VpcVO> sc = AllFieldsSearch.create();
+        sc.setParameters("id", vpcId);
+        sc.setParameters("state", Vpc.State.Enabled);
+        return findOneBy(sc);
+    }
+    
+    @Override
+    public List<? extends Vpc> listByAccountId(long accountId) {
+        SearchCriteria<VpcVO> sc = AllFieldsSearch.create();
+        sc.setParameters("accountId", accountId);
+        return listBy(sc, null);
+    }
+    
+    @Override
+    public List<VpcVO> listInactiveVpcs() {
+        SearchCriteria<VpcVO> sc = AllFieldsSearch.create();
+        sc.setParameters("state", Vpc.State.Inactive);
+        return listBy(sc, null);
+    }
+    
+    @Override
+    @DB
+    public boolean remove(Long id) {
+        Transaction txn = Transaction.currentTxn();
+        txn.start();
+        VpcVO entry = findById(id);
+        if (entry != null) {
+            _tagsDao.removeByIdAndType(id, TaggedResourceType.Vpc);
+        }
+        boolean result = super.remove(id);
+        txn.commit();
+        return result;
+    }
+    
+    @Override
+    public long countByAccountId(long accountId) {
+        SearchCriteria<Long> sc = CountByAccountId.create();
+        sc.setParameters("accountId", accountId);
+        List<Long> results = customSearch(sc, null);
+        return results.get(0);
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/server/src/com/cloud/network/vpc/dao/VpcGatewayDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/dao/VpcGatewayDao.java b/server/src/com/cloud/network/vpc/dao/VpcGatewayDao.java
new file mode 100644
index 0000000..600d67f
--- /dev/null
+++ b/server/src/com/cloud/network/vpc/dao/VpcGatewayDao.java
@@ -0,0 +1,26 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.network.vpc.dao;
+
+import com.cloud.network.vpc.VpcGatewayVO;
+import com.cloud.utils.db.GenericDao;
+
+
+public interface VpcGatewayDao extends GenericDao<VpcGatewayVO, Long>{
+    VpcGatewayVO getPrivateGatewayForVpc(long vpcId);
+    VpcGatewayVO getVpnGatewayForVpc(long vpcId);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/server/src/com/cloud/network/vpc/dao/VpcGatewayDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/dao/VpcGatewayDaoImpl.java b/server/src/com/cloud/network/vpc/dao/VpcGatewayDaoImpl.java
new file mode 100644
index 0000000..73649d6
--- /dev/null
+++ b/server/src/com/cloud/network/vpc/dao/VpcGatewayDaoImpl.java
@@ -0,0 +1,60 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.network.vpc.dao;
+
+import javax.ejb.Local;
+
+import com.cloud.network.vpc.VpcGateway;
+import com.cloud.network.vpc.VpcGatewayVO;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+
+@Local(value = VpcGatewayDao.class)
+@DB(txn = false)
+public class VpcGatewayDaoImpl extends GenericDaoBase<VpcGatewayVO, Long> implements VpcGatewayDao{
+    protected final SearchBuilder<VpcGatewayVO> AllFieldsSearch;
+    
+    protected VpcGatewayDaoImpl() {
+        AllFieldsSearch = createSearchBuilder();
+        AllFieldsSearch.and("vpcId", AllFieldsSearch.entity().getVpcId(), SearchCriteria.Op.EQ);
+        AllFieldsSearch.and("type", AllFieldsSearch.entity().getType(), SearchCriteria.Op.EQ);
+        AllFieldsSearch.done();
+    }
+
+
+    @Override
+    public VpcGatewayVO getPrivateGatewayForVpc(long vpcId) {
+        SearchCriteria<VpcGatewayVO> sc = AllFieldsSearch.create();
+        sc.setParameters("vpcId", vpcId);
+        sc.setParameters("type", VpcGateway.Type.Private);
+
+        return findOneBy(sc);
+    }
+
+    @Override
+    public VpcGatewayVO getVpnGatewayForVpc(long vpcId) {
+        SearchCriteria<VpcGatewayVO> sc = AllFieldsSearch.create();
+        sc.setParameters("vpcId", vpcId);
+        sc.setParameters("type", VpcGateway.Type.Vpn);
+
+        return findOneBy(sc);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/server/src/com/cloud/network/vpc/dao/VpcOfferingDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/dao/VpcOfferingDao.java b/server/src/com/cloud/network/vpc/dao/VpcOfferingDao.java
new file mode 100644
index 0000000..8138ac6
--- /dev/null
+++ b/server/src/com/cloud/network/vpc/dao/VpcOfferingDao.java
@@ -0,0 +1,32 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.network.vpc.dao;
+
+import com.cloud.network.vpc.VpcOfferingVO;
+import com.cloud.utils.db.GenericDao;
+
+
+public interface VpcOfferingDao extends GenericDao<VpcOfferingVO, Long>{
+    /**
+     * Returns the VPC offering that matches the unique name.
+     * 
+     * @param uniqueName
+     *            name
+     * @return VpcOfferingVO
+     */
+    VpcOfferingVO findByUniqueName(String uniqueName);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/057d6ccb/server/src/com/cloud/network/vpc/dao/VpcOfferingDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/dao/VpcOfferingDaoImpl.java b/server/src/com/cloud/network/vpc/dao/VpcOfferingDaoImpl.java
new file mode 100644
index 0000000..55cfd95
--- /dev/null
+++ b/server/src/com/cloud/network/vpc/dao/VpcOfferingDaoImpl.java
@@ -0,0 +1,69 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.network.vpc.dao;
+
+import javax.ejb.Local;
+
+import com.cloud.network.vpc.VpcOfferingVO;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria.Op;
+import com.cloud.utils.db.Transaction;
+
+
+@Local(value = VpcOfferingDao.class)
+@DB(txn = false)
+public class VpcOfferingDaoImpl extends GenericDaoBase<VpcOfferingVO, Long> implements VpcOfferingDao{
+    final SearchBuilder<VpcOfferingVO> AllFieldsSearch;
+
+    protected VpcOfferingDaoImpl() {
+        super();
+        
+        AllFieldsSearch = createSearchBuilder();
+        AllFieldsSearch.and("id", AllFieldsSearch.entity().getId(), Op.EQ);
+        AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.EQ);
+        AllFieldsSearch.and("name", AllFieldsSearch.entity().getName(), Op.EQ);
+        AllFieldsSearch.and("uName", AllFieldsSearch.entity().getUniqueName(), Op.EQ);
+        AllFieldsSearch.and("displayText", AllFieldsSearch.entity().getDisplayText(), Op.EQ);
+        AllFieldsSearch.and("svcOffId", AllFieldsSearch.entity().getServiceOfferingId(), Op.EQ);
+        AllFieldsSearch.done();
+        
+    }
+
+    @Override
+    @DB
+    public boolean remove(Long vpcOffId) {
+        Transaction txn = Transaction.currentTxn();
+        txn.start();
+        VpcOfferingVO offering = findById(vpcOffId);
+        offering.setUniqueName(null);
+        update(vpcOffId, offering);
+        boolean result = super.remove(vpcOffId);
+        txn.commit();
+        return result;
+    }
+
+
+    @Override
+    public VpcOfferingVO findByUniqueName(String uniqueName) {
+        SearchCriteria<VpcOfferingVO> sc = AllFieldsSearch.create();
+        sc.setParameters("uName", uniqueName);
+        return findOneBy(sc);
+    }
+}