@Override public boolean checkRouterVersion(final VirtualRouter router) { if (!VirtualNetworkApplianceManagerImpl.routerVersionCheckEnabled.value()) { // Router version check is disabled. return true; } if (router.getTemplateVersion() == null) { return false; } final long dcid = router.getDataCenterId(); final String trimmedVersion = Version.trimRouterVersion(router.getTemplateVersion()); return Version.compare(trimmedVersion, NetworkOrchestrationService.MinVRVersion.valueIn(dcid)) >= 0; }
@Override public boolean sendCommandsToRouter(final VirtualRouter router, final Commands cmds) throws AgentUnavailableException, ResourceUnavailableException { if (!checkRouterVersion(router)) { s_logger.debug( "Router requires upgrade. Unable to send command to router:" + router.getId() + ", router template version : " + router.getTemplateVersion() + ", minimal required version : " + NetworkOrchestrationService.MinVRVersion.valueIn(router.getDataCenterId())); throw new ResourceUnavailableException( "Unable to send command. Router requires upgrade", VirtualRouter.class, router.getId()); } Answer[] answers = null; try { answers = _agentMgr.send(router.getHostId(), cmds); } catch (final OperationTimedoutException e) { s_logger.warn("Timed Out", e); throw new AgentUnavailableException( "Unable to send commands to virtual router ", router.getHostId(), e); } if (answers == null || answers.length != cmds.size()) { return false; } // FIXME: Have to return state for individual command in the future boolean result = true; for (final Answer answer : answers) { if (!answer.getResult()) { result = false; break; } } return result; }