/** * Constructor to specify stop only or start only or both. * * @param aVmId The VmId of the VM to stop then restart. * @param howToStop The hydra.ClientVmMgr stopMode (unused if stop is false). * @parram doStop If true then this thread stops vms. * @parram doStart If true then this thread starts vms. */ public StopStartVMs(ClientVmInfo aVmId, int howToStop, boolean doStop, boolean doStart) { if (!doStop && !doStart) { throw new TestException( "You must specify at least one of stop or start, stop is " + doStop + " and start is " + doStart); } targetVm = aVmId; stopMode = howToStop; stop = doStop; start = doStart; if (doStop) { setName( "<StopStartVMs-thread to " + getAction(stop, start) + " " + aVmId + " with " + ClientVmMgr.toStopModeString(stopMode) + ">"); } else { setName("<StopStartVMs-thread to " + getAction(stop, start) + " " + aVmId + ">"); } }
/** * Run method for this thread: if this thread is set to stop, then stop a VM and wait for it to * stop. If this thread is set to start then start a VM and wait for it to start. Any errors are * placed in the blackboard errStr. */ public void run() { try { Log.getLogWriter().info("Started " + getName()); try { if (stop) { ClientVmMgr.stop( "Test is synchronously stopping " + targetVm + " with " + ClientVmMgr.toStopModeString(stopMode), stopMode, ClientVmMgr.ON_DEMAND, targetVm); } VMotionUtil.doVMotion(targetVm); if (start) { ClientVmMgr.start("Test is synchronously starting " + targetVm, targetVm); } } catch (hydra.ClientVmNotFoundException e) { Log.getLogWriter() .info("Caught in thread " + getName() + ":" + TestHelper.getStackTrace(e)); StopStartBB.getBB().getSharedMap().put(StopStartBB.errKey, TestHelper.getStackTrace(e)); } } catch (Throwable e) { Log.getLogWriter().info("Caught in thread " + getName() + ":" + TestHelper.getStackTrace(e)); StopStartBB.getBB().getSharedMap().put(StopStartBB.errKey, TestHelper.getStackTrace(e)); } Log.getLogWriter().info(getName() + " terminating"); }
/** * Constructor to specify stop and start. * * @param aVmId The VmId of the VM to stop then restart. * @param howToStop The hydra.ClientVmMgr stopMode (unused if stop is false). */ public StopStartVMs(ClientVmInfo aVmId, int howToStop) { targetVm = aVmId; stopMode = howToStop; stop = true; start = true; setName( "<StopStartVMs-thread to " + getAction(stop, start) + " " + aVmId + " with " + ClientVmMgr.toStopModeString(stopMode) + ">"); }