SAAS-560: Deploy separate cloud storage config files for each development environment

This commit is contained in:
drigato 2015-02-02 12:54:56 -05:00
parent 93da48351c
commit 5040eb498d
3 changed files with 22 additions and 16 deletions

View File

@ -25,19 +25,6 @@ class Config {
$filename = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : "/etc/airtime/airtime.conf";
}
// Parse separate conf file for cloud storage values
$cloudStorageConfig = isset($_SERVER['CLOUD_STORAGE_CONF']) ? $_SERVER['CLOUD_STORAGE_CONF'] : "/etc/airtime-saas/cloud_storage.conf";
$cloudStorageValues = parse_ini_file($cloudStorageConfig, true);
$CC_CONFIG["supportedStorageBackends"] = array('amazon_S3');
foreach ($CC_CONFIG["supportedStorageBackends"] as $backend) {
$CC_CONFIG[$backend] = $cloudStorageValues[$backend];
}
// Tells us where file uploads will be uploaded to.
// It will either be set to a cloud storage backend or local file storage.
$CC_CONFIG["current_backend"] = $cloudStorageValues["current_backend"]["storage_backend"];
$values = parse_ini_file($filename, true);
// Name of the web server user
@ -54,6 +41,19 @@ class Config {
$CC_CONFIG['dev_env'] = 'production';
}
// Parse separate conf file for cloud storage values
$cloudStorageConfig = "/etc/airtime-saas/".$CC_CONFIG['dev_env']."/cloud_storage_".$CC_CONFIG['dev_env'].".conf";
$cloudStorageValues = parse_ini_file($cloudStorageConfig, true);
$CC_CONFIG["supportedStorageBackends"] = array('amazon_S3');
foreach ($CC_CONFIG["supportedStorageBackends"] as $backend) {
$CC_CONFIG[$backend] = $cloudStorageValues[$backend];
}
// Tells us where file uploads will be uploaded to.
// It will either be set to a cloud storage backend or local file storage.
$CC_CONFIG["current_backend"] = $cloudStorageValues["current_backend"]["storage_backend"];
$CC_CONFIG['cache_ahead_hours'] = $values['general']['cache_ahead_hours'];
$CC_CONFIG['monit_user'] = $values['monit']['monit_user'];

View File

@ -89,7 +89,7 @@ class Application_Model_RabbitMq
if (array_key_exists("dev_env", $CC_CONFIG)) {
$devEnv = $CC_CONFIG["dev_env"];
}
$config = parse_ini_file("/etc/airtime-saas/rabbitmq-analyzer-" . $devEnv . ".ini", true);
$config = parse_ini_file("/etc/airtime-saas/".$devEnv."/rabbitmq-analyzer-" . $devEnv . ".ini", true);
$conn = new AMQPConnection($config["rabbitmq"]["host"],
$config["rabbitmq"]["port"],
$config["rabbitmq"]["user"],

View File

@ -5,8 +5,7 @@ import config_file
from boto.s3.connection import S3Connection
from boto.s3.key import Key
CLOUD_CONFIG_PATH = '/etc/airtime-saas/cloud_storage.conf'
AIRTIME_CONFIG_PATH = '/etc/airtime/airtime.conf'
STORAGE_BACKEND_FILE = "file"
class CloudStorageUploader:
@ -25,6 +24,13 @@ class CloudStorageUploader:
def __init__(self):
airtime_config = config_file.read_config_file(AIRTIME_CONFIG_PATH)
dev_env = "production" # Default
if airtime_config.has_option("general", "dev_env"):
dev_env = airtime_config.get("general", "dev_env")
CLOUD_CONFIG_PATH = "/etc/airtime-saas/%s/cloud_storage_%s.conf" % (dev_env, dev_env)
config = config_file.read_config_file(CLOUD_CONFIG_PATH)
CLOUD_STORAGE_CONFIG_SECTION = config.get("current_backend", "storage_backend")