# Path: dzhops/settings.py
# BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# SECRET_KEY = '2vuicou20ne9t&h)#c2!7sz4cc+6hcfxfmy!4agjs7@7-$nddq'
# DEBUG = True
# TEMPLATE_DEBUG = True
# ALLOWED_HOSTS = []
# SESSION_SAVE_EVERY_REQUEST = True
# SESSION_EXPIRE_AT_BROWSER_CLOSE = True
# INSTALLED_APPS = (
#     'django.contrib.admin',
#     'django.contrib.auth',
#     'django.contrib.contenttypes',
#     'django.contrib.sessions',
#     'django.contrib.messages',
#     'django.contrib.staticfiles',
#     'index',
#     'dzhops',
#     'hostlist',
#     'replacedata',
#     'saltstack',
#     'record',
#     'newtest',
# )
# MIDDLEWARE_CLASSES = (
#     'django.contrib.sessions.middleware.SessionMiddleware',
#     'django.middleware.locale.LocaleMiddleware',
#     'django.middleware.common.CommonMiddleware',
#     'django.middleware.csrf.CsrfViewMiddleware',
#     'django.contrib.auth.middleware.AuthenticationMiddleware',
#     'django.contrib.messages.middleware.MessageMiddleware',
#     'django.middleware.clickjacking.XFrameOptionsMiddleware',
# )
# ROOT_URLCONF = 'dzhops.urls'
# WSGI_APPLICATION = 'dzhops.wsgi.application'
# DATABASES = {
#     'default': {
#         'ENGINE': 'django.db.backends.mysql',
#         'NAME': 'dzhops',
#         'USER': 'dzhops',
#         'PORT': 33066,
#         'HOST': 'db-dev.dzh-inc.com',
#         'PASSWORD': 'dzhops',
#     }
# }
# LANGUAGE_CODE = 'en-us'
# TIME_ZONE = 'Asia/Shanghai'
# USE_I18N = True
# USE_L10N = True
# USE_TZ = False
# STATICFILES_DIRS = (
#     BASE_DIR + '/static',
# )
# STATIC_URL = '/static/'
# TEMPLATE_DIRS = (
#     os.path.join(BASE_DIR, 'templates'),
# )
# SALT_API = {
#     'url': 'http://10.15.201.102:18000/',
#     'user': 'zhaogb',
#     'password': 'zhaogb'
# }
# LOGGING = {
#     'version': 1,
#     'disable_existing_loggers': True,
#     'formatters': {
#         'standard': {
#             'format': '%(asctime)s %(levelname)s %(module)s %(funcName)s %(lineno)d %(message)s'
#         },
#         'simple': {
#             'format': '%(levelname)s %(message)s'
#         },
#     },
#     'filters': {
#         'require_debug_false': {
#             '()': 'django.utils.log.RequireDebugFalse'
#         },
#     },
#     'handlers': {
#         'mail_admins': {
#             'level': 'ERROR',
#             'filters': ['require_debug_false'],
#             'class': 'django.utils.log.AdminEmailHandler'
#         },
#         'log_handler': {
#             'level': 'DEBUG',
#             'class': 'logging.handlers.RotatingFileHandler',
#             'filename': os.path.join(BASE_DIR, 'log', 'dzhops.log'),
#             'formatter': 'standard',
#         },
#     },
#     'loggers': {
#         'django.request': {
#             'handlers': ['mail_admins'],
#             'level': 'ERROR',
#             'propagate': True,
#         },
#         'dzhops': {
#             'handlers': ['log_handler'],
#             'level': 'DEBUG',
#             'propagate': False
#         },
#     }
# }


import sys,MySQLdb,urllib
from dzhops import settings
from common.saltapi import SaltAPI
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Guibin created on 2015/10/26
# version: 0.01

sys.path.append('/opt/dzhops')

class scriptApi(SaltAPI):
    def mini_status(self):
        '''
        {u'return': [{u'down': [u'zhaogb-202'], u'up': [u'zhaogb-203', u'zhaogb-212', u'zhaogb-220']}]}
        '''
        params = {"client":"runner","fun":"manage.status"}
        obj = urllib.urlencode(params)
        content = self.postRequest(obj)
        mini_up = content['return'][0]['up']
        mini_down = content['return'][0]['down']
        return mini_up,mini_down
ret = {}
try:

