use of com.cloud.vm.DomainRouterVO in project cloudstack by apache.
the class BasicNetworkTopology method configDhcpForSubnet.
@Override
public boolean configDhcpForSubnet(final Network network, final NicProfile nic, final VirtualMachineProfile profile, final DeployDestination dest, final List<DomainRouterVO> routers) throws ResourceUnavailableException {
s_logger.debug("CONFIG DHCP FOR SUBNETS RULES");
// Assuming we have only one router per network For Now.
final DomainRouterVO router = routers.get(0);
if (router.getState() != State.Running) {
s_logger.warn("Failed to configure dhcp: router not in running state");
throw new ResourceUnavailableException("Unable to assign ip addresses, domR is not in right state " + router.getState(), DataCenter.class, network.getDataCenterId());
}
final DhcpSubNetRules subNetRules = new DhcpSubNetRules(network, nic, profile);
return subNetRules.accept(_basicVisitor, router);
}
use of com.cloud.vm.DomainRouterVO in project cloudstack by apache.
the class OvsNetworkTopologyGuruImpl method getActiveVmsInNetworkOnHost.
/**
* get the list of all Vm id's in the network that are running on the host
*/
@Override
public List<Long> getActiveVmsInNetworkOnHost(long networkId, long hostId, boolean includeVr) {
List<Long> vmIds = new ArrayList<>();
List<UserVmVO> vms = _userVmDao.listByNetworkIdAndStates(networkId, VirtualMachine.State.Running, VirtualMachine.State.Migrating);
// Find routers for the network
List<DomainRouterVO> routers = _routerDao.findByNetwork(networkId);
if (vms != null) {
for (UserVmVO vm : vms) {
if (vm.getHostId() == hostId)
vmIds.add(vm.getId());
}
}
if (routers.size() != 0 && includeVr) {
for (DomainRouterVO router : routers) {
if (router.getHostId() == hostId)
vmIds.add(router.getId());
}
}
return vmIds;
}
use of com.cloud.vm.DomainRouterVO in project cloudstack by apache.
the class OvsNetworkTopologyGuruImpl method getAllActiveVmsInNetwork.
/**
* get the list of all active Vm id's in a network
*/
@Override
public List<Long> getAllActiveVmsInNetwork(long networkId) {
List<Long> vmIds = new ArrayList<>();
List<UserVmVO> vms = _userVmDao.listByNetworkIdAndStates(networkId, VirtualMachine.State.Running, VirtualMachine.State.Starting, VirtualMachine.State.Stopping, VirtualMachine.State.Unknown, VirtualMachine.State.Migrating);
// Find routers for the network
List<DomainRouterVO> routers = _routerDao.findByNetwork(networkId);
if (vms != null) {
for (UserVmVO vm : vms) {
vmIds.add(vm.getId());
}
}
if (routers.size() != 0) {
for (DomainRouterVO router : routers) {
vmIds.add(router.getId());
}
}
return vmIds;
}
use of com.cloud.vm.DomainRouterVO in project cloudstack by apache.
the class OvsElement method applyStaticNats.
@Override
public boolean applyStaticNats(final Network network, final List<? extends StaticNat> rules) throws ResourceUnavailableException {
if (!canHandle(network, Service.StaticNat)) {
return false;
}
final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
if (routers == null || routers.isEmpty()) {
s_logger.debug("Ovs element doesn't need to apply static nat on the backend; virtual " + "router doesn't exist in the network " + network.getId());
return true;
}
final DataCenterVO dcVO = _dcDao.findById(network.getDataCenterId());
final NetworkTopology networkTopology = _networkTopologyContext.retrieveNetworkTopology(dcVO);
boolean result = true;
for (final DomainRouterVO domainRouterVO : routers) {
result = result && networkTopology.applyStaticNats(network, rules, domainRouterVO);
}
return result;
}
use of com.cloud.vm.DomainRouterVO in project cloudstack by apache.
the class OvsNetworkTopologyGuruImpl method getNetworkSpanedHosts.
/**
* get the list of hypervisor hosts on which VM's belonging to a network currently spans
*/
public List<Long> getNetworkSpanedHosts(long networkId) {
List<Long> hostIds = new ArrayList<Long>();
// Find active VMs with a NIC on the target network
List<UserVmVO> vms = _userVmDao.listByNetworkIdAndStates(networkId, VirtualMachine.State.Running, VirtualMachine.State.Starting, VirtualMachine.State.Stopping, VirtualMachine.State.Unknown, VirtualMachine.State.Migrating);
// Find routers for the network
List<DomainRouterVO> routers = _routerDao.findByNetwork(networkId);
List<VMInstanceVO> ins = new ArrayList<VMInstanceVO>();
if (vms != null) {
ins.addAll(vms);
}
if (routers.size() != 0) {
ins.addAll(routers);
}
for (VMInstanceVO v : ins) {
Long rh = v.getHostId();
if (rh == null) {
continue;
}
if (!hostIds.contains(rh)) {
hostIds.add(rh);
}
}
return hostIds;
}
Aggregations