Skip to content

Commit e2ec094

Browse files
author
Alena Prokharchyk
committed
Display flag support for VpnConnection/VpnGateway/RemoteAccessVpn
1 parent 83bef78 commit e2ec094

22 files changed

Lines changed: 168 additions & 28 deletions

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@ enum State {
3838
Long getVpcId();
3939

4040
State getState();
41+
42+
boolean isDisplay();
4143
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,6 @@ enum State {
4242
public Date getRemoved();
4343

4444
public boolean isPassive();
45+
46+
boolean isDisplay();
4547
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
// Licensed to the Apache Software Foundation (ASF) under one
23
// or more contributor license agreements. See the NOTICE file
34
// distributed with this work for additional information
@@ -15,17 +16,19 @@
1516
// specific language governing permissions and limitations
1617
// under the License.
1718
package com.cloud.network;
18-
1919
import java.util.Date;
2020

2121
import org.apache.cloudstack.acl.ControlledEntity;
2222
import org.apache.cloudstack.api.Identity;
2323
import org.apache.cloudstack.api.InternalIdentity;
2424

25+
2526
public interface Site2SiteVpnGateway extends ControlledEntity, Identity, InternalIdentity {
2627
public long getAddrId();
2728

2829
public long getVpcId();
2930

3031
public Date getRemoved();
32+
33+
boolean isDisplay();
3134
}

‎api/src/com/cloud/network/vpn/RemoteAccessVpnService.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
public interface RemoteAccessVpnService {
3232
static final String RemoteAccessVpnClientIpRangeCK = "remote.access.vpn.client.iprange";
3333

34-
RemoteAccessVpn createRemoteAccessVpn(long vpnServerAddressId, String ipRange, boolean openFirewall) throws NetworkRuleConflictException;
34+
RemoteAccessVpn createRemoteAccessVpn(long vpnServerAddressId, String ipRange, boolean openFirewall, Boolean forDisplay) throws NetworkRuleConflictException;
3535

3636
void destroyRemoteAccessVpnForIp(long vpnServerAddressId, Account caller) throws ResourceUnavailableException;
3737

@@ -55,6 +55,6 @@ public interface RemoteAccessVpnService {
5555

5656
RemoteAccessVpn getRemoteAccessVpnById(long vpnId);
5757

58-
RemoteAccessVpn updateRemoteAccessVpn(long id, String customId);
58+
RemoteAccessVpn updateRemoteAccessVpn(long id, String customId, Boolean forDisplay);
5959

6060
}

‎api/src/com/cloud/network/vpn/Site2SiteVpnService.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public interface Site2SiteVpnService {
6464

6565
Site2SiteCustomerGateway updateCustomerGateway(UpdateVpnCustomerGatewayCmd updateVpnCustomerGatewayCmd);
6666

67-
Site2SiteVpnConnection updateVpnConnection(long id, String customId);
67+
Site2SiteVpnConnection updateVpnConnection(long id, String customId, Boolean forDisplay);
6868

69-
Site2SiteVpnGateway updateVpnGateway(Long id, String customId);
69+
Site2SiteVpnGateway updateVpnGateway(Long id, String customId, Boolean forDisplay);
7070
}

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
// under the License.
1717
package org.apache.cloudstack.api.command.user.vpn;
1818

19-
import org.apache.log4j.Logger;
20-
19+
import org.apache.cloudstack.acl.RoleType;
2120
import org.apache.cloudstack.api.APICommand;
2221
import org.apache.cloudstack.api.ApiConstants;
2322
import org.apache.cloudstack.api.ApiErrorCode;
@@ -28,6 +27,7 @@
2827
import org.apache.cloudstack.api.response.DomainResponse;
2928
import org.apache.cloudstack.api.response.IPAddressResponse;
3029
import org.apache.cloudstack.api.response.RemoteAccessVpnResponse;
30+
import org.apache.log4j.Logger;
3131

3232
import com.cloud.event.EventTypes;
3333
import com.cloud.exception.InvalidParameterValueException;
@@ -74,10 +74,14 @@ public class CreateRemoteAccessVpnCmd extends BaseAsyncCreateCmd {
7474
description = "if true, firewall rule for source/end pubic port is automatically created; if false - firewall rule has to be created explicitely. Has value true by default")
7575
private Boolean openFirewall;
7676

77+
@Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the vpn to the end user or not", since = "4.4", authorized = {RoleType.Admin})
78+
private Boolean display;
79+
7780
/////////////////////////////////////////////////////
7881
/////////////////// Accessors ///////////////////////
7982
/////////////////////////////////////////////////////
8083

84+
8185
public Long getPublicIpId() {
8286
return publicIpId;
8387
}
@@ -139,7 +143,7 @@ public String getEventType() {
139143
@Override
140144
public void create() {
141145
try {
142-
RemoteAccessVpn vpn = _ravService.createRemoteAccessVpn(publicIpId, ipRange, getOpenFirewall());
146+
RemoteAccessVpn vpn = _ravService.createRemoteAccessVpn(publicIpId, ipRange, getOpenFirewall(), getDisplay());
143147
if (vpn != null) {
144148
this.setEntityId(vpn.getServerAddressId());
145149
// find uuid for server ip address
@@ -191,4 +195,8 @@ private IpAddress getIp() {
191195
}
192196
return ip;
193197
}
198+
199+
public Boolean getDisplay() {
200+
return display;
201+
}
194202
}

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
// under the License.
1717
package org.apache.cloudstack.api.command.user.vpn;
1818

19-
import org.apache.log4j.Logger;
20-
19+
import org.apache.cloudstack.acl.RoleType;
2120
import org.apache.cloudstack.api.APICommand;
2221
import org.apache.cloudstack.api.ApiConstants;
2322
import org.apache.cloudstack.api.ApiErrorCode;
@@ -28,6 +27,7 @@
2827
import org.apache.cloudstack.api.response.Site2SiteCustomerGatewayResponse;
2928
import org.apache.cloudstack.api.response.Site2SiteVpnConnectionResponse;
3029
import org.apache.cloudstack.api.response.Site2SiteVpnGatewayResponse;
30+
import org.apache.log4j.Logger;
3131

3232
import com.cloud.event.EventTypes;
3333
import com.cloud.exception.NetworkRuleConflictException;
@@ -62,6 +62,9 @@ public class CreateVpnConnectionCmd extends BaseAsyncCreateCmd {
6262
@Parameter(name = ApiConstants.PASSIVE, type = CommandType.BOOLEAN, required = false, description = "connection is passive or not")
6363
private Boolean passive;
6464

65+
@Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the vpn to the end user or not", since = "4.4", authorized = {RoleType.Admin})
66+
private Boolean display;
67+
6568
/////////////////////////////////////////////////////
6669
/////////////////// Accessors ///////////////////////
6770
/////////////////////////////////////////////////////
@@ -81,6 +84,10 @@ public boolean isPassive() {
8184
return passive;
8285
}
8386

87+
public Boolean getDisplay() {
88+
return display;
89+
}
90+
8491
/////////////////////////////////////////////////////
8592
/////////////// API Implementation///////////////////
8693
/////////////////////////////////////////////////////

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
// under the License.
1717
package org.apache.cloudstack.api.command.user.vpn;
1818

19-
import org.apache.log4j.Logger;
20-
19+
import org.apache.cloudstack.acl.RoleType;
2120
import org.apache.cloudstack.api.APICommand;
2221
import org.apache.cloudstack.api.ApiConstants;
2322
import org.apache.cloudstack.api.ApiErrorCode;
@@ -26,6 +25,7 @@
2625
import org.apache.cloudstack.api.ServerApiException;
2726
import org.apache.cloudstack.api.response.Site2SiteVpnGatewayResponse;
2827
import org.apache.cloudstack.api.response.VpcResponse;
28+
import org.apache.log4j.Logger;
2929

3030
import com.cloud.event.EventTypes;
3131
import com.cloud.network.Site2SiteVpnGateway;
@@ -47,6 +47,9 @@ public class CreateVpnGatewayCmd extends BaseAsyncCmd {
4747
description = "public ip address id of the vpn gateway")
4848
private Long vpcId;
4949

50+
@Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the vpn to the end user or not", since = "4.4", authorized = {RoleType.Admin})
51+
private Boolean display;
52+
5053
/////////////////////////////////////////////////////
5154
/////////////////// Accessors ///////////////////////
5255
/////////////////////////////////////////////////////
@@ -55,6 +58,10 @@ public Long getVpcId() {
5558
return vpcId;
5659
}
5760

61+
public Boolean getDisplay() {
62+
return display;
63+
}
64+
5865
/////////////////////////////////////////////////////
5966
/////////////// API Implementation///////////////////
6067
/////////////////////////////////////////////////////

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// under the License.
1717
package org.apache.cloudstack.api.command.user.vpn;
1818

19+
import org.apache.cloudstack.acl.RoleType;
1920
import org.apache.cloudstack.api.APICommand;
2021
import org.apache.cloudstack.api.ApiConstants;
2122
import org.apache.cloudstack.api.BaseAsyncCustomIdCmd;
@@ -45,6 +46,9 @@ public class UpdateRemoteAccessVpnCmd extends BaseAsyncCustomIdCmd {
4546
@Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class, expose = false)
4647
private Long ownerId;
4748

49+
@Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the vpn to the end user or not", since = "4.4", authorized = {RoleType.Admin})
50+
private Boolean display;
51+
4852
/////////////////////////////////////////////////////
4953
/////////////////// Accessors ///////////////////////
5054
/////////////////////////////////////////////////////
@@ -58,6 +62,10 @@ public String getCommandName() {
5862
return s_name;
5963
}
6064

65+
public Boolean getDisplay() {
66+
return display;
67+
}
68+
6169
@Override
6270
public long getEntityOwnerId() {
6371
if (ownerId == null) {
@@ -86,7 +94,7 @@ public String getEventType() {
8694

8795
@Override
8896
public void execute() {
89-
RemoteAccessVpn result = _ravService.updateRemoteAccessVpn(id, this.getCustomId());
97+
RemoteAccessVpn result = _ravService.updateRemoteAccessVpn(id, this.getCustomId(), getDisplay());
9098
RemoteAccessVpnResponse response = _responseGenerator.createRemoteAccessVpnResponse(result);
9199
response.setResponseName(getCommandName());
92100
this.setResponseObject(response);

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// under the License.
1717
package org.apache.cloudstack.api.command.user.vpn;
1818

19+
import org.apache.cloudstack.acl.RoleType;
1920
import org.apache.cloudstack.api.APICommand;
2021
import org.apache.cloudstack.api.ApiConstants;
2122
import org.apache.cloudstack.api.BaseAsyncCustomIdCmd;
@@ -39,12 +40,19 @@ public class UpdateVpnConnectionCmd extends BaseAsyncCustomIdCmd {
3940
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = Site2SiteVpnConnectionResponse.class, required = true, description = "id of vpn connection")
4041
private Long id;
4142

43+
@Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the vpn to the end user or not", since = "4.4", authorized = {RoleType.Admin})
44+
private Boolean display;
45+
4246
/////////////////////////////////////////////////////
4347
/////////////////// Accessors ///////////////////////
4448
/////////////////////////////////////////////////////
4549
public Long getId() {
4650
return id;
4751
}
52+
53+
public Boolean getDisplay() {
54+
return display;
55+
}
4856
/////////////////////////////////////////////////////
4957
/////////////// API Implementation///////////////////
5058
/////////////////////////////////////////////////////
@@ -75,7 +83,7 @@ public String getEventType() {
7583

7684
@Override
7785
public void execute() {
78-
Site2SiteVpnConnection result = _s2sVpnService.updateVpnConnection(id, this.getCustomId());
86+
Site2SiteVpnConnection result = _s2sVpnService.updateVpnConnection(id, this.getCustomId(), getDisplay());
7987
Site2SiteVpnConnectionResponse response = _responseGenerator.createSite2SiteVpnConnectionResponse(result);
8088
response.setResponseName(getCommandName());
8189
setResponseObject(response);

0 commit comments

Comments
 (0)