From 1d2d3cf6d1592c59f34de7312694291b77096685 Mon Sep 17 00:00:00 2001 From: Paul <> Date: Wed, 26 Apr 2023 22:34:40 -0400 Subject: [PATCH 01/21] adding url debug to diagnose asyncio io issue --- features/awx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/awx.py b/features/awx.py index 8cb8ddf8..078e9336 100644 --- a/features/awx.py +++ b/features/awx.py @@ -155,7 +155,7 @@ async def create_aws_account(activity): login=CONFIG.AWX_USERNAME, password=CONFIG.AWX_PASSWORD, encoding="utf-8" ) session = aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=60), auth=auth) - logging.debug("%s %s", logging_message, session) + logging.debug("%s %s URL: %s", logging_message, session, url) try: async with session.request( method="POST", url=url, headers=headers, data=json.dumps(body), ssl=False From 95e21ba36e7cd7de3e10fe5c4a109065ef2c35ea Mon Sep 17 00:00:00 2001 From: Paul <> Date: Wed, 26 Apr 2023 22:39:12 -0400 Subject: [PATCH 02/21] adding url in correct place --- features/awx.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/awx.py b/features/awx.py index 078e9336..ac0eb6f3 100644 --- a/features/awx.py +++ b/features/awx.py @@ -80,7 +80,7 @@ async def create_accounts(activity): login=CONFIG.AWX_USERNAME, password=CONFIG.AWX_PASSWORD, encoding="utf-8" ) session = aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=60), auth=auth) - logging.debug("%s %s", logging_message, session) + logging.debug("%s %s URL: %s", logging_message, session, url) try: async with session.request( method="POST", url=url, headers=headers, data=json.dumps(body), ssl=False @@ -155,7 +155,7 @@ async def create_aws_account(activity): login=CONFIG.AWX_USERNAME, password=CONFIG.AWX_PASSWORD, encoding="utf-8" ) session = aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=60), auth=auth) - logging.debug("%s %s URL: %s", logging_message, session, url) + logging.debug("%s %s", logging_message, session) try: async with session.request( method="POST", url=url, headers=headers, data=json.dumps(body), ssl=False From d07df007f923bc9d16e940b95315cf22391e9a87 Mon Sep 17 00:00:00 2001 From: Paul <> Date: Wed, 26 Apr 2023 23:01:44 -0400 Subject: [PATCH 03/21] adding logging messages for asyncio errors --- features/awx.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/awx.py b/features/awx.py index ac0eb6f3..9da985b2 100644 --- a/features/awx.py +++ b/features/awx.py @@ -104,7 +104,7 @@ async def create_accounts(activity): else: await session.close() except Exception as e: - logging.warning(e) + logging.warning(e + 'warning message 1') if activity.get("parentId"): message = dict( text=awx_server_error_message + str(res.status), @@ -122,7 +122,7 @@ async def create_accounts(activity): try: await session.close() except Exception as e1: - logging.warning(e1) + logging.warning(e1 + "warning message 2") async def create_aws_account(activity): From 8c1c6fec6f11576f2f576b76c674425955d9596e Mon Sep 17 00:00:00 2001 From: Paul <> Date: Wed, 26 Apr 2023 23:12:23 -0400 Subject: [PATCH 04/21] upgrading aiohttp version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 9460abd1..fdd33084 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -aiohttp==3.8.1 +aiohttp==3.8.4 boto3==1.26.23 pymongo==4.1.1 jinja2==3.1.1 From c7ce1216d32e588bc3faefd93a3b0b009d67f535 Mon Sep 17 00:00:00 2001 From: Paul <> Date: Wed, 26 Apr 2023 23:21:09 -0400 Subject: [PATCH 05/21] updating requests library and removing invalid logging statements --- features/awx.py | 4 ++-- requirements.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/features/awx.py b/features/awx.py index 9da985b2..ac0eb6f3 100644 --- a/features/awx.py +++ b/features/awx.py @@ -104,7 +104,7 @@ async def create_accounts(activity): else: await session.close() except Exception as e: - logging.warning(e + 'warning message 1') + logging.warning(e) if activity.get("parentId"): message = dict( text=awx_server_error_message + str(res.status), @@ -122,7 +122,7 @@ async def create_accounts(activity): try: await session.close() except Exception as e1: - logging.warning(e1 + "warning message 2") + logging.warning(e1) async def create_aws_account(activity): diff --git a/requirements.txt b/requirements.txt index fdd33084..830cd3dd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ aiohttp==3.8.4 boto3==1.26.23 pymongo==4.1.1 jinja2==3.1.1 -requests==2.26.0 +requests==2.29.0 webexteamssdk==1.6 virl2_client==2.4.0 PyYAML==5.4 From 825aab6859c091127d980af0beee9d7c67a1fc73 Mon Sep 17 00:00:00 2001 From: Paul <> Date: Wed, 26 Apr 2023 23:34:03 -0400 Subject: [PATCH 06/21] adding logging statement --- features/awx.py | 1 + 1 file changed, 1 insertion(+) diff --git a/features/awx.py b/features/awx.py index ac0eb6f3..ad398477 100644 --- a/features/awx.py +++ b/features/awx.py @@ -82,6 +82,7 @@ async def create_accounts(activity): session = aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=60), auth=auth) logging.debug("%s %s URL: %s", logging_message, session, url) try: + logging.debug("Attempt connection to awx") async with session.request( method="POST", url=url, headers=headers, data=json.dumps(body), ssl=False ) as res: From 014b6480efb898cac29032c203d54c81ffbbf1f9 Mon Sep 17 00:00:00 2001 From: Paul <> Date: Thu, 27 Apr 2023 01:25:22 -0400 Subject: [PATCH 07/21] adding temp value to res to prevent unbound error --- features/awx.py | 1 + 1 file changed, 1 insertion(+) diff --git a/features/awx.py b/features/awx.py index ad398477..4fa1670e 100644 --- a/features/awx.py +++ b/features/awx.py @@ -81,6 +81,7 @@ async def create_accounts(activity): ) session = aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=60), auth=auth) logging.debug("%s %s URL: %s", logging_message, session, url) + res = { "status" : "empty" } try: logging.debug("Attempt connection to awx") async with session.request( From e6fab2f15c697bbb17d6b535b0282c1e5fceb8ee Mon Sep 17 00:00:00 2001 From: Paul <> Date: Thu, 27 Apr 2023 01:51:56 -0400 Subject: [PATCH 08/21] reverting changes, issue located, no changes need to be made to the code --- features/awx.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/features/awx.py b/features/awx.py index 4fa1670e..da0a1442 100644 --- a/features/awx.py +++ b/features/awx.py @@ -80,8 +80,7 @@ async def create_accounts(activity): login=CONFIG.AWX_USERNAME, password=CONFIG.AWX_PASSWORD, encoding="utf-8" ) session = aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=60), auth=auth) - logging.debug("%s %s URL: %s", logging_message, session, url) - res = { "status" : "empty" } + logging.debug("%s %s ", logging_message, session) try: logging.debug("Attempt connection to awx") async with session.request( From 7e2a103538d6ae05e7214be2e976d5e2e39982a3 Mon Sep 17 00:00:00 2001 From: Paul <> Date: Thu, 27 Apr 2023 11:31:49 -0400 Subject: [PATCH 09/21] removing error log message --- features/awx.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/awx.py b/features/awx.py index da0a1442..2c209778 100644 --- a/features/awx.py +++ b/features/awx.py @@ -114,8 +114,8 @@ async def create_accounts(activity): attachments=[], ) else: - message = dict( - text=awx_server_error_message + str(res.status), + message = dict( # + str(res.status) + text=awx_server_error_message, roomId=activity["roomId"], attachments=[], ) From 8240c0343a6ef8bcd0080e2e1735565c891305c6 Mon Sep 17 00:00:00 2001 From: Paul <> Date: Thu, 27 Apr 2023 12:09:10 -0400 Subject: [PATCH 10/21] changing the url for testing --- features/awx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/awx.py b/features/awx.py index 2c209778..908a772e 100644 --- a/features/awx.py +++ b/features/awx.py @@ -65,7 +65,7 @@ async def create_accounts(activity): id_template = "14" # prod else: id_template = "10" # for dev - url = f"https://{CONFIG.AWX_SERVER}/api/v2/job_templates/{id_template}/launch/" + url = f"https://{CONFIG.AWX_SERVER}/api/v2/" headers = {"Content-Type": content_type} user_and_domain = activity["sender_email"].split("@") body = { From cce9d42d7072778daaae97ed4dca56338deae99a Mon Sep 17 00:00:00 2001 From: Paul <> Date: Thu, 27 Apr 2023 12:15:40 -0400 Subject: [PATCH 11/21] changing url and debug --- features/awx.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/features/awx.py b/features/awx.py index 908a772e..c4485386 100644 --- a/features/awx.py +++ b/features/awx.py @@ -65,7 +65,8 @@ async def create_accounts(activity): id_template = "14" # prod else: id_template = "10" # for dev - url = f"https://{CONFIG.AWX_SERVER}/api/v2/" + url = f"https://{CONFIG.AWX_SERVER}/api/v2/applications" + logging.debug("%s", url) headers = {"Content-Type": content_type} user_and_domain = activity["sender_email"].split("@") body = { From fabf1d0ad90128e4862561810078c37412b28a2c Mon Sep 17 00:00:00 2001 From: Paul <> Date: Thu, 27 Apr 2023 12:20:43 -0400 Subject: [PATCH 12/21] resetting changes --- features/awx.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/features/awx.py b/features/awx.py index c4485386..4756bc75 100644 --- a/features/awx.py +++ b/features/awx.py @@ -65,8 +65,7 @@ async def create_accounts(activity): id_template = "14" # prod else: id_template = "10" # for dev - url = f"https://{CONFIG.AWX_SERVER}/api/v2/applications" - logging.debug("%s", url) + url = f"https://{CONFIG.AWX_SERVER}/api/v2/job_templates/{id_template}/launch/" headers = {"Content-Type": content_type} user_and_domain = activity["sender_email"].split("@") body = { @@ -116,7 +115,7 @@ async def create_accounts(activity): ) else: message = dict( # + str(res.status) - text=awx_server_error_message, + text=awx_server_error_message , roomId=activity["roomId"], attachments=[], ) From 55d3f0109874c63becd336acdc73f6493ce8c928 Mon Sep 17 00:00:00 2001 From: Paul <> Date: Thu, 27 Apr 2023 16:35:09 -0400 Subject: [PATCH 13/21] adding code to ensure awx server is reachable --- features/awx.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/features/awx.py b/features/awx.py index 4756bc75..b3c779ec 100644 --- a/features/awx.py +++ b/features/awx.py @@ -65,6 +65,21 @@ async def create_accounts(activity): id_template = "14" # prod else: id_template = "10" # for dev + + + url1 = f"https://{CONFIG.AWX_SERVER}" + try: + async with aiohttp.ClientSession() as session: + async with session.get(url1) as response: + if response.status == 200: + logging.debug(f"Success: {url1} is accessible") + else: + logging.debug(f"Error: {url1} returned status code {response.status}") + except aiohttp.ClientError as error: + logging.debug(f"Error: {url1} could not be accessed ({error})") + + + url = f"https://{CONFIG.AWX_SERVER}/api/v2/job_templates/{id_template}/launch/" headers = {"Content-Type": content_type} user_and_domain = activity["sender_email"].split("@") From e9f5a6a7577e789b79e9d59d7b0283eff9a55c64 Mon Sep 17 00:00:00 2001 From: Paul <> Date: Thu, 27 Apr 2023 17:24:48 -0400 Subject: [PATCH 14/21] further url testing --- features/awx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/awx.py b/features/awx.py index b3c779ec..798c3f7b 100644 --- a/features/awx.py +++ b/features/awx.py @@ -67,7 +67,7 @@ async def create_accounts(activity): id_template = "10" # for dev - url1 = f"https://{CONFIG.AWX_SERVER}" + url1 = f"https://www.google.com" try: async with aiohttp.ClientSession() as session: async with session.get(url1) as response: From 7b420a7cbae8df6dbb6be7959b48080384774e23 Mon Sep 17 00:00:00 2001 From: Paul <> Date: Thu, 27 Apr 2023 17:29:49 -0400 Subject: [PATCH 15/21] attempting url connection with requests --- features/awx.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/features/awx.py b/features/awx.py index 798c3f7b..30fe2a51 100644 --- a/features/awx.py +++ b/features/awx.py @@ -17,6 +17,7 @@ from config import DefaultConfig as CONFIG from webex import WebExClient from .CML import CML +import requests urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) @@ -67,7 +68,17 @@ async def create_accounts(activity): id_template = "10" # for dev - url1 = f"https://www.google.com" + url1 = f"https://{CONFIG.AWX_SERVER}" + + try: + response = requests.get(url1) + if response.status_code == 200: + logging.debug(f"Success: {url1} is accessible") + else: + logging.debug(f"Error: {url1} returned status code {response.status_code}") + except requests.exceptions.RequestException as error: + logging.debug(f"Error: {url1} could not be accessed ({error})") + try: async with aiohttp.ClientSession() as session: async with session.get(url1) as response: From a03afc7a178bc434a66a4e414ab82cf7693a1e82 Mon Sep 17 00:00:00 2001 From: Paul <> Date: Thu, 27 Apr 2023 17:34:45 -0400 Subject: [PATCH 16/21] revert plus changed env flag --- features/awx.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/features/awx.py b/features/awx.py index 30fe2a51..2a9b8045 100644 --- a/features/awx.py +++ b/features/awx.py @@ -71,16 +71,7 @@ async def create_accounts(activity): url1 = f"https://{CONFIG.AWX_SERVER}" try: - response = requests.get(url1) - if response.status_code == 200: - logging.debug(f"Success: {url1} is accessible") - else: - logging.debug(f"Error: {url1} returned status code {response.status_code}") - except requests.exceptions.RequestException as error: - logging.debug(f"Error: {url1} could not be accessed ({error})") - - try: - async with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession(trust_env=True) as session: async with session.get(url1) as response: if response.status == 200: logging.debug(f"Success: {url1} is accessible") From 506b57bb37ede93755c6676f0ddf064b6eaf701e Mon Sep 17 00:00:00 2001 From: Paul <> Date: Thu, 27 Apr 2023 17:42:27 -0400 Subject: [PATCH 17/21] adding timeout --- features/awx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/awx.py b/features/awx.py index 2a9b8045..6767fcce 100644 --- a/features/awx.py +++ b/features/awx.py @@ -71,7 +71,7 @@ async def create_accounts(activity): url1 = f"https://{CONFIG.AWX_SERVER}" try: - async with aiohttp.ClientSession(trust_env=True) as session: + async with aiohttp.ClientSession(trust_env=True, timeout=aiohttp.ClientTimeout(total=60)) as session: async with session.get(url1) as response: if response.status == 200: logging.debug(f"Success: {url1} is accessible") From 38ddaf8ad72694d6fee6193d277ce033c042731f Mon Sep 17 00:00:00 2001 From: Paul <> Date: Thu, 27 Apr 2023 17:50:44 -0400 Subject: [PATCH 18/21] changing ssl to false --- features/awx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/awx.py b/features/awx.py index 6767fcce..9bce108d 100644 --- a/features/awx.py +++ b/features/awx.py @@ -72,7 +72,7 @@ async def create_accounts(activity): try: async with aiohttp.ClientSession(trust_env=True, timeout=aiohttp.ClientTimeout(total=60)) as session: - async with session.get(url1) as response: + async with session.request(url=url1, method="GET", ssl=False) as response: if response.status == 200: logging.debug(f"Success: {url1} is accessible") else: From 3952d1d561b5ba63f8de664ccb3771fc04842122 Mon Sep 17 00:00:00 2001 From: Paul <> Date: Thu, 27 Apr 2023 18:31:58 -0400 Subject: [PATCH 19/21] adding port number --- features/awx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/awx.py b/features/awx.py index 9bce108d..49bd0c0c 100644 --- a/features/awx.py +++ b/features/awx.py @@ -68,7 +68,7 @@ async def create_accounts(activity): id_template = "10" # for dev - url1 = f"https://{CONFIG.AWX_SERVER}" + url1 = f"https://{CONFIG.AWX_SERVER}:443" try: async with aiohttp.ClientSession(trust_env=True, timeout=aiohttp.ClientTimeout(total=60)) as session: From 9d599f80528ee212b616ace34dd6b47333da1837 Mon Sep 17 00:00:00 2001 From: Paul <> Date: Mon, 1 May 2023 15:17:19 -0400 Subject: [PATCH 20/21] adding logging for hostname url --- features/awx.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/features/awx.py b/features/awx.py index 49bd0c0c..6c4dc40a 100644 --- a/features/awx.py +++ b/features/awx.py @@ -68,10 +68,11 @@ async def create_accounts(activity): id_template = "10" # for dev - url1 = f"https://{CONFIG.AWX_SERVER}:443" + url1 = f"https://{CONFIG.AWX_SERVER}" + logging.debug("URL to connect to: %s", url1) try: - async with aiohttp.ClientSession(trust_env=True, timeout=aiohttp.ClientTimeout(total=60)) as session: + async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=60)) as session: async with session.request(url=url1, method="GET", ssl=False) as response: if response.status == 200: logging.debug(f"Success: {url1} is accessible") From f958a7b82f7e54765782c105019e535762e6ace8 Mon Sep 17 00:00:00 2001 From: Paul <> Date: Mon, 1 May 2023 16:20:09 -0400 Subject: [PATCH 21/21] revert, issue resovled --- features/awx.py | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/features/awx.py b/features/awx.py index 6c4dc40a..668f655b 100644 --- a/features/awx.py +++ b/features/awx.py @@ -66,23 +66,6 @@ async def create_accounts(activity): id_template = "14" # prod else: id_template = "10" # for dev - - - url1 = f"https://{CONFIG.AWX_SERVER}" - logging.debug("URL to connect to: %s", url1) - - try: - async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=60)) as session: - async with session.request(url=url1, method="GET", ssl=False) as response: - if response.status == 200: - logging.debug(f"Success: {url1} is accessible") - else: - logging.debug(f"Error: {url1} returned status code {response.status}") - except aiohttp.ClientError as error: - logging.debug(f"Error: {url1} could not be accessed ({error})") - - - url = f"https://{CONFIG.AWX_SERVER}/api/v2/job_templates/{id_template}/launch/" headers = {"Content-Type": content_type} user_and_domain = activity["sender_email"].split("@") @@ -132,8 +115,8 @@ async def create_accounts(activity): attachments=[], ) else: - message = dict( # + str(res.status) - text=awx_server_error_message , + message = dict( + text=awx_server_error_message + str(res.status), roomId=activity["roomId"], attachments=[], )