Search in sources :

Example 91 with Network

use of com.cloud.network.Network in project cloudstack by apache.

the class CreateNetworkOfferingTest method createIsolatedNtwkOffWithVlan.

@Test
public void createIsolatedNtwkOffWithVlan() {
    Map<Service, Set<Provider>> serviceProviderMap = new HashMap<Network.Service, Set<Network.Provider>>();
    Set<Network.Provider> vrProvider = new HashSet<Network.Provider>();
    vrProvider.add(Provider.VirtualRouter);
    serviceProviderMap.put(Network.Service.SourceNat, vrProvider);
    NetworkOfferingVO off = configMgr.createNetworkOffering("isolated", "isolated", TrafficType.Guest, null, true, Availability.Optional, 200, serviceProviderMap, false, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true);
    assertNotNull("Isolated network offering with specifyVlan=true wasn't created", off);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) Network(com.cloud.network.Network) Service(com.cloud.network.Network.Service) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) Provider(com.cloud.network.Network.Provider) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 92 with Network

use of com.cloud.network.Network in project cloudstack by apache.

the class OvsNetworkTopologyGuruImpl method getActiveVmsInVpcOnHost.

/**
     * get the list of all Vm id's in the VPC for all the tiers that are running on the host
     */
@Override
public List<Long> getActiveVmsInVpcOnHost(long vpcId, long hostId) {
    Set<Long> vmIdsSet = new HashSet<>();
    List<? extends Network> vpcNetworks = _vpcMgr.getVpcNetworks(vpcId);
    for (Network network : vpcNetworks) {
        List<Long> networkVmIds = getActiveVmsInNetworkOnHost(network.getId(), hostId, false);
        if (networkVmIds != null && !networkVmIds.isEmpty()) {
            vmIdsSet.addAll(networkVmIds);
        }
    }
    List<Long> vmIds = new ArrayList<>();
    vmIds.addAll(vmIdsSet);
    return vmIds;
}
Also used : Network(com.cloud.network.Network) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Example 93 with Network

use of com.cloud.network.Network in project cloudstack by apache.

the class OvsNetworkTopologyGuruImpl method getAllActiveVmsInVpc.

/**
     * get the list of all active Vm id's in the VPC for all ther tiers
     */
@Override
public List<Long> getAllActiveVmsInVpc(long vpcId) {
    Set<Long> vmIdsSet = new HashSet<>();
    List<? extends Network> vpcNetworks = _vpcMgr.getVpcNetworks(vpcId);
    for (Network network : vpcNetworks) {
        List<Long> networkVmIds = getAllActiveVmsInNetwork(network.getId());
        if (networkVmIds != null && !networkVmIds.isEmpty()) {
            vmIdsSet.addAll(networkVmIds);
        }
    }
    List<Long> vmIds = new ArrayList<>();
    vmIds.addAll(vmIdsSet);
    return vmIds;
}
Also used : Network(com.cloud.network.Network) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Example 94 with Network

use of com.cloud.network.Network in project cloudstack by apache.

the class OvsNetworkTopologyGuruImpl method getVpcOnHost.

/**
     * get the list of VPC id's of the vpc's for which one or more VM's from the VPC are running on the host
     */
@Override
public List<Long> getVpcOnHost(long hostId) {
    List<Long> vpcIds = new ArrayList<>();
    List<VMInstanceVO> vmInstances = _vmInstanceDao.listByHostId(hostId);
    for (VMInstanceVO instance : vmInstances) {
        List<NicVO> nics = _nicDao.listByVmId(instance.getId());
        for (Nic nic : nics) {
            Network network = _networkDao.findById(nic.getNetworkId());
            if (network.getTrafficType() == Networks.TrafficType.Guest && network.getVpcId() != null) {
                if (!vpcIds.contains(network.getVpcId())) {
                    vpcIds.add(network.getVpcId());
                }
            }
        }
    }
    return vpcIds;
}
Also used : Network(com.cloud.network.Network) ArrayList(java.util.ArrayList) VMInstanceVO(com.cloud.vm.VMInstanceVO) Nic(com.cloud.vm.Nic) NicVO(com.cloud.vm.NicVO)

Example 95 with Network

use of com.cloud.network.Network in project cloudstack by apache.

the class OvsNetworkTopologyGuruImpl method getVpcSpannedHosts.

/**
     * get the list of hypervisor hosts on which VM's belonging to a VPC currently spans
     */
@Override
public List<Long> getVpcSpannedHosts(long vpcId) {
    List<? extends Network> vpcNetworks = _vpcMgr.getVpcNetworks(vpcId);
    List<Long> vpcHostIds = new ArrayList<>();
    for (Network vpcNetwork : vpcNetworks) {
        List<Long> networkHostIds = getNetworkSpanedHosts(vpcNetwork.getId());
        if (networkHostIds != null && !networkHostIds.isEmpty()) {
            for (Long hostId : networkHostIds) {
                if (!vpcHostIds.contains(hostId)) {
                    vpcHostIds.add(hostId);
                }
            }
        }
    }
    return vpcHostIds;
}
Also used : Network(com.cloud.network.Network) ArrayList(java.util.ArrayList)

Aggregations

Network (com.cloud.network.Network)235 ArrayList (java.util.ArrayList)86 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)63 Account (com.cloud.user.Account)60 Test (org.junit.Test)55 NetworkOffering (com.cloud.offering.NetworkOffering)52 PhysicalNetwork (com.cloud.network.PhysicalNetwork)50 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)50 NetworkVO (com.cloud.network.dao.NetworkVO)38 DataCenter (com.cloud.dc.DataCenter)34 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)31 NicProfile (com.cloud.vm.NicProfile)31 HostVO (com.cloud.host.HostVO)27 DB (com.cloud.utils.db.DB)27 List (java.util.List)27 DataCenterVO (com.cloud.dc.DataCenterVO)26 IPAddressVO (com.cloud.network.dao.IPAddressVO)25 HashMap (java.util.HashMap)24 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)23 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)20