use of com.cloud.network.topology.NetworkTopology in project cosmic by MissionCriticalCloud.
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 Zone zone = zoneRepository.findOne(network.getDataCenterId());
final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(zone);
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);
}
}
use of com.cloud.network.topology.NetworkTopology in project cosmic by MissionCriticalCloud.
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 = _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;
}
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 Zone zone = zoneRepository.findOne(network.getDataCenterId());
final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(zone);
for (final DomainRouterVO domainRouterVO : routers) {
result = result && networkTopology.applyFirewallRules(network, rules, domainRouterVO);
}
}
return result;
}
use of com.cloud.network.topology.NetworkTopology in project cosmic by MissionCriticalCloud.
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 = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
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 Zone zone = zoneRepository.findOne(network.getDataCenterId());
final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(zone);
for (final DomainRouterVO domainRouterVO : routers) {
result = result && networkTopology.applyStaticNats(network, rules, domainRouterVO);
}
}
return result;
}
use of com.cloud.network.topology.NetworkTopology in project cosmic by MissionCriticalCloud.
the class VirtualRouterElement method savePassword.
@Override
public boolean savePassword(final Network network, final NicProfile nic, final VirtualMachineProfile vm) throws ResourceUnavailableException {
if (!canHandle(network, null)) {
return false;
}
final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
if (routers == null || routers.isEmpty()) {
s_logger.debug("Can't find virtual router element in network " + network.getId());
return true;
}
final VirtualMachineProfile uservm = vm;
final Zone zone = zoneRepository.findOne(network.getDataCenterId());
final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(zone);
// save the password in DB
for (final VirtualRouter router : routers) {
if (router.getState() == State.Running) {
return networkTopology.savePasswordToRouter(network, nic, uservm, router);
}
}
final String password = (String) uservm.getParameter(VirtualMachineProfile.Param.VmPassword);
final String password_encrypted = DBEncryptionUtil.encrypt(password);
final UserVmVO userVmVO = _userVmDao.findById(vm.getId());
_userVmDao.loadDetails(userVmVO);
userVmVO.setDetail("password", password_encrypted);
_userVmDao.saveDetails(userVmVO);
userVmVO.setUpdateParameters(true);
_userVmDao.update(userVmVO.getId(), userVmVO);
return true;
}
use of com.cloud.network.topology.NetworkTopology in project cosmic by MissionCriticalCloud.
the class VpcVirtualRouterElement method applyNetworkACLs.
@Override
public boolean applyNetworkACLs(final Network network, final List<? extends NetworkACLItem> rules) throws ResourceUnavailableException {
boolean result = true;
if (canHandle(network, Service.NetworkACL)) {
final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
if (routers == null || routers.isEmpty()) {
s_logger.debug("Virtual router element doesn't need to apply firewall rules on the backend; virtual router doesn't exist in the network " + network.getId());
return true;
}
final Zone zone = zoneRepository.findOne(network.getDataCenterId());
final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(zone);
for (final DomainRouterVO domainRouterVO : routers) {
try {
result = result && networkTopology.applyNetworkACLs(network, rules, domainRouterVO, false);
} catch (final Exception ex) {
s_logger.debug("Failed to apply network acl in network " + network.getId());
}
}
}
return result;
}
Aggregations