Search in sources :

Example 1 with RouterDeploymentDefinition

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

the class VpcVirtualRouterElement method getRouters.

@Override
protected List<DomainRouterVO> getRouters(final Network network, final DeployDestination dest) {
    // 1st time it runs the domain router of the VM shall be returned
    List<DomainRouterVO> routers = super.getRouters(network, dest);
    if (routers.size() > 0) {
        return routers;
    }
    // For the 2nd time it returns the VPC routers.
    final Long vpcId = network.getVpcId();
    if (vpcId == null) {
        s_logger.error("Network " + network + " is not associated with any VPC");
        return routers;
    }
    final Vpc vpc = _vpcMgr.getActiveVpc(vpcId);
    if (vpc == null) {
        s_logger.warn("Unable to find Enabled VPC by id " + vpcId);
        return routers;
    }
    final RouterDeploymentDefinition routerDeploymentDefinition = routerDeploymentDefinitionBuilder.create().setGuestNetwork(network).setVpc(vpc).setDeployDestination(dest).setAccountOwner(_accountMgr.getAccount(vpc.getAccountId())).build();
    try {
        routers = routerDeploymentDefinition.deployVirtualRouter();
    } catch (final ConcurrentOperationException e) {
        s_logger.error("Error occurred when loading routers from routerDeploymentDefinition.deployVirtualRouter()!", e);
    } catch (final InsufficientCapacityException e) {
        s_logger.error("Error occurred when loading routers from routerDeploymentDefinition.deployVirtualRouter()!", e);
    } catch (final ResourceUnavailableException e) {
        s_logger.error("Error occurred when loading routers from routerDeploymentDefinition.deployVirtualRouter()!", e);
    }
    return routers;
}
Also used : RouterDeploymentDefinition(com.cloud.network.router.deployment.RouterDeploymentDefinition) Vpc(com.cloud.network.vpc.Vpc) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 2 with RouterDeploymentDefinition

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

the class VirtualRouterElement method implement.

@Override
public boolean implement(final Network network, final NetworkOffering offering, final DeployDestination dest, final ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException {
    if (offering.isSystemOnly()) {
        return false;
    }
    final Map<VirtualMachineProfile.Param, Object> params = new HashMap<>(1);
    params.put(VirtualMachineProfile.Param.ReProgramGuestNetworks, true);
    final RouterDeploymentDefinition routerDeploymentDefinition = routerDeploymentDefinitionBuilder.create().setGuestNetwork(network).setDeployDestination(dest).setAccountOwner(_accountMgr.getAccount(network.getAccountId())).setParams(params).build();
    final List<DomainRouterVO> routers = routerDeploymentDefinition.deployVirtualRouter();
    int routerCounts = 1;
    if (offering.getRedundantRouter()) {
        routerCounts = 2;
    }
    if (routers == null || routers.size() < routerCounts) {
        throw new ResourceUnavailableException("Can't find all necessary running routers!", DataCenter.class, network.getDataCenterId());
    }
    return true;
}
Also used : RouterDeploymentDefinition(com.cloud.network.router.deployment.RouterDeploymentDefinition) HashMap(java.util.HashMap) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 3 with RouterDeploymentDefinition

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

the class VirtualRouterElement method prepare.

@Override
public boolean prepare(final Network network, final NicProfile nic, final VirtualMachineProfile vm, final DeployDestination dest, final ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException, IllegalVirtualMachineException {
    if (vm.getType() != VirtualMachine.Type.User) {
        throw new IllegalVirtualMachineException("Illegal VM type informed. Expected USER VM, but got: " + vm.getType());
    }
    if (!canHandle(network, null)) {
        return false;
    }
    final NetworkOfferingVO offering = _networkOfferingDao.findById(network.getNetworkOfferingId());
    if (offering.isSystemOnly()) {
        return false;
    }
    if (!_networkMdl.isProviderEnabledInPhysicalNetwork(_networkMdl.getPhysicalNetworkId(network), getProvider().getName())) {
        return false;
    }
    final RouterDeploymentDefinition routerDeploymentDefinition = routerDeploymentDefinitionBuilder.create().setGuestNetwork(network).setDeployDestination(dest).setAccountOwner(_accountMgr.getAccount(network.getAccountId())).setParams(vm.getParameters()).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());
    }
    return true;
}
Also used : RouterDeploymentDefinition(com.cloud.network.router.deployment.RouterDeploymentDefinition) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) IllegalVirtualMachineException(com.cloud.exception.IllegalVirtualMachineException) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 4 with RouterDeploymentDefinition

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

the class VpcVirtualRouterElement method implementVpc.

@Override
public boolean implementVpc(final Vpc vpc, final DeployDestination dest, final ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
    final Map<VirtualMachineProfile.Param, Object> params = new HashMap<>(1);
    params.put(VirtualMachineProfile.Param.ReProgramGuestNetworks, true);
    final RouterDeploymentDefinition routerDeploymentDefinition = routerDeploymentDefinitionBuilder.create().setVpc(vpc).setDeployDestination(dest).setAccountOwner(_accountMgr.getAccount(vpc.getAccountId())).setParams(params).build();
    routerDeploymentDefinition.deployVirtualRouter();
    return true;
}
Also used : RouterDeploymentDefinition(com.cloud.network.router.deployment.RouterDeploymentDefinition) HashMap(java.util.HashMap)

Example 5 with RouterDeploymentDefinition

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

the class VpcVirtualRouterElement method prepare.

@Override
public boolean prepare(final Network network, final NicProfile nic, final VirtualMachineProfile vm, final DeployDestination dest, final ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException, IllegalVirtualMachineException {
    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;
    }
    if (vm.getType() == VirtualMachine.Type.User) {
        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