cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [40/72] [abbrv] [partial] Moved most of the VOs and DAOs from server package into engine-schema as well
Date Tue, 07 May 2013 22:01:56 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d015fb35/engine/schema/src/com/cloud/network/dao/PhysicalNetworkServiceProviderVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/PhysicalNetworkServiceProviderVO.java b/engine/schema/src/com/cloud/network/dao/PhysicalNetworkServiceProviderVO.java
new file mode 100644
index 0000000..370e498
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/PhysicalNetworkServiceProviderVO.java
@@ -0,0 +1,322 @@
+// 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.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import com.cloud.network.Network.Service;
+import com.cloud.network.PhysicalNetworkServiceProvider;
+import com.cloud.utils.db.GenericDao;
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name = "physical_network_service_providers")
+public class PhysicalNetworkServiceProviderVO implements PhysicalNetworkServiceProvider, InternalIdentity {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    private long id;
+    
+    @Column(name="uuid")
+    private String uuid; 
+
+    @Column(name = "physical_network_id")
+    private long physicalNetworkId;
+    
+    @Column(name = "destination_physical_network_id")
+    private long destPhysicalNetworkId;    
+
+    @Column(name = "provider_name")
+    private String providerName;
+
+    @Column(name="state")
+    @Enumerated(value=EnumType.STRING)
+    State state;
+    
+    @Column(name = "vpn_service_provided")
+    boolean vpnServiceProvided;
+
+    @Column(name = "dhcp_service_provided")
+    boolean dhcpServiceProvided;
+    
+    @Column(name = "dns_service_provided")
+    boolean dnsServiceProvided;
+    
+    @Column(name = "gateway_service_provided")
+    boolean gatewayServiceProvided;
+    
+    @Column(name = "firewall_service_provided")
+    boolean firewallServiceProvided;
+    
+    @Column(name = "source_nat_service_provided")
+    boolean sourcenatServiceProvided;
+    
+    @Column(name = "load_balance_service_provided")
+    boolean lbServiceProvided;
+    
+    @Column(name = "static_nat_service_provided")
+    boolean staticnatServiceProvided;
+    
+    @Column(name = "port_forwarding_service_provided")
+    boolean portForwardingServiceProvided;
+    
+    @Column(name = "user_data_service_provided")
+    boolean userdataServiceProvided;
+    
+    @Column(name = "security_group_service_provided")
+    boolean securitygroupServiceProvided;
+    
+    @Column(name = "networkacl_service_provided")
+    boolean networkAclServiceProvided;
+    
+    @Column(name=GenericDao.REMOVED_COLUMN)
+    Date removed;
+    
+    public PhysicalNetworkServiceProviderVO() {
+    }
+
+    public PhysicalNetworkServiceProviderVO(long physicalNetworkId, String name) {
+        this.physicalNetworkId = physicalNetworkId;
+        this.providerName = name;
+        this.state = State.Disabled;
+        this.uuid = UUID.randomUUID().toString();
+    }
+
+    @Override
+    public long getId() {
+        return id;
+    }
+
+    @Override
+    public long getPhysicalNetworkId() {
+        return physicalNetworkId;
+    }
+
+
+    @Override
+    public State getState() {
+        return state;
+    }
+    
+    @Override
+    public void setState(State state) {
+        this.state = state;
+    }    
+
+    @Override
+    public String getProviderName() {
+        return providerName;
+    }
+
+    public void setDestinationPhysicalNetworkId(long destPhysicalNetworkId) {
+        this.destPhysicalNetworkId = destPhysicalNetworkId;
+    }
+    
+    @Override
+    public long getDestinationPhysicalNetworkId() {
+        return destPhysicalNetworkId;
+    }
+    
+    @Override
+    public boolean isVpnServiceProvided() {
+        return vpnServiceProvided;
+    }
+
+    public void setVpnServiceProvided(boolean vpnServiceProvided) {
+        this.vpnServiceProvided = vpnServiceProvided;
+    }
+
+    @Override
+    public boolean isDhcpServiceProvided() {
+        return dhcpServiceProvided;
+    }
+
+    public void setDhcpServiceProvided(boolean dhcpServiceProvided) {
+        this.dhcpServiceProvided = dhcpServiceProvided;
+    }
+
+    @Override
+    public boolean isDnsServiceProvided() {
+        return dnsServiceProvided;
+    }
+
+    public void setDnsServiceProvided(boolean dnsServiceProvided) {
+        this.dnsServiceProvided = dnsServiceProvided;
+    }
+
+    @Override
+    public boolean isGatewayServiceProvided() {
+        return gatewayServiceProvided;
+    }
+
+    public void setGatewayServiceProvided(boolean gatewayServiceProvided) {
+        this.gatewayServiceProvided = gatewayServiceProvided;
+    }
+
+    @Override
+    public boolean isFirewallServiceProvided() {
+        return firewallServiceProvided;
+    }
+
+    public void setFirewallServiceProvided(boolean firewallServiceProvided) {
+        this.firewallServiceProvided = firewallServiceProvided;
+    }
+
+    @Override
+    public boolean isSourcenatServiceProvided() {
+        return sourcenatServiceProvided;
+    }
+
+    public void setSourcenatServiceProvided(boolean sourcenatServiceProvided) {
+        this.sourcenatServiceProvided = sourcenatServiceProvided;
+    }
+
+    @Override
+    public boolean isLbServiceProvided() {
+        return lbServiceProvided;
+    }
+
+    public void setLbServiceProvided(boolean lbServiceProvided) {
+        this.lbServiceProvided = lbServiceProvided;
+    }
+
+    public boolean isStaticnatServiceProvided() {
+        return staticnatServiceProvided;
+    }
+
+    public void setStaticnatServiceProvided(boolean staticnatServiceProvided) {
+        this.staticnatServiceProvided = staticnatServiceProvided;
+    }
+
+    public boolean isPortForwardingServiceProvided() {
+        return portForwardingServiceProvided;
+    }
+
+    public void setPortForwardingServiceProvided(boolean portForwardingServiceProvided) {
+        this.portForwardingServiceProvided = portForwardingServiceProvided;
+    }
+
+    @Override
+    public boolean isUserdataServiceProvided() {
+        return userdataServiceProvided;
+    }
+
+    public void setUserdataServiceProvided(boolean userdataServiceProvided) {
+        this.userdataServiceProvided = userdataServiceProvided;
+    }
+
+    @Override
+    public boolean isSecuritygroupServiceProvided() {
+        return securitygroupServiceProvided;
+    }
+
+    public void setSecuritygroupServiceProvided(boolean securitygroupServiceProvided) {
+        this.securitygroupServiceProvided = securitygroupServiceProvided;
+    }
+    
+    @Override
+    public String getUuid() {
+        return this.uuid;
+    }
+    
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
+    
+    public Date getRemoved() {
+        return removed;
+    }
+
+    public void setRemoved(Date removed) {
+        this.removed = removed;
+    }
+    
+    public void setEnabledServices(List<Service> services){
+        this.setVpnServiceProvided(services.contains(Service.Vpn));
+        this.setDhcpServiceProvided(services.contains(Service.Dhcp));
+        this.setDnsServiceProvided(services.contains(Service.Dns));
+        this.setGatewayServiceProvided(services.contains(Service.Gateway));
+        this.setFirewallServiceProvided(services.contains(Service.Firewall));
+        this.setLbServiceProvided(services.contains(Service.Lb));
+        this.setSourcenatServiceProvided(services.contains(Service.SourceNat));
+        this.setStaticnatServiceProvided(services.contains(Service.StaticNat));
+        this.setPortForwardingServiceProvided(services.contains(Service.PortForwarding));
+        this.setUserdataServiceProvided(services.contains(Service.UserData));
+        this.setSecuritygroupServiceProvided(services.contains(Service.SecurityGroup));
+        this.setNetworkAclServiceProvided(services.contains(Service.NetworkACL));
+    }
+    
+    @Override
+    public List<Service> getEnabledServices(){
+        List<Service> services = new ArrayList<Service>();
+        if(this.isVpnServiceProvided()){
+            services.add(Service.Vpn);
+        }
+        if(this.isDhcpServiceProvided()){
+            services.add(Service.Dhcp);
+        }
+        if(this.isDnsServiceProvided()){
+            services.add(Service.Dns);
+        }
+        if(this.isGatewayServiceProvided()){
+            services.add(Service.Gateway);
+        }
+        if(this.isFirewallServiceProvided()){
+            services.add(Service.Firewall);
+        }
+        if(this.isLbServiceProvided()){
+            services.add(Service.Lb);
+        }
+        if(this.sourcenatServiceProvided){
+            services.add(Service.SourceNat);
+        }
+        if(this.staticnatServiceProvided){
+            services.add(Service.StaticNat);
+        }
+        if(this.portForwardingServiceProvided){
+            services.add(Service.PortForwarding);
+        }
+        if(this.isUserdataServiceProvided()){
+            services.add(Service.UserData);
+        }
+        if(this.isSecuritygroupServiceProvided()){
+            services.add(Service.SecurityGroup);
+        }
+        return services;
+    }
+    
+    @Override
+    public boolean isNetworkAclServiceProvided() {
+        return networkAclServiceProvided;
+    }
+
+    public void setNetworkAclServiceProvided(boolean networkAclServiceProvided) {
+        this.networkAclServiceProvided = networkAclServiceProvided;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d015fb35/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTagDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTagDaoImpl.java b/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTagDaoImpl.java
new file mode 100644
index 0000000..c3e9f73
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTagDaoImpl.java
@@ -0,0 +1,63 @@
+// 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 org.springframework.stereotype.Component;
+
+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;
+
+@Component
+public class PhysicalNetworkTagDaoImpl extends GenericDaoBase<PhysicalNetworkTagVO, Long> implements GenericDao<PhysicalNetworkTagVO, Long> {
+    private final GenericSearchBuilder<PhysicalNetworkTagVO, String> TagSearch;
+    private final SearchBuilder<PhysicalNetworkTagVO> AllFieldsSearch;
+
+    protected PhysicalNetworkTagDaoImpl() {
+        super();
+        TagSearch = createSearchBuilder(String.class);
+        TagSearch.selectField(TagSearch.entity().getTag());
+        TagSearch.and("physicalNetworkId", TagSearch.entity().getPhysicalNetworkId(), Op.EQ);
+        TagSearch.done();
+
+        AllFieldsSearch = createSearchBuilder();
+        AllFieldsSearch.and("id", AllFieldsSearch.entity().getId(), Op.EQ);
+        AllFieldsSearch.and("physicalNetworkId", AllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
+        AllFieldsSearch.and("tag", AllFieldsSearch.entity().getTag(), Op.EQ);
+        AllFieldsSearch.done();
+    }
+
+    public List<String> getTags(long physicalNetworkId) {
+        SearchCriteria<String> sc = TagSearch.create();
+        sc.setParameters("physicalNetworkId", physicalNetworkId);
+
+        return customSearch(sc, null);
+    }
+
+    public int clearTags(long physicalNetworkId) {
+        SearchCriteria<PhysicalNetworkTagVO> sc = AllFieldsSearch.create();
+        sc.setParameters("physicalNetworkId", physicalNetworkId);
+
+        return remove(sc);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d015fb35/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTagVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTagVO.java b/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTagVO.java
new file mode 100644
index 0000000..787c049
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTagVO.java
@@ -0,0 +1,68 @@
+// 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 org.apache.cloudstack.api.InternalIdentity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+/**
+ * 
+ */
+@Entity
+@Table(name = "physical_network_tags")
+public class PhysicalNetworkTagVO implements InternalIdentity {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    private long id;
+
+    @Column(name = "physical_network_id")
+    private long physicalNetworkId;
+
+    @Column(name = "tag")
+    private String tag;
+
+    /**
+     * There should never be a public constructor for this class. Since it's
+     * only here to define the table for the DAO class.
+     */
+    protected PhysicalNetworkTagVO() {
+    }
+
+    protected PhysicalNetworkTagVO(long physicalNetworkId, String tag) {
+        this.physicalNetworkId = physicalNetworkId;
+        this.tag = tag;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public long getPhysicalNetworkId() {
+        return physicalNetworkId;
+    }
+
+    public String getTag() {
+        return tag;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d015fb35/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDao.java b/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDao.java
new file mode 100644
index 0000000..42e5b4e
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDao.java
@@ -0,0 +1,33 @@
+// 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.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.network.Networks.TrafficType;
+import com.cloud.utils.Pair;
+import com.cloud.utils.db.GenericDao;
+
+public interface PhysicalNetworkTrafficTypeDao extends GenericDao<PhysicalNetworkTrafficTypeVO, Long> {
+    Pair<List<PhysicalNetworkTrafficTypeVO>, Integer> listAndCountBy(long physicalNetworkId);
+    boolean isTrafficTypeSupported(long physicalNetworkId, TrafficType trafficType);
+    String getNetworkTag (long physicalNetworkId, TrafficType trafficType, HypervisorType hType);
+    PhysicalNetworkTrafficTypeVO findBy(long physicalNetworkId, TrafficType trafficType);
+    void deleteTrafficTypes(long physicalNetworkId);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d015fb35/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDaoImpl.java b/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDaoImpl.java
new file mode 100755
index 0000000..7e47239
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDaoImpl.java
@@ -0,0 +1,143 @@
+// 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 javax.ejb.Local;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.network.Networks.TrafficType;
+import com.cloud.utils.Pair;
+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.Op;
+
+@Component
+@Local(value=PhysicalNetworkTrafficTypeDao.class) @DB(txn=false)
+public class PhysicalNetworkTrafficTypeDaoImpl extends GenericDaoBase<PhysicalNetworkTrafficTypeVO, Long> implements PhysicalNetworkTrafficTypeDao {
+    final SearchBuilder<PhysicalNetworkTrafficTypeVO> physicalNetworkSearch;
+    final GenericSearchBuilder<PhysicalNetworkTrafficTypeVO, String> kvmAllFieldsSearch;
+    final GenericSearchBuilder<PhysicalNetworkTrafficTypeVO, String> xenAllFieldsSearch;
+    final GenericSearchBuilder<PhysicalNetworkTrafficTypeVO, String> vmWareAllFieldsSearch;
+    final GenericSearchBuilder<PhysicalNetworkTrafficTypeVO, String> simulatorAllFieldsSearch;
+    final GenericSearchBuilder<PhysicalNetworkTrafficTypeVO, String> ovmAllFieldsSearch;
+
+    protected PhysicalNetworkTrafficTypeDaoImpl() {
+        super();
+        physicalNetworkSearch = createSearchBuilder();
+        physicalNetworkSearch.and("physicalNetworkId", physicalNetworkSearch.entity().getPhysicalNetworkId(), Op.EQ);
+        physicalNetworkSearch.and("trafficType", physicalNetworkSearch.entity().getTrafficType(), Op.EQ);
+        physicalNetworkSearch.done();
+
+        kvmAllFieldsSearch = createSearchBuilder(String.class);
+        kvmAllFieldsSearch.and("physicalNetworkId", kvmAllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
+        kvmAllFieldsSearch.and("trafficType", kvmAllFieldsSearch.entity().getTrafficType(), Op.EQ);
+        kvmAllFieldsSearch.selectField(kvmAllFieldsSearch.entity().getKvmNetworkLabel());
+        kvmAllFieldsSearch.done();
+
+        xenAllFieldsSearch = createSearchBuilder(String.class);
+        xenAllFieldsSearch.and("physicalNetworkId", xenAllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
+        xenAllFieldsSearch.and("trafficType", xenAllFieldsSearch.entity().getTrafficType(), Op.EQ);
+        xenAllFieldsSearch.selectField(xenAllFieldsSearch.entity().getXenNetworkLabel());
+        xenAllFieldsSearch.done();
+
+        vmWareAllFieldsSearch = createSearchBuilder(String.class);
+        vmWareAllFieldsSearch.and("physicalNetworkId", vmWareAllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
+        vmWareAllFieldsSearch.and("trafficType", vmWareAllFieldsSearch.entity().getTrafficType(), Op.EQ);
+        vmWareAllFieldsSearch.selectField(vmWareAllFieldsSearch.entity().getVmwareNetworkLabel());
+        vmWareAllFieldsSearch.done();
+        
+        simulatorAllFieldsSearch = createSearchBuilder(String.class);
+        simulatorAllFieldsSearch.and("physicalNetworkId", simulatorAllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
+        simulatorAllFieldsSearch.and("trafficType", simulatorAllFieldsSearch.entity().getTrafficType(), Op.EQ);
+        simulatorAllFieldsSearch.selectField(simulatorAllFieldsSearch.entity().getSimulatorNetworkLabel());
+        simulatorAllFieldsSearch.done();
+        
+        ovmAllFieldsSearch = createSearchBuilder(String.class);
+        ovmAllFieldsSearch.and("physicalNetworkId", ovmAllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
+        ovmAllFieldsSearch.and("trafficType", ovmAllFieldsSearch.entity().getTrafficType(), Op.EQ);
+        ovmAllFieldsSearch.selectField(ovmAllFieldsSearch.entity().getSimulatorNetworkLabel());
+        ovmAllFieldsSearch.done();
+    }
+
+    @Override
+    public Pair<List<PhysicalNetworkTrafficTypeVO>, Integer> listAndCountBy(long physicalNetworkId) {
+        SearchCriteria<PhysicalNetworkTrafficTypeVO> sc = physicalNetworkSearch.create();
+        sc.setParameters("physicalNetworkId", physicalNetworkId);
+        return searchAndCount(sc, null);
+    }
+
+    @Override
+    public boolean isTrafficTypeSupported(long physicalNetworkId, TrafficType trafficType){
+        SearchCriteria<PhysicalNetworkTrafficTypeVO> sc = physicalNetworkSearch.create();
+        sc.setParameters("physicalNetworkId", physicalNetworkId);
+        sc.setParameters("trafficType", trafficType);
+        if (findOneBy(sc) != null) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    @Override
+    public String getNetworkTag(long physicalNetworkId, TrafficType trafficType, HypervisorType hType) {
+        SearchCriteria<String> sc = null;
+        if (hType == HypervisorType.XenServer) {
+            sc = xenAllFieldsSearch.create();
+        } else if (hType == HypervisorType.KVM) {
+            sc = kvmAllFieldsSearch.create();
+        } else if (hType == HypervisorType.VMware) {
+            sc = vmWareAllFieldsSearch.create();
+        } else if (hType == HypervisorType.Simulator) {
+        	sc = simulatorAllFieldsSearch.create();
+        } else if (hType == HypervisorType.Ovm) {
+        	sc = ovmAllFieldsSearch.create();
+        } else if (hType == HypervisorType.BareMetal) {
+        	return null;
+        } else {
+            assert(false) : "We don't handle this hypervisor type";
+            return null;
+        }
+
+        sc.setParameters("physicalNetworkId", physicalNetworkId);
+        sc.setParameters("trafficType", trafficType);
+        List<String> tag = customSearch(sc, null);
+
+        return tag.size() == 0 ? null : tag.get(0);
+    }
+
+    @Override
+    public PhysicalNetworkTrafficTypeVO findBy(long physicalNetworkId, TrafficType trafficType){
+        SearchCriteria<PhysicalNetworkTrafficTypeVO> sc = physicalNetworkSearch.create();
+        sc.setParameters("physicalNetworkId", physicalNetworkId);
+        sc.setParameters("trafficType", trafficType);
+        return findOneBy(sc);
+    }
+
+    @Override
+    public void deleteTrafficTypes(long physicalNetworkId) {
+        SearchCriteria<PhysicalNetworkTrafficTypeVO> sc = physicalNetworkSearch.create();
+        sc.setParameters("physicalNetworkId", physicalNetworkId);
+        remove(sc);        
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d015fb35/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeVO.java b/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeVO.java
new file mode 100644
index 0000000..4c32d0a
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeVO.java
@@ -0,0 +1,149 @@
+// 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.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import com.cloud.network.Networks.TrafficType;
+import com.cloud.network.PhysicalNetworkTrafficType;
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name = "physical_network_traffic_types")
+public class PhysicalNetworkTrafficTypeVO implements PhysicalNetworkTrafficType {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    private long id;
+    
+    @Column(name="uuid")
+    private String uuid;   
+
+    @Column(name = "physical_network_id")
+    private long physicalNetworkId;
+    
+    @Column(name="traffic_type")
+    @Enumerated(value=EnumType.STRING)
+    TrafficType trafficType;
+
+    @Column(name = "xen_network_label")
+    private String xenNetworkLabel;
+
+    @Column(name = "kvm_network_label")
+    private String kvmNetworkLabel;
+
+    @Column(name = "vmware_network_label")
+    private String vmwareNetworkLabel;
+
+    @Column(name = "simulator_network_label")
+    private String simulatorNetworkLabel;
+    
+    @Column(name = "vlan")
+    private String vlan;
+    
+    public PhysicalNetworkTrafficTypeVO() {
+    }
+
+    public PhysicalNetworkTrafficTypeVO(long physicalNetworkId, TrafficType trafficType, String xenLabel, String kvmLabel, String vmwareLabel, String simulatorLabel, String vlan) {
+        this.physicalNetworkId = physicalNetworkId;
+        this.trafficType = trafficType;
+        this.xenNetworkLabel = xenLabel;
+        this.kvmNetworkLabel = kvmLabel;
+        this.vmwareNetworkLabel = vmwareLabel;
+        this.simulatorNetworkLabel = simulatorLabel;
+        this.setVlan(vlan);
+        this.uuid = UUID.randomUUID().toString();
+    }
+
+    @Override
+    public long getId() {
+        return id;
+    }
+
+    @Override
+    public long getPhysicalNetworkId() {
+        return physicalNetworkId;
+    }
+
+    @Override
+    public TrafficType getTrafficType() {
+        return trafficType;
+    }
+    
+    public void setXenNetworkLabel(String xenNetworkLabel) {
+        this.xenNetworkLabel = xenNetworkLabel;
+    }
+
+    @Override
+    public String getXenNetworkLabel() {
+        return xenNetworkLabel;
+    }
+
+    public void setKvmNetworkLabel(String kvmNetworkLabel) {
+        this.kvmNetworkLabel = kvmNetworkLabel;
+    }
+
+    @Override
+    public String getKvmNetworkLabel() {
+        return kvmNetworkLabel;
+    }
+
+    public void setVmwareNetworkLabel(String vmwareNetworkLabel) {
+        this.vmwareNetworkLabel = vmwareNetworkLabel;
+    }
+    
+    @Override
+    public String getVmwareNetworkLabel() {
+    	return vmwareNetworkLabel;
+    }
+
+	public void setSimulatorNetworkLabel(String simulatorNetworkLabel) {
+		this.simulatorNetworkLabel = simulatorNetworkLabel;
+	}
+	
+	@Override
+	public String getSimulatorNetworkLabel() {
+		return simulatorNetworkLabel;
+	}
+
+    public void setVlan(String vlan) {
+        this.vlan = vlan;
+    }
+
+    public String getVlan() {
+        return vlan;
+    }  
+    
+    @Override
+    public String getUuid() {
+        return this.uuid;
+    }
+    
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d015fb35/engine/schema/src/com/cloud/network/dao/PhysicalNetworkVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/PhysicalNetworkVO.java b/engine/schema/src/com/cloud/network/dao/PhysicalNetworkVO.java
new file mode 100644
index 0000000..f68eee1
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/PhysicalNetworkVO.java
@@ -0,0 +1,246 @@
+// 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.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+import javax.persistence.CollectionTable;
+import javax.persistence.Column;
+import javax.persistence.ElementCollection;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.Table;
+import javax.persistence.TableGenerator;
+
+import com.cloud.network.PhysicalNetwork;
+import com.cloud.utils.NumbersUtil;
+import com.cloud.utils.Pair;
+import com.cloud.utils.db.GenericDao;
+
+/**
+ * NetworkConfigurationVO contains information about a specific physical network.
+ *
+ */
+@Entity
+@Table(name="physical_network")
+public class PhysicalNetworkVO implements PhysicalNetwork {
+    @Id
+    @TableGenerator(name="physical_networks_sq", table="sequence", pkColumnName="name", valueColumnName="value", pkColumnValue="physical_networks_seq", allocationSize=1)
+    @Column(name="id")
+    long id;
+    
+    @Column(name="uuid")
+    private String uuid;
+    
+	@Column(name="name")
+	private String name;
+
+    @Column(name="data_center_id")
+    long dataCenterId;
+
+    @Column(name="vnet")
+    private String vnet = null;
+    
+    @Column(name="speed")
+    private String speed = null;
+    
+    @Column(name="domain_id")
+    Long domainId = null;
+
+    @Column(name="broadcast_domain_range")
+    @Enumerated(value=EnumType.STRING)
+    BroadcastDomainRange broadcastDomainRange;
+
+    @Column(name="state")
+    @Enumerated(value=EnumType.STRING)
+    State state;
+    
+    @Column(name=GenericDao.REMOVED_COLUMN)
+    Date removed;
+
+    @Column(name=GenericDao.CREATED_COLUMN)
+    Date created;
+
+    @ElementCollection(targetClass = String.class, fetch=FetchType.EAGER)
+    @Column(name="tag")
+    @CollectionTable(name="physical_network_tags", joinColumns=@JoinColumn(name="physical_network_id"))
+    List<String> tags;
+    
+    @ElementCollection(targetClass = String.class, fetch=FetchType.EAGER)
+    @Column(name="isolation_method")
+    @CollectionTable(name="physical_network_isolation_methods", joinColumns=@JoinColumn(name="physical_network_id"))
+    List<String> isolationMethods;
+
+    public PhysicalNetworkVO(){
+        
+    }
+    
+    public PhysicalNetworkVO(long id, long dataCenterId, String vnet, String speed, Long domainId, BroadcastDomainRange broadcastDomainRange, String name) {
+        this.dataCenterId = dataCenterId;
+        this.setVnet(vnet);
+        this.setSpeed(speed);
+        this.domainId = domainId;
+        if(broadcastDomainRange != null){
+            this.broadcastDomainRange = broadcastDomainRange;
+        }else{
+            this.broadcastDomainRange = BroadcastDomainRange.POD;
+        }
+        this.state = State.Disabled;
+        this.uuid = UUID.randomUUID().toString();
+        this.name = name;
+        this.id = id;
+    }
+
+    @Override
+    public State getState() {
+        return state;
+    }
+
+    public void setState(State state) {
+        this.state = state;
+    }
+
+    @Override
+    public long getId() {
+        return id;
+    }
+
+    @Override
+    public List<String> getTags() {
+        return tags != null ? tags : new ArrayList<String>();
+    }
+
+    public void addTag(String tag) {
+        if (tags == null) {
+            tags = new ArrayList<String>();
+        }
+        tags.add(tag);
+    }
+
+    public void setTags(List<String> tags) {
+        this.tags = tags;
+    }
+
+    @Override
+    public Long getDomainId() {
+        return domainId;
+    }
+
+    @Override
+    public BroadcastDomainRange getBroadcastDomainRange() {
+        return broadcastDomainRange;
+    }
+
+    public void setBroadcastDomainRange(BroadcastDomainRange broadcastDomainRange) {
+        this.broadcastDomainRange = broadcastDomainRange;
+    }
+
+    @Override
+    public int hashCode() {
+        return NumbersUtil.hash(id);
+    }
+
+    @Override
+    public long getDataCenterId() {
+        return dataCenterId;
+    }
+
+    public Date getRemoved() {
+        return removed;
+    }
+
+    public void setRemoved(Date removed) {
+        this.removed = removed;
+    }
+
+    public Date getCreated() {
+        return created;
+    }
+
+    public void setCreated(Date created) {
+        this.created = created;
+    }
+
+    @Override
+    public List<String> getIsolationMethods() {
+        return isolationMethods != null ? isolationMethods : new ArrayList<String>();
+    }
+    
+    public void addIsolationMethod(String isolationMethod) {
+        if (isolationMethods == null) {
+            isolationMethods = new ArrayList<String>();
+        }
+        isolationMethods.add(isolationMethod);
+    }
+
+    public void setIsolationMethods(List<String> isolationMethods) {
+        this.isolationMethods = isolationMethods;
+    }
+
+    public void setVnet(String vnet) {
+        this.vnet = vnet;
+    }
+
+    @Override
+    public List<Pair<Integer, Integer>> getVnet() {
+        List <Pair<Integer,Integer>>  vnetList = new ArrayList<Pair<Integer, Integer>>();
+        if (vnet != null) {
+           String [] Temp = vnet.split(";");
+           String [] vnetSplit = null;
+           for (String vnetRange : Temp){
+               vnetSplit = vnetRange.split("-");
+               vnetList.add(new Pair<Integer,Integer>(Integer.parseInt(vnetSplit[0]),Integer.parseInt(vnetSplit[1])));
+           }
+        }
+        return vnetList;
+    }
+
+    @Override
+    public String getVnetString() {
+        return vnet;
+    }
+
+    public void setSpeed(String speed) {
+        this.speed = speed;
+    }
+
+    @Override
+    public String getSpeed() {
+        return speed;
+    }
+    
+    @Override
+    public String getUuid() {
+        return this.uuid;
+    }
+    
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
+
+    @Override
+	public String getName() {
+		return name;
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d015fb35/engine/schema/src/com/cloud/network/dao/PortProfileDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/PortProfileDao.java b/engine/schema/src/com/cloud/network/dao/PortProfileDao.java
new file mode 100644
index 0000000..5ecd8f4
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/PortProfileDao.java
@@ -0,0 +1,50 @@
+// 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.utils.db.GenericDao;
+
+public interface PortProfileDao extends GenericDao<PortProfileVO, Long> {
+
+    /**
+     * Return a Port Profile VO (db record) given its name.
+     */
+    PortProfileVO findByName(String portProfileName);
+    
+    /*
+     * Returns true if there already is any portprofile that trunks
+     * vlan IDs in a specified range.
+     */
+    boolean doesVlanRangeClash(int lowVlanId, int highVlanId);
+    
+    /*
+     * Return a list of port profiles that have the specified access vlanID.
+     */
+    List<PortProfileVO> listByVlanId(int vlanId);
+    
+    /**
+     * Other candidate functions that could be helpful.
+     * 
+     * List all portprofiles configured with a particular id.
+     * List<PortProfileVO> listByVlanId(int vlanId);
+     * 
+     * List all uplink portprofiles (these represent physical ports).
+     * List<PortProfileVO> listAllUplinkPortProfiles();	// we may have to provide some filter, like clusterId or zoneId or something.
+     * 
+     */
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d015fb35/engine/schema/src/com/cloud/network/dao/PortProfileDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/PortProfileDaoImpl.java b/engine/schema/src/com/cloud/network/dao/PortProfileDaoImpl.java
new file mode 100644
index 0000000..61fe52a
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/PortProfileDaoImpl.java
@@ -0,0 +1,89 @@
+// 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.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+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.Transaction;
+import com.cloud.utils.db.SearchCriteria.Op;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@Component
+@Local(value=PortProfileDao.class) @DB(txn=false)
+public class PortProfileDaoImpl extends GenericDaoBase<PortProfileVO, Long> implements PortProfileDao {
+	protected static final Logger s_logger     = Logger.getLogger(PortProfileDaoImpl.class);
+	
+    final SearchBuilder<PortProfileVO> nameSearch;
+    final SearchBuilder<PortProfileVO> accessVlanSearch;
+    
+    public PortProfileDaoImpl() {    	
+        super();
+        
+        nameSearch = createSearchBuilder();
+        nameSearch.and("portProfileName", nameSearch.entity().getPortProfileName(), Op.EQ);
+        nameSearch.done();
+        
+        accessVlanSearch = createSearchBuilder();
+        accessVlanSearch.and("accessVlanId", accessVlanSearch.entity().getAccessVlanId(), Op.EQ);
+        accessVlanSearch.done();
+    }
+    
+    public PortProfileVO findByName(String portProfileName) {
+    	SearchCriteria<PortProfileVO> sc = nameSearch.create();
+    	sc.setParameters("portProfileName", portProfileName);
+    	return findOneBy(sc);
+    }
+    
+    @DB
+    public boolean doesVlanRangeClash(int lowVlanId, int highVlanId) {
+    	String dbName = "cloud";
+    	String tableName = "port_profile";
+    	String condition = "(trunk_low_vlan_id BETWEEN " + lowVlanId + " AND " + highVlanId + ")" + " OR (trunk_high_vlan_id BETWEEN " + lowVlanId + " AND " + highVlanId + ")";
+    	String selectSql = "SELECT * FROM `" + dbName + "`.`" + tableName + "` WHERE " + condition;
+
+        Transaction txn = Transaction.currentTxn();
+        try {
+            PreparedStatement stmt = txn.prepareAutoCloseStatement(selectSql);
+            ResultSet rs = stmt.executeQuery();
+            if (rs != null && rs.next()) {
+            	// There are records that contain vlans in this range, so return true
+            	return true;
+            }
+        } catch (SQLException ex) {
+            throw new CloudRuntimeException("Failed to execute SQL query to check for vlan range clash");
+        }
+        return false;
+    }
+    
+    public List<PortProfileVO> listByVlanId(int vlanId) {
+    	SearchCriteria<PortProfileVO> sc = accessVlanSearch.create();
+    	sc.setParameters("accessVlanId", vlanId);
+    	return search(sc, null);
+    }
+    
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d015fb35/engine/schema/src/com/cloud/network/dao/PortProfileVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/PortProfileVO.java b/engine/schema/src/com/cloud/network/dao/PortProfileVO.java
new file mode 100644
index 0000000..6227348
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/PortProfileVO.java
@@ -0,0 +1,204 @@
+// 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.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import com.cloud.exception.InvalidParameterValueException;
+import org.apache.cloudstack.api.InternalIdentity;
+
+/**
+ * PortProfileVO contains information on portprofiles that are created on a Cisco Nexus 1000v VSM associated
+ * with a VMWare cluster. 
+ */
+
+@Entity
+@Table(name="port_profile")
+public class PortProfileVO implements InternalIdentity {
+	
+	// We need to know what properties a VSM has. Put them here.
+	
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    private long id;
+
+    @Column(name="uuid")
+    private String uuid;
+
+    @Column(name = "port_profile_name")
+    private String portProfileName;
+
+    @Column(name = "port_mode")
+    private PortMode portMode;
+    
+    @Column(name = "vsm_id")
+    private long vsmId;
+
+    @Column(name = "trunk_low_vlan_id")
+    private int lowVlanId;
+    
+    @Column(name = "trunk_high_vlan_id")
+    private int highVlanId;
+    
+    @Column(name = "access_vlan_id")
+    private int accessVlanId;
+    
+    @Column(name = "port_type")
+    private PortType portType;
+    
+    @Column(name = "port_binding")
+    private BindingType portBinding;
+
+    public enum BindingType {
+    	Static,
+    	Ephemeral
+    }
+    
+    public enum PortType {
+    	Ethernet,
+    	vEthernet
+    }
+    
+    // This tells us whether the port trunks multiple VLANs
+    // or carries traffic of a single VLAN.
+    public enum PortMode {
+    	Access,
+    	Trunk
+    }
+
+    // Accessor methods
+    public long getId() {
+        return id;
+    }
+
+    public String getUuid() {
+        return uuid;
+    }
+
+    public String getPortProfileName() {
+    	return portProfileName;
+    }
+    
+    public PortMode getPortMode() {
+    	return portMode;
+    }
+    
+    public long getVsmId() {
+    	return vsmId;
+    }
+    
+    public int getLowVlanId() {
+    	return lowVlanId;
+    }
+    
+    public int getHighVlanId() {
+    	return highVlanId;
+    }
+    
+    public int getAccessVlanId() {
+    	return accessVlanId;
+    }
+    
+    public PortType getPortType() {
+    	return portType;
+    }
+    
+    public BindingType getPortBinding() {
+    	return portBinding;
+    }
+    
+    // Setter methods
+
+    public void setPortProfileName(String name) {
+    	portProfileName = name;
+    }
+    
+    public void setPortMode(PortMode mode) {
+    	portMode = mode;
+    }
+    
+    public void setVsmId(long id) {
+    	vsmId = id;
+    }
+    
+    public void setLowVlanId(int vlanId) {
+    	lowVlanId = vlanId;
+    }
+    
+    public void setHighVlanId(int vlanId) {
+    	highVlanId = vlanId;
+    }
+    
+    public void setAccessVlanId(int vlanId) {
+    	accessVlanId = vlanId;
+    }
+    
+    public void setPortType(PortType type) {
+    	portType = type;
+    }
+    
+    public void setPortBinding(BindingType bindingType) {
+    	portBinding = bindingType;
+    }
+
+    // Constructor methods.
+    
+    public PortProfileVO(String portProfName, long vsmId, int vlanId, PortType pType, BindingType bType) {
+    	// Set the relevant portprofile properties here.
+    	// When supplied with a single vlanId, we set this portprofile as an access port profile.
+    	
+    	this.setPortMode(PortMode.Access);
+    	
+        this.uuid = UUID.randomUUID().toString();
+        this.setPortProfileName(portProfName);
+        this.setVsmId(vsmId);
+        this.setAccessVlanId(vlanId);
+        this.setPortType(pType);
+        this.setPortBinding(bType);
+    }
+    
+    public PortProfileVO(String portProfName, long vsmId, int lowVlanId, int highVlanId, PortType pType, BindingType bType) {
+    	// Set the relevant portprofile properties here.
+    	// When supplied with a vlan range, we set this portprofile as a trunk port profile.
+    	
+    	if (lowVlanId >= highVlanId) {
+    		throw new InvalidParameterValueException("Low Vlan Id cannot be greater than or equal to high Vlan Id");
+    	}
+    	this.setPortMode(PortMode.Trunk);
+    	
+        this.uuid = UUID.randomUUID().toString();
+        this.setPortProfileName(portProfName);
+        this.setVsmId(vsmId);
+        this.setLowVlanId(lowVlanId);
+        this.setHighVlanId(highVlanId);
+        this.setPortType(pType);
+        this.setPortBinding(bType);
+    }    
+    
+    public PortProfileVO() {
+        this.uuid = UUID.randomUUID().toString();
+    }    
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d015fb35/engine/schema/src/com/cloud/network/dao/RemoteAccessVpnDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/RemoteAccessVpnDao.java b/engine/schema/src/com/cloud/network/dao/RemoteAccessVpnDao.java
new file mode 100644
index 0000000..6e3b483
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/RemoteAccessVpnDao.java
@@ -0,0 +1,30 @@
+// 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.RemoteAccessVpn;
+import com.cloud.utils.db.GenericDao;
+
+public interface RemoteAccessVpnDao extends GenericDao<RemoteAccessVpnVO, Long> {
+    RemoteAccessVpnVO findByPublicIpAddress(long ipAddressId);
+    RemoteAccessVpnVO findByPublicIpAddressAndState(long ipAddressId, RemoteAccessVpn.State state);
+    RemoteAccessVpnVO findByAccountAndNetwork(Long accountId, Long zoneId);
+    List<RemoteAccessVpnVO> findByAccount(Long accountId);
+    List<RemoteAccessVpnVO> listByNetworkId(Long networkId);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d015fb35/engine/schema/src/com/cloud/network/dao/RemoteAccessVpnDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/RemoteAccessVpnDaoImpl.java b/engine/schema/src/com/cloud/network/dao/RemoteAccessVpnDaoImpl.java
new file mode 100644
index 0000000..ed732d8
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/RemoteAccessVpnDaoImpl.java
@@ -0,0 +1,84 @@
+// 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 javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import com.cloud.network.RemoteAccessVpn;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+@Component
+@Local(value={RemoteAccessVpnDao.class})
+public class RemoteAccessVpnDaoImpl extends GenericDaoBase<RemoteAccessVpnVO, Long> implements RemoteAccessVpnDao {
+    private static final Logger s_logger = Logger.getLogger(RemoteAccessVpnDaoImpl.class);
+    
+    private final SearchBuilder<RemoteAccessVpnVO> AllFieldsSearch;
+
+
+    protected RemoteAccessVpnDaoImpl() {
+        AllFieldsSearch = createSearchBuilder();
+        AllFieldsSearch.and("accountId", AllFieldsSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
+        AllFieldsSearch.and("networkId", AllFieldsSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
+        AllFieldsSearch.and("ipAddress", AllFieldsSearch.entity().getServerAddressId(), SearchCriteria.Op.EQ);
+        AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), SearchCriteria.Op.EQ);
+        AllFieldsSearch.done();
+    }
+
+    @Override
+    public RemoteAccessVpnVO findByPublicIpAddress(long ipAddressId) {
+        SearchCriteria<RemoteAccessVpnVO> sc = AllFieldsSearch.create();
+        sc.setParameters("ipAddress", ipAddressId);
+        return findOneBy(sc);
+    }
+
+    @Override
+    public RemoteAccessVpnVO findByAccountAndNetwork(Long accountId, Long networkId) {
+        SearchCriteria<RemoteAccessVpnVO> sc = AllFieldsSearch.create();
+        sc.setParameters("accountId", accountId);
+        sc.setParameters("networkId", networkId);
+        return findOneBy(sc);
+    }
+
+	@Override
+	public List<RemoteAccessVpnVO> findByAccount(Long accountId) {
+		SearchCriteria<RemoteAccessVpnVO> sc = AllFieldsSearch.create();
+        sc.setParameters("accountId", accountId);
+        return listBy(sc);
+	}
+	
+	@Override
+	public RemoteAccessVpnVO findByPublicIpAddressAndState(long ipAddressId, RemoteAccessVpn.State state) {
+	    SearchCriteria<RemoteAccessVpnVO> sc = AllFieldsSearch.create();
+        sc.setParameters("ipAddress", ipAddressId);
+        sc.setParameters("state", state);
+        return findOneBy(sc);
+	}
+	
+	@Override
+	public List<RemoteAccessVpnVO> listByNetworkId(Long networkId) {
+	    SearchCriteria<RemoteAccessVpnVO> sc = AllFieldsSearch.create();
+        sc.setParameters("networkId", networkId);
+        return listBy(sc);
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d015fb35/engine/schema/src/com/cloud/network/dao/RemoteAccessVpnVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/RemoteAccessVpnVO.java b/engine/schema/src/com/cloud/network/dao/RemoteAccessVpnVO.java
new file mode 100644
index 0000000..2e8ee91
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/RemoteAccessVpnVO.java
@@ -0,0 +1,142 @@
+// 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.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import com.cloud.network.RemoteAccessVpn;
+
+@Entity
+@Table(name=("remote_access_vpn"))
+public class RemoteAccessVpnVO implements RemoteAccessVpn {
+    @Column(name="account_id")
+    private long accountId;
+
+    @Column(name="network_id")
+    private long networkId;
+    
+    @Column(name="domain_id")
+    private long domainId;
+
+    @Column(name="vpn_server_addr_id")
+    private long serverAddressId;
+    
+    @Column(name="local_ip")
+    private String localIp;
+
+    @Column(name="ip_range")
+    private String ipRange;
+
+    @Column(name="ipsec_psk")
+    private String ipsecPresharedKey;
+    
+    @Column(name="state")
+    private State state;
+    
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    private long id;
+    
+    @Column(name="uuid")
+    private String uuid;
+
+    public RemoteAccessVpnVO() { 
+        this.uuid = UUID.randomUUID().toString();
+    }
+
+    public RemoteAccessVpnVO(long accountId, long domainId, long networkId, long publicIpId, String localIp, String ipRange,  String presharedKey) {
+        this.accountId = accountId;
+        this.serverAddressId = publicIpId;
+        this.ipRange = ipRange;
+        this.ipsecPresharedKey = presharedKey;
+        this.localIp = localIp;
+        this.domainId = domainId;
+        this.networkId = networkId;
+        this.state = State.Added;
+        this.uuid = UUID.randomUUID().toString();
+    }
+    
+    @Override
+    public State getState() {
+        return state;
+    }
+    
+    public void setState(State state) {
+        this.state = state;
+    }
+
+    @Override
+    public long getAccountId() {
+        return accountId;
+    }
+    
+    @Override
+	public long getServerAddressId() {
+        return serverAddressId;
+    }
+
+    @Override
+    public String getIpRange() {
+		return ipRange;
+	}
+
+    public void setIpRange(String ipRange) {
+		this.ipRange = ipRange;
+	}
+
+	@Override
+    public String getIpsecPresharedKey() {
+		return ipsecPresharedKey;
+	}
+
+    public void setIpsecPresharedKey(String ipsecPresharedKey) {
+		this.ipsecPresharedKey = ipsecPresharedKey;
+	}
+
+	@Override
+    public String getLocalIp() {
+		return localIp;
+	}
+
+	@Override
+    public long getDomainId() {
+		return domainId;
+	}
+	
+	@Override
+    public long getNetworkId() {
+	    return networkId;
+	}
+
+    @Override
+    public long getId() {
+        return id;
+    }
+
+    @Override
+    public String getUuid() {
+        return uuid;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d015fb35/engine/schema/src/com/cloud/network/dao/RouterNetworkDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/RouterNetworkDao.java b/engine/schema/src/com/cloud/network/dao/RouterNetworkDao.java
new file mode 100644
index 0000000..bd275bd
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/RouterNetworkDao.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.dao;
+
+import java.util.List;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface RouterNetworkDao extends GenericDao<RouterNetworkVO, Long> {
+    public List<Long> getRouterNetworks(long routerId); 
+    public RouterNetworkVO findByRouterAndNetwork (long routerId, long networkId);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d015fb35/engine/schema/src/com/cloud/network/dao/RouterNetworkDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/RouterNetworkDaoImpl.java b/engine/schema/src/com/cloud/network/dao/RouterNetworkDaoImpl.java
new file mode 100644
index 0000000..b0b633c
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/RouterNetworkDaoImpl.java
@@ -0,0 +1,62 @@
+// 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 org.springframework.stereotype.Component;
+
+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;
+
+@Component
+public class RouterNetworkDaoImpl extends GenericDaoBase<RouterNetworkVO, Long> implements RouterNetworkDao {
+    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/cloudstack/blob/d015fb35/engine/schema/src/com/cloud/network/dao/RouterNetworkVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/RouterNetworkVO.java b/engine/schema/src/com/cloud/network/dao/RouterNetworkVO.java
new file mode 100644
index 0000000..c4fe9a5
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/RouterNetworkVO.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.dao;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import com.cloud.network.Network;
+import com.cloud.network.Network.GuestType;
+import org.apache.cloudstack.api.InternalIdentity;
+
+
+@Entity
+@Table(name="router_network_ref")
+public class RouterNetworkVO implements InternalIdentity {
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    long id;
+    
+    @Column(name="router_id")
+    long routerId;
+    
+    @Column(name="network_id")
+    long networkId;
+    
+    @Column(name="guest_type")
+    @Enumerated(value=EnumType.STRING)
+    Network.GuestType guestType;
+
+    protected RouterNetworkVO() {
+    }
+    
+    public RouterNetworkVO(long routerId, long networkId, GuestType guestType) {
+        this.networkId = networkId;
+        this.routerId = routerId;
+        this.guestType = guestType;
+    }
+    
+    
+    public long getRouterId() {
+        return routerId;
+    }
+    
+    public long getNetworkId() {
+        return networkId;
+    }
+
+    public Network.GuestType getGuestType() {
+        return guestType;
+    }
+
+    public long getId() {
+        return id;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d015fb35/engine/schema/src/com/cloud/network/dao/Site2SiteCustomerGatewayDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/Site2SiteCustomerGatewayDao.java b/engine/schema/src/com/cloud/network/dao/Site2SiteCustomerGatewayDao.java
new file mode 100644
index 0000000..20ef12d
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/Site2SiteCustomerGatewayDao.java
@@ -0,0 +1,27 @@
+// 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.utils.db.GenericDao;
+
+public interface Site2SiteCustomerGatewayDao extends GenericDao<Site2SiteCustomerGatewayVO, Long> {
+    Site2SiteCustomerGatewayVO findByGatewayIp(String ip);
+    Site2SiteCustomerGatewayVO findByNameAndAccountId(String name, long accountId);
+    List<Site2SiteCustomerGatewayVO> listByAccountId(long accountId);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d015fb35/engine/schema/src/com/cloud/network/dao/Site2SiteCustomerGatewayDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/Site2SiteCustomerGatewayDaoImpl.java b/engine/schema/src/com/cloud/network/dao/Site2SiteCustomerGatewayDaoImpl.java
new file mode 100644
index 0000000..fcb533a
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/Site2SiteCustomerGatewayDaoImpl.java
@@ -0,0 +1,66 @@
+// 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 javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+@Component
+@Local(value={Site2SiteCustomerGatewayDao.class})
+public class Site2SiteCustomerGatewayDaoImpl extends GenericDaoBase<Site2SiteCustomerGatewayVO, Long> implements Site2SiteCustomerGatewayDao {
+    private static final Logger s_logger = Logger.getLogger(Site2SiteCustomerGatewayDaoImpl.class);
+    
+    private final SearchBuilder<Site2SiteCustomerGatewayVO> AllFieldsSearch;
+
+    protected Site2SiteCustomerGatewayDaoImpl() {
+        AllFieldsSearch = createSearchBuilder();
+        AllFieldsSearch.and("gatewayIp", AllFieldsSearch.entity().getGatewayIp(), SearchCriteria.Op.EQ);
+        AllFieldsSearch.and("name", AllFieldsSearch.entity().getName(), SearchCriteria.Op.EQ);
+        AllFieldsSearch.and("accountId", AllFieldsSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
+        AllFieldsSearch.done();
+    }
+    
+    @Override
+    public Site2SiteCustomerGatewayVO findByGatewayIp(String ip) {
+        SearchCriteria<Site2SiteCustomerGatewayVO> sc = AllFieldsSearch.create();
+        sc.setParameters("gatewayIp", ip);
+        return findOneBy(sc);
+    }
+
+    @Override
+    public Site2SiteCustomerGatewayVO findByNameAndAccountId(String name, long accountId) {
+        SearchCriteria<Site2SiteCustomerGatewayVO> sc = AllFieldsSearch.create();
+        sc.setParameters("name", name);
+        sc.setParameters("accountId", accountId);
+        return findOneBy(sc);
+    }
+
+    @Override
+    public List<Site2SiteCustomerGatewayVO> listByAccountId(long accountId) {
+        SearchCriteria<Site2SiteCustomerGatewayVO> sc = AllFieldsSearch.create();
+        sc.setParameters("accountId", accountId);
+        return listBy(sc, null);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d015fb35/engine/schema/src/com/cloud/network/dao/Site2SiteCustomerGatewayVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/Site2SiteCustomerGatewayVO.java b/engine/schema/src/com/cloud/network/dao/Site2SiteCustomerGatewayVO.java
new file mode 100644
index 0000000..80130ef
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/Site2SiteCustomerGatewayVO.java
@@ -0,0 +1,206 @@
+// 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.Date;
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import com.cloud.network.Site2SiteCustomerGateway;
+import com.cloud.utils.db.GenericDao;
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name=("s2s_customer_gateway"))
+public class Site2SiteCustomerGatewayVO implements Site2SiteCustomerGateway {
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    private long id;
+
+    @Column(name="uuid")
+    private String uuid;
+
+    @Column(name="name")
+    private String name;
+
+    @Column(name="gateway_ip")
+    private String gatewayIp;
+
+    @Column(name="guest_cidr_list")
+    private String guestCidrList;
+
+    @Column(name="ipsec_psk")
+    private String ipsecPsk;
+
+    @Column(name="ike_policy")
+    private String ikePolicy;
+
+    @Column(name="esp_policy")
+    private String espPolicy;
+
+    @Column(name="ike_lifetime")
+    private long ikeLifetime;
+
+    @Column(name="esp_lifetime")
+    private long espLifetime;
+
+    @Column(name="dpd")
+    private boolean dpd;
+
+    @Column(name="domain_id")
+    private Long domainId;
+    
+    @Column(name="account_id")
+    private Long accountId;
+
+    @Column(name=GenericDao.REMOVED_COLUMN)
+    private Date removed;
+
+    public Site2SiteCustomerGatewayVO() { }
+
+    public Site2SiteCustomerGatewayVO(String name, long accountId, long domainId, String gatewayIp, String guestCidrList, String ipsecPsk, String ikePolicy, String espPolicy,
+            long ikeLifetime, long espLifetime, boolean dpd) {
+        this.name = name;
+        this.gatewayIp = gatewayIp;
+        this.guestCidrList = guestCidrList;
+        this.ipsecPsk = ipsecPsk;
+        this.ikePolicy = ikePolicy;
+        this.espPolicy = espPolicy;
+        this.ikeLifetime = ikeLifetime;
+        this.espLifetime = espLifetime;
+        this.dpd = dpd;
+        this.uuid = UUID.randomUUID().toString();
+        this.accountId = accountId;
+        this.domainId = domainId;
+    }
+
+    @Override
+    public long getId() {
+        return id;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    @Override
+    public String getGatewayIp() {
+        return gatewayIp;
+    }
+
+    public void setGatewayIp(String gatewayIp) {
+        this.gatewayIp = gatewayIp;
+    }
+
+    @Override
+    public String getGuestCidrList() {
+        return guestCidrList;
+    }
+
+    public void setGuestCidrList(String guestCidrList) {
+        this.guestCidrList = guestCidrList;
+    }
+
+    @Override
+    public String getIpsecPsk() {
+        return ipsecPsk;
+    }
+
+    public void setIpsecPsk(String ipsecPsk) {
+        this.ipsecPsk = ipsecPsk;
+    }
+
+    @Override
+    public Date getRemoved() {
+        return removed;
+    }
+
+    public void setRemoved(Date removed) {
+        this.removed = removed;
+    }
+
+    @Override
+    public Long getIkeLifetime() {
+        return ikeLifetime;
+    }
+
+    public void setIkeLifetime(long ikeLifetime) {
+        this.ikeLifetime = ikeLifetime;
+    }
+
+    @Override
+    public Long getEspLifetime() {
+        return espLifetime;
+    }
+
+    public void setEspLifetime(long espLifetime) {
+        this.espLifetime = espLifetime;
+    }
+
+    @Override
+    public String getIkePolicy() {
+        return ikePolicy;
+    }
+
+    public void setIkePolicy(String ikePolicy) {
+        this.ikePolicy = ikePolicy;
+    }
+
+    @Override
+    public String getEspPolicy() {
+        return espPolicy;
+    }
+
+    public void setEspPolicy(String espPolicy) {
+        this.espPolicy = espPolicy;
+    }
+
+    @Override
+    public Boolean getDpd() {
+        return dpd;
+    }
+
+    public void setDpd(boolean dpd) {
+        this.dpd = dpd;
+    }
+
+    public String getUuid() {
+        return uuid;
+    }
+    
+    @Override
+    public long getDomainId() {
+        return domainId;
+    }
+
+    @Override
+    public long getAccountId() {
+        return accountId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d015fb35/engine/schema/src/com/cloud/network/dao/Site2SiteVpnConnectionDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/Site2SiteVpnConnectionDao.java b/engine/schema/src/com/cloud/network/dao/Site2SiteVpnConnectionDao.java
new file mode 100644
index 0000000..66d5a4a
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/Site2SiteVpnConnectionDao.java
@@ -0,0 +1,29 @@
+// 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.utils.db.GenericDao;
+
+public interface Site2SiteVpnConnectionDao extends GenericDao<Site2SiteVpnConnectionVO, Long> {
+    List<Site2SiteVpnConnectionVO> listByCustomerGatewayId(long id);
+    List<Site2SiteVpnConnectionVO> listByVpnGatewayId(long id);
+    List<Site2SiteVpnConnectionVO> listByVpcId(long vpcId);
+    Site2SiteVpnConnectionVO findByVpnGatewayIdAndCustomerGatewayId(long vpnId, long customerId);
+    Site2SiteVpnConnectionVO findByCustomerGatewayId(long customerId);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d015fb35/engine/schema/src/com/cloud/network/dao/Site2SiteVpnConnectionDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/Site2SiteVpnConnectionDaoImpl.java b/engine/schema/src/com/cloud/network/dao/Site2SiteVpnConnectionDaoImpl.java
new file mode 100644
index 0000000..4745f9a
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/Site2SiteVpnConnectionDaoImpl.java
@@ -0,0 +1,97 @@
+// 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 javax.annotation.PostConstruct;
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.JoinBuilder.JoinType;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+@Component
+@Local(value={Site2SiteVpnConnectionDao.class})
+public class Site2SiteVpnConnectionDaoImpl extends GenericDaoBase<Site2SiteVpnConnectionVO, Long> implements Site2SiteVpnConnectionDao {
+    private static final Logger s_logger = Logger.getLogger(Site2SiteVpnConnectionDaoImpl.class);
+
+    @Inject protected IPAddressDao _addrDao;
+    @Inject protected Site2SiteVpnGatewayDao _vpnGatewayDao;
+
+    private SearchBuilder<Site2SiteVpnConnectionVO> AllFieldsSearch;
+    private SearchBuilder<Site2SiteVpnConnectionVO> VpcSearch;
+    private SearchBuilder<Site2SiteVpnGatewayVO> VpnGatewaySearch;
+
+    public Site2SiteVpnConnectionDaoImpl() {
+    }
+
+    @PostConstruct
+    protected void init() {
+        AllFieldsSearch = createSearchBuilder();
+        AllFieldsSearch.and("customerGatewayId", AllFieldsSearch.entity().getCustomerGatewayId(), SearchCriteria.Op.EQ);
+        AllFieldsSearch.and("vpnGatewayId", AllFieldsSearch.entity().getVpnGatewayId(), SearchCriteria.Op.EQ);
+        AllFieldsSearch.done();
+
+        VpcSearch = createSearchBuilder();
+        VpnGatewaySearch = _vpnGatewayDao.createSearchBuilder();
+        VpnGatewaySearch.and("vpcId", VpnGatewaySearch.entity().getVpcId(), SearchCriteria.Op.EQ);
+        VpcSearch.join("vpnGatewaySearch", VpnGatewaySearch, VpnGatewaySearch.entity().getId(), VpcSearch.entity().getVpnGatewayId(), JoinType.INNER);
+        VpcSearch.done();
+    }
+
+    @Override
+    public List<Site2SiteVpnConnectionVO> listByCustomerGatewayId(long id) {
+        SearchCriteria<Site2SiteVpnConnectionVO> sc = AllFieldsSearch.create();
+        sc.setParameters("customerGatewayId", id);
+        return listBy(sc);
+    }
+
+    @Override
+    public List<Site2SiteVpnConnectionVO> listByVpnGatewayId(long id) {
+        SearchCriteria<Site2SiteVpnConnectionVO> sc = AllFieldsSearch.create();
+        sc.setParameters("vpnGatewayId", id);
+        return listBy(sc);
+    }
+
+    @Override
+    public List<Site2SiteVpnConnectionVO> listByVpcId(long vpcId) {
+        SearchCriteria<Site2SiteVpnConnectionVO> sc = VpcSearch.create();
+        sc.setJoinParameters("vpnGatewaySearch", "vpcId", vpcId);
+        return listBy(sc);
+    }
+
+    @Override
+    public Site2SiteVpnConnectionVO findByVpnGatewayIdAndCustomerGatewayId(long vpnId, long customerId) {
+        SearchCriteria<Site2SiteVpnConnectionVO> sc = AllFieldsSearch.create();
+        sc.setParameters("vpnGatewayId", vpnId);
+        sc.setParameters("customerGatewayId", customerId);
+        return findOneBy(sc);
+    }
+
+    @Override
+    public Site2SiteVpnConnectionVO findByCustomerGatewayId(long customerId) {
+        SearchCriteria<Site2SiteVpnConnectionVO> sc = AllFieldsSearch.create();
+        sc.setParameters("customerGatewayId", customerId);
+        return findOneBy(sc);
+    }
+}


Mime
View raw message