public CheckOnHostCommand(Host host) { this.host = new HostTO(host); setWait(20); }
@Override public Answer execute(final CheckOnHostCommand command, final XenServer56Resource xenServer56) { final Boolean alive = xenServer56.checkHeartbeat(command.getHost().getGuid()); String msg = ""; if (alive == null) { msg = " cannot determine "; } else if ( alive == true) { msg = "Heart beat is still going"; } else { msg = "Heart beat is gone so dead."; } s_logger.debug(msg); return new CheckOnHostAnswer(command, alive, msg); } }
@Override public Answer execute(final CheckOnHostCommand command, final LibvirtComputingResource libvirtComputingResource) { final ExecutorService executors = Executors.newSingleThreadExecutor(); final KVMHAMonitor monitor = libvirtComputingResource.getMonitor(); final List<NfsStoragePool> pools = monitor.getStoragePools(); final HostTO host = command.getHost(); final NetworkTO privateNetwork = host.getPrivateNetwork(); final KVMHAChecker ha = new KVMHAChecker(pools, privateNetwork.getIp()); final Future<Boolean> future = executors.submit(ha); try { final Boolean result = future.get(); if (result) { return new Answer(command, false, "Heart is beating..."); } else { return new Answer(command); } } catch (final InterruptedException e) { return new Answer(command, false, "CheckOnHostCommand: can't get status of host: InterruptedException"); } catch (final ExecutionException e) { return new Answer(command, false, "CheckOnHostCommand: can't get status of host: ExecutionException"); } } }
public CheckOnHostAnswer execute(CheckOnHostCommand cmd) { LOGGER.debug("CheckOnHostCommand"); CloudstackPlugin csp = new CloudstackPlugin(c); try { Boolean alive = csp.dom0CheckStorageHealth(config.getAgentScriptsDir(), config.getAgentCheckStorageScript(), cmd.getHost().getGuid(), config.getAgentStorageCheckTimeout()); String msg = ""; if (alive == null) { msg = "storage check failed for " + cmd.getHost().getGuid(); } else if (alive) { msg = "storage check ok for " + cmd.getHost().getGuid(); } else { msg = "storage dead for " + cmd.getHost().getGuid(); } LOGGER.debug(msg); return new CheckOnHostAnswer(cmd, alive, msg); } catch (Ovm3ResourceException e) { return new CheckOnHostAnswer(cmd, false, "Error while checking storage for " +cmd.getHost().getGuid() +": " + e.getMessage()); } } }
@Override public Answer execute(final CheckVMActivityOnStoragePoolCommand command, final LibvirtComputingResource libvirtComputingResource) { final ExecutorService executors = Executors.newSingleThreadExecutor(); final KVMHAMonitor monitor = libvirtComputingResource.getMonitor(); final StorageFilerTO pool = command.getPool(); if (Storage.StoragePoolType.NetworkFilesystem == pool.getType()){ final NfsStoragePool nfspool = monitor.getStoragePool(pool.getUuid()); final KVMHAVMActivityChecker ha = new KVMHAVMActivityChecker(nfspool, command.getHost().getPrivateNetwork().getIp(), command.getVolumeList(), libvirtComputingResource.getVmActivityCheckPath(), command.getSuspectTimeInSeconds()); final Future<Boolean> future = executors.submit(ha); try { final Boolean result = future.get(); if (result) { return new Answer(command, false, "VMHA disk activity detected ..."); } else { return new Answer(command); } } catch (InterruptedException e) { return new Answer(command, false, "CheckVMActivityOnStoragePoolCommand: can't get status of host: InterruptedException"); } catch (ExecutionException e) { return new Answer(command, false, "CheckVMActivityOnStoragePoolCommand: can't get status of host: ExecutionException"); } } return new Answer(command, false, "Unsupported Storage"); } }
public CheckVMActivityOnStoragePoolCommand(final Host host, final StoragePool pool, final List<Volume> volumeList, final DateTime suspectTime) { this.host = new HostTO(host); this.pool = new StorageFilerTO(pool); this.suspectTimeSeconds = suspectTime.getMillis()/1000L; final StringBuilder stringBuilder = new StringBuilder(); for (final Volume v : volumeList) { stringBuilder.append(v.getUuid()).append(","); } this.volumeList = stringBuilder.deleteCharAt(stringBuilder.length() - 1).toString(); }