mirror of https://github.com/apache/cloudstack.git
mark VPC to be using distributed router if VPC offerign supports
distributedrouter capability.
This commit is contained in:
parent
e3ec12e5d0
commit
3139b35518
|
|
@ -73,4 +73,10 @@ public interface Vpc extends ControlledEntity, Identity, InternalIdentity {
|
|||
boolean isRestartRequired();
|
||||
|
||||
boolean isDisplay();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return true if VPC is configured to use distributed router to provides one-hop forwarding and hypervisor based ACL
|
||||
*/
|
||||
boolean usesDistributedRouter();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,6 +111,11 @@ public class VpcResponse extends BaseResponse implements ControlledEntityRespons
|
|||
@Param(description = "is vpc for display to the regular user", since = "4.4", authorized = {RoleType.Admin})
|
||||
private Boolean forDisplay;
|
||||
|
||||
|
||||
@SerializedName(ApiConstants.DISTRIBUTED_VPC_ROUTER)
|
||||
@Param(description = "is VPC uses distributed router for one hop forwarding and host based network ACL's")
|
||||
private boolean usesDistributedRouter;
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
|
@ -199,4 +204,8 @@ public class VpcResponse extends BaseResponse implements ControlledEntityRespons
|
|||
public void setForDisplay(Boolean forDisplay) {
|
||||
this.forDisplay = forDisplay;
|
||||
}
|
||||
|
||||
public void setUsesDistributedRouter(Boolean usesDistributedRouter) {
|
||||
this.usesDistributedRouter = usesDistributedRouter;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,11 +81,15 @@ public class VpcVO implements Vpc {
|
|||
@Column(name = "display", updatable = true, nullable = false)
|
||||
protected boolean display = true;
|
||||
|
||||
@Column(name="uses_distributed_router")
|
||||
boolean usesDistributedRouter = false;
|
||||
|
||||
public VpcVO() {
|
||||
uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public VpcVO(long zoneId, String name, String displayText, long accountId, long domainId, long vpcOffId, String cidr, String networkDomain) {
|
||||
public VpcVO(long zoneId, String name, String displayText, long accountId, long domainId, long vpcOffId, String cidr,
|
||||
String networkDomain, boolean useDistributedRouter) {
|
||||
this.zoneId = zoneId;
|
||||
this.name = name;
|
||||
this.displayText = displayText;
|
||||
|
|
@ -95,7 +99,8 @@ public class VpcVO implements Vpc {
|
|||
uuid = UUID.randomUUID().toString();
|
||||
state = State.Enabled;
|
||||
this.networkDomain = networkDomain;
|
||||
vpcOfferingId = vpcOffId;
|
||||
this.vpcOfferingId = vpcOffId;
|
||||
this.usesDistributedRouter = useDistributedRouter;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -201,5 +206,9 @@ public class VpcVO implements Vpc {
|
|||
@Override
|
||||
public IAMEntityType getEntityType() {
|
||||
return IAMEntityType.Vpc;
|
||||
|
||||
@Override
|
||||
public boolean usesDistributedRouter() {
|
||||
return usesDistributedRouter;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2808,6 +2808,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
response.setRestartRequired(vpc.isRestartRequired());
|
||||
response.setNetworkDomain(vpc.getNetworkDomain());
|
||||
response.setForDisplay(vpc.isDisplay());
|
||||
response.setUsesDistributedRouter(vpc.usesDistributedRouter());
|
||||
|
||||
Map<Service, Set<Provider>> serviceProviderMap = ApiDBUtils.listVpcOffServices(vpc.getVpcOfferingId());
|
||||
List<ServiceResponse> serviceResponses = new ArrayList<ServiceResponse>();
|
||||
|
|
|
|||
|
|
@ -728,13 +728,13 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
|||
networkDomain = "cs" + Long.toHexString(owner.getId()) + NetworkOrchestrationService.GuestDomainSuffix.valueIn(zoneId);
|
||||
}
|
||||
}
|
||||
|
||||
return createVpc(zoneId, vpcOffId, owner, vpcName, displayText, cidr, networkDomain, displayVpc);
|
||||
boolean useDistributedRouter = vpcOff.supportsDistributedRouter();
|
||||
return createVpc(zoneId, vpcOffId, owner, vpcName, displayText, cidr, networkDomain, displayVpc, useDistributedRouter);
|
||||
}
|
||||
|
||||
@DB
|
||||
protected Vpc createVpc(final long zoneId, final long vpcOffId, final Account vpcOwner, final String vpcName, final String displayText, final String cidr,
|
||||
final String networkDomain, final Boolean displayVpc) {
|
||||
final String networkDomain, final Boolean displayVpc, final boolean useDistributedRouter) {
|
||||
|
||||
//Validate CIDR
|
||||
if (!NetUtils.isValidCIDR(cidr)) {
|
||||
|
|
@ -756,7 +756,8 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
|||
return Transaction.execute(new TransactionCallback<VpcVO>() {
|
||||
@Override
|
||||
public VpcVO doInTransaction(TransactionStatus status) {
|
||||
VpcVO vpc = new VpcVO(zoneId, vpcName, displayText, vpcOwner.getId(), vpcOwner.getDomainId(), vpcOffId, cidr, networkDomain);
|
||||
VpcVO vpc = new VpcVO(zoneId, vpcName, displayText, vpcOwner.getId(), vpcOwner.getDomainId(), vpcOffId,
|
||||
cidr, networkDomain, useDistributedRouter);
|
||||
if (displayVpc != null) {
|
||||
vpc.setDisplay(displayVpc);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public class VpcApiUnitTest extends TestCase {
|
|||
public void validateNtwkOffForVpc() {
|
||||
//validate network offering
|
||||
//1) correct network offering
|
||||
VpcVO vo = new VpcVO(1, "new vpc", "new vpc", 1, 1, 1, "0.0.0.0/0", "vpc domain");
|
||||
VpcVO vo = new VpcVO(1, "new vpc", "new vpc", 1, 1, 1, "0.0.0.0/0", "vpc domain", false);
|
||||
boolean result = false;
|
||||
try {
|
||||
_vpcService.validateNtwkOffForNtwkInVpc(2L, 1, "0.0.0.0", "111-", vo, "10.1.1.1", new AccountVO(), null);
|
||||
|
|
|
|||
|
|
@ -98,9 +98,9 @@ public class MockVpcDaoImpl extends GenericDaoBase<VpcVO, Long> implements VpcDa
|
|||
public VpcVO findById(Long id) {
|
||||
VpcVO vo = null;
|
||||
if (id.longValue() == 1) {
|
||||
vo = new VpcVO(1, "new vpc", "new vpc", 1, 1, 1, "0.0.0.0/0", "vpc domain");
|
||||
vo = new VpcVO(1, "new vpc", "new vpc", 1, 1, 1, "0.0.0.0/0", "vpc domain", false);
|
||||
} else if (id.longValue() == 2) {
|
||||
vo = new VpcVO(1, "new vpc", "new vpc", 1, 1, 1, "0.0.0.0/0", "vpc domain");
|
||||
vo = new VpcVO(1, "new vpc", "new vpc", 1, 1, 1, "0.0.0.0/0", "vpc domain", false);
|
||||
vo.setState(State.Inactive);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -741,3 +741,4 @@ ALTER TABLE `cloud`.`guest_os` ADD COLUMN `removed` datetime COMMENT 'Time when
|
|||
UPDATE `cloud`.`guest_os` SET `created` = now();
|
||||
ALTER TABLE `cloud`.`vm_reservation` ADD COLUMN `deployment_planner` varchar(40) DEFAULT NULL COMMENT 'Preferred deployment planner for the vm';
|
||||
ALTER TABLE `cloud`.`vpc_offerings` ADD COLUMN supports_distributed_router boolean default false;
|
||||
ALTER TABLE `cloud`.`vpc` ADD COLUMN uses_distributed_router boolean default false;
|
||||
|
|
|
|||
Loading…
Reference in New Issue