Skip to content

Commit 0f48973

Browse files
author
Alena Prokharchyk
committed
Display flag support for LB/InternalLB/NetworkACL rules
1 parent c2fa24a commit 0f48973

33 files changed

Lines changed: 237 additions & 74 deletions

api/src/com/cloud/network/lb/LoadBalancingRulesService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,17 @@
4141
public interface LoadBalancingRulesService {
4242
/**
4343
* Create a load balancer rule from the given ipAddress/port to the given private port
44-
*
4544
* @param openFirewall
4645
* TODO
46+
* @param forDisplay TODO
4747
* @param cmd
4848
* the command specifying the ip address, public port, protocol, private port, and algorithm
49+
*
4950
* @return the newly created LoadBalancerVO if successful, null otherwise
5051
* @throws InsufficientAddressCapacityException
5152
*/
5253
LoadBalancer createPublicLoadBalancerRule(String xId, String name, String description, int srcPortStart, int srcPortEnd, int defPortStart, int defPortEnd,
53-
Long ipAddrId, String protocol, String algorithm, long networkId, long lbOwnerId, boolean openFirewall, String lbProtocol) throws NetworkRuleConflictException,
54+
Long ipAddrId, String protocol, String algorithm, long networkId, long lbOwnerId, boolean openFirewall, String lbProtocol, Boolean forDisplay) throws NetworkRuleConflictException,
5455
InsufficientAddressCapacityException;
5556

5657
LoadBalancer updateLoadBalancerRule(UpdateLoadBalancerRuleCmd cmd);

api/src/com/cloud/network/vpc/NetworkACL.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,6 @@ public interface NetworkACL extends InternalIdentity {
3333
long getId();
3434

3535
String getName();
36+
37+
boolean isDisplay();
3638
}

api/src/com/cloud/network/vpc/NetworkACLItem.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,6 @@ enum Action {
7373
*/
7474
TrafficType getTrafficType();
7575

76+
boolean isDisplay();
77+
7678
}

api/src/com/cloud/network/vpc/NetworkACLService.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ public interface NetworkACLService {
3131
* @param name
3232
* @param description
3333
* @param vpcId
34+
* @param forDisplay TODO
3435
* @return
3536
*/
36-
NetworkACL createNetworkACL(String name, String description, long vpcId);
37+
NetworkACL createNetworkACL(String name, String description, long vpcId, Boolean forDisplay);
3738

3839
/**
3940
* Get Network ACL with specified Id
@@ -115,11 +116,12 @@ public interface NetworkACLService {
115116
* @param icmpCode
116117
* @param icmpType
117118
* @param newUUID TODO
119+
* @param forDisplay TODO
118120
* @return
119121
* @throws ResourceUnavailableException
120122
*/
121123
NetworkACLItem updateNetworkACLItem(Long id, String protocol, List<String> sourceCidrList, NetworkACLItem.TrafficType trafficType, String action, Integer number,
122-
Integer sourcePortStart, Integer sourcePortEnd, Integer icmpCode, Integer icmpType, String newUUID) throws ResourceUnavailableException;
124+
Integer sourcePortStart, Integer sourcePortEnd, Integer icmpCode, Integer icmpType, String newUUID, Boolean forDisplay) throws ResourceUnavailableException;
123125

124126
/**
125127
* Associates ACL with specified Network
@@ -130,6 +132,6 @@ NetworkACLItem updateNetworkACLItem(Long id, String protocol, List<String> sourc
130132
*/
131133
boolean replaceNetworkACLonPrivateGw(long aclId, long privateGatewayId) throws ResourceUnavailableException;
132134

133-
NetworkACL updateNetworkACL(Long id, String customId);
135+
NetworkACL updateNetworkACL(Long id, String customId, Boolean forDisplay);
134136

135137
}

api/src/org/apache/cloudstack/api/command/user/firewall/CreateFirewallRuleCmd.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
9090
// ///////////////// Accessors ///////////////////////
9191
// ///////////////////////////////////////////////////
9292

93+
9394
public Long getIpAddressId() {
9495
return ipAddressId;
9596
}

api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateApplicationLoadBalancerCmd.java

