/** * @param string $filename * @return object */ public function getFileDetails($filename) { // what are we doing? $log = usingLog()->startAction("get details for '{$filename}' on host '{$this->args[0]}'"); // make sure we have valid host details $hostDetails = $this->getHostDetails(); // get an object to talk to this host $host = OsLib::getHostAdapter($this->st, $hostDetails->osName); // get the details $details = $host->getFileDetails($hostDetails, $filename); // all done $log->endAction(); return $details; }
/** * * @param stdClass $vmDetails * @return string */ public function determineHostname($vmDetails) { // what are we doing? $log = usingLog()->startAction("determine hostname of Vagrant VM '{$vmDetails->hostId}'"); // create an adapter to talk to the host operating system $host = OsLib::getHostAdapter($this->st, $vmDetails->osName); // get the hostname $hostname = $host->determineHostname($vmDetails, new VagrantVm($this->st)); // all done $log->endAction("hostname is '{$hostname}'"); return $hostname; }
public function uploadFile($sourceFilename, $destFilename) { // what are we doing? $log = usingLog()->startAction("upload file '{$sourceFilename}' to '{$this->args[0]}':'{$destFilename}'"); // does the source file exist? if (!is_file($sourceFilename)) { $log->endAction("file '{$sourceFilename}' not found :("); throw new E5xx_ActionFailed(__METHOD__); } // make sure we have valid host details $hostDetails = $this->getHostDetails(); // get an object to talk to this host $host = OsLib::getHostAdapter($this->st, $hostDetails->osName); // upload the file $result = $host->uploadFile($hostDetails, $sourceFilename, $destFilename); // did the command used to upload succeed? if ($result->didCommandFail()) { $msg = "upload failed with return code '{$result->returnCode}' and output '{$result->output}'"; $log->endAction($msg); throw new E5xx_ActionFailed(__METHOD__, $msg); } // all done $log->endAction(); return $result; }