本文整理汇总了PHP中DBServer::GetProperty方法的典型用法代码示例。如果您正苦于以下问题:PHP DBServer::GetProperty方法的具体用法?PHP DBServer::GetProperty怎么用?PHP DBServer::GetProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBServer
的用法示例。
在下文中一共展示了DBServer::GetProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: removeIpFromServer
public static function removeIpFromServer(\DBServer $dbServer)
{
try {
if ($dbServer->GetProperty(\OPENSTACK_SERVER_PROPERTIES::FLOATING_IP)) {
if ($dbServer->farmRoleId) {
if ($dbServer->GetFarmRoleObject()->GetSetting(\DBFarmRole::SETTING_OPENSTACK_KEEP_FIP_ON_SUSPEND)) {
if (in_array($dbServer->status, array(\SERVER_STATUS::PENDING_SUSPEND, \SERVER_STATUS::SUSPENDED)) || $dbServer->GetRealStatus()->isSuspended()) {
return false;
}
}
}
$environment = $dbServer->GetEnvironmentObject();
$osClient = $environment->openstack($dbServer->platform, $dbServer->GetCloudLocation());
$ipId = $dbServer->GetProperty(\OPENSTACK_SERVER_PROPERTIES::FLOATING_IP_ID);
if ($osClient->hasService('network')) {
$osClient->network->floatingIps->delete($ipId);
} else {
$osClient->servers->deleteFloatingIp($ipId);
}
$dbServer->SetProperties(array(\OPENSTACK_SERVER_PROPERTIES::FLOATING_IP => null, \OPENSTACK_SERVER_PROPERTIES::FLOATING_IP_ID => null));
}
} catch (\Exception $e) {
\Logger::getLogger("OpenStackObserver")->fatal("OpenStackObserver observer failed: " . $e->getMessage());
}
}
示例2: GetServerIPAddresses
public function GetServerIPAddresses(DBServer $DBServer)
{
$client = $this->getOsClient($DBServer->GetEnvironmentObject(), $DBServer->GetProperty(OPENSTACK_SERVER_PROPERTIES::CLOUD_LOCATION));
$result = $client->servers->getServerDetails($DBServer->GetProperty(OPENSTACK_SERVER_PROPERTIES::SERVER_ID));
if ($result->accessIPv4) {
$remoteIp = $result->accessIPv4;
}
if (!$remoteIp) {
if (is_array($result->addresses->public)) {
foreach ($result->addresses->public as $addr) {
if ($addr->version == 4) {
$remoteIp = $addr->addr;
break;
}
}
}
}
if (is_array($result->addresses->private)) {
foreach ($result->addresses->private as $addr) {
if ($addr->version == 4) {
$localIp = $addr->addr;
break;
}
}
}
if (!$localIp) {
$localIp = $remoteIp;
}
return array('localIp' => $localIp, 'remoteIp' => $remoteIp);
}
示例3: GetServerIPAddresses
/**
* {@inheritdoc}
* @see \Scalr\Modules\Platforms\Openstack\OpenstackPlatformModule::GetServerIPAddresses()
*/
public function GetServerIPAddresses(\DBServer $DBServer)
{
$config = \Scalr::getContainer()->config;
$client = $this->getOsClient($DBServer->GetEnvironmentObject(), $DBServer->GetProperty(\OPENSTACK_SERVER_PROPERTIES::CLOUD_LOCATION));
$result = $client->servers->getServerDetails($DBServer->GetProperty(\OPENSTACK_SERVER_PROPERTIES::SERVER_ID));
$publicNetworkName = 'public';
$privateNetworkName = 'private';
if (is_array($result->addresses->{$publicNetworkName})) {
foreach ($result->addresses->{$publicNetworkName} as $addr) {
if ($addr->version == 4) {
$remoteIp = $addr->addr;
break;
}
}
}
if (!$remoteIp && $result->accessIPv4) {
$remoteIp = $result->accessIPv4;
}
if (is_array($result->addresses->{$privateNetworkName})) {
foreach ($result->addresses->{$privateNetworkName} as $addr) {
if ($addr->version == 4) {
$localIp = $addr->addr;
break;
}
}
}
if (!$localIp) {
$localIp = $remoteIp;
}
return array('localIp' => $localIp, 'remoteIp' => $remoteIp);
}
示例4: setupScalrAgent
public static function setupScalrAgent(\DBServer $dbServer)
{
$baseurl = \Scalr::config('scalr.endpoint.scheme') . "://" . \Scalr::config('scalr.endpoint.host');
$env = $dbServer->GetEnvironmentObject();
$azure = $env->azure();
$branch = $dbServer->getScalarizrRepository()['repository'];
$develRepos = \Scalr::getContainer()->config->get('scalr.scalarizr_update.devel_repos');
$scmBranch = $dbServer->GetFarmRoleObject()->GetSetting('user-data.scm_branch');
if ($scmBranch != '' && $develRepos) {
$branch = $dbServer->GetFarmRoleObject()->GetSetting('base.devel_repository');
$scmBranch = "{$scmBranch}/";
} else {
$scmBranch = '';
}
if ($dbServer->osType == 'linux') {
$extensionProperties = new ResourceExtensionProperties('Microsoft.OSTCExtensions', 'CustomScriptForLinux', '1.2');
$extensionProperties->setSettings(['commandToExecute' => "bash -c 'curl -k -L \"{$baseurl}/public/linux/{$branch}/azure/{$scmBranch}install_scalarizr.sh\" | bash && service scalr-upd-client start'"]);
} else {
$extensionProperties = new ResourceExtensionProperties('Microsoft.Compute', 'CustomScriptExtension', '1.4');
$extensionProperties->setSettings(["commandToExecute" => "powershell -NoProfile -ExecutionPolicy Bypass -Command \"iex ((new-object net.webclient).DownloadString('{$baseurl}/public/windows/{$branch}/{$scmBranch}install_scalarizr.ps1')); start-service ScalrUpdClient\""]);
}
$createExtension = new CreateResourceExtension('scalarizr', $dbServer->cloudLocation, $extensionProperties);
try {
$response = $azure->compute->resourceExtension->create($env->keychain(SERVER_PLATFORMS::AZURE)->properties[Entity\CloudCredentialsProperty::AZURE_SUBSCRIPTION_ID], $dbServer->GetProperty(\AZURE_SERVER_PROPERTIES::RESOURCE_GROUP), $dbServer->GetProperty(\AZURE_SERVER_PROPERTIES::SERVER_NAME), $createExtension);
\Scalr::getContainer()->logger(\LOG_CATEGORY::FARM)->info(new \FarmLogMessage($dbServer, sprintf(_("Created azure resource extension to install and launch scalr agent"))));
$dbServer->SetProperty(\AZURE_SERVER_PROPERTIES::SZR_EXTENSION_DEPLOYED, 1);
} catch (\Exception $e) {
\Scalr::getContainer()->logger(\LOG_CATEGORY::FARM)->fatal(new \FarmLogMessage($dbServer, sprintf(_("Unable to create azure resource extension to install and launch scalr agent: %s"), $e->getMessage())));
}
}
示例5: TerminateServer
/**
* {@inheritdoc}
* @see \Scalr\Modules\Platforms\Cloudstack\CloudstackPlatformModule::TerminateServer()
*/
public function TerminateServer(\DBServer $DBServer)
{
$cs = $DBServer->GetEnvironmentObject()->cloudstack($this->platform);
if (!$DBServer->GetProperty(\CLOUDSTACK_SERVER_PROPERTIES::IS_STOPPED_BEFORE_TERMINATE)) {
$cs->instance->stop($DBServer->GetProperty(\CLOUDSTACK_SERVER_PROPERTIES::SERVER_ID), true);
$DBServer->SetProperty(\CLOUDSTACK_SERVER_PROPERTIES::IS_STOPPED_BEFORE_TERMINATE, 1);
}
return parent::TerminateServer($DBServer);
}
示例6: DeregisterInstanceFromLB
private function DeregisterInstanceFromLB(DBServer $DBServer)
{
try {
$DBFarmRole = $DBServer->GetFarmRoleObject();
if ($DBFarmRole->GetSetting(DBFarmRole::SETTING_BALANCING_USE_ELB) == 1) {
$Client = $DBServer->GetClient();
$AmazonELBClient = Scalr_Service_Cloud_Aws::newElb($DBServer->GetProperty(EC2_SERVER_PROPERTIES::REGION), $DBServer->GetEnvironmentObject()->getPlatformConfigValue(Modules_Platforms_Ec2::ACCESS_KEY), $DBServer->GetEnvironmentObject()->getPlatformConfigValue(Modules_Platforms_Ec2::SECRET_KEY));
$AmazonELBClient->DeregisterInstancesFromLoadBalancer($DBFarmRole->GetSetting(DBFarmRole::SETTING_BALANCING_NAME), array($DBServer->GetProperty(EC2_SERVER_PROPERTIES::INSTANCE_ID)));
Logger::getLogger(LOG_CATEGORY::FARM)->info(new FarmLogMessage($this->FarmID, sprintf(_("Instance '%s' deregistered from '%s' load balancer"), $DBServer->GetProperty(EC2_SERVER_PROPERTIES::INSTANCE_ID), $DBFarmRole->GetSetting(DBFarmRole::SETTING_BALANCING_NAME))));
}
} catch (Exception $e) {
Logger::getLogger(LOG_CATEGORY::FARM)->info(new FarmLogMessage($this->FarmID, sprintf(_("Cannot deregister instance from the load balancer: %s"), $e->getMessage())));
}
}
示例7: __construct
public function __construct(DBFarmRole $dbFarmRole, DBServer $dbServer, $type)
{
$this->dbFarmRole = $dbFarmRole;
$this->dbServer = $dbServer;
$this->logger = Logger::getLogger(__CLASS__);
$this->replicationMaster = (int) $dbServer->GetProperty(Scalr_Db_Msr::REPLICATION_MASTER);
$this->buildStorageSettings();
}
示例8: onHostDown
public function onHostDown(DBServer $dbServer)
{
$nodeName = $dbServer->GetProperty(self::SERVER_CHEF_NODENAME);
$config = $this->getConfiguration($dbServer);
if (!empty($nodeName) && isset($config->serverUrl)) {
$this->removeNodeFromChefServer($dbServer, $config, $nodeName);
$dbServer->SetProperty(self::SERVER_CHEF_NODENAME, "");
}
}
示例9: cleanupFloatingIps
private function cleanupFloatingIps(DBServer $dbServer)
{
try {
if ($dbServer->GetProperty(OPENSTACK_SERVER_PROPERTIES::FLOATING_IP)) {
$environment = $dbServer->GetEnvironmentObject();
$osClient = $environment->openstack($dbServer->platform, $dbServer->GetCloudLocation());
$ipId = $dbServer->GetProperty(OPENSTACK_SERVER_PROPERTIES::FLOATING_IP_ID);
if ($osClient->hasService('network')) {
$osClient->network->floatingIps->delete($ipId);
} else {
$osClient->servers->deleteFloatingIp($ipId);
}
$dbServer->SetProperties(array(OPENSTACK_SERVER_PROPERTIES::FLOATING_IP => null, OPENSTACK_SERVER_PROPERTIES::FLOATING_IP_ID => null));
}
} catch (Exception $e) {
Logger::getLogger("OpenStackObserver")->fatal("OpenStackObserver observer failed: " . $e->getMessage());
}
}
示例10: listDnsRecords
public function listDnsRecords(DBServer $dbServer)
{
$records = array();
array_push($records, array("name" => "int-rabbitmq", "value" => $dbServer->localIp, "type" => "A", "ttl" => 90, "server_id" => $dbServer->serverId, "issystem" => '1'));
array_push($records, array("name" => "ext-rabbitmq", "value" => $dbServer->remoteIp, "type" => "A", "ttl" => 90, "server_id" => $dbServer->serverId, "issystem" => '1'));
$nodeType = $dbServer->GetProperty(self::SERVER_NODE_TYPE);
array_push($records, array("name" => "int-rabbitmq-{$nodeType}", "value" => $dbServer->localIp, "type" => "A", "ttl" => 90, "server_id" => $dbServer->serverId, "issystem" => '1'));
array_push($records, array("name" => "ext-rabbitmq-{$nodeType}", "value" => $dbServer->remoteIp, "type" => "A", "ttl" => 90, "server_id" => $dbServer->serverId, "issystem" => '1'));
}
示例11: setConfig
private function setConfig(DBServer $dbServer, $behavior, $config)
{
$port = $dbServer->GetProperty(SERVER_PROPERTIES::SZR_API_PORT);
if (!$port) {
$port = 8010;
}
$client = Scalr_Net_Scalarizr_Client::getClient($dbServer, Scalr_Net_Scalarizr_Client::NAMESPACE_SERVICE, $port);
$result = $client->setPreset($behavior, $config);
return $result->result;
}
示例12: getDbStorageStatus
private function getDbStorageStatus(DBServer $masterServer, $behavior)
{
// Get Stoarge usage
$size = array('total' => -1, 'used' => -1, 'free' => -1);
try {
$port = $masterServer->GetProperty(SERVER_PROPERTIES::SZR_API_PORT);
if (!$port) {
$port = 8010;
}
$client = Scalr_Net_Scalarizr_Client::getClient($masterServer, Scalr_Net_Scalarizr_Client::NAMESPACE_SYSTEM, $port);
if ($behavior == ROLE_BEHAVIORS::REDIS) {
$mpoint = '/mnt/redisstorage';
} elseif ($behavior == ROLE_BEHAVIORS::POSTGRESQL) {
$mpoint = '/mnt/pgstorage';
} else {
$mpoint = '/mnt/dbstorage';
}
$usage = (array) $client->statvfs(array($mpoint));
$size = (array) $usage[$mpoint];
if ($size['total']) {
$size['used'] = $size['total'] - $size['free'];
// Convert KB to GB
foreach ($size as $k => $v) {
$size[$k] = round($v / 1024 / 1024, 2);
}
}
} catch (Exception $e) {
$this->response->varDump($e->getMessage());
}
$retval = array('engine' => $masterServer->GetFarmRoleObject()->GetSetting(Scalr_Db_Msr::DATA_STORAGE_ENGINE), 'id' => $masterServer->GetFarmRoleObject()->GetSetting(Scalr_Db_Msr::VOLUME_ID) ? $masterServer->GetFarmRoleObject()->GetSetting(Scalr_Db_Msr::VOLUME_ID) : '', 'fs' => $masterServer->GetFarmRoleObject()->GetSetting(Scalr_Db_Msr::DATA_STORAGE_FSTYPE), 'size' => $size);
$retval['growSupported'] = in_array($retval['engine'], array(MYSQL_STORAGE_ENGINE::EBS, MYSQL_STORAGE_ENGINE::RAID_EBS)) && in_array($behavior, array(ROLE_BEHAVIORS::MYSQL2, ROLE_BEHAVIORS::PERCONA, ROLE_BEHAVIORS::MARIADB));
switch ($retval['engine']) {
case MYSQL_STORAGE_ENGINE::EBS:
$retval['engineName'] = 'Single EBS volume';
break;
case MYSQL_STORAGE_ENGINE::RAID_EBS:
$retval['engineName'] = sprintf('RAID %s on %s EBS volumes', $masterServer->GetFarmRoleObject()->GetSetting(Scalr_Db_Msr::DATA_STORAGE_RAID_LEVEL), $masterServer->GetFarmRoleObject()->GetSetting(Scalr_Db_Msr::DATA_STORAGE_RAID_DISKS_COUNT));
break;
case MYSQL_STORAGE_ENGINE::LVM:
$retval['engineName'] = 'LVM on ephemeral device(s)';
break;
case MYSQL_STORAGE_ENGINE::EPH:
$retval['engineName'] = 'Ephemeral device';
break;
case MYSQL_STORAGE_ENGINE::CSVOL:
$retval['engineName'] = 'Single Cloudstack volume';
break;
default:
$retval['engineName'] = $retval['engine'];
break;
}
return $retval;
}
示例13: openstackSetFloatingIp
private function openstackSetFloatingIp(DBServer $DBServer)
{
$ipPool = $DBServer->GetFarmRoleObject()->GetSetting(DBFarmRole::SETTING_OPENSTACK_IP_POOL);
if (!$DBServer->remoteIp && in_array($DBServer->status, array(SERVER_STATUS::PENDING, SERVER_STATUS::INIT, SERVER_STATUS::SUSPENDED)) && $ipPool) {
//$ipAddress = \Scalr\Modules\Platforms\Openstack\Helpers\OpenstackHelper::setFloatingIpForServer($DBServer);
$osClient = $DBServer->GetEnvironmentObject()->openstack($DBServer->platform, $DBServer->GetProperty(OPENSTACK_SERVER_PROPERTIES::CLOUD_LOCATION));
if ($osClient->hasService('network')) {
$platform = PlatformFactory::NewPlatform($DBServer->platform);
$serverIps = $platform->GetServerIPAddresses($DBServer);
/********* USE Quantum (Neuron) NETWORK *******/
$ips = $osClient->network->floatingIps->list();
//Check free existing IP
$ipAssigned = false;
$ipAddress = false;
$ipInfo = false;
foreach ($ips as $ip) {
if ($ip->fixed_ip_address == $serverIps['localIp'] && $ip->port_id) {
$ipAssigned = true;
$ipInfo = $ip;
break;
}
if (!$ip->fixed_ip_address && $ip->floating_ip_address && !$ip->port_id) {
$ipInfo = $ip;
}
}
if ($ipInfo) {
Logger::getLogger("Openstack")->warn(new FarmLogMessage($DBServer->farmId, "Found free floating IP: {$ipInfo->floating_ip_address} for use (" . json_encode($ipInfo) . ")"));
}
if (!$ipInfo || !$ipAssigned) {
// Get instance port
$ports = $osClient->network->ports->list();
foreach ($ports as $port) {
/* */
if ($port->device_id == $DBServer->GetProperty(OPENSTACK_SERVER_PROPERTIES::SERVER_ID)) {
$serverNetworkPort[] = $port;
}
}
if (count($serverNetworkPort) == 0) {
Logger::getLogger("Openstack")->error(new FarmLogMessage($DBServer->farmId, "Unable to identify network port of instance"));
} else {
$publicNetworkId = $ipPool;
while (count($serverNetworkPort) > 0) {
try {
$port = array_shift($serverNetworkPort);
if (!$ipInfo) {
$ipInfo = $osClient->network->floatingIps->create($publicNetworkId, $port->id);
Logger::getLogger("Openstack")->warn(new FarmLogMessage($DBServer->farmId, "Allocated new IP {$ipInfo->floating_ip_address} for port: {$port->id}"));
} else {
$osClient->network->floatingIps->update($ipInfo->id, $port->id);
Logger::getLogger("Openstack")->warn(new FarmLogMessage($DBServer->farmId, "Existing floating IP {$ipInfo->floating_ip_address} was used for port: {$port->id}"));
}
$DBServer->SetProperties(array(OPENSTACK_SERVER_PROPERTIES::FLOATING_IP => $ipInfo->floating_ip_address, OPENSTACK_SERVER_PROPERTIES::FLOATING_IP_ID => $ipInfo->id));
$ipAddress = $ipInfo->floating_ip_address;
break;
} catch (Exception $e) {
$this->logger->error("Scalr unable to allocate new floating IP from pool: " . $e->getMessage());
}
}
}
} else {
Logger::getLogger("Openstack")->warn(new FarmLogMessage($DBServer->farmId, "IP: {$ipInfo->floating_ip_address} already assigned"));
$ipAddress = $ipInfo->floating_ip_address;
}
} else {
/********* USE NOVA NETWORK *******/
//Check free existing IP
$ipAssigned = false;
$ipAddress = false;
$ips = $osClient->servers->floatingIps->list($ipPool);
foreach ($ips as $ip) {
//if (!$ip->instance_id) {
// $ipAddress = $ip->ip;
//}
if ($ip->instance_id == $DBServer->GetProperty(OPENSTACK_SERVER_PROPERTIES::SERVER_ID)) {
$ipAddress = $ip->ip;
$ipAssigned = true;
}
}
//If no free IP allocate new from pool
if (!$ipAddress) {
$ip = $osClient->servers->floatingIps->create($ipPool);
$ipAddress = $ip->ip;
$DBServer->SetProperties(array(OPENSTACK_SERVER_PROPERTIES::FLOATING_IP => $ip->ip, OPENSTACK_SERVER_PROPERTIES::FLOATING_IP_ID => $ip->id));
}
if (!$ipAssigned) {
//Associate floating IP with Instance
$osClient->servers->addFloatingIp($DBServer->GetCloudServerID(), $ipAddress);
}
}
if ($ipAddress) {
$DBServer->remoteIp = $ipAddress;
$DBServer->Save();
$DBServer->SetProperty(SERVER_PROPERTIES::SYSTEM_IGNORE_INBOUND_MESSAGES, null);
}
}
}
示例14: PutAccessData
public function PutAccessData(DBServer $DBServer, Scalr_Messaging_Msg $message)
{
$put = false;
$put |= $message instanceof Scalr_Messaging_Msg_Rebundle;
$put |= $message instanceof Scalr_Messaging_Msg_HostInitResponse;
$put |= $message instanceof Scalr_Messaging_Msg_Mysql_PromoteToMaster;
$put |= $message instanceof Scalr_Messaging_Msg_Mysql_NewMasterUp;
$put |= $message instanceof Scalr_Messaging_Msg_Mysql_CreateDataBundle;
$put |= $message instanceof Scalr_Messaging_Msg_Mysql_CreateBackup;
$put |= $message instanceof Scalr_Messaging_Msg_DbMsr_PromoteToMaster;
$put |= $message instanceof Scalr_Messaging_Msg_DbMsr_CreateDataBundle;
$put |= $message instanceof Scalr_Messaging_Msg_DbMsr_CreateBackup;
if ($put) {
$environment = $DBServer->GetEnvironmentObject();
$accessData = new stdClass();
$accessData->username = $environment->getPlatformConfigValue(self::USERNAME, true, $DBServer->GetProperty(OPENSTACK_SERVER_PROPERTIES::CLOUD_LOCATION));
$accessData->password = $environment->getPlatformConfigValue(self::API_KEY, true, $DBServer->GetProperty(OPENSTACK_SERVER_PROPERTIES::CLOUD_LOCATION));
$accessData->authUrl = $environment->getPlatformConfigValue(self::API_URL, true, $DBServer->GetProperty(OPENSTACK_SERVER_PROPERTIES::CLOUD_LOCATION));
$accessData->projectId = $environment->getPlatformConfigValue(self::PROJECT_NAME, true, $DBServer->GetProperty(OPENSTACK_SERVER_PROPERTIES::CLOUD_LOCATION));
$accessData->cloudLocation = $DBServer->GetProperty(OPENSTACK_SERVER_PROPERTIES::CLOUD_LOCATION);
$message->platformAccessData = $accessData;
}
}
示例15: PutAccessData
public function PutAccessData(DBServer $DBServer, Scalr_Messaging_Msg $message)
{
$put = false;
$put |= $message instanceof Scalr_Messaging_Msg_Rebundle;
$put |= $message instanceof Scalr_Messaging_Msg_HostInitResponse;
$put |= $message instanceof Scalr_Messaging_Msg_Mysql_PromoteToMaster;
$put |= $message instanceof Scalr_Messaging_Msg_Mysql_NewMasterUp;
$put |= $message instanceof Scalr_Messaging_Msg_Mysql_CreateDataBundle;
$put |= $message instanceof Scalr_Messaging_Msg_Mysql_CreateBackup;
$put |= $message instanceof Scalr_Messaging_Msg_DbMsr_PromoteToMaster;
$put |= $message instanceof Scalr_Messaging_Msg_DbMsr_CreateDataBundle;
$put |= $message instanceof Scalr_Messaging_Msg_DbMsr_CreateBackup;
if ($put) {
$environment = $DBServer->GetEnvironmentObject();
$accessData = new stdClass();
$accessData->username = $environment->getPlatformConfigValue(self::USERNAME, true, $DBServer->GetProperty(RACKSPACE_SERVER_PROPERTIES::DATACENTER));
$accessData->apiKey = $environment->getPlatformConfigValue(self::API_KEY, true, $DBServer->GetProperty(RACKSPACE_SERVER_PROPERTIES::DATACENTER));
switch ($DBServer->GetProperty(RACKSPACE_SERVER_PROPERTIES::DATACENTER)) {
case 'rs-ORD1':
$accessData->authHost = 'auth.api.rackspacecloud.com';
break;
case 'rs-LONx':
$accessData->authHost = 'lon.auth.api.rackspacecloud.com';
break;
}
$message->platformAccessData = $accessData;
}
}