Lines changed: 9 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.loadbalancer;
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.ApiCommandJobType;
2322
import org.apache.cloudstack.api.ApiConstants;
@@ -29,6 +28,7 @@
2928
import org.apache.cloudstack.api.response.NetworkResponse;
3029
import org.apache.cloudstack.context.CallContext;
3130
import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
31+
import org.apache.log4j.Logger;
3232

3333
import com.cloud.event.EventTypes;
3434
import com.cloud.exception.InsufficientAddressCapacityException;
@@ -94,9 +94,15 @@ public class CreateApplicationLoadBalancerCmd extends BaseAsyncCreateCmd {
9494
description = "the load balancer scheme. Supported value in this release is Internal")
9595
private String scheme;
9696

97+
@Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the rule to the end user or not", since = "4.4", authorized = {RoleType.Admin})
98+
private Boolean display;
99+
97100
/////////////////////////////////////////////////////
98101
/////////////////// Accessors ///////////////////////
99102
/////////////////////////////////////////////////////
103+
public Boolean getDisplay() {
104+
return display;
105+
}
100106

101107
public String getAlgorithm() {
102108
return algorithm;
@@ -215,7 +221,7 @@ public void create() {
215221

216222
ApplicationLoadBalancerRule result =
217223
_appLbService.createApplicationLoadBalancer(getName(), getDescription(), getScheme(), getSourceIpNetworkId(), getSourceIp(), getSourcePort(),
218-
getInstancePort(), getAlgorithm(), getNetworkId(), getEntityOwnerId());
224+
getInstancePort(), getAlgorithm(), getNetworkId(), getEntityOwnerId(), getDisplay());
219225
this.setEntityId(result.getId());
220226
this.setEntityUuid(result.getUuid());
221227
} catch (NetworkRuleConflictException e) {

api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818

1919
import java.util.List;
2020

21-
import org.apache.log4j.Logger;
22-
21+
import org.apache.cloudstack.acl.RoleType;
2322
import org.apache.cloudstack.api.APICommand;
2423
import org.apache.cloudstack.api.ApiCommandJobType;
2524
import org.apache.cloudstack.api.ApiConstants;
@@ -34,6 +33,7 @@
3433
import org.apache.cloudstack.api.response.NetworkResponse;
3534
import org.apache.cloudstack.api.response.ZoneResponse;
3635
import org.apache.cloudstack.context.CallContext;
36+
import org.apache.log4j.Logger;
3737

3838
import com.cloud.dc.DataCenter;
3939
import com.cloud.dc.DataCenter.NetworkType;
@@ -116,10 +116,17 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements L
116116
@Parameter(name = ApiConstants.PROTOCOL, type = CommandType.STRING, description = "The protocol for the LB")
117117
private String lbProtocol;
118118

119+
@Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the rule to the end user or not", since = "4.4", authorized = {RoleType.Admin})
120+
private Boolean display;
121+
119122
/////////////////////////////////////////////////////
120123
/////////////////// Accessors ///////////////////////
121124
/////////////////////////////////////////////////////
122125

126+
public Boolean getDisplay() {
127+
return display;
128+
}
129+
123130
public String getAlgorithm() {
124131
return algorithm;
125132
}
@@ -301,7 +308,7 @@ public void create() {
301308
try {
302309
LoadBalancer result =
303310
_lbService.createPublicLoadBalancerRule(getXid(), getName(), getDescription(), getSourcePortStart(), getSourcePortEnd(), getDefaultPortStart(),
304-
getDefaultPortEnd(), getSourceIpAddressId(), getProtocol(), getAlgorithm(), getNetworkId(), getEntityOwnerId(), getOpenFirewall(), getLbProtocol());
311+
getDefaultPortEnd(), getSourceIpAddressId(), getProtocol(), getAlgorithm(), getNetworkId(), getEntityOwnerId(), getOpenFirewall(), getLbProtocol(), getDisplay());
305312
this.setEntityId(result.getId());
306313
this.setEntityUuid(result.getUuid());
307314
} catch (NetworkRuleConflictException e) {

api/src/org/apache/cloudstack/api/command/user/loadbalancer/UpdateApplicationLoadBalancerCmd.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.loadbalancer;
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;
@@ -42,6 +43,9 @@ public class UpdateApplicationLoadBalancerCmd extends BaseAsyncCustomIdCmd {
4243
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = FirewallRuleResponse.class, required = true, description = "the ID of the Load Balancer")
4344
private Long id;
4445

46+
@Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the rule to the end user or not", since = "4.4", authorized = {RoleType.Admin})
47+
private Boolean display;
48+
4549
/////////////////////////////////////////////////////
4650
/////////////////// Accessors ///////////////////////
4751
/////////////////////////////////////////////////////
@@ -54,6 +58,10 @@ public Long getId() {
5458
return id;
5559
}
5660

61+
public Boolean getDisplay() {
62+
return display;
63+
}
64+
5765
@Override
5866
public long getEntityOwnerId() {
5967
ApplicationLoadBalancerRule lb = _entityMgr.findById(ApplicationLoadBalancerRule.class, getId());
@@ -81,7 +89,7 @@ public String getEventDescription() {
8189
@Override
8290
public void execute() {
8391
CallContext.current().setEventDetails("Load balancer Id: " + getId());
84-
ApplicationLoadBalancerRule rule = _appLbService.deleteApplicationLoadBalancer(getId(), this.getCustomId());
92+
ApplicationLoadBalancerRule rule = _appLbService.updateApplicationLoadBalancer(getId(), this.getCustomId(), getDisplay());
8593
ApplicationLoadBalancerResponse lbResponse = _responseGenerator.createLoadBalancerContainerReponse(rule, _lbService.getLbInstances(getId()));
8694
setResponseObject(lbResponse);
8795
lbResponse.setResponseName(getCommandName());

api/src/org/apache/cloudstack/api/command/user/loadbalancer/UpdateLoadBalancerRuleCmd.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// under the License.
1717
package org.apache.cloudstack.api.command.user.loadbalancer;
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.ApiErrorCode;
@@ -59,6 +60,9 @@ public class UpdateLoadBalancerRuleCmd extends BaseAsyncCustomIdCmd {
5960
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "the name of the load balancer rule")
6061
private String loadBalancerName;
6162

63+
@Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the rule to the end user or not", since = "4.4", authorized = {RoleType.Admin})
64+
private Boolean display;
65+
6266
/////////////////////////////////////////////////////
6367
/////////////////// Accessors ///////////////////////
6468
/////////////////////////////////////////////////////
@@ -79,6 +83,10 @@ public String getLoadBalancerName() {
7983
return loadBalancerName;
8084
}
8185

86+
public Boolean getDisplay() {
87+
return display;
88+
}
89+
8290
/////////////////////////////////////////////////////
8391
/////////////// API Implementation///////////////////
8492
/////////////////////////////////////////////////////

api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLCmd.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
import java.util.ArrayList;
2020
import java.util.List;
2121

22-
import org.apache.commons.lang.StringUtils;
23-
import org.apache.log4j.Logger;
24-
22+
import org.apache.cloudstack.acl.RoleType;
2523
import org.apache.cloudstack.api.APICommand;
2624
import org.apache.cloudstack.api.ApiConstants;
2725
import org.apache.cloudstack.api.ApiErrorCode;
@@ -32,6 +30,8 @@
3230
import org.apache.cloudstack.api.response.NetworkACLResponse;
3331
import org.apache.cloudstack.api.response.NetworkResponse;
3432
import org.apache.cloudstack.context.CallContext;
33+
import org.apache.commons.lang.StringUtils;
34+
import org.apache.log4j.Logger;
3535

3636
import com.cloud.event.EventTypes;
3737
import com.cloud.exception.InvalidParameterValueException;
@@ -95,9 +95,15 @@ public class CreateNetworkACLCmd extends BaseAsyncCreateCmd {
9595
@Parameter(name = ApiConstants.ACTION, type = CommandType.STRING, description = "scl entry action, allow or deny")
9696
private String action;
9797

98+
@Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the rule to the end user or not", since = "4.4", authorized = {RoleType.Admin})
99+
private Boolean display;
100+
98101
// ///////////////////////////////////////////////////
99102
// ///////////////// Accessors ///////////////////////
100103
// ///////////////////////////////////////////////////
104+
public Boolean getDisplay() {
105+
return display;
106+
}
101107

102108
public String getProtocol() {
103109
String p = protocol.trim();

0 commit comments

Comments
 (0)