DataSift\Storyplayer\HostLib\VagrantVm::powerOffHost PHP Method

powerOffHost() public method

public powerOffHost ( VagrantVmDetails $vmDetails ) : void
$vmDetails VagrantVmDetails
return void
    public function powerOffHost($vmDetails)
    {
        // what are we doing?
        $log = usingLog()->startAction("power off VM");
        // is the VM actually running?
        if (!$this->isRunning($vmDetails)) {
            // we've decided not to treat this as an error ... that might
            // change in a future release
            $log->endAction("VM was already stopped or destroyed");
            return;
        }
        // yes it is ... shut it down
        $command = "vagrant halt --force";
        $result = $this->runCommandAgainstHostManager($vmDetails, $command);
        // did it work?
        if ($result->returnCode != 0) {
            $log->endAction("VM failed to power off :(");
            throw new E5xx_ActionFailed(__METHOD__);
        }
        // all done - success!
        $log->endAction("VM successfully powered off");
    }