当前位置: 首页>>代码示例>>PHP>>正文


PHP DBServer::isCloudstack方法代码示例

本文整理汇总了PHP中DBServer::isCloudstack方法的典型用法代码示例。如果您正苦于以下问题:PHP DBServer::isCloudstack方法的具体用法?PHP DBServer::isCloudstack怎么用?PHP DBServer::isCloudstack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBServer的用法示例。


在下文中一共展示了DBServer::isCloudstack方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onHostInit

 private function onHostInit($message, DBServer $dbserver)
 {
     if ($dbserver->status == SERVER_STATUS::PENDING) {
         $platform = PlatformFactory::NewPlatform($dbserver->platform);
         // 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;
         }
         $srv_props[SERVER_PROPERTIES::SZR_SNMP_PORT] = $message->snmpPort;
         if ($dbserver->isCloudstack()) {
             $ips = $platform->GetServerIPAddresses($dbserver);
             if ($ips['remoteIp']) {
                 $remoteIp = $ips['remoteIp'];
                 $dbserver->GetFarmRoleObject()->SetSetting(DBFarmRole::SETTING_CLOUDSTACK_NETWORK_TYPE, 'Direct', DBFarmRole::TYPE_LCL);
             } else {
                 if ($dbserver->farmRoleId) {
                     $dbFarmRole = $dbserver->GetFarmRoleObject();
                     $networkType = $dbFarmRole->GetSetting(DBFarmRole::SETTING_CLOUDSTACK_NETWORK_TYPE);
                     if ($networkType == 'Direct') {
                         $remoteIp = $message->localIp;
                     } else {
                         $useStaticNat = $dbFarmRole->GetSetting(DBFarmRole::SETIING_CLOUDSTACK_USE_STATIC_NAT);
                         if (!$useStaticNat) {
                             $sharedIp = $dbFarmRole->GetSetting(DBFarmRole::SETTING_CLOUDSTACK_SHARED_IP_ADDRESS);
                             if (!$sharedIp) {
                                 $env = $dbserver->GetEnvironmentObject();
                                 $remoteIp = $platform->getConfigVariable(CloudstackPlatformModule::SHARED_IP . "." . $dbserver->GetProperty(CLOUDSTACK_SERVER_PROPERTIES::CLOUD_LOCATION), $env, false);
                             } else {
                                 $remoteIp = $sharedIp;
                             }
                         }
                     }
                 }
             }
         }
         if ($dbserver->isOpenstack()) {
             if ($dbserver->farmRoleId) {
                 $ipPool = $dbserver->GetFarmRoleObject()->GetSetting(DBFarmRole::SETTING_OPENSTACK_IP_POOL);
                 if ($ipPool && empty($dbserver->remoteIp)) {
                     return false;
                 } else {
                     $remoteIp = $dbserver->remoteIp;
                 }
             }
         }
         if (!$remoteIp) {
             $ips = $platform->GetServerIPAddresses($dbserver);
             if ($ips['remoteIp']) {
                 $remoteIp = $ips['remoteIp'];
             } else {
                 $remoteIp = $message->remoteIp ? $ips['remoteIp'] : '';
             }
         }
         $dbserver->remoteIp = $remoteIp;
         $dbserver->Save();
         //Update auto-update settings
         //TODO: Check auto-update client version
         if ($dbserver->IsSupported('0.7.225') && !$dbserver->IsSupported('2.7.10')) {
             $dbserver->SetProperties($srv_props);
             try {
                 $repo = $dbserver->GetFarmRoleObject()->GetSetting(Scalr_Role_Behavior::ROLE_BASE_SZR_UPD_REPOSITORY);
                 if (!$repo) {
                     $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, DBFarmRole::TYPE_LCL);
                 $srv_props[Scalr_Db_Msr::REPLICATION_MASTER] = 1;
//.........这里部分代码省略.........
开发者ID:rickb838,项目名称:scalr,代码行数:101,代码来源:ScalarizrMessaging.php


注:本文中的DBServer::isCloudstack方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。