@Override public StopAnswer execute(StopCommand cmd) { String vmName = cmd.getVmName(); try { OvmVm.Details vm = null; try { vm = OvmVm.getDetails(_conn, vmName); } catch (XmlRpcException e) { s_logger.debug("Unable to get details of vm: " + vmName + ", treating it as stopped", e); return new StopAnswer(cmd, "success", true); } deleteAllNetworkRulesForVm(vmName); OvmVm.stop(_conn, vmName); cleanup(vm); return new StopAnswer(cmd, "success", true); } catch (Exception e) { s_logger.debug("Stop " + vmName + "failed", e); return new StopAnswer(cmd, e.getMessage(), false); } }
public Command cleanup(final String vmName) { VirtualMachine vm = _vmDao.findVMByInstanceName(vmName); StopCommand cmd = new StopCommand(vmName, getExecuteInSequence(null), false); cmd.setControlIp(getControlNicIpForVM(vm)); return cmd; }
@Override public Answer execute(final StopCommand command, final LibvirtComputingResource libvirtComputingResource) { final String vmName = command.getVmName(); if (command.checkBeforeCleanup()) { try { final Connect conn = libvirtUtilitiesHelper.getConnectionByVmName(vmName); final Domain vm = conn.domainLookupByName(command.getVmName()); if (vm != null && vm.getInfo().state == DomainState.VIR_DOMAIN_RUNNING) { return new StopAnswer(command, "vm is still running on host", false); Pair<Boolean, String> ret = SshHelper.sshExecute(command.getControlIp(), 3922, "root", pemFile, null,"cp -f "+CMDLINE_PATH+" "+CMDLINE_BACKUP_PATH); if(!ret.first()){ s_logger.debug("Failed to backup cmdline file due to "+ret.second()); final String result = libvirtComputingResource.stopVM(conn, vmName, command.isForceStop()); List<Map<String, String>> volumesToDisconnect = command.getVolumesToDisconnect(); if(vmName.startsWith("s-") || vmName.startsWith("v-")) s_logger.debug("restoring cmdline file from backup"); Pair<Boolean, String> ret = SshHelper.sshExecute(command.getControlIp(), 3922, "root", pemFile, null, "mv "+CMDLINE_BACKUP_PATH+" "+CMDLINE_PATH); if(!ret.first()){ s_logger.debug("unable to restore cmdline due to "+ret.second());
@Override public Answer execute(final StopCommand command, final CitrixResourceBase citrixResourceBase) { final String vmName = command.getVmName(); String platformstring = null; try { if (command.checkBeforeCleanup() && vmr.powerState == VmPowerState.RUNNING) { final String msg = "Vm " + vmName + " is running on host and checkBeforeCleanup flag is set, so bailing out"; s_logger.debug(msg); final String result = citrixResourceBase.callHostPlugin(conn, "vmops", "destroy_network_rules_for_vm", "vmName", command.getVmName()); if (result == null || result.isEmpty() || !Boolean.parseBoolean(result)) { s_logger.warn("Failed to remove network rules for vm " + command.getVmName()); } else { s_logger.info("Removed network rules for vm " + command.getVmName()); citrixResourceBase.shutdownVM(conn, vm, vmName, command.isForceStop()); final String msg = "Catch exception " + e.getClass().getName() + " when stop VM:" + command.getVmName() + " due to " + e.toString(); s_logger.debug(msg); return new StopAnswer(command, msg, platformstring, false); command.setGpuDevice(new GPUDeviceTO(null, null, groupDetails)); final SR sr = citrixResourceBase.getISOSRbyVmName(conn, command.getVmName()); citrixResourceBase.removeSR(conn, sr);
protected boolean sendStop(final VirtualMachineGuru guru, final VirtualMachineProfile profile, final boolean force, final boolean checkBeforeCleanup) { final VirtualMachine vm = profile.getVirtualMachine(); StopCommand stpCmd = new StopCommand(vm, getExecuteInSequence(vm.getHypervisorType()), checkBeforeCleanup); stpCmd.setControlIp(getControlNicIpForVM(vm)); stpCmd.setVolumesToDisconnect(getVolumesToDisconnect(vm)); final StopCommand stop = stpCmd; try { final GPUDeviceTO gpuDevice = stop.getGpuDevice(); if (gpuDevice != null) { _resourceMgr.updateGPUDetails(vm.getHostId(), gpuDevice.getGroupDetails());
final StopCommand stop = new StopCommand(vm, getExecuteInSequence(vm.getHypervisorType()), false, cleanUpEvenIfUnableToStop); stop.setControlIp(getControlNicIpForVM(vm)); final GPUDeviceTO gpuDevice = stop.getGpuDevice(); if (gpuDevice != null) { _resourceMgr.updateGPUDetails(vm.getHostId(), gpuDevice.getGroupDetails());
String vmName = cmd.getVmName(); State state = State.Error; hypervisorsupport.setVmState(vmName, State.Stopping);
public Command cleanup(final VirtualMachine vm) { StopCommand cmd = new StopCommand(vm, getExecuteInSequence(vm.getHypervisorType()), false); cmd.setControlIp(getControlNicIpForVM(vm)); return cmd; }
s_logger.info("The guru did not like the answers so stopping " + vm); StopCommand stopCmd = new StopCommand(vm, getExecuteInSequence(vm.getHypervisorType()), false); stopCmd.setControlIp(getControlNicIpForVM(vm)); final StopCommand cmd = stopCmd; final Answer answer = _agentMgr.easySend(destHostId, cmd);