Skip to content

Commit 3205cd4

Browse files
author
Sheng Yang
committed
CLOUDSTACK-730: Site-to-site VPN between VPC VR to VR
Now VPN connection can be created as "passive", which would enable the ability of remote peer initiate the connection. So it's possible for VPC VR to establish the connection to another VPC VR of CloudStack. Test case also included. The test case would create 2 vpcs and using VPN to connect them.
1 parent 1460196 commit 3205cd4

15 files changed

Lines changed: 304 additions & 39 deletions

File tree

‎api/src/com/cloud/network/Site2SiteVpnConnection.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ enum State {
3535
public State getState();
3636
public Date getCreated();
3737
public Date getRemoved();
38+
public boolean isPassive();
3839
}

‎api/src/org/apache/cloudstack/api/ApiConstants.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ public class ApiConstants {
524524
public static final String RESOURCE_DETAILS = "resourcedetails";
525525
public static final String EXPUNGE = "expunge";
526526
public static final String FOR_DISPLAY = "fordisplay";
527+
public static final String PASSIVE = "passive";
527528

528529
public enum HostDetails {
529530
all, capacity, events, stats, min;

‎api/src/org/apache/cloudstack/api/command/user/vpn/CreateVpnConnectionCmd.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ public class CreateVpnConnectionCmd extends BaseAsyncCreateCmd {
5353
required=true, description="id of the customer gateway")
5454
private Long customerGatewayId;
5555

56+
@Parameter(name=ApiConstants.PASSIVE, type=CommandType.BOOLEAN, required=false, description="connection is passive or not")
57+
private Boolean passive;
58+
5659
/////////////////////////////////////////////////////
5760
/////////////////// Accessors ///////////////////////
5861
/////////////////////////////////////////////////////
@@ -65,6 +68,13 @@ public Long getVpnGatewayId() {
6568
public Long getCustomerGatewayId() {
6669
return customerGatewayId;
6770
}
71+
72+
public boolean isPassive() {
73+
if (passive == null) {
74+
return false;
75+
}
76+
return passive;
77+
}
6878

6979
/////////////////////////////////////////////////////
7080
/////////////// API Implementation///////////////////

‎api/src/org/apache/cloudstack/api/response/Site2SiteVpnConnectionResponse.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ public class Site2SiteVpnConnectionResponse extends BaseResponse implements Cont
6868
@SerializedName(ApiConstants.STATE) @Param(description="State of vpn connection")
6969
private String state;
7070

71+
@SerializedName(ApiConstants.PASSIVE) @Param(description="State of vpn connection")
72+
private boolean passive;
73+
7174
@SerializedName(ApiConstants.ACCOUNT) @Param(description="the owner")
7275
private String accountName;
7376

@@ -141,6 +144,10 @@ public void setState(String state) {
141144
this.state = state;
142145
}
143146

147+
public void setPassive(boolean passive) {
148+
this.passive = passive;
149+
}
150+
144151
public void setCreated(Date created) {
145152
this.created = created;
146153
}

‎core/src/com/cloud/agent/api/routing/Site2SiteVpnCfgCommand.java‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class Site2SiteVpnCfgCommand extends NetworkElementCommand {
3030
private long ikeLifetime;
3131
private long espLifetime;
3232
private boolean dpd;
33+
private boolean passive;
3334

3435
@Override
3536
public boolean executeInSequence() {
@@ -41,7 +42,7 @@ public Site2SiteVpnCfgCommand () {
4142
}
4243

4344
public Site2SiteVpnCfgCommand (boolean create, String localPublicIp, String localPublicGateway, String localGuestCidr, String peerGatewayIp,
44-
String peerGuestCidrList, String ikePolicy, String espPolicy, String ipsecPsk, Long ikeLifetime, Long espLifetime, Boolean dpd) {
45+
String peerGuestCidrList, String ikePolicy, String espPolicy, String ipsecPsk, Long ikeLifetime, Long espLifetime, Boolean dpd, boolean passive) {
4546
this.create = create;
4647
this.setLocalPublicIp(localPublicIp);
4748
this.setLocalPublicGateway(localPublicGateway);
@@ -54,6 +55,7 @@ public Site2SiteVpnCfgCommand (boolean create, String localPublicIp, String loca
5455
this.ikeLifetime = ikeLifetime;
5556
this.espLifetime = espLifetime;
5657
this.dpd = dpd;
58+
this.passive = passive;
5759
}
5860

5961
public boolean isCreate() {
@@ -151,4 +153,12 @@ public String getPeerGuestCidrList() {
151153
public void setPeerGuestCidrList(String peerGuestCidrList) {
152154
this.peerGuestCidrList = peerGuestCidrList;
153155
}
156+
157+
public boolean isPassive() {
158+
return passive;
159+
}
160+
161+
public void setPassive(boolean passive) {
162+
this.passive = passive;
163+
}
154164
}

‎core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,9 @@ protected Answer execute(Site2SiteVpnCfgCommand cmd) {
761761
} else {
762762
args += "0";
763763
}
764+
if (cmd.isPassive()) {
765+
args += " -p ";
766+
}
764767
} else {
765768
args = "-D";
766769
args += " -r ";

‎engine/schema/src/com/cloud/network/dao/Site2SiteVpnConnectionVO.java‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,19 @@ public class Site2SiteVpnConnectionVO implements Site2SiteVpnConnection, Interna
6666
@Column(name=GenericDao.REMOVED_COLUMN)
6767
private Date removed;
6868

69+
@Column(name="passive")
70+
private boolean passive;
71+
6972
public Site2SiteVpnConnectionVO() { }
7073

71-
public Site2SiteVpnConnectionVO(long accountId, long domainId, long vpnGatewayId, long customerGatewayId) {
74+
public Site2SiteVpnConnectionVO(long accountId, long domainId, long vpnGatewayId, long customerGatewayId, boolean passive) {
7275
this.uuid = UUID.randomUUID().toString();
7376
this.setVpnGatewayId(vpnGatewayId);
7477
this.setCustomerGatewayId(customerGatewayId);
7578
this.setState(State.Pending);
7679
this.accountId = accountId;
7780
this.domainId = domainId;
81+
this.passive = passive;
7882
}
7983

8084
@Override
@@ -140,4 +144,12 @@ public long getDomainId() {
140144
public long getAccountId() {
141145
return accountId;
142146
}
147+
148+
public boolean isPassive() {
149+
return passive;
150+
}
151+
152+
public void setPassive(boolean passive) {
153+
this.passive = passive;
154+
}
143155
}

‎plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,6 +1559,9 @@ protected Answer execute(Site2SiteVpnCfgCommand cmd) {
15591559
} else {
15601560
args += "0";
15611561
}
1562+
if (cmd.isPassive()) {
1563+
args += " -p ";
1564+
}
15621565
} else {
15631566
args += " -D";
15641567
args += " -r ";

‎plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8519,6 +8519,9 @@ protected Answer execute(Site2SiteVpnCfgCommand cmd) {
85198519
} else {
85208520
args += "0";
85218521
}
8522+
if (cmd.isPassive()) {
8523+
args += " -p ";
8524+
}
85228525
} else {
85238526
args += " -D";
85248527
args += " -r ";

‎server/src/com/cloud/api/ApiResponseHelper.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3195,6 +3195,7 @@ public Site2SiteCustomerGatewayResponse createSite2SiteCustomerGatewayResponse(S
31953195
public Site2SiteVpnConnectionResponse createSite2SiteVpnConnectionResponse(Site2SiteVpnConnection result) {
31963196
Site2SiteVpnConnectionResponse response = new Site2SiteVpnConnectionResponse();
31973197
response.setId(result.getUuid());
3198+
response.setPassive(result.isPassive());
31983199

31993200
Long vpnGatewayId = result.getVpnGatewayId();
32003201
if (vpnGatewayId != null) {

0 commit comments

Comments
 (0)