diff --git a/OpsManage/utils/ansible_api_v2.py b/OpsManage/utils/ansible_api_v2.py index 4896f304..f23f9036 100755 --- a/OpsManage/utils/ansible_api_v2.py +++ b/OpsManage/utils/ansible_api_v2.py @@ -630,7 +630,7 @@ def handle_model_data(self,data,module_name,module_args=None): else: data['status'] = 'failed' data_list.append(data) - elif success: + if success: for x,y in success.items(): data = {} data['ip'] = x @@ -663,7 +663,7 @@ def handle_model_data(self,data,module_name,module_args=None): data['status'] = 'succeed' data_list.append(data) - elif failed: + if failed: for x,y in failed.items(): data = {} data['ip'] = x @@ -703,10 +703,10 @@ def handle_model_data(self,data,module_name,module_args=None): # } # } - rbt = ANSRunner(resource,redisKey='1') - rbt.run_model(host_list=["192.168.1.235","192.168.1.234","192.168.1.233"],module_name='yum',module_args="name=htop state=present") +# rbt = ANSRunner(resource,redisKey='1') +# rbt.run_model(host_list=["192.168.1.235","192.168.1.234","192.168.1.233"],module_name='shell',module_args="1.sh") # data = rbt.get_model_result() -# print data +# print(data) # print data # print rbt.handle_model_data(data, 'synchronize', module_args='src=/data/webserver/VManagePlatform/ dest=/data/webserver/VManagePlatform/ compress=yes delete=yes recursive=yes') #rbt.run_model(host_list=["192.168.1.34","192.168.1.130","192.168.1.1"],module_name='ping',module_args="") @@ -715,4 +715,4 @@ def handle_model_data(self,data,module_name,module_args=None): # data = rbt.get_playbook_result() # print data # print rbt.handle_playbook_data_to_html(data) - #print rbt.handle_model_data(module_name='copy',module_args="src=/root/git.log dest=/tmp/test.txt",data=data) \ No newline at end of file +# print(rbt.handle_model_data(module_name='shell',module_args="1.sh",data=data)) \ No newline at end of file diff --git a/OpsManage/views/cron.py b/OpsManage/views/cron.py index c0b1cdfc..8722be7c 100755 --- a/OpsManage/views/cron.py +++ b/OpsManage/views/cron.py @@ -60,7 +60,7 @@ def cron_add(request): else:resource = [{"ip": server.ip, "port": int(server.port),"username": server.username,"password": server.passwd}] ANS = ANSRunner(resource) if cron.cron_script: - src = os.getcwd() + '/' + str(cron.cron_script) + src = os.getcwd() + '/upload/' + str(cron.cron_script) file_args = """src={src} dest={dest} owner={user} group={user} mode=755""".format(src=src,dest=cron.cron_script_path,user=cron.cron_user) ANS.run_model(host_list=sList,module_name="copy",module_args=file_args) result = ANS.handle_model_data(ANS.get_model_result(), 'copy',file_args) @@ -151,7 +151,7 @@ def cron_mod(request,cid): if cron.cron_status == 0:ANS.run_model(host_list=sList,module_name="cron",module_args="""name={name} state=absent""".format(name=cron.cron_name)) else: if cron.cron_script: - src = os.getcwd() + '/' + str(cron.cron_script) + src = os.getcwd() + '/upload/' + str(cron.cron_script) file_args = """src={src} dest={dest} owner={user} group={user} mode=755""".format(src=src,dest=cron.cron_script_path,user=cron.cron_user) ANS.run_model(host_list=sList,module_name="copy",module_args=file_args) cron_args = """name={name} minute='{minute}' hour='{hour}' day='{day}' diff --git a/OpsManage/views/index.py b/OpsManage/views/index.py index 0820dbba..2a72b847 100755 --- a/OpsManage/views/index.py +++ b/OpsManage/views/index.py @@ -56,8 +56,14 @@ def index(request): order.order_url = '/file/download/run/{id}/'.format(id=order.id) order.order_content = order.filedownload_audit_order.order_content else:order.order_content = '未知' - order.order_user = User.objects.get(id=order.order_user).username - order.order_executor = User.objects.get(id=order.order_executor).username + try: + order.order_user = User.objects.get(id=order.order_user).username + except: + order.order_user = '未知' + try: + order.order_executor = User.objects.get(id=order.order_executor).username + except: + order.order_executor = '未知' #月度更新频率统计 monthList = [ base.getDaysAgo(num)[0:6] for num in (0,30,60,90,120,150,180) ][::-1] monthDataList = [] diff --git a/README.md b/README.md index bc020bca..cf29585c 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ [传送门](http://47.75.140.140:8896) ``` 用户:demo 密码:demo -只能演示部分功能,并且每隔两小时重置数据。 +正在开发v3.0,demo环境暂时关闭. ``` ## QQ交流群 ![image](https://github.com/welliamcao/OpsManage/blob/master/demo_imgs/qq_group.png) diff --git a/logs/opsmanage.log b/logs/opsmanage.log index 5f282702..d42e4efd 100644 --- a/logs/opsmanage.log +++ b/logs/opsmanage.log @@ -1 +1,11 @@ - \ No newline at end of file +2018-09-18 21:43:39 [WARNING] Session data corrupted +2018-09-18 21:43:39 [WARNING] Session data corrupted +2018-09-18 21:43:45 [WARNING] Session data corrupted +2018-09-18 21:43:51 [WARNING] Session data corrupted +2018-09-28 21:26:23 [WARNING] Session data corrupted +2018-09-28 21:26:23 [WARNING] Session data corrupted +2018-09-28 21:26:34 [WARNING] Session data corrupted +2018-09-28 21:26:40 [WARNING] Session data corrupted +2018-09-28 21:26:45 [WARNING] Session data corrupted +2018-09-28 21:26:50 [WARNING] Session data corrupted +2018-09-28 21:26:55 [WARNING] Session data corrupted