use of com.cloud.legacymodel.network.Network in project cosmic by MissionCriticalCloud.
the class VpcVirtualRouterElement method applyACLItemsToPrivateGw.
@Override
public boolean applyACLItemsToPrivateGw(final PrivateGateway gateway, final List<? extends NetworkACLItem> rules) throws ResourceUnavailableException {
final Network network = _networkDao.findById(gateway.getNetworkId());
final boolean isPrivateGateway = true;
final List<DomainRouterVO> routers = _vpcRouterMgr.getVpcRouters(gateway.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 in the network " + network.getId());
return true;
}
final Zone zone = zoneRepository.findById(network.getDataCenterId()).orElse(null);
final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(zone);
final Network privateNetwork = _networkModel.getNetwork(gateway.getNetworkId());
boolean result = true;
for (final DomainRouterVO domainRouterVO : routers) {
final NicProfile nicProfile = _networkModel.getNicProfile(domainRouterVO, privateNetwork.getId(), null);
if (nicProfile != null) {
result = result && networkTopology.applyNetworkACLs(network, rules, domainRouterVO, isPrivateGateway);
} else {
s_logger.warn("Nic Profile for router '" + domainRouterVO + "' has already been removed. Router is redundant = " + domainRouterVO.getIsRedundantRouter());
}
}
return result;
}
use of com.cloud.legacymodel.network.Network in project cosmic by MissionCriticalCloud.
the class NetworkModelImpl method isSharedNetworkWithoutServices.
@Override
public boolean isSharedNetworkWithoutServices(final long networkId) {
final Network network = _networksDao.findById(networkId);
if (network != null && network.getGuestType() != GuestType.Shared) {
return false;
}
final List<Service> services = listNetworkOfferingServices(network.getNetworkOfferingId());
if (services == null || services.isEmpty()) {
return true;
}
return false;
}
use of com.cloud.legacymodel.network.Network in project cosmic by MissionCriticalCloud.
the class NetworkModelImpl method isPrivateGateway.
@Override
public boolean isPrivateGateway(final long ntwkId) {
final Network network = getNetwork(ntwkId);
s_logger.debug("Network [" + network.getName() + "] is of type [" + network.getGuestType() + "].");
return GuestType.Private.equals(network.getGuestType());
}
use of com.cloud.legacymodel.network.Network in project cosmic by MissionCriticalCloud.
the class NetworkModelImpl method getNetworkRate.
@Override
public Integer getNetworkRate(final long networkId, final Long vmId) {
VMInstanceVO vm = null;
if (vmId != null) {
vm = _vmDao.findById(vmId);
}
final Network network = getNetwork(networkId);
final NetworkOffering ntwkOff = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
// For default userVm Default network and domR guest/public network, get rate information from the service
// offering; for other situations get information
// from the network offering
boolean isUserVmsDefaultNetwork = false;
boolean isDomRGuestOrPublicNetwork = false;
boolean isSystemVmNetwork = false;
if (vm != null) {
final Nic nic = _nicDao.findByNtwkIdAndInstanceId(networkId, vmId);
if (vm.getType() == VirtualMachineType.User && nic != null && nic.isDefaultNic()) {
isUserVmsDefaultNetwork = true;
} else if (vm.getType() == VirtualMachineType.DomainRouter && ntwkOff != null && (ntwkOff.getTrafficType() == TrafficType.Public || ntwkOff.getTrafficType() == TrafficType.Guest)) {
isDomRGuestOrPublicNetwork = true;
} else if (vm.getType() == VirtualMachineType.ConsoleProxy || vm.getType() == VirtualMachineType.SecondaryStorageVm) {
isSystemVmNetwork = true;
}
}
if (isUserVmsDefaultNetwork || isDomRGuestOrPublicNetwork) {
return _configMgr.getServiceOfferingNetworkRate(vm.getServiceOfferingId(), network.getDataCenterId());
} else if (isSystemVmNetwork) {
return -1;
} else {
return _configMgr.getNetworkOfferingNetworkRate(ntwkOff.getId(), network.getDataCenterId());
}
}
use of com.cloud.legacymodel.network.Network in project cosmic by MissionCriticalCloud.
the class NetworkModelImpl method listSupportedNetworkServiceProviders.
@Override
public List<? extends Provider> listSupportedNetworkServiceProviders(final String serviceName) {
Network.Service service = null;
if (serviceName != null) {
service = Network.Service.getService(serviceName);
if (service == null) {
throw new InvalidParameterValueException("Invalid Network Service=" + serviceName);
}
}
final Set<Provider> supportedProviders = new HashSet<>();
if (service != null) {
final List<Provider> providers = s_serviceToImplementedProvidersMap.get(service);
if (providers != null && !providers.isEmpty()) {
supportedProviders.addAll(providers);
}
} else {
for (final List<Provider> pList : s_serviceToImplementedProvidersMap.values()) {
supportedProviders.addAll(pList);
}
}
return new ArrayList<>(supportedProviders);
}
Aggregations