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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations