import os
from datetime import datetime

LOG_DIR = '/var/log/graphite'
if os.getenv("CARBONLINK_HOSTS"):
    CARBONLINK_HOSTS = os.getenv("CARBONLINK_HOSTS").split(',')

if os.getenv("CLUSTER_SERVERS"):
    CLUSTER_SERVERS = os.getenv("CLUSTER_SERVERS").split(',')

if os.getenv("MEMCACHE_HOSTS"):
    CLUSTER_SERVERS = os.getenv("MEMCACHE_HOSTS").split(',')

if os.getenv("WHISPER_DIR"):
    WHISPER_DIR = os.getenv("WHISPER_DIR")

SECRET_KEY = str(datetime.now())

import os
from datetime import datetime

LOG_DIR = '/var/log/graphite'
if os.getenv("CARBONLINK_HOSTS"):
    CARBONLINK_HOSTS = os.getenv("CARBONLINK_HOSTS").split(',')

if os.getenv("CLUSTER_SERVERS"):
    CLUSTER_SERVERS = os.getenv("CLUSTER_SERVERS").split(',')

if os.getenv("MEMCACHE_HOSTS"):
    MEMCACHE_HOSTS = os.getenv("MEMCACHE_HOSTS").split(',')

if os.getenv("WHISPER_DIR"):
    WHISPER_DIR = os.getenv("WHISPER_DIR")

SECRET_KEY = str(datetime.now())

Fix memcache hosts setting from env
Fix memcache hosts setting from env

Before this fix if one had set OS env vars for both CLUSTER_SERVERS and
MEMCACHE_HOSTS the value of later would override the former and the
graphite web application fails to show any metrics.

  import os
  from datetime import datetime
  
  LOG_DIR = '/var/log/graphite'
  if os.getenv("CARBONLINK_HOSTS"):
      CARBONLINK_HOSTS = os.getenv("CARBONLINK_HOSTS").split(',')
  
  if os.getenv("CLUSTER_SERVERS"):
      CLUSTER_SERVERS = os.getenv("CLUSTER_SERVERS").split(',')
  
  if os.getenv("MEMCACHE_HOSTS"):
-     CLUSTER_SERVERS = os.getenv("MEMCACHE_HOSTS").split(',')
+     MEMCACHE_HOSTS = os.getenv("MEMCACHE_HOSTS").split(',')
  
  if os.getenv("WHISPER_DIR"):
      WHISPER_DIR = os.getenv("WHISPER_DIR")
  
  SECRET_KEY = str(datetime.now())
  
Fix memcache hosts setting from env
## Code Before:
import os
from datetime import datetime

LOG_DIR = '/var/log/graphite'
if os.getenv("CARBONLINK_HOSTS"):
    CARBONLINK_HOSTS = os.getenv("CARBONLINK_HOSTS").split(',')

if os.getenv("CLUSTER_SERVERS"):
    CLUSTER_SERVERS = os.getenv("CLUSTER_SERVERS").split(',')

if os.getenv("MEMCACHE_HOSTS"):
    CLUSTER_SERVERS = os.getenv("MEMCACHE_HOSTS").split(',')

if os.getenv("WHISPER_DIR"):
    WHISPER_DIR = os.getenv("WHISPER_DIR")

SECRET_KEY = str(datetime.now())

## Instruction:
Fix memcache hosts setting from env
## Code After:
import os
from datetime import datetime

LOG_DIR = '/var/log/graphite'
if os.getenv("CARBONLINK_HOSTS"):
    CARBONLINK_HOSTS = os.getenv("CARBONLINK_HOSTS").split(',')

if os.getenv("CLUSTER_SERVERS"):
    CLUSTER_SERVERS = os.getenv("CLUSTER_SERVERS").split(',')

if os.getenv("MEMCACHE_HOSTS"):
    MEMCACHE_HOSTS = os.getenv("MEMCACHE_HOSTS").split(',')

if os.getenv("WHISPER_DIR"):
    WHISPER_DIR = os.getenv("WHISPER_DIR")

SECRET_KEY = str(datetime.now())
