public function setSnapshotConfig($snapshotConfig, DBFarmRole $dbFarmRole, DBServer $dbServer)
{
try {
$storageSnapshot = Scalr_Storage_Snapshot::init();
try {
$storageSnapshot->loadById($snapshotConfig->id);
$storageSnapshot->setConfig($snapshotConfig);
$storageSnapshot->save();
} catch (Exception $e) {
if (strpos($e->getMessage(), 'not found')) {
$storageSnapshot->loadBy(array('id' => $snapshotConfig->id, 'client_id' => $dbServer->clientId, 'farm_id' => $dbServer->farmId, 'farm_roleid' => $dbServer->farmRoleId, 'env_id' => $dbServer->envId, 'name' => sprintf(_("%s data bundle #%s"), $this->behavior, $snapshotConfig->id), 'type' => $dbFarmRole->GetSetting(static::ROLE_DATA_STORAGE_ENGINE), 'platform' => $dbServer->platform, 'description' => sprintf(_("{$this->behavior} data bundle created on Farm '%s' -> Role '%s'"), $dbFarmRole->GetFarmObject()->Name, $dbFarmRole->GetRoleObject()->name), 'service' => $this->behavior));
$storageSnapshot->setConfig($snapshotConfig);
$storageSnapshot->save(true);
} else {
throw $e;
}
}
$dbFarmRole->SetSetting(static::ROLE_SNAPSHOT_ID, $storageSnapshot->id, Entity\FarmRoleSetting::TYPE_LCL);
} catch (Exception $e) {
$this->logger->error(new FarmLogMessage(!empty($dbFarmRole->FarmID) ? $dbFarmRole->FarmID : null, "Cannot save storage volume: {$e->getMessage()}", !empty($dbServer->serverId) ? $dbServer->serverId : null, !empty($dbServer->envId) ? $dbServer->envId : null, !empty($dbServer->farmRoleId) ? $dbServer->farmRoleId : null));
}
}