public function destroyHost($vmDetails)
{
// what are we doing?
$log = usingLog()->startAction("destroy VM");
// is the VM actually running?
if ($this->isRunning($vmDetails)) {
// yes it is ... shut it down
$command = "vagrant destroy --force";
$result = $this->runCommandAgainstHostManager($vmDetails, $command);
// did it work?
if ($result->returnCode != 0) {
$log->endAction("VM failed to shutdown :(");
throw new E5xx_ActionFailed(__METHOD__);
}
}
// if we get here, we need to forget about this VM
usingHostsTable()->removeHost($vmDetails->hostId);
// remove any roles
usingRolesTable()->removeHostFromAllRoles($vmDetails->hostId);
// all done
$log->endAction();
}