您好,登錄后才能下訂單哦!
后端
前端
data_info = {'id':1,'ip':'192.168.56.1','hostname':'test'}
OpServerM.objects.get_or_create(**data_info)
update_data = {'id':1,'ip':'192.168.56.101','hostname':'test01'}
server = OpServerM.objects.filter(pk=update_data['id'])
server.update(**update_data)
response = HttpResponse()
response['Content-Type'] = "text/javascript"
hostsFile = request.FILES.getlist('uploadhosts')
for i in hostsFile:
filename = os.path.join(MEDIA_ROOT,i.name)
file = open(filename, 'wb')
for chrunk in i.chunks():
file.write(chrunk)
file.close()
def imp_hosts(filename,sheet_name,model_name):
fileds = model_name._meta.get_fields(include_parents=False)
flist = []
for filed in fileds:
flist.append(str(filed).split('.')[-1])
wb = load_workbook(filename)
##讀取excel表sheet名稱為sheet_name的數據
ws = wb[sheet_name]
List=[]
for row in list(ws.rows)[1:]:
cols = []
for col in row:
cols.append(col.value)
tab_dic = dict(map(lambda x, y: [x, y], flist, cols))
List.append(model_name(**tab_dic))
model_name.objects.bulk_create(List)
log-monitor:
file.managed:
- name: /data/shell/log-monitor.sh
- source: salt://init/centos/files/log-monitor.sh
- template: jinja
參考資料
Saltstack API
salt '192.168.56.101' cmd.run 'free -m'
參考資料
Saltstack任務編排stats.sls
vim {django_root}/project/settings.py
MEDIA_URL='/media/'
MEDIA_ROOT='media'
salt '192.168.56.101' cp.get_url http://{django-server:port}/media/upload.file /tmp/upload.file
salt '192.168.56.101' cp.push /tmp/download.file
salt 'django-server' cp.get_file salt://192.168.56.101/tmp/download.file /{DJANGO_ROOT}/media/download.file
wget http://{django-server:port}/media/download.file
參考資料
Django2集成celery4執行異步任務、定時任務
celery -A celery_tasks worker -l info
官方文檔
Celery管理和監控工具-Flower
Flower API
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。