Skip to content

Commit ca62353

Browse files
committed
Fix conserve mode for VPC Source NAT and extend rules for VPC tiers
1 parent 1b0a036 commit ca62353

File tree

17 files changed

+78
-30
lines changed

17 files changed

+78
-30
lines changed

api/src/main/java/com/cloud/network/vpc/VpcOffering.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,6 @@ public enum State {
8484
NetworkOffering.RoutingMode getRoutingMode();
8585

8686
Boolean isSpecifyAsNumber();
87+
88+
boolean isConserveMode();
8789
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,7 @@ public class ApiConstants {
980980
public static final String REGION_ID = "regionid";
981981
public static final String VPC_OFF_ID = "vpcofferingid";
982982
public static final String VPC_OFF_NAME = "vpcofferingname";
983+
public static final String VPC_OFFERING_CONSERVE_MODE = "vpcofferingconservemode";
983984
public static final String NETWORK = "network";
984985
public static final String VPC_ID = "vpcid";
985986
public static final String VPC_NAME = "vpcname";

api/src/main/java/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public long getNetworkId() {
280280
IpAddress ip = _entityMgr.findById(IpAddress.class, getIpAddressId());
281281
Long ntwkId = null;
282282

283-
if (ip.getAssociatedWithNetworkId() != null) {
283+
if (ip.getVpcId() == null && ip.getAssociatedWithNetworkId() != null) {
284284
ntwkId = ip.getAssociatedWithNetworkId();
285285
} else {
286286
ntwkId = networkId;

api/src/main/java/org/apache/cloudstack/api/response/VpcResponse.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ public class VpcResponse extends BaseResponseWithAnnotations implements Controll
7373
@Param(description = "VPC offering name the VPC is created from", since = "4.13.2")
7474
private String vpcOfferingName;
7575

76+
@SerializedName(ApiConstants.VPC_OFFERING_CONSERVE_MODE)
77+
@Param(description = "true if VPC offering is ip conserve mode enabled", since = "4.23")
78+
private Boolean vpcOfferingConserveMode;
79+
7680
@SerializedName(ApiConstants.CREATED)
7781
@Param(description = "The date this VPC was created")
7882
private Date created;
@@ -197,6 +201,10 @@ public void setDisplayText(final String displayText) {
197201
this.displayText = displayText;
198202
}
199203

204+
public void setVpcOfferingConserveMode(Boolean vpcOfferingConserveMode) {
205+
this.vpcOfferingConserveMode = vpcOfferingConserveMode;
206+
}
207+
200208
public void setCreated(final Date created) {
201209
this.created = created;
202210
}

engine/components-api/src/main/java/com/cloud/network/lb/LoadBalancingRulesManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
public interface LoadBalancingRulesManager {
4040

4141
LoadBalancer createPublicLoadBalancer(String xId, String name, String description, int srcPort, int destPort, long sourceIpId, String protocol, String algorithm,
42-
boolean openFirewall, CallContext caller, String lbProtocol, Boolean forDisplay, String cidrList) throws NetworkRuleConflictException;
42+
boolean openFirewall, CallContext caller, String lbProtocol, Boolean forDisplay, String cidrList, Long networkId) throws NetworkRuleConflictException;
4343

4444
boolean removeAllLoadBalanacersForIp(long ipId, Account caller, long callerUserId);
4545

engine/schema/src/main/java/com/cloud/network/vpc/VpcOfferingVO.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ public class VpcOfferingVO implements VpcOffering {
9191
@Column(name = "specify_as_number")
9292
private Boolean specifyAsNumber = false;
9393

94+
@Column(name = "conserve_mode")
95+
private boolean conserveMode;
96+
9497
public VpcOfferingVO() {
9598
this.uuid = UUID.randomUUID().toString();
9699
}
@@ -242,4 +245,13 @@ public Boolean isSpecifyAsNumber() {
242245
public void setSpecifyAsNumber(Boolean specifyAsNumber) {
243246
this.specifyAsNumber = specifyAsNumber;
244247
}
248+
249+
@Override
250+
public boolean isConserveMode() {
251+
return conserveMode;
252+
}
253+
254+
public void setConserveMode(boolean conserveMode) {
255+
this.conserveMode = conserveMode;
256+
}
245257
}

engine/schema/src/main/resources/META-INF/db/schema-42100to42200.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,5 @@ CALL `cloud`.`INSERT_EXTENSION_DETAIL_IF_NOT_EXISTS`('MaaS', 'orchestratorrequir
8787

8888
CALL `cloud`.`IDEMPOTENT_DROP_UNIQUE_KEY`('counter', 'uc_counter__provider__source__value');
8989
CALL `cloud`.`IDEMPOTENT_ADD_UNIQUE_KEY`('cloud.counter', 'uc_counter__provider__source__value__removed', '(provider, source, value, removed)');
90+
91+
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.vpc_offerings','conserve_mode', 'tinyint(1) unsigned NULL DEFAULT 1');

engine/schema/src/main/resources/META-INF/db/views/cloud.vpc_offering_view.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ select
3838
`vpc_offerings`.`sort_key` AS `sort_key`,
3939
`vpc_offerings`.`routing_mode` AS `routing_mode`,
4040
`vpc_offerings`.`specify_as_number` AS `specify_as_number`,
41+
`vpc_offerings`.`conserve_mode` AS `conserve_mode`,
4142
group_concat(distinct `domain`.`id` separator ',') AS `domain_id`,
4243
group_concat(distinct `domain`.`uuid` separator ',') AS `domain_uuid`,
4344
group_concat(distinct `domain`.`name` separator ',') AS `domain_name`,

plugins/network-elements/elastic-loadbalancer/src/main/java/com/cloud/network/lb/LoadBalanceRuleHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ private LoadBalancer handleCreateLoadBalancerRuleWithLock(final CreateLoadBalanc
363363
lb.setSourceIpAddressId(ipId);
364364

365365
result = _lbMgr.createPublicLoadBalancer(lb.getXid(), lb.getName(), lb.getDescription(), lb.getSourcePortStart(), lb.getDefaultPortStart(), ipId.longValue(),
366-
lb.getProtocol(), lb.getAlgorithm(), false, CallContext.current(), lb.getLbProtocol(), true, null);
366+
lb.getProtocol(), lb.getAlgorithm(), false, CallContext.current(), lb.getLbProtocol(), true, null, networkId);
367367
} catch (final NetworkRuleConflictException e) {
368368
logger.warn("Failed to create LB rule, not continuing with ELB deployment");
369369
if (newIp) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3499,6 +3499,7 @@ public VpcResponse createVpcResponse(ResponseView view, Vpc vpc) {
34993499
if (voff != null) {
35003500
response.setVpcOfferingId(voff.getUuid());
35013501
response.setVpcOfferingName(voff.getName());
3502+
response.setVpcOfferingConserveMode(voff.isConserveMode());
35023503
}
35033504
response.setCidr(vpc.getCidr());
35043505
response.setRestartRequired(vpc.isRestartRequired());

0 commit comments

Comments
 (0)