use of org.apache.cloudstack.network.topology.NetworkTopology in project cloudstack by apache.
the class VirtualNetworkApplianceManagerImpl method finalizeStop.
@Override
public void finalizeStop(final VirtualMachineProfile profile, final Answer answer) {
if (answer != null) {
final VirtualMachine vm = profile.getVirtualMachine();
final DomainRouterVO domR = _routerDao.findById(vm.getId());
processStopOrRebootAnswer(domR, answer);
final List<? extends Nic> routerNics = _nicDao.listByVmId(profile.getId());
for (final Nic nic : routerNics) {
final Network network = _networkModel.getNetwork(nic.getNetworkId());
final DataCenterVO dcVO = _dcDao.findById(network.getDataCenterId());
if (network.getTrafficType() == TrafficType.Guest && nic.getBroadcastUri() != null && nic.getBroadcastUri().getScheme().equals("pvlan")) {
final NicProfile nicProfile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), 0, false, "pvlan-nic");
final NetworkTopology networkTopology = _networkTopologyContext.retrieveNetworkTopology(dcVO);
try {
networkTopology.setupDhcpForPvlan(false, domR, domR.getHostId(), nicProfile);
} catch (final ResourceUnavailableException e) {
s_logger.debug("ERROR in finalizeStop: ", e);
}
}
}
}
}
use of org.apache.cloudstack.network.topology.NetworkTopology in project cloudstack by apache.
the class OvsElement method applyLBRules.
@Override
public boolean applyLBRules(final Network network, final List<LoadBalancingRule> rules) throws ResourceUnavailableException {
boolean result = true;
if (canHandle(network, Service.Lb)) {
if (!canHandleLbRules(rules)) {
return false;
}
final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
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;
}
final DataCenterVO dcVO = _dcDao.findById(network.getDataCenterId());
final NetworkTopology networkTopology = _networkTopologyContext.retrieveNetworkTopology(dcVO);
for (final DomainRouterVO domainRouterVO : routers) {
result = result && networkTopology.applyLoadBalancingRules(network, rules, domainRouterVO);
if (!result) {
s_logger.debug("Failed to apply load balancing rules in network " + network.getId());
}
}
}
return result;
}
use of org.apache.cloudstack.network.topology.NetworkTopology 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 org.apache.cloudstack.network.topology.NetworkTopology in project cloudstack by apache.
the class VirtualRouterElement 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 = getRouters(network);
if (routers == null || routers.isEmpty()) {
s_logger.debug("Virtual router elemnt doesn't need to associate ip addresses 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.associatePublicIP(network, ipAddress, domainRouterVO);
}
}
return result;
}
use of org.apache.cloudstack.network.topology.NetworkTopology in project cloudstack by apache.
the class VirtualRouterElement method applyVpnUsers.
@Override
public String[] applyVpnUsers(final RemoteAccessVpn vpn, final List<? extends VpnUser> users) throws ResourceUnavailableException {
if (vpn.getNetworkId() == null) {
return null;
}
final Network network = _networksDao.findById(vpn.getNetworkId());
if (canHandle(network, Service.Vpn)) {
final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
if (routers == null || routers.isEmpty()) {
s_logger.debug("Virtual router elemnt doesn't need to apply vpn users on the backend; virtual router" + " doesn't exist in the network " + network.getId());
return null;
}
final DataCenterVO dcVO = _dcDao.findById(network.getDataCenterId());
final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(dcVO);
return networkTopology.applyVpnUsers(network, users, routers);
} else {
s_logger.debug("Element " + getName() + " doesn't handle applyVpnUsers command");
return null;
}
}
Aggregations