| @@ 174-189 (lines=16) @@ | ||
| 171 | * @param PhysicalHostDetails $vmDetails |
|
| 172 | * @return string |
|
| 173 | */ |
|
| 174 | public function determineIpAddress($vmDetails) |
|
| 175 | { |
|
| 176 | // what are we doing? |
|
| 177 | $log = usingLog()->startAction("determine IP address of physical host '{$vmDetails->hostId}'"); |
|
| 178 | ||
| 179 | // create an adapter to talk to the host operating system |
|
| 180 | $host = OsLib::getHostAdapter($this->st, $vmDetails->osName); |
|
| 181 | ||
| 182 | // get the IP address |
|
| 183 | $ipAddress = $host->determineIpAddress($vmDetails, $this); |
|
| 184 | $vmDetails->ipAddress = $ipAddress; |
|
| 185 | ||
| 186 | // all done |
|
| 187 | $log->endAction("IP address is '{$ipAddress}'"); |
|
| 188 | return $ipAddress; |
|
| 189 | } |
|
| 190 | ||
| 191 | /** |
|
| 192 | * |
|
| @@ 196-211 (lines=16) @@ | ||
| 193 | * @param PhysicalHostDetails $vmDetails |
|
| 194 | * @return string |
|
| 195 | */ |
|
| 196 | public function determineHostname($vmDetails) |
|
| 197 | { |
|
| 198 | // what are we doing? |
|
| 199 | $log = usingLog()->startAction("determine hostname of physical host '{$vmDetails->hostId}'"); |
|
| 200 | ||
| 201 | // create an adapter to talk to the host operating system |
|
| 202 | $host = OsLib::getHostAdapter($this->st, $vmDetails->osName); |
|
| 203 | ||
| 204 | // get the hostname |
|
| 205 | $hostname = $host->determineHostname($vmDetails, $this); |
|
| 206 | $vmDetails->hostname = $hostname; |
|
| 207 | ||
| 208 | // all done |
|
| 209 | $log->endAction("hostname is '{$hostname}'"); |
|
| 210 | return $hostname; |
|
| 211 | } |
|
| 212 | } |
|
| 213 | ||
| @@ 380-394 (lines=15) @@ | ||
| 377 | * @param stdClass $vmDetails |
|
| 378 | * @return string |
|
| 379 | */ |
|
| 380 | public function determineIpAddress($vmDetails) |
|
| 381 | { |
|
| 382 | // what are we doing? |
|
| 383 | $log = usingLog()->startAction("determine IP address of Vagrant VM '{$vmDetails->hostId}'"); |
|
| 384 | ||
| 385 | // create an adapter to talk to the host operating system |
|
| 386 | $host = OsLib::getHostAdapter($this->st, $vmDetails->osName); |
|
| 387 | ||
| 388 | // get the IP address |
|
| 389 | $ipAddress = $host->determineIpAddress($vmDetails, new VagrantVm($this->st)); |
|
| 390 | ||
| 391 | // all done |
|
| 392 | $log->endAction("IP address is '{$ipAddress}'"); |
|
| 393 | return $ipAddress; |
|
| 394 | } |
|
| 395 | ||
| 396 | /** |
|
| 397 | * |
|
| @@ 401-415 (lines=15) @@ | ||
| 398 | * @param stdClass $vmDetails |
|
| 399 | * @return string |
|
| 400 | */ |
|
| 401 | public function determineHostname($vmDetails) |
|
| 402 | { |
|
| 403 | // what are we doing? |
|
| 404 | $log = usingLog()->startAction("determine hostname of Vagrant VM '{$vmDetails->hostId}'"); |
|
| 405 | ||
| 406 | // create an adapter to talk to the host operating system |
|
| 407 | $host = OsLib::getHostAdapter($this->st, $vmDetails->osName); |
|
| 408 | ||
| 409 | // get the hostname |
|
| 410 | $hostname = $host->determineHostname($vmDetails, new VagrantVm($this->st)); |
|
| 411 | ||
| 412 | // all done |
|
| 413 | $log->endAction("hostname is '{$hostname}'"); |
|
| 414 | return $hostname; |
|
| 415 | } |
|
| 416 | ||
| 417 | /** |
|
| 418 | * Set the VAGRANT_BRIDGE_ADAPTER and VIRTUALBOX_BRIDGE_ADAPTER |
|
| @@ 73-91 (lines=19) @@ | ||
| 70 | /** |
|
| 71 | * @return object |
|
| 72 | */ |
|
| 73 | public function getDetails() |
|
| 74 | { |
|
| 75 | // what are we doing? |
|
| 76 | $log = usingLog()->startAction("retrieve details for host '{$this->args[0]}'"); |
|
| 77 | ||
| 78 | // get the host details |
|
| 79 | $hostDetails = $this->getHostDetails(); |
|
| 80 | ||
| 81 | // we already have details - are they valid? |
|
| 82 | if (isset($hostDetails->invalidHost) && $hostDetails->invalidHost) { |
|
| 83 | $msg = "there are no details about host '{$hostDetails->hostId}'"; |
|
| 84 | $log->endAction($msg); |
|
| 85 | throw Exceptions::newActionFailedException(__METHOD__, $msg); |
|
| 86 | } |
|
| 87 | ||
| 88 | // return the details |
|
| 89 | $log->endAction(); |
|
| 90 | return $hostDetails; |
|
| 91 | } |
|
| 92 | ||
| 93 | /** |
|
| 94 | * is a host up and running? |
|
| @@ 172-189 (lines=18) @@ | ||
| 169 | * @param string $packageName |
|
| 170 | * @return object |
|
| 171 | */ |
|
| 172 | public function getInstalledPackageDetails($packageName) |
|
| 173 | { |
|
| 174 | // what are we doing? |
|
| 175 | $log = usingLog()->startAction("get details for package '{$packageName}' installed on host '{$this->args[0]}'"); |
|
| 176 | ||
| 177 | // make sure we have valid host details |
|
| 178 | $hostDetails = $this->getHostDetails(); |
|
| 179 | ||
| 180 | // get an object to talk to this host |
|
| 181 | $host = OsLib::getHostAdapter($this->st, $hostDetails->osName); |
|
| 182 | ||
| 183 | // get the information |
|
| 184 | $return = $host->getInstalledPackageDetails($hostDetails, $packageName); |
|
| 185 | ||
| 186 | // all done |
|
| 187 | $log->endAction(); |
|
| 188 | return $return; |
|
| 189 | } |
|
| 190 | ||
| 191 | /** |
|
| 192 | * @param int $pid |
|
| @@ 251-268 (lines=18) @@ | ||
| 248 | * @param string $processName |
|
| 249 | * @return int |
|
| 250 | */ |
|
| 251 | public function getPid($processName) |
|
| 252 | { |
|
| 253 | // log some info to the user |
|
| 254 | $log = usingLog()->startAction("get id of process '{$processName}' running on VM '{$this->args[0]}'"); |
|
| 255 | ||
| 256 | // make sure we have valid host details |
|
| 257 | $hostDetails = $this->getHostDetails(); |
|
| 258 | ||
| 259 | // get an object to talk to this host |
|
| 260 | $host = OsLib::getHostAdapter($this->st, $hostDetails->osName); |
|
| 261 | ||
| 262 | // get the information |
|
| 263 | $return = $host->getPid($hostDetails, $processName); |
|
| 264 | ||
| 265 | // success |
|
| 266 | $log->endAction("pid is '{$return}'"); |
|
| 267 | return $return; |
|
| 268 | } |
|
| 269 | ||
| 270 | /** |
|
| 271 | * @return string |
|
| @@ 617-634 (lines=18) @@ | ||
| 614 | * @param string $filename |
|
| 615 | * @return object |
|
| 616 | */ |
|
| 617 | public function getFileDetails($filename) |
|
| 618 | { |
|
| 619 | // what are we doing? |
|
| 620 | $log = usingLog()->startAction("get details for '{$filename}' on host '{$this->args[0]}'"); |
|
| 621 | ||
| 622 | // make sure we have valid host details |
|
| 623 | $hostDetails = $this->getHostDetails(); |
|
| 624 | ||
| 625 | // get an object to talk to this host |
|
| 626 | $host = OsLib::getHostAdapter($this->st, $hostDetails->osName); |
|
| 627 | ||
| 628 | // get the details |
|
| 629 | $details = $host->getFileDetails($hostDetails, $filename); |
|
| 630 | ||
| 631 | // all done |
|
| 632 | $log->endAction(); |
|
| 633 | return $details; |
|
| 634 | } |
|
| 635 | ||
| 636 | /** |
|
| 637 | * which local folder do we need to be in when working with this host? |
|
| @@ 119-136 (lines=18) @@ | ||
| 116 | return $result; |
|
| 117 | } |
|
| 118 | ||
| 119 | public function runCommandAndIgnoreErrors($command) |
|
| 120 | { |
|
| 121 | // what are we doing? |
|
| 122 | $log = usingLog()->startAction("run command '{$command}' on host '{$this->args[0]}'"); |
|
| 123 | ||
| 124 | // make sure we have valid host details |
|
| 125 | $hostDetails = $this->getHostDetails(); |
|
| 126 | ||
| 127 | // get an object to talk to this host |
|
| 128 | $host = OsLib::getHostAdapter($this->st, $hostDetails->osName); |
|
| 129 | ||
| 130 | // run the command in the guest operating system |
|
| 131 | $result = $host->runCommand($hostDetails, $command); |
|
| 132 | ||
| 133 | // all done |
|
| 134 | $log->endAction(); |
|
| 135 | return $result; |
|
| 136 | } |
|
| 137 | ||
| 138 | public function runCommandAsUserAndIgnoreErrors($command, $user) |
|
| 139 | { |
|