mirror of https://github.com/apache/cloudstack.git
CS-6840: Add data structure for site-to-site vpn tables
This commit is contained in:
parent
78b31bb7db
commit
9bb65b1126
|
|
@ -0,0 +1,11 @@
|
|||
package com.cloud.network;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public interface Site2SiteCustomerGateway {
|
||||
public long getId();
|
||||
public String getGatewayIp();
|
||||
public String getGuestCidrList();
|
||||
public String getIpsecPsk();
|
||||
public Date getRemoved();
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.cloud.network;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public interface Site2SiteVpnConnection {
|
||||
enum State {
|
||||
Pending,
|
||||
Connected,
|
||||
Disconnecting,
|
||||
Disconnected,
|
||||
Error,
|
||||
}
|
||||
public long getId();
|
||||
public long getVpnGatewayId();
|
||||
public long getCustomerGatewayId();
|
||||
public State getState();
|
||||
public Date getCreated();
|
||||
public Date getRemoved();
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.cloud.network;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public interface Site2SiteVpnGateway {
|
||||
public long getId();
|
||||
public long getAddrId();
|
||||
public Date getRemoved();
|
||||
}
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
package com.cloud.network;
|
||||
|
||||
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.utils.db.GenericDao;
|
||||
|
||||
@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="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="lifetime")
|
||||
private long lifetime;
|
||||
|
||||
@Column(name=GenericDao.REMOVED_COLUMN)
|
||||
private Date removed;
|
||||
|
||||
public Site2SiteCustomerGatewayVO() { }
|
||||
|
||||
public Site2SiteCustomerGatewayVO(String gatewayIp, String guestCidrList, String ipsecPsk, String ikePolicy, String espPolicy, long lifetime) {
|
||||
this.gatewayIp = gatewayIp;
|
||||
this.guestCidrList = guestCidrList;
|
||||
this.ipsecPsk = ipsecPsk;
|
||||
this.ikePolicy = ikePolicy;
|
||||
this.espPolicy = espPolicy;
|
||||
this.lifetime = lifetime;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
public long getLifetime() {
|
||||
return lifetime;
|
||||
}
|
||||
|
||||
public void setLifetime(long lifetime) {
|
||||
this.lifetime = lifetime;
|
||||
}
|
||||
|
||||
public String getIkePolicy() {
|
||||
return ikePolicy;
|
||||
}
|
||||
|
||||
public void setIkePolicy(String ikePolicy) {
|
||||
this.ikePolicy = ikePolicy;
|
||||
}
|
||||
|
||||
public String getEspPolicy() {
|
||||
return espPolicy;
|
||||
}
|
||||
|
||||
public void setEspPolicy(String espPolicy) {
|
||||
this.espPolicy = espPolicy;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
package com.cloud.network;
|
||||
|
||||
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.utils.db.GenericDao;
|
||||
|
||||
@Entity
|
||||
@Table(name=("s2s_vpn_connection"))
|
||||
public class Site2SiteVpnConnectionVO implements Site2SiteVpnConnection {
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
private long id;
|
||||
|
||||
@Column(name="uuid")
|
||||
private String uuid;
|
||||
|
||||
@Column(name="vpn_gateway_id")
|
||||
private long vpnGatewayId;
|
||||
|
||||
@Column(name="customer_gateway_id")
|
||||
private long customerGatewayId;
|
||||
|
||||
@Column(name="state")
|
||||
private State state;
|
||||
|
||||
@Column(name=GenericDao.CREATED_COLUMN)
|
||||
private Date created;
|
||||
|
||||
@Column(name=GenericDao.REMOVED_COLUMN)
|
||||
private Date removed;
|
||||
|
||||
public Site2SiteVpnConnectionVO() { }
|
||||
|
||||
public Site2SiteVpnConnectionVO(long vpnGatewayId, long customerGatewayId) {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.setVpnGatewayId(vpnGatewayId);
|
||||
this.setCustomerGatewayId(customerGatewayId);
|
||||
this.setState(State.Pending);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(State state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getVpnGatewayId() {
|
||||
return vpnGatewayId;
|
||||
}
|
||||
|
||||
public void setVpnGatewayId(long vpnGatewayId) {
|
||||
this.vpnGatewayId = vpnGatewayId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCustomerGatewayId() {
|
||||
return customerGatewayId;
|
||||
}
|
||||
|
||||
public void setCustomerGatewayId(long customerGatewayId) {
|
||||
this.customerGatewayId = customerGatewayId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getRemoved() {
|
||||
return removed;
|
||||
}
|
||||
|
||||
public void setRemoved(Date removed) {
|
||||
this.removed = removed;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
package com.cloud.network;
|
||||
|
||||
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.utils.db.GenericDao;
|
||||
|
||||
@Entity
|
||||
@Table(name=("s2s_vpn_gateway"))
|
||||
public class Site2SiteVpnGatewayVO implements Site2SiteVpnGateway {
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
private long id;
|
||||
|
||||
@Column(name="uuid")
|
||||
private String uuid;
|
||||
|
||||
@Column(name="addr_id")
|
||||
private long addrId;
|
||||
|
||||
@Column(name=GenericDao.REMOVED_COLUMN)
|
||||
private Date removed;
|
||||
|
||||
public Site2SiteVpnGatewayVO() { }
|
||||
|
||||
public Site2SiteVpnGatewayVO(long addrId) {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.setAddrId(addrId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAddrId() {
|
||||
return addrId;
|
||||
}
|
||||
|
||||
public void setAddrId(long addrId) {
|
||||
this.addrId = addrId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getRemoved() {
|
||||
return removed;
|
||||
}
|
||||
|
||||
public void setRemoved(Date removed) {
|
||||
this.removed = removed;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.cloud.network.dao;
|
||||
|
||||
import com.cloud.network.Site2SiteCustomerGatewayVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface Site2SiteCustomerGatewayDao extends GenericDao<Site2SiteCustomerGatewayVO, Long> {
|
||||
Site2SiteCustomerGatewayVO findByGatewayIp(String ip);
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.cloud.network.dao;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.network.Site2SiteCustomerGatewayVO;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
@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.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Site2SiteCustomerGatewayVO findByGatewayIp(String ip) {
|
||||
SearchCriteria<Site2SiteCustomerGatewayVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("gatewayIp", ip);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.cloud.network.dao;
|
||||
|
||||
import com.cloud.network.Site2SiteVpnConnectionVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface Site2SiteVpnConnectionDao extends GenericDao<Site2SiteVpnConnectionVO, Long> {
|
||||
Site2SiteVpnConnectionVO findByCustomerGatewayId(long id);
|
||||
Site2SiteVpnConnectionVO findByVpnGatewayId(long id);
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package com.cloud.network.dao;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.network.Site2SiteVpnConnectionVO;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
@Local(value={Site2SiteVpnConnectionDao.class})
|
||||
public class Site2SiteVpnConnectionDaoImpl extends GenericDaoBase<Site2SiteVpnConnectionVO, Long> implements Site2SiteVpnConnectionDao {
|
||||
private static final Logger s_logger = Logger.getLogger(Site2SiteVpnConnectionDaoImpl.class);
|
||||
|
||||
private final SearchBuilder<Site2SiteVpnConnectionVO> AllFieldsSearch;
|
||||
|
||||
protected Site2SiteVpnConnectionDaoImpl() {
|
||||
AllFieldsSearch = createSearchBuilder();
|
||||
AllFieldsSearch.and("customerGatewayId", AllFieldsSearch.entity().getCustomerGatewayId(), SearchCriteria.Op.EQ);
|
||||
AllFieldsSearch.and("vpnGatewayId", AllFieldsSearch.entity().getVpnGatewayId(), SearchCriteria.Op.EQ);
|
||||
AllFieldsSearch.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Site2SiteVpnConnectionVO findByCustomerGatewayId(long id) {
|
||||
SearchCriteria<Site2SiteVpnConnectionVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("customerGatewayId", id);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Site2SiteVpnConnectionVO findByVpnGatewayId(long id) {
|
||||
SearchCriteria<Site2SiteVpnConnectionVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("vpnGatewayId", id);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.cloud.network.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.network.Site2SiteVpnGatewayVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface Site2SiteVpnGatewayDao extends GenericDao<Site2SiteVpnGatewayVO, Long> {
|
||||
Site2SiteVpnGatewayVO findByIpAddrId(long id);
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.cloud.network.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.network.Site2SiteVpnGatewayVO;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
@Local(value={Site2SiteVpnGatewayDao.class})
|
||||
public class Site2SiteVpnGatewayDaoImpl extends GenericDaoBase<Site2SiteVpnGatewayVO, Long> implements Site2SiteVpnGatewayDao {
|
||||
private static final Logger s_logger = Logger.getLogger(Site2SiteVpnGatewayDaoImpl.class);
|
||||
|
||||
private final SearchBuilder<Site2SiteVpnGatewayVO> AllFieldsSearch;
|
||||
|
||||
protected Site2SiteVpnGatewayDaoImpl() {
|
||||
AllFieldsSearch = createSearchBuilder();
|
||||
AllFieldsSearch.and("addrId", AllFieldsSearch.entity().getAddrId(), SearchCriteria.Op.EQ);
|
||||
AllFieldsSearch.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Site2SiteVpnGatewayVO findByIpAddrId(long id) {
|
||||
SearchCriteria<Site2SiteVpnGatewayVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("addrId", id);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue