@Override public List<DomainRouterVO> findInternalLbVms(final long guestNetworkId, final Ip requestedGuestIp) { final List<DomainRouterVO> internalLbVms = _internalLbVmDao.listByNetworkAndRole(guestNetworkId, Role.INTERNAL_LB_VM); if (requestedGuestIp != null && !internalLbVms.isEmpty()) { final Iterator<DomainRouterVO> it = internalLbVms.iterator(); while (it.hasNext()) { final DomainRouterVO vm = it.next(); final Nic nic = _nicDao.findByNtwkIdAndInstanceId(guestNetworkId, vm.getId()); if (!nic.getIPv4Address().equalsIgnoreCase(requestedGuestIp.addr())) { it.remove(); } } } return internalLbVms; }
protected void configureGuestNetwork(final Network network, final List<DomainRouterVO> routers ) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException { s_logger.info("Adding VPC routers to Guest Network: " + routers.size() + " to be added!"); for (final DomainRouterVO router : routers) { if (!_networkMdl.isVmPartOfNetwork(router.getId(), network.getId())) { final Map<VirtualMachineProfile.Param, Object> paramsForRouter = new HashMap<VirtualMachineProfile.Param, Object>(1); if (network.getState() == State.Setup) { paramsForRouter.put(VirtualMachineProfile.Param.ReProgramGuestNetworks, true); } if (!_vpcRouterMgr.addVpcRouterToGuestNetwork(router, network, paramsForRouter)) { s_logger.error("Failed to add VPC router " + router + " to guest network " + network); } else { s_logger.debug("Successfully added VPC router " + router + " to guest network " + network); } } } }
protected DomainRouterVO start(final DomainRouterVO elbVm, final Map<Param, Object> params) throws ConcurrentOperationException { s_logger.debug("Starting ELB VM " + elbVm); _itMgr.start(elbVm.getUuid(), params); return _routerDao.findById(elbVm.getId()); } }
protected VirtualRouter stopInternalLbVm(DomainRouterVO internalLbVm, boolean forced, Account caller, long callerUserId) throws ResourceUnavailableException, ConcurrentOperationException { s_logger.debug("Stopping internal lb vm " + internalLbVm); try { _itMgr.advanceStop(internalLbVm.getUuid(), forced); return _internalLbVmDao.findById(internalLbVm.getId()); } catch (OperationTimedoutException e) { throw new CloudRuntimeException("Unable to stop " + internalLbVm, e); } }
protected VirtualRouter stopInternalLbVm(final DomainRouterVO internalLbVm, final boolean forced, final Account caller, final long callerUserId) throws ResourceUnavailableException, ConcurrentOperationException { s_logger.debug("Stopping internal lb vm " + internalLbVm); try { _itMgr.advanceStop(internalLbVm.getUuid(), forced); return _internalLbVmDao.findById(internalLbVm.getId()); } catch (final OperationTimedoutException e) { throw new CloudRuntimeException("Unable to stop " + internalLbVm, e); } }
private DomainRouterVO stop(DomainRouterVO elbVm, boolean forced) throws ConcurrentOperationException, ResourceUnavailableException { s_logger.debug("Stopping ELB vm " + elbVm); try { _itMgr.advanceStop(elbVm.getUuid(), forced); return _routerDao.findById(elbVm.getId()); } catch (OperationTimedoutException e) { throw new CloudRuntimeException("Unable to stop " + elbVm, e); } }
@Override public boolean destroyInternalLbVm(final long vmId, final Account caller, final Long callerUserId) throws ResourceUnavailableException, ConcurrentOperationException { if (s_logger.isDebugEnabled()) { s_logger.debug("Attempting to destroy Internal LB vm " + vmId); } final DomainRouterVO internalLbVm = _internalLbVmDao.findById(vmId); if (internalLbVm == null) { return true; } _accountMgr.checkAccess(caller, null, true, internalLbVm); _itMgr.expunge(internalLbVm.getUuid()); _internalLbVmDao.remove(internalLbVm.getId()); return true; }
@Override public VirtualRouter destroyRouter(final long routerId, final Account caller, final Long callerUserId) throws ResourceUnavailableException, ConcurrentOperationException { if (s_logger.isDebugEnabled()) { s_logger.debug("Attempting to destroy router " + routerId); } final DomainRouterVO router = _routerDao.findById(routerId); if (router == null) { return null; } _accountMgr.checkAccess(caller, null, true, router); _itMgr.expunge(router.getUuid()); _routerDao.remove(router.getId()); return router; }
@Override public List<DomainRouterVO> listByStateAndNetworkType(final State state, final Network.GuestType type, final long mgmtSrvrId) { final SearchCriteria<DomainRouterVO> sc = StateNetworkTypeSearch.create(); sc.setParameters("state", state); sc.setJoinParameters("networkRouter", "type", type); sc.setJoinParameters("host", "mgmtServerId", mgmtSrvrId); final List<DomainRouterVO> routerIds = listBy(sc); final List<DomainRouterVO> routers = new ArrayList<DomainRouterVO>(); for (final DomainRouterVO router : routerIds) { routers.add(findById(router.getId())); } return routers; }
protected DomainRouterVO startInternalLbVm(DomainRouterVO internalLbVm, final Account caller, final long callerUserId, final Map<Param, Object> params) throws StorageUnavailableException, InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException { s_logger.debug("Starting Internal LB VM " + internalLbVm); _itMgr.start(internalLbVm.getUuid(), params, null, null); if (internalLbVm.isStopPending()) { s_logger.info("Clear the stop pending flag of Internal LB VM " + internalLbVm.getHostName() + " after start router successfully!"); internalLbVm.setStopPending(false); internalLbVm = _internalLbVmDao.persist(internalLbVm); } return _internalLbVmDao.findById(internalLbVm.getId()); }
@Override public boolean shutdownVpc(final Vpc vpc, final ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException { final List<DomainRouterVO> routers = _routerDao.listByVpcId(vpc.getId()); if (routers == null || routers.isEmpty()) { return true; } boolean result = true; for (final DomainRouterVO router : routers) { result = result && _routerMgr.destroyRouter(router.getId(), context.getAccount(), context.getCaller().getId()) != null; } return result; }
@Override public List<DomainRouterVO> listIsolatedByHostId(final Long hostId) { final SearchCriteria<DomainRouterVO> sc = HostUpSearch.create(); if (hostId != null) { sc.setParameters("host", hostId); } sc.setJoinParameters("networkRouter", "type", Network.GuestType.Isolated); final List<DomainRouterVO> routerIds = listBy(sc); final List<DomainRouterVO> routers = new ArrayList<DomainRouterVO>(); for (final DomainRouterVO router : routerIds) { CollectionUtils.addIgnoreNull(routers, findById(router.getId())); } return routers; }
protected VirtualRouter stopNetScalerVm(final long vmId, final boolean forced, final Account caller, final long callerUserId) throws ResourceUnavailableException, ConcurrentOperationException { final DomainRouterVO netscalerVm = _routerDao.findById(vmId); s_logger.debug("Stopping NetScaler vm " + netscalerVm); if (netscalerVm == null || netscalerVm.getRole() != Role.NETSCALER_VM) { throw new InvalidParameterValueException("Can't find NetScaler vm by id specified"); } _accountMgr.checkAccess(caller, null, true, netscalerVm); try { _itMgr.expunge(netscalerVm.getUuid()); return _routerDao.findById(netscalerVm.getId()); } catch (final Exception e) { throw new CloudRuntimeException("Unable to stop " + netscalerVm, e); } }
@Override public VirtualRouter stopNetScalerVm(Long vmId, boolean forced, Account caller, long callingUserId) { final DomainRouterVO netscalerVm = _routerDao.findById(vmId); s_logger.debug("Stopping NetScaler vm " + netscalerVm); if (netscalerVm == null || netscalerVm.getRole() != Role.NETSCALER_VM) { throw new InvalidParameterValueException("Can't find NetScaler vm by id specified"); } _accountMgr.checkAccess(caller, null, true, netscalerVm); try { _itMgr.expunge(netscalerVm.getUuid()); return _routerDao.findById(netscalerVm.getId()); } catch (final Exception e) { throw new CloudRuntimeException("Unable to stop " + netscalerVm, e); } } }
public void createDeleteIpAliasCommand(final DomainRouterVO router, final List<IpAliasTO> deleteIpAliasTOs, final List<IpAliasTO> createIpAliasTos, final long networkId, final Commands cmds) { final String routerip = _routerControlHelper.getRouterIpInNetwork(networkId, router.getId()); final DataCenterVO dcVo = _dcDao.findById(router.getDataCenterId()); final DeleteIpAliasCommand deleteIpaliasCmd = new DeleteIpAliasCommand(routerip, deleteIpAliasTOs, createIpAliasTos); deleteIpaliasCmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, _routerControlHelper.getRouterControlIp(router.getId())); deleteIpaliasCmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName()); deleteIpaliasCmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, routerip); deleteIpaliasCmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString()); cmds.addCommand("deleteIpalias", deleteIpaliasCmd); }
private void assignRouterNicsToNewNetwork(long srcNetworkId, long dstNetworkId) { final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(srcNetworkId, VirtualRouter.Role.VIRTUAL_ROUTER); for (DomainRouterVO domainRouter : routers) { NicVO vrNic = _nicDao.findByNetworkIdAndType(srcNetworkId, VirtualMachine.Type.DomainRouter); vrNic.setNetworkId(dstNetworkId); _nicDao.update(vrNic.getId(), vrNic); RouterNetworkVO routerNetwork = _routerNetworkDao.findByRouterAndNetwork(domainRouter.getId(), srcNetworkId); routerNetwork.setNetworkId(dstNetworkId); _routerNetworkDao.persist(routerNetwork); } }
@Override public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException { VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(provider.getId(), Type.InternalLbVm); if (element == null) { return true; } long elementId = element.getId(); List<DomainRouterVO> internalLbVms = _routerDao.listByElementId(elementId); boolean result = true; for (DomainRouterVO internalLbVm : internalLbVms) { result = result && (_internalLbMgr.destroyInternalLbVm(internalLbVm.getId(), context.getAccount(), context.getCaller().getId())); } _vrProviderDao.remove(elementId); return result; }
@Override public boolean finalizeDeployment(final Commands cmds, final VirtualMachineProfile profile, final DeployDestination dest, final ReservationContext context) throws ResourceUnavailableException { final DomainRouterVO internalLbVm = _internalLbVmDao.findById(profile.getId()); final List<NicProfile> nics = profile.getNics(); for (final NicProfile nic : nics) { if (nic.getTrafficType() == TrafficType.Control) { internalLbVm.setPrivateIpAddress(nic.getIPv4Address()); internalLbVm.setPrivateMacAddress(nic.getMacAddress()); } } _internalLbVmDao.update(internalLbVm.getId(), internalLbVm); finalizeCommandsOnStart(cmds, profile); return true; }
public void createStaticRouteCommands(final List<StaticRouteProfile> staticRoutes, final DomainRouterVO router, final Commands cmds) { final SetStaticRouteCommand cmd = new SetStaticRouteCommand(staticRoutes); cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, _routerControlHelper.getRouterControlIp(router.getId())); cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName()); final DataCenterVO dcVo = _dcDao.findById(router.getDataCenterId()); cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString()); cmds.addCommand(cmd); }
@Override public boolean shutdownProviderInstances(final PhysicalNetworkServiceProvider provider, final ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException { final VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(provider.getId(), getVirtualRouterProvider()); if (element == null) { return true; } // Find domain routers final long elementId = element.getId(); final List<DomainRouterVO> routers = _routerDao.listByElementId(elementId); boolean result = true; for (final DomainRouterVO router : routers) { result = result && _routerMgr.destroyRouter(router.getId(), context.getAccount(), context.getCaller().getId()) != null; } _vrProviderDao.remove(elementId); return result; }