Search in sources :

Example 16 with Network

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;
}
Also used : Zone(com.cloud.db.model.Zone) Network(com.cloud.legacymodel.network.Network) NetworkTopology(com.cloud.network.topology.NetworkTopology) NicProfile(com.cloud.vm.NicProfile) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 17 with Network

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;
}
Also used : Network(com.cloud.legacymodel.network.Network) Service(com.cloud.legacymodel.network.Network.Service)

Example 18 with Network

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());
}
Also used : Network(com.cloud.legacymodel.network.Network)

Example 19 with Network

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());
    }
}
Also used : NetworkOffering(com.cloud.offering.NetworkOffering) Network(com.cloud.legacymodel.network.Network) VMInstanceVO(com.cloud.vm.VMInstanceVO) Nic(com.cloud.legacymodel.network.Nic)

Example 20 with Network

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);
}
Also used : InvalidParameterValueException(com.cloud.legacymodel.exceptions.InvalidParameterValueException) Network(com.cloud.legacymodel.network.Network) ArrayList(java.util.ArrayList) Service(com.cloud.legacymodel.network.Network.Service) UserDataServiceProvider(com.cloud.network.element.UserDataServiceProvider) Provider(com.cloud.legacymodel.network.Network.Provider) HashSet(java.util.HashSet)

Aggregations

Network (com.cloud.legacymodel.network.Network)160 ArrayList (java.util.ArrayList)57 InvalidParameterValueException (com.cloud.legacymodel.exceptions.InvalidParameterValueException)56 Account (com.cloud.legacymodel.user.Account)46 CloudRuntimeException (com.cloud.legacymodel.exceptions.CloudRuntimeException)42 NetworkOffering (com.cloud.offering.NetworkOffering)36 PhysicalNetwork (com.cloud.network.PhysicalNetwork)34 IPAddressVO (com.cloud.network.dao.IPAddressVO)32 ResourceUnavailableException (com.cloud.legacymodel.exceptions.ResourceUnavailableException)30 NetworkVO (com.cloud.network.dao.NetworkVO)28 List (java.util.List)28 Zone (com.cloud.db.model.Zone)27 DB (com.cloud.utils.db.DB)27 NicProfile (com.cloud.vm.NicProfile)26 Nic (com.cloud.legacymodel.network.Nic)21 DataCenter (com.cloud.legacymodel.dc.DataCenter)20 ConcurrentOperationException (com.cloud.legacymodel.exceptions.ConcurrentOperationException)20 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)19 DomainRouterVO (com.cloud.vm.DomainRouterVO)18 ActionEvent (com.cloud.event.ActionEvent)17