"""
Django settings for saltshaker project.

Generated by 'django-admin startproject' using Django 1.8.4.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
import django_crontab.crontab
# celery
import djcelery
from celery import Celery, platforms

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '<KEY>'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

SESSION_EXPIRE_AT_BROWSER_CLOSE = True
SESSION_COOKIE_AGE = 60*60

ALLOWED_HOSTS = []

# django-crontab
CRONJOBS = (
    ('*/1 * * * *', 'shaker.cron.dashboard_scheduled_job'),
    ('*/1 * * * *', 'shaker.cron.minions_status_scheduled_job'),
    ('*/1 * * * *', 'shaker.cron.grains_scheduled_job'),
)

# Application definition
#
INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django_crontab',
    'shaker',
    'account',
    'code_update',
    'dashboard',
    'execute',
    'groups',
    'jobs',
    'minions',
    'states_config',
    'system_setup',
    'returner',
    'djcelery',
    'jenkins_wrapper',
    'svn_wrapper'
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    #'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
)

ROOT_URLCONF = 'saltshaker.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'django.core.context_processors.request',
            ],
        },
    },
]

WSGI_APPLICATION = 'saltshaker.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'saltshaker', # Or path to database file if using sqlite3.
        'USER': 'saltshaker', # Not used with sqlite3.
        'PASSWORD': '<PASSWORD>', # Not used with sqlite3.
        'HOST': 'localhost', # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '3306', # Set to empty string for default. Not used with sqlite3.
    }
}


# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Asia/Shanghai'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/

STATIC_URL = '/static/'
STATICFILES_DIRS = (os.path.join(BASE_DIR, "static"),)

# SaltStack API
SALT_API_URL = 'http://127.0.0.1:8000'
SALT_API_USER = 'admin'
SALT_API_PASSWD = '<PASSWORD>'

# django logging
LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    'formatters': {
        'standard': {
            'format': '%(asctime)s [%(threadName)s:%(thread)d] [%(module)s %(process)d] [%(name)s:%(lineno)d] [%(levelname)s]- %(message)s'
        },
    },
    'filters': {
    },
    'handlers': {
        'shaker_default': {
            'level': 'DEBUG',
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': '/var/log/saltshaker/all.log',
            'maxBytes': 1024 * 1024 * 5,
            'backupCount': 5,
            'formatter': 'standard',
        },

    },
    'loggers': {
        'django': {
            'handlers': ['shaker_default'],
            'level': 'INFO',
            'propagate': False
        },
    }
}


# celery + rabbitmq
platforms.C_FORCE_ROOT = True   # Running a worker with superuser privileges
djcelery.setup_loader()
BROKER_HOST = "127.0.0.1"
BROKER_PORT = 5672
BROKER_USER = "guest"
BROKER_PASSWORD = "<PASSWORD>"
BROKER_VHOST = "/"

#SaltStack API
SALT_API_URL = 'http://1172.16.17.32:8000'
SALT_API_USER = 'admin'
SALT_API_PASSWD = '<PASSWORD>'

# JENKINs SETTING
JENKINS_URL = 'http://192.168.1.203:8080/'
JENKINS_USER = 'admin'
JENKINS_PWD = '<PASSWORD>'
JENKINS_MAVEN_CONFIG = '''<?xml version='1.0' encoding='UTF-8'?>
<maven2-moduleset plugin="maven-plugin@2.13">
  <actions/>
  <description></description>
  <keepDependencies>false</keepDependencies>
  <properties>
    <jenkins.plugins.maveninfo.config.MavenInfoJobConfig plugin="maven-info@0.2.0">
      <mainModulePattern></mainModulePattern>
      <dependenciesPattern></dependenciesPattern>
      <assignName>false</assignName>
      <nameTemplate></nameTemplate>
      <assignDescription>false</assignDescription>
      <descriptionTemplate></descriptionTemplate>
    </jenkins.plugins.maveninfo.config.MavenInfoJobConfig>
    <org.jenkinsci.plugins.mavenrepocleaner.MavenRepoCleanerProperty plugin="maven-repo-cleaner@1.2">
      <notOnThisProject>false</notOnThisProject>
    </org.jenkinsci.plugins.mavenrepocleaner.MavenRepoCleanerProperty>
  </properties>
  <scm class="hudson.scm.SubversionSCM" plugin="subversion@2.6">
    <locations>
      <hudson.scm.SubversionSCM_-ModuleLocation>
        <remote>{%SVN_ADDR%}</remote>
        <credentialsId>{%CID%}</credentialsId>
        <local>.</local>
        <depthOption>infinity</depthOption>
        <ignoreExternalsOption>true</ignoreExternalsOption>
      </hudson.scm.SubversionSCM_-ModuleLocation>
    </locations>
    <excludedRegions></excludedRegions>
    <includedRegions></includedRegions>
    <excludedUsers></excludedUsers>
    <excludedRevprop></excludedRevprop>
    <excludedCommitMessages></excludedCommitMessages>
    <workspaceUpdater class="hudson.scm.subversion.UpdateUpdater"/>
    <ignoreDirPropChanges>false</ignoreDirPropChanges>
    <filterChangelog>false</filterChangelog>
  </scm>
  <canRoam>true</canRoam>
  <disabled>false</disabled>
  <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
  <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
  <triggers/>
  <concurrentBuild>false</concurrentBuild>
  <rootPOM>{%ROOT_POM%}</rootPOM>
  <goals>{%GOALS%}</goals>
  <aggregatorStyleBuild>true</aggregatorStyleBuild>
  <incrementalBuild>false</incrementalBuild>
  <ignoreUpstremChanges>true</ignoreUpstremChanges>
  <ignoreUnsuccessfulUpstreams>false</ignoreUnsuccessfulUpstreams>
  <archivingDisabled>false</archivingDisabled>
  <siteArchivingDisabled>false</siteArchivingDisabled>
  <fingerprintingDisabled>false</fingerprintingDisabled>
  <resolveDependencies>false</resolveDependencies>
  <processPlugins>false</processPlugins>
  <mavenValidationLevel>-1</mavenValidationLevel>
  <runHeadless>false</runHeadless>
  <disableTriggerDownstreamProjects>false</disableTriggerDownstreamProjects>
  <blockTriggerWhenBuilding>true</blockTriggerWhenBuilding>
  <settings class="jenkins.mvn.DefaultSettingsProvider"/>
  <globalSettings class="jenkins.mvn.DefaultGlobalSettingsProvider"/>
  <reporters/>
  <publishers/>
  <buildWrappers/>
  <prebuilders/>
  <postbuilders/>
  <runPostStepsIfResult>
    <name>FAILURE</name>
    <ordinal>2</ordinal>
    <color>RED</color>
    <completeBuild>true</completeBuild>
  </runPostStepsIfResult>
</maven2-moduleset>
'''

# SVN SETTING
SVN_URL = 'svn://10.5.85.116/'
SVN_USER = 'admin'
SVN_PWD = '<PASSWORD>'

"""
Django settings for saltshaker project.

Generated by 'django-admin startproject' using Django 1.8.4.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
import django_crontab.crontab
# celery
import djcelery
from celery import Celery, platforms

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '<KEY>'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

SESSION_EXPIRE_AT_BROWSER_CLOSE = True
SESSION_COOKIE_AGE = 60*60

ALLOWED_HOSTS = []

# django-crontab
CRONJOBS = (
    ('*/1 * * * *', 'shaker.cron.dashboard_scheduled_job'),
    ('*/1 * * * *', 'shaker.cron.minions_status_scheduled_job'),
    ('*/1 * * * *', 'shaker.cron.grains_scheduled_job'),
)

# Application definition
#
INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django_crontab',
    'shaker',
    'account',
    'code_update',
    'dashboard',
    'execute',
    'groups',
    'jobs',
    'minions',
    'states_config',
    'system_setup',
    'returner',
    'djcelery',
    'jenkins_wrapper',
    'svn_wrapper'
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    #'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
)

ROOT_URLCONF = 'saltshaker.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'django.core.context_processors.request',
            ],
        },
    },
]

WSGI_APPLICATION = 'saltshaker.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'saltshaker', # Or path to database file if using sqlite3.
        'USER': 'saltshaker', # Not used with sqlite3.
        'PASSWORD': '<PASSWORD>', # Not used with sqlite3.
        'HOST': 'localhost', # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '3306', # Set to empty string for default. Not used with sqlite3.
    }
}


# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Asia/Shanghai'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/

STATIC_URL = '/static/'
STATICFILES_DIRS = (os.path.join(BASE_DIR, "static"),)

# SaltStack API
SALT_API_URL = 'http://127.0.0.1:8000'
SALT_API_USER = 'admin'
SALT_API_PASSWD = '<PASSWORD>'

# django logging
LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    'formatters': {
        'standard': {
            'format': '%(asctime)s [%(threadName)s:%(thread)d] [%(module)s %(process)d] [%(name)s:%(lineno)d] [%(levelname)s]- %(message)s'
        },
    },
    'filters': {
    },
    'handlers': {
        'shaker_default': {
            'level': 'DEBUG',
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': '/var/log/saltshaker/all.log',
            'maxBytes': 1024 * 1024 * 5,
            'backupCount': 5,
            'formatter': 'standard',
        },

    },
    'loggers': {
        'django': {
            'handlers': ['shaker_default'],
            'level': 'INFO',
            'propagate': False
        },
    }
}


# celery + rabbitmq
platforms.C_FORCE_ROOT = True   # Running a worker with superuser privileges
djcelery.setup_loader()
BROKER_HOST = "127.0.0.1"
BROKER_PORT = 5672
BROKER_USER = "guest"
BROKER_PASSWORD = "<PASSWORD>"
BROKER_VHOST = "/"

#SaltStack API
SALT_API_URL = 'http://1172.16.17.32:8000'
SALT_API_USER = 'admin'
SALT_API_PASSWD = '<PASSWORD>'

# JENKINs SETTING
JENKINS_URL = 'http://192.168.1.203:8080/'
JENKINS_USER = 'admin'
JENKINS_PWD = '<PASSWORD>'
JENKINS_MAVEN_CONFIG = '''<?xml version='1.0' encoding='UTF-8'?>
<maven2-moduleset plugin="maven-plugin@2.13">
  <actions/>
  <description></description>
  <keepDependencies>false</keepDependencies>
  <properties>
    <jenkins.plugins.maveninfo.config.MavenInfoJobConfig plugin="maven-info@0.2.0">
      <mainModulePattern></mainModulePattern>
      <dependenciesPattern></dependenciesPattern>
      <assignName>false</assignName>
      <nameTemplate></nameTemplate>
      <assignDescription>false</assignDescription>
      <descriptionTemplate></descriptionTemplate>
    </jenkins.plugins.maveninfo.config.MavenInfoJobConfig>
    <org.jenkinsci.plugins.mavenrepocleaner.MavenRepoCleanerProperty plugin="maven-repo-cleaner@1.2">
      <notOnThisProject>false</notOnThisProject>
    </org.jenkinsci.plugins.mavenrepocleaner.MavenRepoCleanerProperty>
  </properties>
  <scm class="hudson.scm.SubversionSCM" plugin="subversion@2.6">
    <locations>
      <hudson.scm.SubversionSCM_-ModuleLocation>
        <remote>{%SVN_ADDR%}</remote>
        <credentialsId>{%CID%}</credentialsId>
        <local>.</local>
        <depthOption>infinity</depthOption>
        <ignoreExternalsOption>true</ignoreExternalsOption>
      </hudson.scm.SubversionSCM_-ModuleLocation>
    </locations>
    <excludedRegions></excludedRegions>
    <includedRegions></includedRegions>
    <excludedUsers></excludedUsers>
    <excludedRevprop></excludedRevprop>
    <excludedCommitMessages></excludedCommitMessages>
    <workspaceUpdater class="hudson.scm.subversion.UpdateUpdater"/>
    <ignoreDirPropChanges>false</ignoreDirPropChanges>
    <filterChangelog>false</filterChangelog>
  </scm>
  <canRoam>true</canRoam>
  <disabled>false</disabled>
  <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
  <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
  <triggers/>
  <concurrentBuild>false</concurrentBuild>
  <rootPOM>{%ROOT_POM%}</rootPOM>
  <goals>{%GOALS%}</goals>
  <aggregatorStyleBuild>true</aggregatorStyleBuild>
  <incrementalBuild>false</incrementalBuild>
  <ignoreUpstremChanges>true</ignoreUpstremChanges>
  <ignoreUnsuccessfulUpstreams>false</ignoreUnsuccessfulUpstreams>
  <archivingDisabled>false</archivingDisabled>
  <siteArchivingDisabled>false</siteArchivingDisabled>
  <fingerprintingDisabled>false</fingerprintingDisabled>
  <resolveDependencies>false</resolveDependencies>
  <processPlugins>false</processPlugins>
  <mavenValidationLevel>-1</mavenValidationLevel>
  <runHeadless>false</runHeadless>
  <disableTriggerDownstreamProjects>false</disableTriggerDownstreamProjects>
  <blockTriggerWhenBuilding>true</blockTriggerWhenBuilding>
  <settings class="jenkins.mvn.DefaultSettingsProvider"/>
  <globalSettings class="jenkins.mvn.DefaultGlobalSettingsProvider"/>
  <reporters/>
  <publishers/>
  <buildWrappers/>
  <prebuilders/>
  <postbuilders/>
  <runPostStepsIfResult>
    <name>FAILURE</name>
    <ordinal>2</ordinal>
    <color>RED</color>
    <completeBuild>true</completeBuild>
  </runPostStepsIfResult>
</maven2-moduleset>
'''

# SVN SETTING
SVN_URL = 'svn://10.5.85.116/'
SVN_USER = 'admin'
SVN_PWD = '<PASSWORD>'

Django settings for saltshaker project.  Generated by 'django-admin startproject' using Django 1.8.4.  For more information on this file, see https://docs.djangoproject.com/en/1.8/topics/settings/  For the full list of settings and their values, see https://docs.djangoproject.com/en/1.8/ref/settings/ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) # celery # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: don't run with debug turned on in production! # django-crontab # Application definition # #'django.middleware.csrf.CsrfViewMiddleware', # Database # https://docs.djangoproject.com/en/1.8/ref/settings/#databases # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. # Or path to database file if using sqlite3. # Not used with sqlite3. # Not used with sqlite3. # Set to empty string for localhost. Not used with sqlite3. # Set to empty string for default. Not used with sqlite3. # Internationalization # https://docs.djangoproject.com/en/1.8/topics/i18n/ # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.8/howto/static-files/ # SaltStack API # django logging # celery + rabbitmq # Running a worker with superuser privileges #SaltStack API # JENKINs SETTING <?xml version='1.0' encoding='UTF-8'?> <maven2-moduleset plugin="maven-plugin@2.13">   <actions/>   <description></description>   <keepDependencies>false</keepDependencies>   <properties>     <jenkins.plugins.maveninfo.config.MavenInfoJobConfig plugin="maven-info@0.2.0">       <mainModulePattern></mainModulePattern>       <dependenciesPattern></dependenciesPattern>       <assignName>false</assignName>       <nameTemplate></nameTemplate>       <assignDescription>false</assignDescription>       <descriptionTemplate></descriptionTemplate>     </jenkins.plugins.maveninfo.config.MavenInfoJobConfig>     <org.jenkinsci.plugins.mavenrepocleaner.MavenRepoCleanerProperty plugin="maven-repo-cleaner@1.2">       <notOnThisProject>false</notOnThisProject>     </org.jenkinsci.plugins.mavenrepocleaner.MavenRepoCleanerProperty>   </properties>   <scm class="hudson.scm.SubversionSCM" plugin="subversion@2.6">     <locations>       <hudson.scm.SubversionSCM_-ModuleLocation>         <remote>{%SVN_ADDR%}</remote>         <credentialsId>{%CID%}</credentialsId>         <local>.</local>         <depthOption>infinity</depthOption>         <ignoreExternalsOption>true</ignoreExternalsOption>       </hudson.scm.SubversionSCM_-ModuleLocation>     </locations>     <excludedRegions></excludedRegions>     <includedRegions></includedRegions>     <excludedUsers></excludedUsers>     <excludedRevprop></excludedRevprop>     <excludedCommitMessages></excludedCommitMessages>     <workspaceUpdater class="hudson.scm.subversion.UpdateUpdater"/>     <ignoreDirPropChanges>false</ignoreDirPropChanges>     <filterChangelog>false</filterChangelog>   </scm>   <canRoam>true</canRoam>   <disabled>false</disabled>   <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>   <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>   <triggers/>   <concurrentBuild>false</concurrentBuild>   <rootPOM>{%ROOT_POM%}</rootPOM>   <goals>{%GOALS%}</goals>   <aggregatorStyleBuild>true</aggregatorStyleBuild>   <incrementalBuild>false</incrementalBuild>   <ignoreUpstremChanges>true</ignoreUpstremChanges>   <ignoreUnsuccessfulUpstreams>false</ignoreUnsuccessfulUpstreams>   <archivingDisabled>false</archivingDisabled>   <siteArchivingDisabled>false</siteArchivingDisabled>   <fingerprintingDisabled>false</fingerprintingDisabled>   <resolveDependencies>false</resolveDependencies>   <processPlugins>false</processPlugins>   <mavenValidationLevel>-1</mavenValidationLevel>   <runHeadless>false</runHeadless>   <disableTriggerDownstreamProjects>false</disableTriggerDownstreamProjects>   <blockTriggerWhenBuilding>true</blockTriggerWhenBuilding>   <settings class="jenkins.mvn.DefaultSettingsProvider"/>   <globalSettings class="jenkins.mvn.DefaultGlobalSettingsProvider"/>   <reporters/>   <publishers/>   <buildWrappers/>   <prebuilders/>   <postbuilders/>   <runPostStepsIfResult>     <name>FAILURE</name>     <ordinal>2</ordinal>     <color>RED</color>     <completeBuild>true</completeBuild>   </runPostStepsIfResult> </maven2-moduleset> # SVN SETTING