@Override public List<ConfigItem> generateConfig(final NetworkElementCommand cmd) { final SetMonitorServiceCommand command = (SetMonitorServiceCommand) cmd; final MonitorService monitorService = new MonitorService(command.getConfiguration(), cmd.getAccessDetail(NetworkElementCommand.ROUTER_MONITORING_ENABLE)); return generateConfigItems(monitorService); }
throw new CloudRuntimeException("VirtualMachine " + profile.getInstanceName() + " doesn't have a control interface"); final SetMonitorServiceCommand command = new SetMonitorServiceCommand(servicesTO); command.setAccessDetail(NetworkElementCommand.ROUTER_IP, controlNic.getIPv4Address()); command.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, _routerControlHelper.getRouterIpInNetwork(networkId, router.getId())); command.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName()); command.setAccessDetail(NetworkElementCommand.ROUTER_MONITORING_ENABLE, add.toString());
protected Answer execute(final SetMonitorServiceCommand cmd) { if (s_logger.isInfoEnabled()) { s_logger.info("Executing resource SetMonitorServiceCommand: " + s_gson.toJson(cmd)); } final String controlIp = getRouterSshControlIp(cmd); final String config = cmd.getConfiguration(); final String args = String.format(" %s %s", "-c", config); final String command = String.format("%s%s %s", "/opt/cloud/bin/", VRScripts.MONITOR_SERVICE, args); try { final Pair<Boolean, String> result = SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, command); if (!result.first()) { final String msg= "monitor_service.sh failed on domain router " + controlIp + " failed " + result.second(); s_logger.error(msg); return new Answer(cmd, false, msg); } return new Answer(cmd); } catch (final Throwable e) { s_logger.error("Unexpected exception: " + e.toString(), e); return new Answer(cmd, false, "SetMonitorServiceCommand failed due to " + e); } }