public function getBaseConfiguration(DBServer $dbServer, $isHostInit = false, $onlyBase = false)
{
$configuration = new stdClass();
$dbFarmRole = $dbServer->GetFarmRoleObject();
//Storage
if (!$onlyBase) {
try {
if ($dbFarmRole) {
$storage = new FarmRoleStorage($dbFarmRole);
$volumes = $storage->getVolumesConfigs($dbServer, $isHostInit);
if (!empty($volumes)) {
$configuration->volumes = $volumes;
}
}
} catch (Exception $e) {
$this->logger->error(new FarmLogMessage($dbServer, "Cannot init storage: {$e->getMessage()}"));
}
}
// Base
try {
if ($dbFarmRole) {
$scriptingLogTimeout = $dbFarmRole->GetSetting(self::ROLE_BASE_KEEP_SCRIPTING_LOGS_TIME);
if (!$scriptingLogTimeout) {
$scriptingLogTimeout = 3600;
}
$configuration->base = new stdClass();
$configuration->base->keepScriptingLogsTime = $scriptingLogTimeout;
$configuration->base->abortInitOnScriptFail = (int) $dbFarmRole->GetSetting(self::ROLE_BASE_ABORT_INIT_ON_SCRIPT_FAIL);
$configuration->base->disableFirewallManagement = (int) $dbFarmRole->GetSetting(self::ROLE_BASE_DISABLE_FIREWALL_MANAGEMENT);
$configuration->base->rebootAfterHostinitPhase = (int) $dbFarmRole->GetSetting(self::ROLE_BASE_REBOOT_AFTER_HOSTINIT_PHASE);
// For backward compatibility
$configuration->base->resumeStrategy = 'reboot';
if ($dbFarmRole->GetSetting('base.union_script_executor') === null) {
$configuration->base->unionScriptExecutor = 1;
$dbFarmRole->SetSetting('base.union_script_executor', 1);
} else {
$configuration->base->unionScriptExecutor = (int) $dbFarmRole->GetSetting('base.union_script_executor');
}
$configuration->base->scalrLabsFatmouseUpdate = (int) $dbFarmRole->GetSetting('scalr-labs.fatmouse_update');
// On GCE it's set during launch
$hostname = $dbServer->GetProperty(self::SERVER_BASE_HOSTNAME);
if (!$hostname) {
$governance = new Scalr_Governance($dbFarmRole->GetFarmObject()->EnvID);
if ($governance->isEnabled(Scalr_Governance::CATEGORY_GENERAL, Scalr_Governance::GENERAL_HOSTNAME_FORMAT)) {
$hostNameFormat = $governance->getValue(Scalr_Governance::CATEGORY_GENERAL, Scalr_Governance::GENERAL_HOSTNAME_FORMAT);
} else {
$hostNameFormat = $dbFarmRole->GetSetting(self::ROLE_BASE_HOSTNAME_FORMAT);
}
$configuration->base->hostname = !empty($hostNameFormat) ? $dbServer->applyGlobalVarsToValue($hostNameFormat) : '';
if ($configuration->base->hostname != '') {
$dbServer->SetProperty(self::SERVER_BASE_HOSTNAME, $configuration->base->hostname);
}
} else {
$configuration->base->hostname = $hostname;
}
$apiPort = null;
$messagingPort = null;
if (!PlatformFactory::isCloudstack($dbFarmRole->Platform)) {
$apiPort = $dbFarmRole->GetSetting(self::ROLE_BASE_API_PORT);
$messagingPort = $dbFarmRole->GetSetting(self::ROLE_BASE_MESSAGING_PORT);
}
$configuration->base->apiPort = $apiPort ? $apiPort : 8010;
$configuration->base->messagingPort = $messagingPort ? $messagingPort : 8013;
}
//Update settings
$updateSettings = $dbServer->getScalarizrRepository();
$configuration->base->update = new stdClass();
foreach ($updateSettings as $k => $v) {
$configuration->base->update->{$k} = $v;
}
} catch (Exception $e) {
}
return $configuration;
}