Skip to content

Commit

Permalink
pdate
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Apr 3, 2018
1 parent e4d52b3 commit 97a8e79
Show file tree
Hide file tree
Showing 1,631 changed files with 566,550 additions and 1 deletion.
339 changes: 339 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

Empty file added OpsManage/__init__.py
Empty file.
Binary file added OpsManage/__init__.pyc
Binary file not shown.
11 changes: 11 additions & 0 deletions OpsManage/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""
ASGI entrypoint file for default channel layer.
Points to the channel layer configured as "default" so you can point
ASGI applications at "databinding.asgi:channel_layer" as their channel layer.
"""

import os
from channels.asgi import get_channel_layer
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "OpsManage.settings")
channel_layer = get_channel_layer()
65 changes: 65 additions & 0 deletions OpsManage/data/DsMySQL.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env python
# _#_ coding:utf-8 _*_
from OpsManage.models import (Log_Ansible_Model,Ansible_CallBack_Model_Result,
Global_Config,Ansible_CallBack_PlayBook_Result,
Log_Ansible_Playbook)

class AnsibleSaveResult(object):
class Model(object):
@staticmethod
def insert(logId,content):
try:
config = Global_Config.objects.get(id=1)
if config.ansible_model == 1:
return Ansible_CallBack_Model_Result.objects.create(
logId= logId,
content = content
)
except Exception,e:
return False

class PlayBook(object):
@staticmethod
def insert(logId,content):
try:
config = Global_Config.objects.get(id=1)
if config.ansible_playbook == 1:
return Ansible_CallBack_PlayBook_Result.objects.create(
logId= logId,
content = content
)
except Exception,e:
return False

class AnsibleRecord(object):
class Model(object):
@staticmethod
def insert(user,ans_model,ans_server,ans_args=None):
try:
config = Global_Config.objects.get(id=1)
if config.ansible_model == 1:
return Log_Ansible_Model.objects.create(
ans_user = user,
ans_server = ans_server,
ans_args = ans_args,
ans_model = ans_model,
)
except Exception,e:
return False

class PlayBook(object):
@staticmethod
def insert(user,ans_id,ans_name,ans_content,ans_server=None):
try:
config = Global_Config.objects.get(id=1)
if config.ansible_playbook == 1:
return Log_Ansible_Playbook.objects.create(
ans_user = user,
ans_server = ans_server,
ans_name = ans_name,
ans_id = ans_id,
ans_content = ans_content,
)
except Exception, ex:
print ex
return False
Binary file added OpsManage/data/DsMySQL.pyc
Binary file not shown.
166 changes: 166 additions & 0 deletions OpsManage/data/DsRedisOps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# -*- coding=utf-8 -*-
from OpsManage.data.base import APBase
from OpsManage.utils.logger import logger

class DsRedis(object):
class OpsDeploy(object):
@staticmethod
def lpush(redisKey,data):
try:
redisConn = APBase.getRedisConnection(APBase.REDSI_POOL)
redisConn.lpush(redisKey, data)
redisConn = None
except Exception, ex:
logger.warn(msg="Lpush data to redis failed: {ex}".format(ex=str(ex)))
return False

@staticmethod
def rpop(redisKey):
try:
redisConn = APBase.getRedisConnection(APBase.REDSI_POOL)
data = redisConn.rpop(redisKey)
redisConn = None
return data
except Exception, ex:
logger.warn(msg="Rpop redis key failed: {ex}".format(ex=str(ex)))
return False
@staticmethod
def delete(redisKey):
try:
redisConn = APBase.getRedisConnection(APBase.REDSI_POOL)
data = redisConn.delete(redisKey)
redisConn = None
return data
except Exception, ex:
logger.warn(msg="Delete redis key failed: {ex}".format(ex=str(ex)))
return False

class OpsProject(object):
@staticmethod
def set(redisKey,value):
try:
redisConn = APBase.getRedisConnection(APBase.REDSI_POOL)
redisConn.set(redisKey, value)
redisConn.expire(redisKey, 300)
redisConn = None
except Exception, ex:
logger.warn(msg="Set redis key failed: {ex}".format(ex=str(ex)))
return False

@staticmethod
def delete(redisKey):
try:
redisConn = APBase.getRedisConnection(APBase.REDSI_POOL)
redisConn.delete(redisKey)
redisConn = None
except Exception, ex:
logger.warn(msg="Delete redis key failed: {ex}".format(ex=str(ex)))
return False

@staticmethod
def get(redisKey):
try:
redisConn = APBase.getRedisConnection(APBase.REDSI_POOL)
result = redisConn.get(redisKey)
redisConn = None
return result
except Exception, ex:
logger.warn(msg="Get redis key failed: {ex}".format(ex=str(ex)))
return False

class OpsAnsibleModel(object):
@staticmethod
def lpush(redisKey,data):
try:
redisConn = APBase.getRedisConnection(APBase.REDSI_POOL)
redisConn.lpush(redisKey, data)
redisConn = None
except Exception, ex:
logger.warn(msg="Lpush redis data failed: {ex}".format(ex=str(ex)))
return False

@staticmethod
def rpop(redisKey):
try:
redisConn = APBase.getRedisConnection(APBase.REDSI_POOL)
data = redisConn.rpop(redisKey)
redisConn = None
return data
except Exception, ex:
logger.warn(msg="Rpop redis data failed: {ex}".format(ex=str(ex)))
return False
@staticmethod
def delete(redisKey):
try:
redisConn = APBase.getRedisConnection(APBase.REDSI_POOL)
data = redisConn.delete(redisKey)
redisConn = None
return data
except Exception, ex:
logger.warn(msg="Delete redis key failed: {ex}".format(ex=str(ex)))
return False

class OpsAnsiblePlayBook(object):
@staticmethod
def lpush(redisKey,data):
try:
redisConn = APBase.getRedisConnection(APBase.REDSI_POOL)
redisConn.lpush(redisKey, data)
redisConn = None
except Exception, ex:
logger.warn(msg="Lpush redis data failed: {ex}".format(ex=str(ex)))
return False

@staticmethod
def rpop(redisKey):
try:
redisConn = APBase.getRedisConnection(APBase.REDSI_POOL)
data = redisConn.rpop(redisKey)
redisConn = None
return data
except Exception, ex:
logger.warn(msg="Rpop redis data failed: {ex}".format(ex=str(ex)))
return False
@staticmethod
def delete(redisKey):
try:
redisConn = APBase.getRedisConnection(APBase.REDSI_POOL)
data = redisConn.delete(redisKey)
redisConn = None
return data
except Exception, ex:
logger.warn(msg="Delete redis key failed: {ex}".format(ex=str(ex)))
return False


class OpsAnsiblePlayBookLock(object):
@staticmethod
def set(redisKey,value):
try:
redisConn = APBase.getRedisConnection(APBase.REDSI_POOL)
redisConn.set(redisKey, value)
redisConn.expire(redisKey, 1800)
redisConn = None
except Exception, ex:
logger.warn(msg="Set redis key failed: {ex}".format(ex=str(ex)))
return False
@staticmethod
def delete(redisKey):
try:
redisConn = APBase.getRedisConnection(APBase.REDSI_POOL)
redisConn.delete(redisKey)
redisConn = None
except Exception, ex:
logger.warn(msg="Delete redis key failed: {ex}".format(ex=str(ex)))
return False

@staticmethod
def get(redisKey):
try:
redisConn = APBase.getRedisConnection(APBase.REDSI_POOL)
result = redisConn.get(redisKey)
redisConn = None
return result
except Exception, ex:
logger.warn(msg="Get redis key failed: {ex}".format(ex=str(ex)))
return False
Binary file added OpsManage/data/DsRedisOps.pyc
Binary file not shown.
Empty file added OpsManage/data/__init__.py
Empty file.
Binary file added OpsManage/data/__init__.pyc
Binary file not shown.
Loading

0 comments on commit 97a8e79

Please sign in to comment.