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 void handleSingleWorkingRedundantRouter(final List<? extends VirtualRouter> connectedRouters, final List<? extends VirtualRouter> disconnectedRouters, final String reason) throws ResourceUnavailableException { if (connectedRouters.isEmpty() || disconnectedRouters.isEmpty()) { return; } for (final VirtualRouter virtualRouter : connectedRouters) { if (!virtualRouter.getIsRedundantRouter()) { throw new ResourceUnavailableException("Who is calling this with non-redundant router or non-domain router?", DataCenter.class, virtualRouter.getDataCenterId()); } } for (final VirtualRouter virtualRouter : disconnectedRouters) { if (!virtualRouter.getIsRedundantRouter()) { throw new ResourceUnavailableException("Who is calling this with non-redundant router or non-domain router?", DataCenter.class, virtualRouter.getDataCenterId()); } } final DomainRouterVO connectedRouter = (DomainRouterVO) connectedRouters.get(0); DomainRouterVO disconnectedRouter = (DomainRouterVO) disconnectedRouters.get(0); if (s_logger.isDebugEnabled()) { s_logger.debug("About to stop the router " + disconnectedRouter.getInstanceName() + " due to: " + reason); } final String title = "Virtual router " + disconnectedRouter.getInstanceName() + " would be stopped after connecting back, due to " + reason; final String context = "Virtual router (name: " + disconnectedRouter.getInstanceName() + ", id: " + disconnectedRouter.getId() + ") would be stopped after connecting back, due to: " + reason; _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER, disconnectedRouter.getDataCenterId(), disconnectedRouter.getPodIdToDeployIn(), title, context); disconnectedRouter.setStopPending(true); disconnectedRouter = _routerDao.persist(disconnectedRouter); }
@Override public void processConnect(final Host host, final StartupCommand cmd, final boolean forRebalance) throws ConnectionException { final List<DomainRouterVO> routers = _routerDao.listIsolatedByHostId(host.getId()); for (DomainRouterVO router : routers) { if (router.isStopPending()) { s_logger.info("Stopping router " + router.getInstanceName() + " due to stop pending flag found!"); final VirtualMachine.State state = router.getState(); if (state != VirtualMachine.State.Stopped && state != VirtualMachine.State.Destroyed) { try { stopRouter(router.getId(), false); } catch (final ResourceUnavailableException e) { s_logger.warn("Fail to stop router " + router.getInstanceName(), e); throw new ConnectionException(false, "Fail to stop router " + router.getInstanceName()); } catch (final ConcurrentOperationException e) { s_logger.warn("Fail to stop router " + router.getInstanceName(), e); throw new ConnectionException(false, "Fail to stop router " + router.getInstanceName()); } } router.setStopPending(false); router = _routerDao.persist(router); } } }
protected DomainRouterVO start(DomainRouterVO router, final User user, final Account caller, final Map<Param, Object> params, final DeploymentPlan planToDeploy) throws StorageUnavailableException, InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException { s_logger.debug("Starting router " + router); try { _itMgr.advanceStart(router.getUuid(), params, planToDeploy, null); } catch (final OperationTimedoutException e) { throw new ResourceUnavailableException("Starting router " + router + " failed! " + e.toString(), DataCenter.class, router.getDataCenterId()); } if (router.isStopPending()) { s_logger.info("Clear the stop pending flag of router " + router.getHostName() + " after start router successfully!"); router.setStopPending(false); router = _routerDao.persist(router); } // We don't want the failure of VPN Connection affect the status of // router, so we try to make connection // only after router start successfully final Long vpcId = router.getVpcId(); if (vpcId != null) { _s2sVpnMgr.reconnectDisconnectedVpnByVpc(vpcId); } return _routerDao.findById(router.getId()); }
@ActionEvent(eventType = EventTypes.EVENT_ROUTER_STOP, eventDescription = "stopping router Vm", async = true) @Override public VirtualRouter stopRouter(final long routerId, final boolean forced) throws ResourceUnavailableException, ConcurrentOperationException { final CallContext context = CallContext.current(); final Account account = context.getCallingAccount(); // verify parameters final DomainRouterVO router = _routerDao.findById(routerId); if (router == null) { throw new InvalidParameterValueException("Unable to find router by id " + routerId + "."); } _accountMgr.checkAccess(account, null, true, router); final UserVO user = _userDao.findById(CallContext.current().getCallingUserId()); final VirtualRouter virtualRouter = stop(router, forced, user, account); if (virtualRouter == null) { throw new CloudRuntimeException("Failed to stop router with id " + routerId); } // Clear stop pending flag after stopped successfully if (router.isStopPending()) { s_logger.info("Clear the stop pending flag of router " + router.getHostName() + " after stop router successfully"); router.setStopPending(false); _routerDao.persist(router); virtualRouter.setStopPending(false); } return virtualRouter; }