本文整理汇总了PHP中DBServer::GetEnvironmentObject方法的典型用法代码示例。如果您正苦于以下问题:PHP DBServer::GetEnvironmentObject方法的具体用法?PHP DBServer::GetEnvironmentObject怎么用?PHP DBServer::GetEnvironmentObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBServer
的用法示例。
在下文中一共展示了DBServer::GetEnvironmentObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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())));
}
}
示例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: 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());
}
}
示例5: 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_BeforeHostUp;
$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;
$put |= $message instanceof \Scalr_Messaging_Msg_DbMsr_NewMasterUp;
if ($put) {
$ccProps = $DBServer->GetEnvironmentObject()->keychain($DBServer->platform)->properties;
$accessData = new \stdClass();
$accessData->apiKey = $ccProps[CloudCredentialsProperty::CLOUDSTACK_API_KEY];
$accessData->secretKey = $ccProps[CloudCredentialsProperty::CLOUDSTACK_SECRET_KEY];
$apiUrl = $ccProps[CloudCredentialsProperty::CLOUDSTACK_API_URL];
if ($apiUrl == 'https://apis.i.noahcloud.jp/portal/client/api') {
$accessData->apiUrl = "https://api.noahcloud.jp/portal/client/api";
} else {
$accessData->apiUrl = $apiUrl;
}
$message->platformAccessData = $accessData;
}
}
示例6: 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())));
}
}
示例7: 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_BeforeHostUp;
$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;
$put |= $message instanceof \Scalr_Messaging_Msg_DbMsr_NewMasterUp;
if ($put) {
$environment = $DBServer->GetEnvironmentObject();
$accessData = new \stdClass();
$accessData->apiKey = $this->getConfigVariable(self::API_KEY, $environment);
$accessData->secretKey = $this->getConfigVariable(self::SECRET_KEY, $environment);
$apiUrl = $this->getConfigVariable(self::API_URL, $environment);
if ($apiUrl == 'https://apis.i.noahcloud.jp/portal/client/api') {
$accessData->apiUrl = "https://api.noahcloud.jp/portal/client/api";
} else {
$accessData->apiUrl = $apiUrl;
}
$message->platformAccessData = $accessData;
}
}
示例8: TerminateServer
public function TerminateServer(DBServer $DBServer)
{
$cs = $this->getCloudStackClient($DBServer->GetEnvironmentObject(), $this->GetServerCloudLocation($DBServer));
if (!$DBServer->GetProperty(CLOUDSTACK_SERVER_PROPERTIES::IS_STOPPED_BEFORE_TERMINATE)) {
$cs->stopVirtualMachine($DBServer->GetProperty(CLOUDSTACK_SERVER_PROPERTIES::SERVER_ID), true);
$DBServer->SetProperty(CLOUDSTACK_SERVER_PROPERTIES::IS_STOPPED_BEFORE_TERMINATE, 1);
}
return parent::TerminateServer($DBServer);
}
示例9: 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);
}
示例10: associateIpAddress
/**
* Associates IP Address to the server
*
* @param DBServer $dbServer DBServer object
* @param string $ipAddress Public IP address to associate with server.
* @throws Exception
*/
private static function associateIpAddress(DBServer $dbServer, $ipAddress, $allocationId = null)
{
$platform = PlatformFactory::NewPlatform($dbServer->platform);
$cs = Scalr_Service_Cloud_Cloudstack::newCloudstack($platform->getConfigVariable(Modules_Platforms_Cloudstack::API_URL, $dbServer->GetEnvironmentObject()), $platform->getConfigVariable(Modules_Platforms_Cloudstack::API_KEY, $dbServer->GetEnvironmentObject()), $platform->getConfigVariable(Modules_Platforms_Cloudstack::SECRET_KEY, $dbServer->GetEnvironmentObject()), $dbServer->platform);
$assign_retries = 1;
$retval = false;
// Remove OLD static NAT
if ($dbServer->remoteIp) {
try {
$info = $cs->listPublicIpAddresses(null, null, null, null, null, $dbServer->remoteIp);
$info = $info->publicipaddress[0];
if ($info->issystem && $info->isstaticnat) {
$cs->disableStaticNat($info->id);
}
} catch (Exception $e) {
Logger::getLogger('Cloudstack_Helper')->error("Unable to disable old static NAT: {$e->getMessage()}");
}
}
try {
$cs->disableStaticNat($allocationId);
} catch (Exception $e) {
}
$assignRetries = 0;
while (true) {
try {
$assignRetries++;
$cs->enableStaticNat($allocationId, $dbServer->GetCloudServerID());
$retval = true;
break;
} catch (Exception $e) {
if (!stristr($e->getMessage(), "already assigned to antoher vm") || $assignRetries == 3) {
throw new Exception($e->getMessage());
} else {
sleep(1);
}
}
//break;
}
return $retval;
}
示例11: 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());
}
}
示例12: listServerGlobalVariables
public static function listServerGlobalVariables(DBServer $dbServer, $includeSystem = false, AbstractServerEvent $event = null)
{
$retval = array();
if ($includeSystem) {
$variables = $dbServer->GetScriptingVars();
if ($event) {
if ($event->DBServer) {
foreach ($event->DBServer->GetScriptingVars() as $k => $v) {
$variables["event_{$k}"] = $v;
}
}
foreach ($event->GetScriptingVars() as $k => $v) {
$variables[$k] = $event->{$v};
}
if (isset($event->params) && is_array($event->params)) {
foreach ($event->params as $k => $v) {
$variables[$k] = $v;
}
}
$variables['event_name'] = $event->GetName();
}
$formats = \Scalr::config("scalr.system.global_variables.format");
foreach ($variables as $name => $value) {
$name = "SCALR_" . strtoupper($name);
$value = trim($value);
if (isset($formats[$name])) {
$value = @sprintf($formats[$name], $value);
}
$private = strpos($name, 'SCALR_EVENT_') === 0 ? 1 : 0;
$retval[] = (object) array('name' => $name, 'value' => $value, 'private' => $private, 'system' => 1);
}
}
try {
$globalVariables = new Scalr_Scripting_GlobalVariables($dbServer->GetEnvironmentObject()->clientId, $dbServer->envId, ScopeInterface::SCOPE_SERVER);
$vars = $globalVariables->listVariables($dbServer->GetFarmRoleObject()->RoleID, $dbServer->farmId, $dbServer->farmRoleId, $dbServer->serverId);
foreach ($vars as $v) {
$retval[] = (object) $v;
}
} catch (Exception $e) {
}
return $retval;
}
示例13: 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;
}
}
示例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(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;
}
}
示例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_BeforeHostUp;
$put |= $message instanceof Scalr_Messaging_Msg_HostInitResponse;
$put |= $message instanceof Scalr_Messaging_Msg_Mysql_PromoteToMaster;
$put |= $message instanceof Scalr_Messaging_Msg_Mysql_CreateDataBundle;
$put |= $message instanceof Scalr_Messaging_Msg_Mysql_CreateBackup;
$put |= $message instanceof Scalr_Messaging_Msg_BeforeHostTerminate;
$put |= $message instanceof Scalr_Messaging_Msg_DbMsr_PromoteToMaster;
$put |= $message instanceof Scalr_Messaging_Msg_DbMsr_CreateDataBundle;
$put |= $message instanceof Scalr_Messaging_Msg_DbMsr_CreateBackup;
$put |= $message instanceof Scalr_Messaging_Msg_DbMsr_NewMasterUp;
if ($put) {
$environment = $DBServer->GetEnvironmentObject();
$message->platformAccessData = $this->GetPlatformAccessData($environment, $DBServer);
}
}