-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
root
committed
Apr 3, 2018
1 parent
e4d52b3
commit 97a8e79
Showing
1,631 changed files
with
566,550 additions
and
1 deletion.
There are no files selected for viewing
Empty file.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
Empty file.
Binary file not shown.
Oops, something went wrong.