本文整理汇总了PHP中DBServer::SetProperties方法的典型用法代码示例。如果您正苦于以下问题:PHP DBServer::SetProperties方法的具体用法?PHP DBServer::SetProperties怎么用?PHP DBServer::SetProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBServer
的用法示例。
在下文中一共展示了DBServer::SetProperties方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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());
}
}
示例3: onHostInit
private function onHostInit($message, DBServer $dbserver)
{
if ($dbserver->status == SERVER_STATUS::PENDING) {
// Update server crypto key
$srv_props = array();
if ($message->cryptoKey) {
$srv_props[SERVER_PROPERTIES::SZR_KEY] = trim($message->cryptoKey);
$srv_props[SERVER_PROPERTIES::SZR_KEY_TYPE] = SZR_KEY_TYPE::PERMANENT;
}
if ($dbserver->platform != SERVER_PLATFORMS::CLOUDSTACK) {
$srv_props[SERVER_PROPERTIES::SZR_SNMP_PORT] = $message->snmpPort;
$remoteIp = $message->remoteIp;
} else {
if ($dbserver->farmRoleId) {
$dbFarmRole = $dbserver->GetFarmRoleObject();
$networkType = $dbFarmRole->GetSetting(DBFarmRole::SETTING_CLOUDSTACK_NETWORK_TYPE);
if ($networkType == 'Direct') {
$remoteIp = $message->localIp;
$srv_props[SERVER_PROPERTIES::SZR_SNMP_PORT] = $message->snmpPort;
} else {
$env = $dbserver->GetEnvironmentObject();
$remoteIp = $env->getPlatformConfigValue(Modules_Platforms_Cloudstack::SHARED_IP . "." . $dbserver->GetProperty(CLOUDSTACK_SERVER_PROPERTIES::CLOUD_LOCATION), false);
}
} else {
$remoteIp = $message->localIp;
$srv_props[SERVER_PROPERTIES::SZR_SNMP_PORT] = $message->snmpPort;
}
}
//Update auto-update settings
//TODO: Check auto-update client version
if ($dbserver->IsSupported('0.7.225')) {
$dbserver->SetProperties($srv_props);
try {
$repo = $dbserver->GetFarmObject()->GetSetting(DBFarm::SETTING_SZR_UPD_REPOSITORY);
$schedule = $dbserver->GetFarmObject()->GetSetting(DBFarm::SETTING_SZR_UPD_SCHEDULE);
if ($repo && $schedule) {
$updateClient = new Scalr_Net_Scalarizr_UpdateClient($dbserver);
$updateClient->configure($repo, $schedule);
}
} catch (Exception $e) {
}
}
// MySQL specific
$dbFarmRole = $dbserver->GetFarmRoleObject();
if ($dbFarmRole->GetRoleObject()->hasBehavior(ROLE_BEHAVIORS::MYSQL)) {
$master = $dbFarmRole->GetFarmObject()->GetMySQLInstances(true);
// If no masters in role this server becomes it
if (!$master[0] && !(int) $dbFarmRole->GetSetting(DbFarmRole::SETTING_MYSQL_SLAVE_TO_MASTER)) {
$srv_props[SERVER_PROPERTIES::DB_MYSQL_MASTER] = 1;
}
}
//MSR Replication Master
//TODO: MySQL
if ($dbFarmRole->GetRoleObject()->getDbMsrBehavior()) {
$servers = $dbFarmRole->GetServersByFilter(array('status' => array(SERVER_STATUS::INIT, SERVER_STATUS::RUNNING)));
if (!$dbFarmRole->GetSetting(Scalr_Db_Msr::SLAVE_TO_MASTER)) {
$masterFound = false;
foreach ($servers as $server) {
if ($server->GetProperty(Scalr_Db_Msr::REPLICATION_MASTER)) {
$masterFound = true;
}
}
if (!$masterFound) {
$srv_props[Scalr_Db_Msr::REPLICATION_MASTER] = 1;
}
} elseif ($dbFarmRole->GetSetting(Scalr_Db_Msr::SLAVE_TO_MASTER) && count($servers) == 0) {
$dbFarmRole->SetSetting(Scalr_Db_Msr::SLAVE_TO_MASTER, 0);
$srv_props[Scalr_Db_Msr::REPLICATION_MASTER] = 1;
}
}
$dbserver->SetProperties($srv_props);
return new HostInitEvent($dbserver, $message->localIp, $remoteIp, $message->sshPubKey);
} else {
$this->logger->error("Strange situation. Received HostInit message" . " from server '{$dbserver->serverId}' ({$message->remoteIp})" . " with state {$dbserver->status}!");
}
}
示例4: onHello
private function onHello($message, DBServer $dbserver)
{
if ($dbserver->status == SERVER_STATUS::TEMPORARY) {
$bundleTask = BundleTask::LoadById($dbserver->GetProperty(SERVER_PROPERTIES::SZR_IMPORTING_BUNDLE_TASK_ID));
$bundleTask->status = SERVER_SNAPSHOT_CREATION_STATUS::PENDING;
$bundleTask->Log("Received Hello message from scalarizr on server. Creating image");
$bundleTask->osFamily = $message->dist->distributor;
$bundleTask->osName = $message->dist->codename;
$bundleTask->osVersion = $message->dist->release;
if (in_array($message->dist->distributor, array('redhat', 'oel', 'scientific')) && $dbserver->platform == SERVER_PLATFORMS::EC2) {
$bundleTask->bundleType = SERVER_SNAPSHOT_CREATION_TYPE::EC2_EBS_HVM;
}
$bundleTask->save();
}
if ($dbserver->status == SERVER_STATUS::IMPORTING) {
if (!$dbserver->remoteIp || !$dbserver->localIp) {
if (!$dbserver->remoteIp && $message->remoteIp && $dbserver->platform != SERVER_PLATFORMS::IDCF) {
$dbserver->remoteIp = $message->remoteIp;
}
if (!$dbserver->localIp && $message->localIp) {
$dbserver->localIp = $message->localIp;
}
if (!$message->behaviour) {
$message->behaviour = array('base');
}
if ((!$dbserver->remoteIp || $dbserver->localIp == $dbserver->remoteIp) && $message->messageIpAddress != $dbserver->remoteIp) {
$dbserver->remoteIp = $message->messageIpAddress;
}
}
if (count($message->behaviour) == 1 && $message->behaviour[0] == ROLE_BEHAVIORS::CHEF) {
$message->behaviour[] = ROLE_BEHAVIORS::BASE;
}
$dbserver->SetProperty(SERVER_PROPERTIES::SZR_IMPORTING_BEHAVIOR, @implode(",", $message->behaviour));
$dbserver->save();
$importVersion = $dbserver->GetProperty(SERVER_PROPERTIES::SZR_IMPORTING_VERSION);
if ($importVersion == 2) {
$dbserver->SetProperties(array(SERVER_PROPERTIES::ARCHITECTURE => $message->architecture));
} else {
if ($dbserver->isOpenstack()) {
$env = $dbserver->GetEnvironmentObject();
$os = $env->openstack($dbserver->platform, $dbserver->GetProperty(OPENSTACK_SERVER_PROPERTIES::CLOUD_LOCATION));
$csServer = null;
$list = $os->servers->list(true);
do {
foreach ($list as $_tmp) {
$ipaddresses = array();
if (!is_array($_tmp->addresses)) {
$_tmp->addresses = (array) $_tmp->addresses;
}
foreach ($_tmp->addresses as $net => $addresses) {
foreach ($addresses as $addr) {
if ($addr->version == 4) {
array_push($ipaddresses, $addr->addr);
}
}
}
if ($_tmp->accessIPv4) {
array_push($ipaddresses, $_tmp->accessIPv4);
}
if (in_array($dbserver->localIp, $ipaddresses) || in_array($dbserver->remoteIp, $ipaddresses)) {
$osServer = $_tmp;
}
}
} while (false !== ($list = $list->getNextPage()));
if (!$osServer) {
$this->logger->error(sprintf("Server not found on Openstack (server_id: %s, remote_ip: %s, local_ip: %s)", $dbserver->serverId, $dbserver->remoteIp, $dbserver->localIp));
return;
}
$dbserver->SetProperties(array(OPENSTACK_SERVER_PROPERTIES::SERVER_ID => $osServer->id, OPENSTACK_SERVER_PROPERTIES::NAME => $osServer->name, OPENSTACK_SERVER_PROPERTIES::IMAGE_ID => $osServer->image->id, OPENSTACK_SERVER_PROPERTIES::FLAVOR_ID => $osServer->flavor->id, OPENSTACK_SERVER_PROPERTIES::HOST_ID => $osServer->hostId, SERVER_PROPERTIES::ARCHITECTURE => $message->architecture));
} elseif ($dbserver->isCloudstack()) {
$dbserver->SetProperties(array(CLOUDSTACK_SERVER_PROPERTIES::SERVER_ID => $message->cloudstack->instanceId, CLOUDSTACK_SERVER_PROPERTIES::CLOUD_LOCATION => $message->cloudstack->availZone, SERVER_PROPERTIES::ARCHITECTURE => $message->architecture));
} else {
switch ($dbserver->platform) {
case SERVER_PLATFORMS::EC2:
$dbserver->SetProperties(array(EC2_SERVER_PROPERTIES::AMIID => $message->awsAmiId, EC2_SERVER_PROPERTIES::INSTANCE_ID => $message->awsInstanceId, EC2_SERVER_PROPERTIES::INSTANCE_TYPE => $message->awsInstanceType, EC2_SERVER_PROPERTIES::AVAIL_ZONE => $message->awsAvailZone, EC2_SERVER_PROPERTIES::REGION => substr($message->awsAvailZone, 0, -1), SERVER_PROPERTIES::ARCHITECTURE => $message->architecture));
break;
case SERVER_PLATFORMS::EUCALYPTUS:
$dbserver->SetProperties(array(EUCA_SERVER_PROPERTIES::EMIID => $message->awsAmiId, EUCA_SERVER_PROPERTIES::INSTANCE_ID => $message->awsInstanceId, EUCA_SERVER_PROPERTIES::INSTANCE_TYPE => $message->awsInstanceType, EUCA_SERVER_PROPERTIES::AVAIL_ZONE => $message->awsAvailZone, SERVER_PROPERTIES::ARCHITECTURE => $message->architecture));
break;
case SERVER_PLATFORMS::GCE:
$dbserver->SetProperties(array(GCE_SERVER_PROPERTIES::CLOUD_LOCATION => $message->{$dbserver->platform}->cloudLocation, GCE_SERVER_PROPERTIES::SERVER_ID => $message->{$dbserver->platform}->serverId, GCE_SERVER_PROPERTIES::SERVER_NAME => $message->{$dbserver->platform}->serverName, GCE_SERVER_PROPERTIES::MACHINE_TYPE => $message->{$dbserver->platform}->machineType, SERVER_PROPERTIES::ARCHITECTURE => $message->architecture));
break;
case SERVER_PLATFORMS::NIMBULA:
$dbserver->SetProperties(array(NIMBULA_SERVER_PROPERTIES::NAME => $message->serverName, SERVER_PROPERTIES::ARCHITECTURE => $message->architecture));
break;
case SERVER_PLATFORMS::RACKSPACE:
$env = $dbserver->GetEnvironmentObject();
$cs = Scalr_Service_Cloud_Rackspace::newRackspaceCS($env->getPlatformConfigValue(RackspacePlatformModule::USERNAME, true, $dbserver->GetProperty(RACKSPACE_SERVER_PROPERTIES::DATACENTER)), $env->getPlatformConfigValue(RackspacePlatformModule::API_KEY, true, $dbserver->GetProperty(RACKSPACE_SERVER_PROPERTIES::DATACENTER)), $dbserver->GetProperty(RACKSPACE_SERVER_PROPERTIES::DATACENTER));
$csServer = null;
$list = $cs->listServers(true);
if ($list) {
foreach ($list->servers as $_tmp) {
if ($_tmp->addresses->public && in_array($message->remoteIp, $_tmp->addresses->public)) {
$csServer = $_tmp;
}
}
}
if (!$csServer) {
$this->logger->error(sprintf("Server not found on CloudServers (server_id: %s, remote_ip: %s, local_ip: %s)", $dbserver->serverId, $message->remoteIp, $message->localIp));
return;
//.........这里部分代码省略.........