コード例 #1
0
ファイル: Service.php プロジェクト: antriver/cloud-scaler
 /**
  * Check if the given host belongs to this service, by checking its hostname against this
  * service's hostnamePattern. Returns the instance number from the hostname on success else returns false.
  *
  * @param Host $host
  *
  * @return bool|int
  */
 public function isThisYourHost(Host $host)
 {
     $matches = [];
     if (preg_match($this->hostnamePattern, $host->getHostname(), $matches)) {
         return (int) $matches[1];
     }
     return false;
 }
コード例 #2
0
 /**
  * Destroy a droplet.
  *
  * @param Host $host
  *
  * @return bool
  * @throws Exception
  */
 public function destroy(Host $host)
 {
     if (!$host instanceof Droplet) {
         throw new Exception(self::class . " can only destroy DigitalOcean droplets");
     }
     $this->api->droplet()->delete($host->getDroplet()->id);
     return true;
 }