# Path: dzhops/settings.py
# BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# SECRET_KEY = '2vuicou20ne9t&h)#c2!7sz4cc+6hcfxfmy!4agjs7@7-$nddq'
# DEBUG = True
# TEMPLATE_DEBUG = True
# ALLOWED_HOSTS = []
# SESSION_SAVE_EVERY_REQUEST = True
# SESSION_EXPIRE_AT_BROWSER_CLOSE = True
# INSTALLED_APPS = (
#     'django.contrib.admin',
#     'django.contrib.auth',
#     'django.contrib.contenttypes',
#     'django.contrib.sessions',
#     'django.contrib.messages',
#     'django.contrib.staticfiles',
#     'index',
#     'dzhops',
#     'hostlist',
#     'replacedata',
#     'saltstack',
#     'record',
#     'newtest',
# )
# MIDDLEWARE_CLASSES = (
#     'django.contrib.sessions.middleware.SessionMiddleware',
#     'django.middleware.locale.LocaleMiddleware',
#     'django.middleware.common.CommonMiddleware',
#     'django.middleware.csrf.CsrfViewMiddleware',
#     'django.contrib.auth.middleware.AuthenticationMiddleware',
#     'django.contrib.messages.middleware.MessageMiddleware',
#     'django.middleware.clickjacking.XFrameOptionsMiddleware',
# )
# ROOT_URLCONF = 'dzhops.urls'
# WSGI_APPLICATION = 'dzhops.wsgi.application'
# DATABASES = {
#     'default': {
#         'ENGINE': 'django.db.backends.mysql',
#         'NAME': 'dzhops',
#         'USER': 'dzhops',
#         'PORT': 33066,
#         'HOST': 'db-dev.dzh-inc.com',
#         'PASSWORD': 'dzhops',
#     }
# }
# LANGUAGE_CODE = 'en-us'
# TIME_ZONE = 'Asia/Shanghai'
# USE_I18N = True
# USE_L10N = True
# USE_TZ = False
# STATICFILES_DIRS = (
#     BASE_DIR + '/static',
# )
# STATIC_URL = '/static/'
# TEMPLATE_DIRS = (
#     os.path.join(BASE_DIR, 'templates'),
# )
# SALT_API = {
#     'url': 'http://10.15.201.102:18000/',
#     'user': 'zhaogb',
#     'password': 'zhaogb'
# }
# LOGGING = {
#     'version': 1,
#     'disable_existing_loggers': True,
#     'formatters': {
#         'standard': {
#             'format': '%(asctime)s %(levelname)s %(module)s %(funcName)s %(lineno)d %(message)s'
#         },
#         'simple': {
#             'format': '%(levelname)s %(message)s'
#         },
#     },
#     'filters': {
#         'require_debug_false': {
#             '()': 'django.utils.log.RequireDebugFalse'
#         },
#     },
#     'handlers': {
#         'mail_admins': {
#             'level': 'ERROR',
#             'filters': ['require_debug_false'],
#             'class': 'django.utils.log.AdminEmailHandler'
#         },
#         'log_handler': {
#             'level': 'DEBUG',
#             'class': 'logging.handlers.RotatingFileHandler',
#             'filename': os.path.join(BASE_DIR, 'log', 'dzhops.log'),
#             'formatter': 'standard',
#         },
#     },
#     'loggers': {
#         'django.request': {
#             'handlers': ['mail_admins'],
#             'level': 'ERROR',
#             'propagate': True,
#         },
#         'dzhops': {
#             'handlers': ['log_handler'],
#             'level': 'DEBUG',
#             'propagate': False
#         },
#     }
# }


# Path: scripts/slapi.py
import sys,MySQLdb,urllib
from dzhops import settings
from common.saltapi import SaltAPI

#!/usr/bin/python
# -*- coding: utf-8 -*-
# Guibin created on 2015/10/26
# version: 0.01

sys.path.append('/opt/dzhops')

class scriptApi(SaltAPI):
    def mini_status(self):
        '''
        {u'return': [{u'down': [u'zhaogb-202'], u'up': [u'zhaogb-203', u'zhaogb-212', u'zhaogb-220']}]}
        '''
        params = {"client":"runner","fun":"manage.status"}
        obj = urllib.urlencode(params)
        content = self.postRequest(obj)
        mini_up = content['return'][0]['up']
        mini_down = content['return'][0]['down']
        return mini_up,mini_down
ret = {}
try:

    sapi = scriptApi(url=settings.SALT_API['url'],username=settings.SALT_API['user'],password=settings.SALT_API['password'])