use of com.cloud.dc.DataCenterVO in project cloudstack by apache.
the class ControlNetworkGuru method release.
@Override
public boolean release(NicProfile nic, VirtualMachineProfile vm, String reservationId) {
assert nic.getTrafficType() == TrafficType.Control;
HypervisorType hType = vm.getHypervisorType();
if (((hType == HypervisorType.VMware) || (hType == HypervisorType.Hyperv)) && isRouterVm(vm)) {
long dcId = vm.getVirtualMachine().getDataCenterId();
DataCenterVO dcVo = _dcDao.findById(dcId);
if (dcVo.getNetworkType() != NetworkType.Basic) {
super.release(nic, vm, reservationId);
if (s_logger.isDebugEnabled()) {
s_logger.debug("Released nic: " + nic);
}
return true;
} else {
nic.deallocate();
if (s_logger.isDebugEnabled()) {
s_logger.debug("Released nic: " + nic);
}
return true;
}
}
_dcDao.releaseLinkLocalIpAddress(nic.getId(), reservationId);
nic.deallocate();
if (s_logger.isDebugEnabled()) {
s_logger.debug("Released nic: " + nic);
}
return true;
}
use of com.cloud.dc.DataCenterVO in project cloudstack by apache.
the class VirtualRouterElement 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 = getRouters(network);
if (routers == null || routers.isEmpty()) {
s_logger.debug("Virtual router elemnt doesn't need to apply lb 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);
}
}
return result;
}
use of com.cloud.dc.DataCenterVO in project cloudstack by apache.
the class VirtualRouterElement method applyPFRules.
@Override
public boolean applyPFRules(final Network network, final List<PortForwardingRule> rules) throws ResourceUnavailableException {
boolean result = true;
if (canHandle(network, Service.PortForwarding)) {
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.applyFirewallRules(network, rules, domainRouterVO);
}
}
return result;
}
use of com.cloud.dc.DataCenterVO in project cloudstack by apache.
the class VpcVirtualRouterElement method createPrivateGateway.
@Override
public boolean createPrivateGateway(final PrivateGateway gateway) throws ConcurrentOperationException, ResourceUnavailableException {
if (gateway.getType() != VpcGateway.Type.Private) {
s_logger.warn("Type of vpc gateway is not " + VpcGateway.Type.Private);
return true;
}
final List<DomainRouterVO> routers = _vpcRouterMgr.getVpcRouters(gateway.getVpcId());
if (routers == null || routers.isEmpty()) {
s_logger.debug(getName() + " element doesn't need to create Private gateway on the backend; VPC virtual " + "router doesn't exist in the vpc id=" + gateway.getVpcId());
return true;
}
s_logger.info("Adding VPC routers to Guest Network: " + routers.size() + " to be added!");
final DataCenterVO dcVO = _dcDao.findById(gateway.getZoneId());
final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(dcVO);
boolean result = true;
final Network network = _networkDao.findById(gateway.getNetworkId());
final boolean isPrivateGateway = true;
for (final DomainRouterVO domainRouterVO : routers) {
if (networkTopology.setupPrivateGateway(gateway, domainRouterVO)) {
try {
final List<NetworkACLItemVO> rules = _networkACLItemDao.listByACL(gateway.getNetworkACLId());
result = result && networkTopology.applyNetworkACLs(network, rules, domainRouterVO, isPrivateGateway);
} catch (final Exception ex) {
s_logger.debug("Failed to apply network acl id " + gateway.getNetworkACLId() + " on gateway ");
return false;
}
}
}
return result;
}
use of com.cloud.dc.DataCenterVO in project cloudstack by apache.
the class VpcVirtualRouterElement method applyStaticRoutes.
@Override
public boolean applyStaticRoutes(final Vpc vpc, final List<StaticRouteProfile> routes) throws ResourceUnavailableException {
final List<DomainRouterVO> routers = _routerDao.listByVpcId(vpc.getId());
if (routers == null || routers.isEmpty()) {
s_logger.debug("Virtual router elemnt doesn't need to static routes on the backend; virtual " + "router doesn't exist in the vpc " + vpc);
return true;
}
final DataCenterVO dcVO = _dcDao.findById(vpc.getZoneId());
final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(dcVO);
if (!networkTopology.applyStaticRoutes(routes, routers)) {
throw new CloudRuntimeException("Failed to apply static routes in vpc " + vpc);
} else {
s_logger.debug("Applied static routes on vpc " + vpc);
return true;
}
}
Aggregations