From 9aeaa11bd62092fb606d11f475075b5bd8ab3205 Mon Sep 17 00:00:00 2001 From: "Welliam.Cao" <303350019@qq.com> Date: Fri, 28 Sep 2018 21:47:57 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E5=B7=A5=E5=8D=95=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=B7=BB=E5=8A=A0=E5=BC=82=E5=B8=B8=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpsManage/views/index.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/OpsManage/views/index.py b/OpsManage/views/index.py index 0820dbba..8cfa063c 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 = [] From eb57e64c745e07554a569830053300588a62132c Mon Sep 17 00:00:00 2001 From: "Welliam.Cao" <303350019@qq.com> Date: Fri, 28 Sep 2018 21:51:07 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E5=B7=A5=E5=8D=95=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=B7=BB=E5=8A=A0=E5=BC=82=E5=B8=B8=E5=A4=84?= =?UTF-8?q?=E7=90=861?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpsManage/views/index.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/OpsManage/views/index.py b/OpsManage/views/index.py index 8cfa063c..b995c46e 100755 --- a/OpsManage/views/index.py +++ b/OpsManage/views/index.py @@ -56,14 +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 = '未知' - 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 = '未知' + 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 = [] From 916fad52305aad788da1f7bf62358c3883a86f92 Mon Sep 17 00:00:00 2001 From: "Welliam.Cao" <303350019@qq.com> Date: Fri, 28 Sep 2018 22:00:30 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E7=BC=A9=E8=BF=9B%>=5F<%?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpsManage/views/index.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/OpsManage/views/index.py b/OpsManage/views/index.py index b995c46e..2a72b847 100755 --- a/OpsManage/views/index.py +++ b/OpsManage/views/index.py @@ -56,14 +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 = '未知' - 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 = '未知' + 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 = [] From c4c6fd0f0c4113dd101b55d591aed20005abe8fe Mon Sep 17 00:00:00 2001 From: "Welliam.Cao" <303350019@qq.com> Date: Tue, 6 Nov 2018 22:07:26 +0800 Subject: [PATCH 4/7] fix cron bug --- OpsManage/views/cron.py | 4 ++-- logs/opsmanage.log | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) 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/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 From a703f96da12998f9cf131f3209e36958e99f2182 Mon Sep 17 00:00:00 2001 From: "Welliam.Cao" <303350019@qq.com> Date: Tue, 6 Nov 2018 22:09:24 +0800 Subject: [PATCH 5/7] fix cron bug --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bc020bca..d50dd43c 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) From 18420c8d1868aa12be15848e8f9c9acb58c93aab Mon Sep 17 00:00:00 2001 From: "Welliam.Cao" <303350019@qq.com> Date: Tue, 6 Nov 2018 22:11:10 +0800 Subject: [PATCH 6/7] fix cron bug --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d50dd43c..cf29585c 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ [传送门](http://47.75.140.140:8896) ``` 用户:demo 密码:demo -正在开发v3.0,demo环境关闭. +正在开发v3.0,demo环境暂时关闭. ``` ## QQ交流群 ![image](https://github.com/welliamcao/OpsManage/blob/master/demo_imgs/qq_group.png) From 4be90607fd8f4f9b8e58de842aebce297dfb6731 Mon Sep 17 00:00:00 2001 From: "Welliam.Cao" <303350019@qq.com> Date: Thu, 15 Nov 2018 09:03:29 +0800 Subject: [PATCH 7/7] fix ansible api handle_model_data function bug --- OpsManage/utils/ansible_api_v2.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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