十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
后端
创新互联主营牡丹江网站建设的网络公司,主营网站建设方案,app软件定制开发,牡丹江h5成都小程序开发搭建,牡丹江网站营销推广欢迎牡丹江等地区企业咨询
前端
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