DBFarmRole::GetRoleObject PHP Method

GetRoleObject() public method

public GetRoleObject ( ) : DBRole
return DBRole
    public function GetRoleObject()
    {
        if (!$this->dbRole) {
            $this->dbRole = DBRole::loadById($this->RoleID);
        }
        return $this->dbRole;
    }

Usage Example

コード例 #1
0
ファイル: Info.php プロジェクト: rickb838/scalr
 public function setMsrSettings($settings)
 {
     if ($settings->volumeConfig) {
         try {
             $storageVolume = Scalr_Storage_Volume::init();
             try {
                 $storageVolume->loadById($settings->volumeConfig->id);
                 $storageVolume->setConfig($settings->volumeConfig);
                 $storageVolume->save();
             } catch (Exception $e) {
                 if (strpos($e->getMessage(), 'not found')) {
                     $storageVolume->loadBy(array('id' => $settings->volumeConfig->id, 'client_id' => $this->dbServer->clientId, 'env_id' => $this->dbServer->envId, 'name' => "'{$this->databaseType}' data volume", 'type' => $this->dbFarmRole->GetSetting(Scalr_Db_Msr::DATA_STORAGE_ENGINE), 'platform' => $this->dbServer->platform, 'size' => $settings->volumeConfig->size, 'fstype' => $settings->volumeConfig->fstype, 'purpose' => $this->databaseType, 'farm_roleid' => $this->dbFarmRole->ID, 'server_index' => $this->dbServer->index));
                     $storageVolume->setConfig($settings->volumeConfig);
                     $storageVolume->save(true);
                 } else {
                     throw $e;
                 }
             }
             $this->dbFarmRole->SetSetting(Scalr_Db_Msr::VOLUME_ID, $storageVolume->id, DBFarmRole::TYPE_LCL);
         } catch (Exception $e) {
             $this->logger->error(new FarmLogMessage($this->dbServer->farmId, "Cannot save storage volume: {$e->getMessage()}"));
         }
     }
     if ($settings->snapshotConfig) {
         try {
             $storageSnapshot = Scalr_Model::init(Scalr_Model::STORAGE_SNAPSHOT);
             try {
                 $storageSnapshot->loadById($settings->snapshotConfig->id);
                 $storageSnapshot->setConfig($settings->snapshotConfig);
                 $storageSnapshot->save();
             } catch (Exception $e) {
                 if (strpos($e->getMessage(), 'not found')) {
                     $storageSnapshot->loadBy(array('id' => $settings->snapshotConfig->id, 'client_id' => $this->dbServer->clientId, 'farm_id' => $this->dbServer->farmId, 'farm_roleid' => $this->dbServer->farmRoleId, 'env_id' => $this->dbServer->envId, 'name' => sprintf(_("'{$this->databaseType}' data bundle #%s"), $settings->snapshotConfig->id), 'type' => $this->dbFarmRole->GetSetting(Scalr_Db_Msr::DATA_STORAGE_ENGINE), 'platform' => $this->dbServer->platform, 'description' => sprintf(_("'{$this->databaseType}' data bundle created on Farm '%s' -> Role '%s'"), $this->dbFarmRole->GetFarmObject()->name, $this->dbFarmRole->GetRoleObject()->name), 'service' => $this->databaseType));
                     $storageSnapshot->setConfig($settings->snapshotConfig);
                     $storageSnapshot->save(true);
                 } else {
                     throw $e;
                 }
             }
             $this->dbFarmRole->SetSetting(Scalr_Db_Msr::SNAPSHOT_ID, $storageSnapshot->id, DBFarmRole::TYPE_LCL);
         } catch (Exception $e) {
             $this->logger->error(new FarmLogMessage($event->DBServer->farmId, "Cannot save storage snapshot: {$e->getMessage()}"));
         }
     }
 }
All Usage Examples Of DBFarmRole::GetRoleObject