use of com.cloud.network.topology.NetworkTopology in project cosmic by MissionCriticalCloud.
the class VpcVirtualRouterElement method applyVpnUsers.
@Override
public String[] applyVpnUsers(final RemoteAccessVpn vpn, final List<? extends VpnUser> users) throws ResourceUnavailableException {
final Long vpcId = vpn.getVpcId();
if (vpcId == null) {
return null;
}
final List<DomainRouterVO> routers = _vpcRouterMgr.getVpcRouters(vpcId);
if (routers == null) {
s_logger.debug("Cannot apply vpn users on the backend; virtual router doesn't exist in the network " + vpcId);
return null;
}
final Vpc vpc = _entityMgr.findById(Vpc.class, vpcId);
final Zone zone = zoneRepository.findOne(vpc.getZoneId());
final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(zone);
String[] result;
final List<String> combinedResults = new ArrayList<>();
for (final DomainRouterVO domainRouterVO : routers) {
result = networkTopology.applyVpnUsers(vpn, users, domainRouterVO);
combinedResults.addAll(Arrays.asList(result));
}
result = new String[combinedResults.size()];
final Object[] resultCast = combinedResults.toArray();
System.arraycopy(resultCast, 0, result, 0, resultCast.length);
return result;
}
use of com.cloud.network.topology.NetworkTopology in project cosmic by MissionCriticalCloud.
the class VpcVirtualRouterElement method applyIps.
@Override
public boolean applyIps(final Network network, final List<? extends PublicIpAddress> ipAddress, final Set<Service> services) throws ResourceUnavailableException {
boolean canHandle = true;
for (final Service service : services) {
if (!canHandle(network, service)) {
canHandle = false;
break;
}
}
boolean result = true;
if (canHandle) {
final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
if (routers == null || routers.isEmpty()) {
s_logger.debug(getName() + " element doesn't need to associate ip addresses on the backend; VPC virtual router doesn't exist in the network " + network.getId());
return false;
}
final Zone zone = zoneRepository.findOne(network.getDataCenterId());
final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(zone);
for (final DomainRouterVO domainRouterVO : routers) {
result = result && networkTopology.associatePublicIP(network, ipAddress, domainRouterVO);
}
}
return result;
}
use of com.cloud.network.topology.NetworkTopology in project cosmic by MissionCriticalCloud.
the class VpcVirtualRouterElement method applyACLItemsToPublicIp.
@Override
public boolean applyACLItemsToPublicIp(final IpAddress publicIp, final List<? extends NetworkACLItem> rules) throws ResourceUnavailableException {
final List<DomainRouterVO> routers = _vpcRouterMgr.getVpcRouters(publicIp.getVpcId());
if (routers == null || routers.isEmpty()) {
s_logger.debug("Virtual router element doesn't need to apply network acl rules on the backend; virtual router doesn't exist for the public ip " + publicIp.getId());
return true;
}
final Zone zone = zoneRepository.findOne(publicIp.getDataCenterId());
final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(zone);
final Network publicNetwork = _networkModel.getNetwork(publicIp.getNetworkId());
boolean result = true;
for (final DomainRouterVO domainRouterVO : routers) {
final NicProfile nicProfile = _networkModel.getNicProfile(domainRouterVO, publicNetwork.getId(), null);
if (nicProfile != null) {
result = result && networkTopology.applyPublicIpACLs(publicNetwork, publicIp, rules, domainRouterVO);
} else {
s_logger.warn("Nic Profile for router '" + domainRouterVO + "' has already been removed. Router is redundant = " + domainRouterVO.getIsRedundantRouter());
}
}
return result;
}
Aggregations