Search in sources :

Example 6 with RouterDeploymentDefinition

use of com.cloud.network.router.deployment.RouterDeploymentDefinition in project cosmic by MissionCriticalCloud.

the class VpcVirtualRouterElement method implement.

@Override
public boolean implement(final Network network, final NetworkOffering offering, final DeployDestination dest, final ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException {
    final Long vpcId = network.getVpcId();
    if (vpcId == null) {
        s_logger.trace("Network " + network + " is not associated with any VPC");
        return false;
    }
    final Vpc vpc = _vpcMgr.getActiveVpc(vpcId);
    if (vpc == null) {
        s_logger.warn("Unable to find Enabled VPC by id " + vpcId);
        return false;
    }
    final Map<VirtualMachineProfile.Param, Object> params = new HashMap<>(1);
    params.put(VirtualMachineProfile.Param.ReProgramGuestNetworks, true);
    final RouterDeploymentDefinition routerDeploymentDefinition = routerDeploymentDefinitionBuilder.create().setGuestNetwork(network).setVpc(vpc).setDeployDestination(dest).setAccountOwner(_accountMgr.getAccount(vpc.getAccountId())).setParams(params).build();
    final List<DomainRouterVO> routers = routerDeploymentDefinition.deployVirtualRouter();
    if (routers == null || routers.size() == 0) {
        throw new ResourceUnavailableException("Can't find at least one running router!", DataCenter.class, network.getDataCenterId());
    }
    configureGuestNetwork(network, routers);
    return true;
}
Also used : RouterDeploymentDefinition(com.cloud.network.router.deployment.RouterDeploymentDefinition) HashMap(java.util.HashMap) Vpc(com.cloud.network.vpc.Vpc) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Aggregations

RouterDeploymentDefinition (com.cloud.network.router.deployment.RouterDeploymentDefinition)6 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)5 DomainRouterVO (com.cloud.vm.DomainRouterVO)5 HashMap (java.util.HashMap)4 Vpc (com.cloud.network.vpc.Vpc)3 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)1 IllegalVirtualMachineException (com.cloud.exception.IllegalVirtualMachineException)1 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)1 NetworkOfferingVO (com.cloud.offerings.NetworkOfferingVO)1