您好,登錄后才能下訂單哦!
后端
前端
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的數(shù)據(jù)
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任務(wù)編排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執(zhí)行異步任務(wù)、定時任務(wù)
celery -A celery_tasks worker -l info
官方文檔
Celery管理和監(jiān)控工具-Flower
Flower API
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。