Skip to content

Commit 3139b35

Browse files
committed
mark VPC to be using distributed router if VPC offerign supports
distributedrouter capability.
1 parent e3ec12e commit 3139b35

8 files changed

Lines changed: 36 additions & 9 deletions

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,10 @@ public enum State {
7373
boolean isRestartRequired();
7474

7575
boolean isDisplay();
76+
77+
/**
78+
*
79+
* @return true if VPC is configured to use distributed router to provides one-hop forwarding and hypervisor based ACL
80+
*/
81+
boolean usesDistributedRouter();
7682
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ public class VpcResponse extends BaseResponse implements ControlledEntityRespons
111111
@Param(description = "is vpc for display to the regular user", since = "4.4", authorized = {RoleType.Admin})
112112
private Boolean forDisplay;
113113

114+
115+
@SerializedName(ApiConstants.DISTRIBUTED_VPC_ROUTER)
116+
@Param(description = "is VPC uses distributed router for one hop forwarding and host based network ACL's")
117+
private boolean usesDistributedRouter;
118+
114119
public void setId(String id) {
115120
this.id = id;
116121
}
@@ -199,4 +204,8 @@ public void setTags(List<ResourceTagResponse> tags) {
199204
public void setForDisplay(Boolean forDisplay) {
200205
this.forDisplay = forDisplay;
201206
}
207+
208+
public void setUsesDistributedRouter(Boolean usesDistributedRouter) {
209+
this.usesDistributedRouter = usesDistributedRouter;
210+
}
202211
}

engine/schema/src/com/cloud/network/vpc/VpcVO.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,15 @@ public class VpcVO implements Vpc {
8181
@Column(name = "display", updatable = true, nullable = false)
8282
protected boolean display = true;
8383

84+
@Column(name="uses_distributed_router")
85+
boolean usesDistributedRouter = false;
86+
8487
public VpcVO() {
8588
uuid = UUID.randomUUID().toString();
8689
}
8790

88-
public VpcVO(long zoneId, String name, String displayText, long accountId, long domainId, long vpcOffId, String cidr, String networkDomain) {
91+
public VpcVO(long zoneId, String name, String displayText, long accountId, long domainId, long vpcOffId, String cidr,
92+
String networkDomain, boolean useDistributedRouter) {
8993
this.zoneId = zoneId;
9094
this.name = name;
9195
this.displayText = displayText;
@@ -95,7 +99,8 @@ public VpcVO(long zoneId, String name, String displayText, long accountId, long
9599
uuid = UUID.randomUUID().toString();
96100
state = State.Enabled;
97101
this.networkDomain = networkDomain;
98-
vpcOfferingId = vpcOffId;
102+
this.vpcOfferingId = vpcOffId;
103+
this.usesDistributedRouter = useDistributedRouter;
99104
}
100105

101106
@Override
@@ -201,5 +206,9 @@ public boolean isDisplay() {
201206
@Override
202207
public IAMEntityType getEntityType() {
203208
return IAMEntityType.Vpc;
209+
210+
@Override
211+
public boolean usesDistributedRouter() {
212+
return usesDistributedRouter;
204213
}
205214
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2808,6 +2808,7 @@ public VpcResponse createVpcResponse(ResponseView view, Vpc vpc) {
28082808
response.setRestartRequired(vpc.isRestartRequired());
28092809
response.setNetworkDomain(vpc.getNetworkDomain());
28102810
response.setForDisplay(vpc.isDisplay());
2811+
response.setUsesDistributedRouter(vpc.usesDistributedRouter());
28112812

28122813
Map<Service, Set<Provider>> serviceProviderMap = ApiDBUtils.listVpcOffServices(vpc.getVpcOfferingId());
28132814
List<ServiceResponse> serviceResponses = new ArrayList<ServiceResponse>();

server/src/com/cloud/network/vpc/VpcManagerImpl.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -728,13 +728,13 @@ public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName
728728
networkDomain = "cs" + Long.toHexString(owner.getId()) + NetworkOrchestrationService.GuestDomainSuffix.valueIn(zoneId);
729729
}
730730
}
731-
732-
return createVpc(zoneId, vpcOffId, owner, vpcName, displayText, cidr, networkDomain, displayVpc);
731+
boolean useDistributedRouter = vpcOff.supportsDistributedRouter();
732+
return createVpc(zoneId, vpcOffId, owner, vpcName, displayText, cidr, networkDomain, displayVpc, useDistributedRouter);
733733
}
734734

735735
@DB
736736
protected Vpc createVpc(final long zoneId, final long vpcOffId, final Account vpcOwner, final String vpcName, final String displayText, final String cidr,
737-
final String networkDomain, final Boolean displayVpc) {
737+
final String networkDomain, final Boolean displayVpc, final boolean useDistributedRouter) {
738738

739739
//Validate CIDR
740740
if (!NetUtils.isValidCIDR(cidr)) {
@@ -756,7 +756,8 @@ protected Vpc createVpc(final long zoneId, final long vpcOffId, final Account vp
756756
return Transaction.execute(new TransactionCallback<VpcVO>() {
757757
@Override
758758
public VpcVO doInTransaction(TransactionStatus status) {
759-
VpcVO vpc = new VpcVO(zoneId, vpcName, displayText, vpcOwner.getId(), vpcOwner.getDomainId(), vpcOffId, cidr, networkDomain);
759+
VpcVO vpc = new VpcVO(zoneId, vpcName, displayText, vpcOwner.getId(), vpcOwner.getDomainId(), vpcOffId,
760+
cidr, networkDomain, useDistributedRouter);
760761
if (displayVpc != null) {
761762
vpc.setDisplay(displayVpc);
762763
}

server/test/com/cloud/vpc/VpcApiUnitTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public void getActiveVpc() {
8585
public void validateNtwkOffForVpc() {
8686
//validate network offering
8787
//1) correct network offering
88-
VpcVO vo = new VpcVO(1, "new vpc", "new vpc", 1, 1, 1, "0.0.0.0/0", "vpc domain");
88+
VpcVO vo = new VpcVO(1, "new vpc", "new vpc", 1, 1, 1, "0.0.0.0/0", "vpc domain", false);
8989
boolean result = false;
9090
try {
9191
_vpcService.validateNtwkOffForNtwkInVpc(2L, 1, "0.0.0.0", "111-", vo, "10.1.1.1", new AccountVO(), null);

server/test/com/cloud/vpc/dao/MockVpcDaoImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ public void persistVpcServiceProviders(long vpcId, Map<String, List<String>> ser
9898
public VpcVO findById(Long id) {
9999
VpcVO vo = null;
100100
if (id.longValue() == 1) {
101-
vo = new VpcVO(1, "new vpc", "new vpc", 1, 1, 1, "0.0.0.0/0", "vpc domain");
101+
vo = new VpcVO(1, "new vpc", "new vpc", 1, 1, 1, "0.0.0.0/0", "vpc domain", false);
102102
} else if (id.longValue() == 2) {
103-
vo = new VpcVO(1, "new vpc", "new vpc", 1, 1, 1, "0.0.0.0/0", "vpc domain");
103+
vo = new VpcVO(1, "new vpc", "new vpc", 1, 1, 1, "0.0.0.0/0", "vpc domain", false);
104104
vo.setState(State.Inactive);
105105
}
106106

setup/db/db/schema-430to440.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,3 +741,4 @@ ALTER TABLE `cloud`.`guest_os` ADD COLUMN `removed` datetime COMMENT 'Time when
741741
UPDATE `cloud`.`guest_os` SET `created` = now();
742742
ALTER TABLE `cloud`.`vm_reservation` ADD COLUMN `deployment_planner` varchar(40) DEFAULT NULL COMMENT 'Preferred deployment planner for the vm';
743743
ALTER TABLE `cloud`.`vpc_offerings` ADD COLUMN supports_distributed_router boolean default false;
744+
ALTER TABLE `cloud`.`vpc` ADD COLUMN uses_distributed_router boolean default false;

0 commit comments

Comments
 (0)