Update from master
Squashed commit of the following:
commit b5015160aca7f04f2b0fb35c87281c0ab480f429
Author: Pedro Escaleira <escaleira@av.it.pt>
Date: Wed May 17 00:13:05 2023 +0100
Bug 2246 fixed
Change-Id: Ic35d131d4e44686de207b0a6acc3360e04306cb2
Signed-off-by: Pedro Escaleira <escaleira@av.it.pt>
commit 01df3ee231471330760e03b013382464e773eee2
Author: Gulsum Atici <gulsum.atici@canonical.com>
Date: Thu May 11 11:07:54 2023 +0300
Fix AttributeError caused by updated pymongo version
AttributeError: 'Cursor' object has no attribute 'count' is fixed.
Change-Id: Id1b9133376d5a7dcb3998c623163bb57dd5c534b
Signed-off-by: Gulsum Atici <gulsum.atici@canonical.com>
commit 8f3ab9a82608ffe74e6fd5d0c532822412dbc88a
Author: k4.rahul <rahul.k4@tataelxsi.co.in>
Date: Fri May 5 14:18:47 2023 +0530
Coverity-CWE 22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Coverity fix for 137960 Filesystem path, filename, or URI manipulation
Change-Id: I0691a9f231d6b7019fe413c261f50262ea7fb923
Signed-off-by: k4.rahul <rahul.k4@tataelxsi.co.in>
commit bc94e3403ebab364fff7603c1a353c793b52966e
Author: k4.rahul <rahul.k4@tataelxsi.co.in>
Date: Fri May 5 15:52:47 2023 +0530
Coverity-CWE 260: Password in Configuration File
Hardcoded credentials in configuration file
remove from the cloud-config.txt file as it is not being used anywhere in the test case
Change-Id: I101e4b9b6f48fa6d34822bc6f400552329f9aa18
Signed-off-by: k4.rahul <rahul.k4@tataelxsi.co.in>
commit db28d4290a34ed1a7ac7a2ca10cab7eb34a55fd1
Author: garciadeblas <gerardo.garciadeblas@telefonica.com>
Date: Wed May 10 16:26:55 2023 +0200
Minor updates in Dockerfile
Change-Id: Ia12406fef38b13c56ebec3be5bee53cd00441181
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
commit 0edc5108ac7e584cac210ed6bae8b8ef09511388
Author: garciadeblas <gerardo.garciadeblas@telefonica.com>
Date: Tue Apr 18 15:07:15 2023 +0200
Clean stage-archive.sh and use allowlist_extenals in tox.ini
Change-Id: I511cd5009563589f54899f667d779239745f2778
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
commit a06b854f2b278aaee015fc1f76015895f8cf50c1
Author: Gulsum Atici <gulsum.atici@canonical.com>
Date: Tue May 9 13:42:13 2023 +0300
Ubuntu 22.04 and Python 3.10 preparation
Change-Id: I740202d48977467a0c2b2afb4b17bd7597331dee
Signed-off-by: Gulsum Atici <gulsum.atici@canonical.com>
commit b2d732a70efa33e4bc478d351d64bc4adb4ea332
Author: k4.rahul <rahul.k4@tataelxsi.co.in>
Date: Thu Apr 27 16:20:47 2023 +0530
Coverity-CWE 476: NULL Pointer Dereference (137978 Bad use of null-like value)
Coverity fix for Bad use of null-like value
Change-Id: I7437c2b2aeeff25619b5405bcd7c962f3fbd70bb
Signed-off-by: k4.rahul <rahul.k4@tataelxsi.co.in>
commit 09496abf441b0f3730f0288df161da1ca004be69
Author: Gabriel Cuba <gcuba@whitestack.com>
Date: Tue Apr 4 01:57:17 2023 -0500
Fix bug 2231: reverse_sync in fsmongo obtains file timestamp with UTC timezone instead of local timezone, so
that filesystem and mongodb timestamps are correctly compared
Change-Id: I0056026704a624329aae1ae52a45143d12f6dfdd
Signed-off-by: Gabriel Cuba <gcuba@whitestack.com>
commit 76394efe9fbee088dddd1dc9d4da6f043c3959a5
Author: Gulsum Atici <gulsum.atici@canonical.com>
Date: Mon Jan 9 23:19:18 2023 +0300
Feature 10950 Replace pycrypto with pycryptodome
Remove the pycrypto library and change encrypt and decrypt methods to work with pycryptodome.
Move encryption methods from N2VC to common.
Change-Id: I12a5f6138664ab6ebb7100c82523e91750f05f14
Signed-off-by: Gulsum Atici <gulsum.atici@canonical.com>
Change-Id: Iccf3fcafe14305099fcceef65efd6e3c57cf6d2f
Signed-off-by: Dario Faccin <dario.faccin@canonical.com>
diff --git a/osm_common/msgkafka.py b/osm_common/msgkafka.py
index 5487093..02b8241 100644
--- a/osm_common/msgkafka.py
+++ b/osm_common/msgkafka.py
@@ -35,7 +35,6 @@
self.port = None
self.consumer = None
self.producer = None
- self.loop = None
self.broker = None
self.group_id = None
@@ -45,7 +44,6 @@
self.logger = logging.getLogger(config["logger_name"])
self.host = config["host"]
self.port = config["port"]
- self.loop = config.get("loop") or asyncio.get_event_loop()
self.broker = str(self.host) + ":" + str(self.port)
self.group_id = config.get("group_id")
@@ -55,7 +53,6 @@
def disconnect(self):
try:
pass
- # self.loop.close()
except Exception as e: # TODO refine
raise MsgException(str(e))
@@ -70,9 +67,7 @@
retry = 2 # Try two times
while retry:
try:
- self.loop.run_until_complete(
- self.aiowrite(topic=topic, key=key, msg=msg)
- )
+ asyncio.run(self.aiowrite(topic=topic, key=key, msg=msg))
break
except Exception as e:
retry -= 1
@@ -88,27 +83,22 @@
:return: topic, key, message; or None
"""
try:
- return self.loop.run_until_complete(self.aioread(topic, self.loop))
+ return asyncio.run(self.aioread(topic))
except MsgException:
raise
except Exception as e:
raise MsgException("Error reading {} topic: {}".format(topic, str(e)))
- async def aiowrite(self, topic, key, msg, loop=None):
+ async def aiowrite(self, topic, key, msg):
"""
Asyncio write
:param topic: str kafka topic
:param key: str kafka key
:param msg: str or dictionary kafka message
- :param loop: asyncio loop. To be DEPRECATED! in near future!!! loop must be provided inside config at connect
:return: None
"""
-
- if not loop:
- loop = self.loop
try:
self.producer = AIOKafkaProducer(
- loop=loop,
key_serializer=str.encode,
value_serializer=str.encode,
bootstrap_servers=self.broker,
@@ -127,7 +117,6 @@
async def aioread(
self,
topic,
- loop=None,
callback=None,
aiocallback=None,
group_id=None,
@@ -137,7 +126,6 @@
"""
Asyncio read from one or several topics.
:param topic: can be str: single topic; or str list: several topics
- :param loop: asyncio loop. To be DEPRECATED! in near future!!! loop must be provided inside config at connect
:param callback: synchronous callback function that will handle the message in kafka bus
:param aiocallback: async callback function that will handle the message in kafka bus
:param group_id: kafka group_id to use. Can be False (set group_id to None), None (use general group_id provided
@@ -148,9 +136,6 @@
:param kwargs: optional keyword arguments for callback function
:return: If no callback defined, it returns (topic, key, message)
"""
-
- if not loop:
- loop = self.loop
if group_id is False:
group_id = None
elif group_id is None:
@@ -161,7 +146,6 @@
else:
topic_list = (topic,)
self.consumer = AIOKafkaConsumer(
- loop=loop,
bootstrap_servers=self.broker,
group_id=group_id,
auto_offset_reset="earliest" if from_beginning else "latest",