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