/** * Build the Server Matrix * * @return array */ public function build() { $self = ['alias' => getServerAlias(), 'url' => getServerUrl(), 'type' => getServerType()]; $servers = []; if (hasSlaves()) { $servers['servers'] = []; foreach (getSlaves() as $slave) { $servers['servers'][] = $this->getSlaveInformations($slave); } } return array_merge($self, $servers); }
/** * Set slave and filename * Set the timeout based on the server type * * @param string $slave * @param string $filename */ public function __construct($slave, $filename) { $this->slave = $slave; $this->filename = $filename; switch (getServerType()) { case 'master': $this->timeout = 10; break; case 'submaster': $this->timeout = 5; break; default: $this->timeout = 2; break; } }
/** * Set the timeout based on the server type * Set from and to filename * * @param $slave * @param $from * @param $to */ public function __construct($slave, $from, $to) { $this->slave = $slave; switch (getServerType()) { case 'master': $this->timeout = 10; break; case 'submaster': $this->timeout = 5; break; default: $this->timeout = 2; break; } $this->from = $from; $this->to = $to; }
/** * deleteServer * @param string $idOrNameServer server id or server name * @param string $type value of the server (auto, name, id) * @return array informations */ function deleteServer($idOrNameServer, $type = "auto") { if ($type == "auto") { $realType = getServerType($idOrNameServer); } else { $realType = $type; } if ($realType == "name") { $serverId = $this->getServerId($idOrNameServer); } else { $serverId = $idOrNameServer; } $result = null; $params = array(new SoapParam($serverId, "id")); try { $result = $this->auth->execSoapCall("DeleteServerRequest", $params); } catch (SoapFault $exception) { $result = $exception; } return $result; }
/** * Collect and return serverinfos as json * * @return array */ public function info() { return ['alias' => getServerAlias(), 'url' => getServerUrl(), 'type' => getServerType(), 'slaves' => getSlaves(), "whitelisted_ips" => getWhitelistedIps()]; }
/** * Check if server has slaves * * @return bool */ function hasSlaves() { return (getServerType() == 'master' || getServerType() == 'submaster') && getSlaves(); }