cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [42/90] [abbrv] [partial] Moved most of the VOs and DAOs from server package into engine-schema as well
Date Wed, 08 May 2013 20:48:08 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/dao/IPAddressVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/IPAddressVO.java b/engine/schema/src/com/cloud/network/dao/IPAddressVO.java
new file mode 100644
index 0000000..c5c78e5
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/IPAddressVO.java
@@ -0,0 +1,307 @@
+// 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.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+
+import org.apache.cloudstack.api.Identity;
+
+import com.cloud.network.IpAddress;
+import com.cloud.network.IpAddress.State;
+import com.cloud.utils.net.Ip;
+import org.apache.cloudstack.api.InternalIdentity;
+
+/**
+ * A bean representing a public IP Address
+ *
+ */
+@Entity
+@Table(name=("user_ip_address"))
+public class IPAddressVO implements IpAddress {
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    long id;
+
+	@Column(name="account_id")
+	private Long allocatedToAccountId = null;
+
+    @Column(name="domain_id")
+    private Long allocatedInDomainId = null;
+
+	@Id
+	@Column(name="public_ip_address")
+	@Enumerated(value=EnumType.STRING)
+	private Ip address = null;
+
+	@Column(name="data_center_id", updatable=false)
+	private long dataCenterId;
+
+	@Column(name="source_nat")
+	private boolean sourceNat;
+
+	@Column(name="allocated")
+	@Temporal(value=TemporalType.TIMESTAMP)
+	private Date allocatedTime;
+
+	@Column(name="vlan_db_id")
+	private long vlanId;
+
+	@Column(name="one_to_one_nat")
+	private boolean oneToOneNat;
+
+	@Column(name="vm_id")
+    private Long associatedWithVmId;
+
+	@Column(name="state")
+	private State state;
+
+	@Column(name="mac_address")
+	private long macAddress;
+
+	@Column(name="source_network_id")
+    private Long sourceNetworkId;
+
+	@Column(name="network_id")
+	private Long associatedWithNetworkId;
+
+	@Column(name="uuid")
+	private String uuid;
+
+    @Column(name="physical_network_id")
+    private Long physicalNetworkId;
+
+    @Column(name="is_system")
+    private boolean system;
+
+	@Column(name="account_id")
+	@Transient
+	private Long accountId = null;
+
+	@Transient
+    @Column(name="domain_id")
+    private Long domainId = null;
+
+    @Column(name="vpc_id")
+    private Long vpcId;
+
+    @Column(name="dnat_vmip")
+    private String vmIp;
+
+
+	protected IPAddressVO() {
+		this.uuid = UUID.randomUUID().toString();
+	}
+
+	@Override
+    public boolean readyToUse() {
+	    return state == State.Allocated;
+	}
+
+	public IPAddressVO(Ip address, long dataCenterId, long macAddress, long vlanDbId, boolean sourceNat) {
+		this.address = address;
+		this.dataCenterId = dataCenterId;
+		this.vlanId = vlanDbId;
+		this.sourceNat = sourceNat;
+		this.allocatedInDomainId = null;
+		this.allocatedToAccountId = null;
+		this.allocatedTime = null;
+		this.state = State.Free;
+		this.macAddress = macAddress;
+		this.uuid = UUID.randomUUID().toString();
+	}
+
+    public long getMacAddress() {
+	    return macAddress;
+	}
+
+	@Override
+    public long getDataCenterId() {
+	    return dataCenterId;
+	}
+
+	@Override
+    public Ip getAddress() {
+		return address;
+	}
+
+	@Override
+    public Long getAllocatedToAccountId() {
+		return allocatedToAccountId;
+	}
+
+    @Override
+    public Long getAllocatedInDomainId() {
+        return allocatedInDomainId;
+    }
+
+	@Override
+	public Long getAssociatedWithNetworkId() {
+	    return associatedWithNetworkId;
+	}
+
+	public void setAssociatedWithNetworkId(Long networkId) {
+	    this.associatedWithNetworkId = networkId;
+	}
+
+	@Override
+    public Long getAssociatedWithVmId() {
+        return associatedWithVmId;
+    }
+
+    public void setAssociatedWithVmId(Long associatedWithVmId) {
+        this.associatedWithVmId = associatedWithVmId;
+    }
+
+	@Override
+    public Date getAllocatedTime() {
+		return allocatedTime;
+	}
+
+    public void setAllocatedToAccountId(Long accountId) {
+		this.allocatedToAccountId = accountId;
+	}
+
+    public void setAllocatedInDomainId(Long domainId) {
+        this.allocatedInDomainId = domainId;
+    }
+
+    public void setSourceNat(boolean sourceNat) {
+		this.sourceNat = sourceNat;
+	}
+
+	@Override
+    public boolean isSourceNat() {
+		return sourceNat;
+	}
+
+    public void setAllocatedTime(Date allocated) {
+		this.allocatedTime = allocated;
+	}
+
+	@Override
+    public long getVlanId() {
+		return this.vlanId;
+	}
+
+    public void setVlanId(long vlanDbId) {
+		this.vlanId = vlanDbId;
+	}
+
+	@Override
+    public boolean isOneToOneNat() {
+		return oneToOneNat;
+	}
+
+    public void setOneToOneNat(boolean oneToOneNat) {
+		this.oneToOneNat = oneToOneNat;
+	}
+
+    @Override
+    public long getDomainId() {
+        return allocatedInDomainId == null ? -1 : allocatedInDomainId;
+    }
+
+    @Override
+    public long getAccountId() {
+        return allocatedToAccountId == null ? -1 : allocatedToAccountId;
+    }
+
+    @Override
+    public State getState() {
+        return state;
+    }
+
+    public void setState(State state) {
+        this.state = state;
+    }
+
+	@Override
+    public String toString() {
+	    return new StringBuilder("Ip[").append(address).append("-").append(dataCenterId).append("]").toString();
+	}
+
+	@Override
+    public long getId() {
+        return id;
+    }
+
+    public Long getSourceNetworkId() {
+        return sourceNetworkId;
+    }
+
+    public void setSourceNetworkId(Long sourceNetworkId) {
+        this.sourceNetworkId = sourceNetworkId;
+    }
+
+    @Override
+    public String getUuid() {
+    	return this.uuid;
+    }
+
+    public void setUuid(String uuid) {
+    	this.uuid = uuid;
+    }
+
+    public Long getPhysicalNetworkId() {
+        return physicalNetworkId;
+    }
+
+    public void setPhysicalNetworkId(Long physicalNetworkId) {
+        this.physicalNetworkId = physicalNetworkId;
+    }
+
+    @Override
+	public boolean getSystem() {
+		return system;
+	}
+
+	public void setSystem(boolean isSystem) {
+		this.system = isSystem;
+	}
+
+	@Override
+    public Long getVpcId() {
+        return vpcId;
+    }
+
+    public void setVpcId(Long vpcId) {
+        this.vpcId = vpcId;
+    }
+
+    @Override
+    public String getVmIp() {
+        return vmIp;
+    }
+
+    public void setVmIp(String vmIp) {
+        this.vmIp = vmIp;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/dao/InlineLoadBalancerNicMapDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/InlineLoadBalancerNicMapDao.java b/engine/schema/src/com/cloud/network/dao/InlineLoadBalancerNicMapDao.java
new file mode 100644
index 0000000..36a8eef
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/InlineLoadBalancerNicMapDao.java
@@ -0,0 +1,24 @@
+// 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 com.cloud.utils.db.GenericDao;
+
+public interface InlineLoadBalancerNicMapDao extends GenericDao<InlineLoadBalancerNicMapVO, Long> {
+	InlineLoadBalancerNicMapVO findByPublicIpAddress(String publicIpAddress);
+	InlineLoadBalancerNicMapVO findByNicId(long nicId);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/dao/InlineLoadBalancerNicMapDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/InlineLoadBalancerNicMapDaoImpl.java b/engine/schema/src/com/cloud/network/dao/InlineLoadBalancerNicMapDaoImpl.java
new file mode 100644
index 0000000..f3f04ed
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/InlineLoadBalancerNicMapDaoImpl.java
@@ -0,0 +1,46 @@
+// 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.ejb.Local;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchCriteria;
+
+@Component
+@Local(value={InlineLoadBalancerNicMapDao.class})
+public class InlineLoadBalancerNicMapDaoImpl extends GenericDaoBase<InlineLoadBalancerNicMapVO, Long> implements InlineLoadBalancerNicMapDao {
+
+    @Override
+    public InlineLoadBalancerNicMapVO findByPublicIpAddress(String publicIpAddress) {
+        SearchCriteria<InlineLoadBalancerNicMapVO> sc = createSearchCriteria();
+        sc.addAnd("publicIpAddress", SearchCriteria.Op.EQ, publicIpAddress);
+
+        return findOneBy(sc);
+    }
+    
+    @Override
+    public InlineLoadBalancerNicMapVO findByNicId(long nicId) {
+    	SearchCriteria<InlineLoadBalancerNicMapVO> sc = createSearchCriteria();
+    	sc.addAnd("nicId", SearchCriteria.Op.EQ, nicId);
+    	
+    	return findOneBy(sc);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/dao/InlineLoadBalancerNicMapVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/InlineLoadBalancerNicMapVO.java b/engine/schema/src/com/cloud/network/dao/InlineLoadBalancerNicMapVO.java
new file mode 100644
index 0000000..35aeefa
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/InlineLoadBalancerNicMapVO.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.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=("inline_load_balancer_nic_map"))
+public class InlineLoadBalancerNicMapVO implements InternalIdentity {
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    private long id;
+
+    @Column(name="public_ip_address")
+    private String publicIpAddress;
+
+    @Column(name="nic_id")
+    private long nicId;
+
+    public InlineLoadBalancerNicMapVO() { }
+
+    public InlineLoadBalancerNicMapVO(String publicIpAddress, long nicId) {
+        this.publicIpAddress = publicIpAddress;
+        this.nicId = nicId;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public String getPublicIpAddress() {
+    	return publicIpAddress;
+    }
+
+    public long getNicId() {
+    	return nicId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/dao/LBHealthCheckPolicyDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/LBHealthCheckPolicyDao.java b/engine/schema/src/com/cloud/network/dao/LBHealthCheckPolicyDao.java
new file mode 100644
index 0000000..42a9e42
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/LBHealthCheckPolicyDao.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.dao;
+
+import java.util.List;
+
+import com.cloud.network.LBHealthCheckPolicyVO;
+import com.cloud.utils.db.GenericDao;
+
+
+public interface LBHealthCheckPolicyDao extends
+        GenericDao<LBHealthCheckPolicyVO, Long> {
+    void remove(long loadBalancerId);
+
+    void remove(long loadBalancerId, Boolean pending);
+
+    List<LBHealthCheckPolicyVO> listByLoadBalancerId(long loadBalancerId);
+
+    List<LBHealthCheckPolicyVO> listByLoadBalancerId(long loadBalancerId,
+            boolean revoke);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/dao/LBHealthCheckPolicyDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/LBHealthCheckPolicyDaoImpl.java b/engine/schema/src/com/cloud/network/dao/LBHealthCheckPolicyDaoImpl.java
new file mode 100644
index 0000000..65e0689
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/LBHealthCheckPolicyDaoImpl.java
@@ -0,0 +1,71 @@
+// 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.network.LBHealthCheckPolicyVO;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchCriteria;
+
+
+@Component
+@Local(value = { LBHealthCheckPolicyDao.class })
+public class LBHealthCheckPolicyDaoImpl extends
+        GenericDaoBase<LBHealthCheckPolicyVO, Long> implements
+        LBHealthCheckPolicyDao {
+
+    @Override
+    public void remove(long loadBalancerId) {
+        SearchCriteria<LBHealthCheckPolicyVO> sc = createSearchCriteria();
+        sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
+
+        expunge(sc);
+    }
+
+    @Override
+    public void remove(long loadBalancerId, Boolean revoke) {
+        SearchCriteria<LBHealthCheckPolicyVO> sc = createSearchCriteria();
+        sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
+        sc.addAnd("revoke", SearchCriteria.Op.EQ, revoke);
+
+        expunge(sc);
+    }
+
+    @Override
+    public List<LBHealthCheckPolicyVO> listByLoadBalancerId(long loadBalancerId) {
+        SearchCriteria<LBHealthCheckPolicyVO> sc = createSearchCriteria();
+        sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
+
+        return listBy(sc);
+    }
+
+    @Override
+    public List<LBHealthCheckPolicyVO> listByLoadBalancerId(long loadBalancerId,
+            boolean pending) {
+        SearchCriteria<LBHealthCheckPolicyVO> sc = createSearchCriteria();
+        sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
+        sc.addAnd("revoke", SearchCriteria.Op.EQ, pending);
+
+        return listBy(sc);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/dao/LBStickinessPolicyDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/LBStickinessPolicyDao.java b/engine/schema/src/com/cloud/network/dao/LBStickinessPolicyDao.java
new file mode 100644
index 0000000..9a25c1a
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/LBStickinessPolicyDao.java
@@ -0,0 +1,34 @@
+// 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 LBStickinessPolicyDao extends
+        GenericDao<LBStickinessPolicyVO, Long> {
+    void remove(long loadBalancerId);
+
+    void remove(long loadBalancerId, Boolean pending);
+
+    List<LBStickinessPolicyVO> listByLoadBalancerId(long loadBalancerId);
+
+    List<LBStickinessPolicyVO> listByLoadBalancerId(long loadBalancerId,
+            boolean revoke);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/dao/LBStickinessPolicyDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/LBStickinessPolicyDaoImpl.java b/engine/schema/src/com/cloud/network/dao/LBStickinessPolicyDaoImpl.java
new file mode 100644
index 0000000..43b4669
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/LBStickinessPolicyDaoImpl.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.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchCriteria;
+
+@Component
+@Local(value = { LBStickinessPolicyDao.class })
+public class LBStickinessPolicyDaoImpl extends
+        GenericDaoBase<LBStickinessPolicyVO, Long> implements
+        LBStickinessPolicyDao {
+
+    @Override
+    public void remove(long loadBalancerId) {
+        SearchCriteria<LBStickinessPolicyVO> sc = createSearchCriteria();
+        sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
+
+        expunge(sc);
+    }
+
+    @Override
+    public void remove(long loadBalancerId, Boolean revoke) {
+        SearchCriteria<LBStickinessPolicyVO> sc = createSearchCriteria();
+        sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
+        sc.addAnd("revoke", SearchCriteria.Op.EQ, revoke);
+
+        expunge(sc);
+    }
+
+    @Override
+    public List<LBStickinessPolicyVO> listByLoadBalancerId(long loadBalancerId) {
+        SearchCriteria<LBStickinessPolicyVO> sc = createSearchCriteria();
+        sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
+
+        return listBy(sc);
+    }
+
+    @Override
+    public List<LBStickinessPolicyVO> listByLoadBalancerId(long loadBalancerId,
+            boolean pending) {
+        SearchCriteria<LBStickinessPolicyVO> sc = createSearchCriteria();
+        sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
+        sc.addAnd("revoke", SearchCriteria.Op.EQ, pending);
+
+        return listBy(sc);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/dao/LBStickinessPolicyVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/LBStickinessPolicyVO.java b/engine/schema/src/com/cloud/network/dao/LBStickinessPolicyVO.java
new file mode 100644
index 0000000..3fbba68
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/LBStickinessPolicyVO.java
@@ -0,0 +1,145 @@
+// 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.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+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.PrimaryKeyJoinColumn;
+import javax.persistence.Table;
+import com.cloud.network.rules.StickinessPolicy;
+import com.cloud.utils.Pair;
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name = ("load_balancer_stickiness_policies"))
+@PrimaryKeyJoinColumn(name = "load_balancer_id", referencedColumnName = "id")
+public class LBStickinessPolicyVO implements StickinessPolicy {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    private long id;
+
+    @Column(name = "load_balancer_id")
+    private long loadBalancerId;
+
+    @Column(name = "name")
+    private String name;
+
+    @Column(name = "description")
+    private String description;
+
+    @Column(name = "method_name")
+    private String methodName;
+
+    @Column(name = "params")
+    private String paramsInDB;
+
+    @Column(name = "uuid")
+    private String uuid;
+    
+    @Column(name = "revoke")
+    private boolean revoke = false;
+    protected LBStickinessPolicyVO() {
+        this.uuid = UUID.randomUUID().toString();
+    }
+
+/*  get the params in Map format and converts in to string format and stores in DB
+ *  paramsInDB represent the string stored in database :
+ *  Format :  param1=value1&param2=value2&param3=value3& 
+ *  Example for App cookie method:  "name=cookapp&length=12&holdtime=3h" . Here 3 parameters name,length and holdtime with corresponding values.
+ *  getParams function is used to get in List<Pair<string,String>> Format.
+ *           - API response use Map format
+ *           - In database plain String with DB_PARM_DELIMITER 
+ *           - rest of the code uses List<Pair<string,String>> 
+ */
+    public LBStickinessPolicyVO(long loadBalancerId, String name, String methodName, Map paramList, String description) {
+        this.loadBalancerId = loadBalancerId;
+        this.name = name;
+        this.methodName = methodName;
+        StringBuilder sb = new StringBuilder("");
+
+        if (paramList != null) {
+            Iterator<HashMap<String, String>> iter = paramList.values().iterator();
+            while (iter.hasNext())  {
+                HashMap<String, String>  paramKVpair =  iter.next();
+                String paramName = paramKVpair.get("name");
+                String paramValue =  paramKVpair.get("value");
+                sb.append(paramName + "=" + paramValue + "&");
+            }
+        } 
+        paramsInDB = sb.toString();
+        this.description = description;
+        this.uuid = UUID.randomUUID().toString();
+    }
+
+    public List<Pair<String, String>> getParams() {
+        List<Pair<String, String>> paramsList = new ArrayList<Pair<String, String>>();
+        String[] params = paramsInDB.split("[=&]");
+ 
+        for (int i = 0; i < (params.length - 1); i = i + 2) {
+            paramsList.add(new Pair<String, String>(params[i], params[i + 1]));
+        }
+        return paramsList;
+    }
+    
+    public long getId() {
+        return id;
+    }
+
+    public long getLoadBalancerId() {
+        return loadBalancerId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public String getMethodName() {
+        return methodName;
+    }
+    
+    public boolean isRevoke() {
+        return revoke;
+    }
+
+    public void setRevoke(boolean revoke) {
+        this.revoke = revoke;
+    }
+    
+    @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/572e71e5/engine/schema/src/com/cloud/network/dao/LoadBalancerDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/LoadBalancerDao.java b/engine/schema/src/com/cloud/network/dao/LoadBalancerDao.java
new file mode 100644
index 0000000..611282e
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/LoadBalancerDao.java
@@ -0,0 +1,36 @@
+// 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 LoadBalancerDao extends GenericDao<LoadBalancerVO, Long> {
+    List<Long> listInstancesByLoadBalancer(long loadBalancerId);
+
+    List<LoadBalancerVO> listByIpAddress(long ipAddressId);
+
+    LoadBalancerVO findByIpAddressAndPublicPort(long ipAddressId, String publicPort);
+
+    LoadBalancerVO findByAccountAndName(Long accountId, String name);
+
+    List<LoadBalancerVO> listByNetworkId(long networkId);
+
+    List<LoadBalancerVO> listInTransitionStateByNetworkId(long networkId);
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/dao/LoadBalancerDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/LoadBalancerDaoImpl.java b/engine/schema/src/com/cloud/network/dao/LoadBalancerDaoImpl.java
new file mode 100644
index 0000000..f211a7f
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/LoadBalancerDaoImpl.java
@@ -0,0 +1,137 @@
+// 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.util.ArrayList;
+import java.util.List;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import com.cloud.network.rules.FirewallRule.State;
+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;
+
+@Component
+@Local(value = { LoadBalancerDao.class })
+public class LoadBalancerDaoImpl extends GenericDaoBase<LoadBalancerVO, Long> implements LoadBalancerDao {
+    private static final Logger s_logger = Logger.getLogger(LoadBalancerDaoImpl.class);
+    private static final String LIST_INSTANCES_BY_LOAD_BALANCER = "SELECT vm.id " +
+            "    FROM vm_instance vm, load_balancer lb, ip_forwarding fwd, user_ip_address ip " +
+            "    WHERE lb.id = ? AND " +
+            "          fwd.group_id = lb.id AND " +
+            "          fwd.forwarding = 0 AND " +
+            "          fwd.private_ip_address = vm.private_ip_address AND " +
+            "          lb.ip_address = ip.public_ip_address AND " +
+            "          ip.data_center_id = vm.data_center_id ";
+    private final SearchBuilder<LoadBalancerVO> ListByIp;
+    private final SearchBuilder<LoadBalancerVO> IpAndPublicPortSearch;
+    private final SearchBuilder<LoadBalancerVO> AccountAndNameSearch;
+    protected final SearchBuilder<LoadBalancerVO> TransitionStateSearch;
+
+    @Inject protected FirewallRulesCidrsDao _portForwardingRulesCidrsDao;
+
+    protected LoadBalancerDaoImpl() {
+        ListByIp = createSearchBuilder();
+        ListByIp.and("ipAddressId", ListByIp.entity().getSourceIpAddressId(), SearchCriteria.Op.EQ);
+        ListByIp.and("networkId", ListByIp.entity().getNetworkId(), SearchCriteria.Op.EQ);
+        ListByIp.done();
+
+        IpAndPublicPortSearch = createSearchBuilder();
+        IpAndPublicPortSearch.and("ipAddressId", IpAndPublicPortSearch.entity().getSourceIpAddressId(), SearchCriteria.Op.EQ);
+        IpAndPublicPortSearch.and("publicPort", IpAndPublicPortSearch.entity().getSourcePortStart(), SearchCriteria.Op.EQ);
+        IpAndPublicPortSearch.done();
+
+        AccountAndNameSearch = createSearchBuilder();
+        AccountAndNameSearch.and("accountId", AccountAndNameSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
+        AccountAndNameSearch.and("name", AccountAndNameSearch.entity().getName(), SearchCriteria.Op.EQ);
+        AccountAndNameSearch.done();
+
+        TransitionStateSearch = createSearchBuilder();
+        TransitionStateSearch.and("networkId", TransitionStateSearch.entity().getNetworkId(), Op.EQ);
+        TransitionStateSearch.and("state", TransitionStateSearch.entity().getState(), Op.IN);
+        TransitionStateSearch.done();
+    }
+
+    @Override
+    public List<Long> listInstancesByLoadBalancer(long loadBalancerId) {
+        Transaction txn = Transaction.currentTxn();
+        String sql = LIST_INSTANCES_BY_LOAD_BALANCER;
+        PreparedStatement pstmt = null;
+        List<Long> instanceList = new ArrayList<Long>();
+        try {
+            pstmt = txn.prepareAutoCloseStatement(sql);
+            pstmt.setLong(1, loadBalancerId);
+
+            ResultSet rs = pstmt.executeQuery();
+            while (rs.next()) {
+                Long vmId = rs.getLong(1);
+                instanceList.add(vmId);
+            }
+        } catch (Exception ex) {
+            s_logger.error("error getting recent usage network stats", ex);
+        }
+        return instanceList;
+    }
+
+    @Override
+    public List<LoadBalancerVO> listByIpAddress(long ipAddressId) {
+        SearchCriteria<LoadBalancerVO> sc = ListByIp.create();
+        sc.setParameters("ipAddressId", ipAddressId);
+        return listBy(sc);
+    }
+
+    @Override
+    public List<LoadBalancerVO> listByNetworkId(long networkId) {
+        SearchCriteria<LoadBalancerVO> sc = ListByIp.create();
+        sc.setParameters("networkId", networkId);
+        return listBy(sc);
+    }
+
+    @Override
+    public LoadBalancerVO findByIpAddressAndPublicPort(long ipAddressId, String publicPort) {
+        SearchCriteria<LoadBalancerVO> sc = IpAndPublicPortSearch.create();
+        sc.setParameters("ipAddressId", ipAddressId);
+        sc.setParameters("publicPort", publicPort);
+        return findOneBy(sc);
+    }
+
+    @Override
+    public LoadBalancerVO findByAccountAndName(Long accountId, String name) {
+        SearchCriteria<LoadBalancerVO> sc = AccountAndNameSearch.create();
+        sc.setParameters("accountId", accountId);
+        sc.setParameters("name", name);
+        return findOneBy(sc);
+    }
+
+    @Override
+    public List<LoadBalancerVO> listInTransitionStateByNetworkId(long networkId) {
+        SearchCriteria<LoadBalancerVO> sc = TransitionStateSearch.create();
+        sc.setParameters("networkId", networkId);
+        sc.setParameters("state", State.Add.toString(), State.Revoke.toString());
+        return listBy(sc);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/dao/LoadBalancerVMMapDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/LoadBalancerVMMapDao.java b/engine/schema/src/com/cloud/network/dao/LoadBalancerVMMapDao.java
new file mode 100644
index 0000000..e122d0a
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/LoadBalancerVMMapDao.java
@@ -0,0 +1,31 @@
+// 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 LoadBalancerVMMapDao extends GenericDao<LoadBalancerVMMapVO, Long> {
+    void remove(long loadBalancerId);
+    void remove(long loadBalancerId, List<Long> instanceIds, Boolean pending);
+    List<LoadBalancerVMMapVO> listByInstanceId(long instanceId);
+    List<LoadBalancerVMMapVO> listByLoadBalancerId(long loadBalancerId);
+    List<LoadBalancerVMMapVO> listByLoadBalancerId(long loadBalancerId, boolean revoke);
+    LoadBalancerVMMapVO findByLoadBalancerIdAndVmId(long loadBalancerId, long instanceId);
+    boolean isVmAttachedToLoadBalancer(long loadBalancerId);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/dao/LoadBalancerVMMapDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/LoadBalancerVMMapDaoImpl.java b/engine/schema/src/com/cloud/network/dao/LoadBalancerVMMapDaoImpl.java
new file mode 100644
index 0000000..8f979cd
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/LoadBalancerVMMapDaoImpl.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.ejb.Local;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.GenericSearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria.Func;
+
+@Component
+@Local(value={LoadBalancerVMMapDao.class})
+public class LoadBalancerVMMapDaoImpl extends GenericDaoBase<LoadBalancerVMMapVO, Long> implements LoadBalancerVMMapDao {
+
+    @Override
+    public void remove(long loadBalancerId) {
+        SearchCriteria<LoadBalancerVMMapVO> sc = createSearchCriteria();
+        sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
+
+        expunge(sc);
+    }
+
+    @Override
+    public void remove(long loadBalancerId, List<Long> instanceIds, Boolean revoke) {
+        SearchCriteria<LoadBalancerVMMapVO> sc = createSearchCriteria();
+        sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
+        sc.addAnd("instanceId", SearchCriteria.Op.IN, instanceIds.toArray());
+        if (revoke != null) {
+            sc.addAnd("revoke", SearchCriteria.Op.EQ, revoke);
+        }
+
+        expunge(sc);
+    }
+
+    @Override
+    public List<LoadBalancerVMMapVO> listByInstanceId(long instanceId) {
+        SearchCriteria<LoadBalancerVMMapVO> sc = createSearchCriteria();
+        sc.addAnd("instanceId", SearchCriteria.Op.EQ, instanceId);
+
+        return listBy(sc);
+    }
+
+    @Override
+    public List<LoadBalancerVMMapVO> listByLoadBalancerId(long loadBalancerId) {
+        SearchCriteria<LoadBalancerVMMapVO> sc = createSearchCriteria();
+        sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
+
+        return listBy(sc);
+    }
+
+    @Override
+    public List<LoadBalancerVMMapVO> listByLoadBalancerId(long loadBalancerId, boolean pending) {
+        SearchCriteria<LoadBalancerVMMapVO> sc = createSearchCriteria();
+        sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
+        sc.addAnd("revoke", SearchCriteria.Op.EQ, pending);
+
+        return listBy(sc);
+    }
+    
+    @Override
+    public LoadBalancerVMMapVO findByLoadBalancerIdAndVmId(long loadBalancerId, long instanceId) {
+        SearchCriteria<LoadBalancerVMMapVO> sc = createSearchCriteria();
+        sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
+        sc.addAnd("instanceId", SearchCriteria.Op.EQ, instanceId);
+        return findOneBy(sc);
+    }
+
+    @Override
+    public boolean isVmAttachedToLoadBalancer(long loadBalancerId) {
+        GenericSearchBuilder<LoadBalancerVMMapVO, Long> CountByAccount = createSearchBuilder(Long.class);
+        CountByAccount.select(null, Func.COUNT, null);
+        CountByAccount.and("loadBalancerId", CountByAccount.entity().getLoadBalancerId(), SearchCriteria.Op.EQ);
+
+        SearchCriteria<Long> sc = CountByAccount.create();
+        sc.setParameters("loadBalancerId", loadBalancerId);
+        return customSearch(sc, null).get(0) > 0;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/dao/LoadBalancerVMMapVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/LoadBalancerVMMapVO.java b/engine/schema/src/com/cloud/network/dao/LoadBalancerVMMapVO.java
new file mode 100644
index 0000000..852302e
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/LoadBalancerVMMapVO.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 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=("load_balancer_vm_map"))
+public class LoadBalancerVMMapVO implements InternalIdentity {
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    private long id;
+
+    @Column(name="load_balancer_id")
+    private long loadBalancerId;
+
+    @Column(name="instance_id")
+    private long instanceId;
+
+    @Column(name = "revoke")
+    private boolean revoke = false;
+
+    @Column(name = "state")
+    private String state;
+
+    public LoadBalancerVMMapVO() {
+    }
+
+    public LoadBalancerVMMapVO(long loadBalancerId, long instanceId) {
+        this.loadBalancerId = loadBalancerId;
+        this.instanceId = instanceId;
+    }
+
+    public LoadBalancerVMMapVO(long loadBalancerId, long instanceId, boolean revoke) {
+        this.loadBalancerId = loadBalancerId;
+        this.instanceId = instanceId;
+        this.revoke = revoke;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public long getLoadBalancerId() {
+        return loadBalancerId;
+    }
+
+    public long getInstanceId() {
+        return instanceId;
+    }
+
+    public boolean isRevoke() {
+        return revoke;
+    }
+
+    public void setRevoke(boolean revoke) {
+        this.revoke = revoke;
+    }
+
+    public String getState() {
+        return state;
+    }
+
+    public void setState(String state) {
+        this.state = state;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/dao/LoadBalancerVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/LoadBalancerVO.java b/engine/schema/src/com/cloud/network/dao/LoadBalancerVO.java
new file mode 100644
index 0000000..5422f41
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/LoadBalancerVO.java
@@ -0,0 +1,98 @@
+// 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.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.PrimaryKeyJoinColumn;
+import javax.persistence.Table;
+
+import com.cloud.network.rules.FirewallRuleVO;
+import com.cloud.network.rules.LoadBalancer;
+import com.cloud.utils.net.NetUtils;
+
+@Entity
+@Table(name=("load_balancing_rules"))
+@DiscriminatorValue(value="LoadBalancing")
+@PrimaryKeyJoinColumn(name="id")
+public class LoadBalancerVO extends FirewallRuleVO implements LoadBalancer {
+    
+    @Column(name="name")
+    private String name;
+
+    @Column(name="description", length=4096)
+    private String description;
+
+    @Column(name="algorithm")
+    private String algorithm;
+
+    @Column(name="default_port_start")
+    private int defaultPortStart;
+    
+    @Column(name="default_port_end")
+    private int defaultPortEnd;
+
+    public LoadBalancerVO() { 
+    }
+
+    public LoadBalancerVO(String xId, String name, String description, long srcIpId, int srcPort, int dstPort, String algorithm, long networkId, long accountId, long domainId) {
+        super(xId, srcIpId, srcPort, NetUtils.TCP_PROTO, networkId, accountId, domainId, Purpose.LoadBalancing, null, null, null, null);
+        this.name = name;
+        this.description = description;
+        this.algorithm = algorithm;
+        this.defaultPortStart = dstPort;
+        this.defaultPortEnd = dstPort;
+    }
+    
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public String getDescription() {
+        return description;
+    }
+
+    @Override
+    public String getAlgorithm() {
+        return algorithm;
+    }
+    
+    @Override
+    public int getDefaultPortStart() { 
+        return defaultPortStart;
+    }
+
+    @Override
+    public int getDefaultPortEnd() {
+        return defaultPortEnd;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setAlgorithm(String algorithm) {
+        this.algorithm = algorithm;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }  
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/dao/NetworkAccountDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/NetworkAccountDao.java b/engine/schema/src/com/cloud/network/dao/NetworkAccountDao.java
new file mode 100644
index 0000000..c4435c8
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/NetworkAccountDao.java
@@ -0,0 +1,22 @@
+// 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 com.cloud.utils.db.GenericDao;
+
+public interface NetworkAccountDao extends GenericDao<NetworkAccountVO, Long> {
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/dao/NetworkAccountDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/NetworkAccountDaoImpl.java b/engine/schema/src/com/cloud/network/dao/NetworkAccountDaoImpl.java
new file mode 100644
index 0000000..0947905
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/NetworkAccountDaoImpl.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 org.springframework.stereotype.Component;
+
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.db.GenericDaoBase;
+
+@Component
+public class NetworkAccountDaoImpl extends GenericDaoBase<NetworkAccountVO, Long> implements NetworkAccountDao {
+    public NetworkAccountDaoImpl() {
+        super();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/dao/NetworkAccountVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/NetworkAccountVO.java b/engine/schema/src/com/cloud/network/dao/NetworkAccountVO.java
new file mode 100644
index 0000000..afce805
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/NetworkAccountVO.java
@@ -0,0 +1,72 @@
+// 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.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import com.cloud.user.OwnedBy;
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name="account_network_ref")
+public class NetworkAccountVO implements OwnedBy, InternalIdentity {
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    long id;
+    
+    @Column(name="account_id")
+    long accountId;
+    
+    @Column(name="network_id")
+    long networkId;
+    
+    @Column(name="is_owner")
+    boolean owner;
+
+    protected NetworkAccountVO() {
+    }
+    
+    public NetworkAccountVO(long networkId, long accountId, boolean owner) {
+        this.networkId = networkId;
+        this.accountId = accountId;
+        this.owner = owner;
+    }
+
+    @Override
+    public long getId() {
+        return id;
+    }
+
+    @Override
+    public long getAccountId() {
+        return accountId;
+    }
+    
+    public long getNetworkId() {
+        return networkId;
+    }
+    
+    public boolean isOwner() {
+        return owner;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/dao/NetworkDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/NetworkDao.java b/engine/schema/src/com/cloud/network/dao/NetworkDao.java
new file mode 100644
index 0000000..1d3f0b8
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/NetworkDao.java
@@ -0,0 +1,114 @@
+// 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 java.util.Map;
+
+import com.cloud.network.Network;
+import com.cloud.network.Network.GuestType;
+import com.cloud.network.Networks.TrafficType;
+import com.cloud.network.Network.State;
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.fsm.StateDao;
+
+public interface NetworkDao extends GenericDao<NetworkVO, Long> , StateDao<State, Network.Event, Network> {
+
+    List<NetworkVO> listByOwner(long ownerId);
+
+    List<NetworkVO> listBy(long accountId, long offeringId, long dataCenterId);
+
+    List<NetworkVO> listBy(long accountId, long dataCenterId, String cidr, boolean skipVpc);
+
+    List<NetworkVO> listByZoneAndGuestType(long accountId, long dataCenterId, Network.GuestType type, Boolean isSystem);
+
+    NetworkVO persist(NetworkVO network, boolean gc, Map<String, String> serviceProviderMap);
+
+    SearchBuilder<NetworkAccountVO> createSearchBuilderForAccount();
+
+    List<NetworkVO> getNetworksForOffering(long offeringId, long dataCenterId, long accountId);
+
+    @Override
+    @Deprecated
+    NetworkVO persist(NetworkVO vo);
+
+    /**
+     * Retrieves the next available mac address in this network configuration.
+     * 
+     * @param networkConfigId
+     *            id
+     * @return mac address if there is one. null if not.
+     */
+    String getNextAvailableMacAddress(long networkConfigId);
+
+    List<NetworkVO> listBy(long accountId, long networkId);
+
+    long countByZoneAndUri(long zoneId, String broadcastUri);
+    
+    long countByZoneUriAndGuestType(long zoneId, String broadcastUri, GuestType guestType);
+
+    List<NetworkVO> listByZone(long zoneId);
+
+    void changeActiveNicsBy(long networkId, int nicsCount);
+
+    int getActiveNicsIn(long networkId);
+
+    List<Long> findNetworksToGarbageCollect();
+
+    void clearCheckForGc(long networkId);
+
+    List<NetworkVO> listByZoneSecurityGroup(Long zoneId);
+
+    void addDomainToNetwork(long networkId, long domainId, Boolean subdomainAccess);
+
+    List<NetworkVO> listByPhysicalNetwork(long physicalNetworkId);
+
+    List<NetworkVO> listSecurityGroupEnabledNetworks();
+
+    List<NetworkVO> listByPhysicalNetworkTrafficType(long physicalNetworkId, TrafficType trafficType);
+
+    List<NetworkVO> listBy(long accountId, long dataCenterId, Network.GuestType type, TrafficType trafficType);
+
+    List<NetworkVO> listByPhysicalNetworkAndProvider(long physicalNetworkId, String providerName);
+
+    void persistNetworkServiceProviders(long networkId, Map<String, String> serviceProviderMap);
+
+    boolean update(Long networkId, NetworkVO network, Map<String, String> serviceProviderMap);
+
+    List<NetworkVO> listByZoneAndTrafficType(long zoneId, TrafficType trafficType);
+
+    void setCheckForGc(long networkId);
+    
+    int getNetworkCountByNetworkOffId(long networkOfferingId);
+    
+    long countNetworksUserCanCreate(long ownerId);
+
+    List<NetworkVO> listSourceNATEnabledNetworks(long accountId, long dataCenterId, GuestType type);
+    
+    int getNetworkCountByVpcId(long vpcId);
+    
+    List<NetworkVO> listByVpc(long vpcId);
+    
+    NetworkVO getPrivateNetwork(String broadcastUri, String cidr, long accountId, long zoneId);
+    
+    long countVpcNetworks(long vpcId);
+
+    List<NetworkVO> listNetworksByAccount(long accountId, long zoneId, Network.GuestType type, boolean isSystem);
+
+    List<NetworkVO> listRedundantNetworks();
+}


Mime
View raw message