use of org.apache.cloudstack.network.topology.NetworkTopology in project cloudstack by apache.
the class VirtualRouterElement method configureDhcpSupport.
protected boolean configureDhcpSupport(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, Service service) throws ResourceUnavailableException {
if (canHandle(network, service)) {
if (vm.getType() != VirtualMachine.Type.User) {
return false;
}
final VirtualMachineProfile uservm = vm;
final List<DomainRouterVO> routers = getRouters(network, dest);
if (routers == null || routers.size() == 0) {
throw new ResourceUnavailableException("Can't find at least one router!", DataCenter.class, network.getDataCenterId());
}
final DataCenterVO dcVO = _dcDao.findById(network.getDataCenterId());
final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(dcVO);
return networkTopology.configDhcpForSubnet(network, nic, uservm, dest, routers);
}
return false;
}
use of org.apache.cloudstack.network.topology.NetworkTopology in project cloudstack by apache.
the class VirtualRouterElement method applyStaticNats.
@Override
public boolean applyStaticNats(final Network network, final List<? extends StaticNat> rules) throws ResourceUnavailableException {
boolean result = true;
if (canHandle(network, Service.StaticNat)) {
final List<DomainRouterVO> routers = getRouters(network);
if (routers == null || routers.isEmpty()) {
s_logger.debug("Virtual router elemnt 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);
for (final DomainRouterVO domainRouterVO : routers) {
result = result && networkTopology.applyStaticNats(network, rules, domainRouterVO);
}
}
return result;
}
use of org.apache.cloudstack.network.topology.NetworkTopology in project cloudstack by apache.
the class VirtualRouterElement method applyFWRules.
@Override
public boolean applyFWRules(final Network network, final List<? extends FirewallRule> rules) throws ResourceUnavailableException {
boolean result = true;
if (canHandle(network, Service.Firewall)) {
final List<DomainRouterVO> routers = getRouters(network);
if (routers == null || routers.isEmpty()) {
s_logger.debug("Virtual router elemnt doesn't need to apply firewall rules on the backend; virtual " + "router doesn't exist in the network " + network.getId());
return true;
}
if (rules != null && rules.size() == 1) {
//The default allow rule is added from the router defalut iptables rules iptables-router
if (rules.get(0).getTrafficType() == FirewallRule.TrafficType.Egress && rules.get(0).getType() == FirewallRule.FirewallRuleType.System && _networkMdl.getNetworkEgressDefaultPolicy(network.getId())) {
return true;
}
}
final DataCenterVO dcVO = _dcDao.findById(network.getDataCenterId());
final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(dcVO);
for (final DomainRouterVO domainRouterVO : routers) {
result = result && networkTopology.applyFirewallRules(network, rules, domainRouterVO);
}
}
return result;
}
use of org.apache.cloudstack.network.topology.NetworkTopology in project cloudstack by apache.
the class VpcVirtualRouterElement method applyIps.
@Override
public boolean applyIps(final Network network, final List<? extends PublicIpAddress> ipAddress, final Set<Service> services) throws ResourceUnavailableException {
boolean canHandle = true;
for (final Service service : services) {
if (!canHandle(network, service)) {
canHandle = false;
break;
}
}
boolean result = true;
if (canHandle) {
final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
if (routers == null || routers.isEmpty()) {
s_logger.debug(getName() + " element doesn't need to associate ip addresses on the backend; VPC virtual " + "router doesn't exist in the network " + network.getId());
return false;
}
final DataCenterVO dcVO = _dcDao.findById(network.getDataCenterId());
final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(dcVO);
for (final DomainRouterVO domainRouterVO : routers) {
result = result && networkTopology.associatePublicIP(network, ipAddress, domainRouterVO);
}
}
return result;
}
use of org.apache.cloudstack.network.topology.NetworkTopology in project cloudstack by apache.
the class VirtualRouterElement method commitMigration.
@Override
public void commitMigration(final NicProfile nic, final Network network, final VirtualMachineProfile vm, final ReservationContext src, final ReservationContext dst) {
if (nic.getBroadcastType() != Networks.BroadcastDomainType.Pvlan) {
return;
}
if (vm.getType() == VirtualMachine.Type.DomainRouter) {
assert vm instanceof DomainRouterVO;
final DomainRouterVO router = (DomainRouterVO) vm.getVirtualMachine();
final DataCenterVO dcVO = _dcDao.findById(network.getDataCenterId());
final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(dcVO);
try {
networkTopology.setupDhcpForPvlan(true, router, router.getHostId(), nic);
} catch (final ResourceUnavailableException e) {
s_logger.warn("Timed Out", e);
}
} else if (vm.getType() == VirtualMachine.Type.User) {
assert vm instanceof UserVmVO;
final UserVmVO userVm = (UserVmVO) vm.getVirtualMachine();
_userVmMgr.setupVmForPvlan(true, userVm.getHostId(), nic);
}
}
Aggregations