# devops-stages/stage-build.sh
#
-FROM ubuntu:20.04
+FROM ubuntu:22.04
ARG APT_PROXY
RUN if [ ! -z $APT_PROXY ] ; then \
python3 \
python3-all \
python3-dev \
- python3-setuptools
+ python3-setuptools \
+ python3-pip \
+ tox
-RUN python3 -m easy_install pip==21.3.1
-RUN pip install tox==3.24.5
+ENV LC_ALL C.UTF-8
+ENV LANG C.UTF-8
# contact: bdiaz@whitestack.com or glavado@whitestack.com
##
import argparse
-import asyncio
import logging
import sys
log.info("Starting MON Server...")
log.debug("Config: %s", cfg.conf)
log.info("Initializing database...")
- loop = asyncio.get_event_loop()
try:
- server = Server(cfg, loop)
+ server = Server(cfg)
server.run()
except Exception as e:
log.error("Failed to start MON Server")
def __init__(self, config: Config):
super().__init__(config)
self.common_db = CommonDbClient(config)
- self.loop = asyncio.get_event_loop()
# host = config.get("vca", "host")
# port = config.get("vca", "port") if "port" in config.conf["vca"] else 17070
db=self.common_db.common_db,
fs=object(),
log=log,
- loop=self.loop,
on_update_db=None,
)
if vca_deployment_info.get("model") and vca_deployment_info.get(
"application"
):
- measures = self.loop.run_until_complete(
+ measures = asyncio.run(
self.n2vc.get_metrics(
vca_deployment_info["model"],
vca_deployment_info["application"],
# For those usages not covered by the Apache License, Version 2.0 please
# contact: bdiaz@whitestack.com or glavado@whitestack.com
##
-import asyncio
from typing import List, Callable
from osm_common import msgkafka, msglocal
class MessageBusClient:
- def __init__(self, config: Config, loop=None):
+ def __init__(self, config: Config):
if config.get("message", "driver") == "local":
self.msg_bus = msglocal.MsgLocal()
elif config.get("message", "driver") == "kafka":
"Unknown message bug driver {}".format(config.get("section", "driver"))
)
self.msg_bus.connect(config.get("message"))
- if not loop:
- loop = asyncio.get_event_loop()
- self.loop = loop
async def aioread(self, topics: List[str], callback: Callable = None, **kwargs):
"""
:param kwargs: Keyword arguments to be passed to callback function.
:return: None
"""
- await self.msg_bus.aioread(topics, self.loop, aiocallback=callback, **kwargs)
+ await self.msg_bus.aioread(topics, aiocallback=callback, **kwargs)
async def aiowrite(self, topic: str, key: str, msg: dict):
"""
:param msg: Dictionary containing message to be written.
:return: None
"""
- await self.msg_bus.aiowrite(topic, key, msg, self.loop)
+ await self.msg_bus.aiowrite(topic, key, msg)
async def aioread_once(self, topic: str):
"""
:param topic: topic to retrieve message from.
:return: tuple(topic, key, message)
"""
- result = await self.msg_bus.aioread(topic, self.loop)
+ result = await self.msg_bus.aioread(topic)
return result
class Dashboarder:
- def __init__(self, config: Config, loop=None):
+ def __init__(self, config: Config):
self.conf = config
self.service = DashboarderService(config)
- if not loop:
- loop = asyncio.get_event_loop()
- self.loop = loop
self.msg_bus = MessageBusClient(config)
# run consumer for grafana user management
def run(self):
- self.loop.run_until_complete(self.start())
+ asyncio.run(self.start())
async def start(self, wait_time=5):
topics = ["users", "project"]
class Evaluator:
- def __init__(self, config: Config, loop=None):
+ def __init__(self, config: Config):
self.conf = config
- if not loop:
- loop = asyncio.get_event_loop()
- self.loop = loop
self.service = EvaluatorService(config)
self.msg_bus = MessageBusClient(config)
log.debug("_notify_alarm")
resp_message = self._build_alarm_response(alarm, status)
log.info("Sent alarm notification: %s", resp_message)
- self.loop.run_until_complete(
+ asyncio.run(
self.msg_bus.aiowrite("alarm_response", "notify_alarm", resp_message)
)
evaluator_service = EvaluatorService(self.conf)
class Server:
- def __init__(self, config: Config, loop=None):
+ def __init__(self, config: Config):
self.conf = config
- if not loop:
- loop = asyncio.get_event_loop()
- self.loop = loop
self.msg_bus = MessageBusClient(config)
self.service = ServerService(config)
self.service.populate_prometheus()
def run(self):
- self.loop.run_until_complete(self.start())
+ asyncio.run(self.start())
async def start(self, wait_time=5):
topics = ["alarm_request"]
def setUp(self):
self.config = Config()
self.config.set("message", "driver", "kafka")
- self.loop = asyncio.new_event_loop()
@mock.patch.object(MsgKafka, "aioread")
def test_aioread(self, aioread):
async def mock_callback():
pass
- future = asyncio.Future(loop=self.loop)
+ future = asyncio.Future(loop=asyncio.new_event_loop())
future.set_result("mock")
aioread.return_value = future
- msg_bus = MessageBusClient(self.config, loop=self.loop)
+ msg_bus = MessageBusClient(self.config)
topic = "test_topic"
- self.loop.run_until_complete(msg_bus.aioread([topic], mock_callback))
- aioread.assert_called_with(["test_topic"], self.loop, aiocallback=mock_callback)
+ asyncio.run(msg_bus.aioread([topic], mock_callback))
+ aioread.assert_called_with(["test_topic"], aiocallback=mock_callback)
@mock.patch.object(MsgKafka, "aiowrite")
def test_aiowrite(self, aiowrite):
- future = asyncio.Future(loop=self.loop)
+ future = asyncio.Future(loop=asyncio.new_event_loop())
future.set_result("mock")
aiowrite.return_value = future
- msg_bus = MessageBusClient(self.config, loop=self.loop)
+ msg_bus = MessageBusClient(self.config)
topic = "test_topic"
key = "test_key"
msg = {"test": "test_msg"}
- self.loop.run_until_complete(msg_bus.aiowrite(topic, key, msg))
- aiowrite.assert_called_with(topic, key, msg, self.loop)
+ asyncio.run(msg_bus.aiowrite(topic, key, msg))
+ aiowrite.assert_called_with(topic, key, msg)
@mock.patch.object(MsgKafka, "aioread")
def test_aioread_once(self, aioread):
- future = asyncio.Future(loop=self.loop)
+ future = asyncio.Future(loop=asyncio.new_event_loop())
future.set_result("mock")
aioread.return_value = future
- msg_bus = MessageBusClient(self.config, loop=self.loop)
+ msg_bus = MessageBusClient(self.config)
topic = "test_topic"
- self.loop.run_until_complete(msg_bus.aioread_once(topic))
- aioread.assert_called_with("test_topic", self.loop)
+ asyncio.run(msg_bus.aioread_once(topic))
+ aioread.assert_called_with("test_topic")
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master
# google-auth
-certifi==2022.12.7
+certifi==2023.5.7
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master
# kubernetes
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master
# requests
-cryptography==39.0.0
+cryptography==40.0.2
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master
# paramiko
dataclasses==0.6
# via -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master
-google-auth==2.16.0
+dnspython==2.3.0
+ # via
+ # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master
+ # -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master
+ # pymongo
+google-auth==2.17.3
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master
# kubernetes
# via
# -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master
# aiokafka
-kubernetes==25.3.0
+kubernetes==26.1.0
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master
# juju
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master
# juju
# theblues
-motor==1.3.1
+motor==3.1.2
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master
# -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master
-mypy-extensions==0.4.3
+mypy-extensions==1.0.0
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master
# typing-inspect
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master
# requests-oauthlib
-packaging==23.0
+packaging==23.1
# via
# -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master
# aiokafka
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master
# macaroonbakery
-pyasn1==0.4.8
+pyasn1==0.5.0
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master
# juju
# pyasn1-modules
# rsa
-pyasn1-modules==0.2.8
+pyasn1-modules==0.3.0
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master
# google-auth
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master
# macaroonbakery
-pymongo==3.13.0
+pymongo==4.3.3
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master
# -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master
# kubernetes
-pytz==2022.7.1
+pytz==2023.3
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master
# pyrfc3339
# juju
# jujubundlelib
# kubernetes
-requests==2.28.2
+requests==2.30.0
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master
# kubernetes
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master
# juju
-toposort==1.9
+toposort==1.10
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master
# juju
-typing-extensions==4.4.0
+typing-extensions==4.5.0
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master
# typing-inspect
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master
# juju
-urllib3==1.26.14
+urllib3==2.0.2
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master
# kubernetes
# requests
-websocket-client==1.5.0
+websocket-client==1.5.1
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master
# kubernetes
-websockets==7.0
+websockets==11.0.3
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=master
# juju
# See the License for the specific language governing permissions and
# limitations under the License.
#######################################################################################
-certifi==2022.12.7
+certifi==2023.5.7
# via
# -r requirements-test.in
# requests
# via
# -r requirements-test.in
# requests
-coverage==7.1.0
+coverage==7.2.5
# via -r requirements-test.in
idna==3.4
# via requests
-mock==5.0.1
+mock==5.0.2
# via -r requirements-test.in
-nose2==0.12.0
+nose2==0.13.0
# via -r requirements-test.in
-requests==2.28.2
+requests==2.30.0
# via requests-mock
requests-mock==1.10.0
# via -r requirements-test.in
six==1.16.0
# via requests-mock
-urllib3==1.26.14
+urllib3==2.0.2
# via requests
# via openstacksdk
async-timeout==4.0.2
# via aiokafka
-attrs==22.2.0
+attrs==23.1.0
# via cmd2
autopage==0.5.1
# via cliff
-backports-zoneinfo==0.2.1
- # via
- # pytz-deprecation-shim
- # tzlocal
-certifi==2022.12.7
+certifi==2023.5.7
# via
# -r requirements.in
# requests
# via
# -r requirements.in
# requests
-cliff==4.1.0
+cliff==4.3.0
# via
# gnocchiclient
# osc-lib
# via cliff
contourpy==1.0.7
# via matplotlib
-cryptography==39.0.0
+cryptography==40.0.2
# via
# -r requirements.in
# openstacksdk
cycler==0.11.0
# via matplotlib
-dateparser==1.1.6
+dateparser==1.1.8
# via prometheus-api-client
debtcollector==2.5.0
# via
# via
# dogpile-cache
# openstacksdk
-dogpile-cache==1.1.8
+dogpile-cache==1.2.0
# via openstacksdk
-fonttools==4.38.0
+fonttools==4.39.4
# via matplotlib
futurist==2.4.1
# via gnocchiclient
-gnocchiclient==7.0.7
+gnocchiclient==7.0.8
# via -r requirements.in
httmock==1.4.0
# via prometheus-api-client
# pyvcloud
idna==3.4
# via requests
-importlib-metadata==6.0.0
+importlib-metadata==6.6.0
# via cliff
iso8601==1.1.0
# via
# via jsonpatch
kafka-python==2.0.2
# via aiokafka
-keystoneauth1==5.1.1
+keystoneauth1==5.1.2
# via
# gnocchiclient
# openstacksdk
# -r requirements.in
# pyvcloud
# unittest-xml-reporting
-matplotlib==3.6.3
+matplotlib==3.7.1
# via prometheus-api-client
-monotonic==1.6
- # via gnocchiclient
-msgpack==1.0.4
+msgpack==1.0.5
# via oslo-serialization
-munch==2.5.0
- # via openstacksdk
netaddr==0.8.0
# via
# oslo-config
# via
# openstacksdk
# oslo-utils
-numpy==1.24.1
+numpy==1.24.3
# via
# contourpy
# matplotlib
# pandas
# prometheus-api-client
-openstacksdk==0.103.0
+openstacksdk==1.1.0
# via
# os-client-config
# osc-lib
# via
# keystoneauth1
# openstacksdk
-osc-lib==2.6.2
+osc-lib==2.8.0
# via python-neutronclient
-oslo-config==9.1.0
+oslo-config==9.1.1
# via
# oslo-log
# python-keystoneclient
-oslo-context==5.0.0
+oslo-context==5.1.1
# via oslo-log
-oslo-i18n==5.1.0
+oslo-i18n==6.0.0
# via
# osc-lib
# oslo-config
# python-keystoneclient
# python-neutronclient
# python-novaclient
-oslo-log==5.0.2
+oslo-log==5.2.0
# via python-neutronclient
-oslo-serialization==5.0.0
+oslo-serialization==5.1.1
# via
# oslo-log
# python-ceilometerclient
# python-keystoneclient
# python-neutronclient
# python-novaclient
-packaging==23.0
+packaging==23.1
# via
# aiokafka
# matplotlib
# oslo-utils
# python-keystoneclient
# pyvcloud
-pandas==1.5.3
+pandas==2.0.1
# via prometheus-api-client
pbr==5.11.1
# via
- # gnocchiclient
# keystoneauth1
# openstacksdk
# os-service-types
# python-neutronclient
# python-novaclient
# stevedore
-pillow==9.4.0
+pillow==9.5.0
# via matplotlib
prettytable==0.7.2
# via
# python-ceilometerclient
# python-cinderclient
# python-novaclient
-prometheus-api-client==0.5.2
+prometheus-api-client==0.5.3
# via -r requirements.in
prometheus-client==0.16.0
# via -r requirements.in
pycparser==2.21
# via cffi
-pygments==2.14.0
+pygments==2.15.1
# via pyvcloud
pyinotify==0.9.6
# via oslo-log
# oslo-log
# pandas
# pyvcloud
-python-keystoneclient==5.0.1
+python-keystoneclient==5.1.0
# via
# -r requirements.in
# python-neutronclient
-python-neutronclient==8.2.1
+python-neutronclient==9.0.0
# via -r requirements.in
-python-novaclient==18.2.0
+python-novaclient==18.3.0
# via -r requirements.in
-pytz==2022.7.1
+pytz==2023.3
# via
# dateparser
# oslo-serialization
# openstacksdk
# oslo-config
# pyvcloud
-regex==2022.10.31
+regex==2023.5.5
# via dateparser
-requests==2.28.2
+requests==2.30.0
# via
# -r requirements.in
# httmock
# via openstacksdk
rfc3986==2.0.0
# via oslo-config
-simplejson==3.18.1
+simplejson==3.19.1
# via
# osc-lib
# python-cinderclient
# -r requirements.in
# gnocchiclient
# keystoneauth1
- # munch
# python-ceilometerclient
# python-dateutil
# python-keystoneclient
-stevedore==4.1.1
+stevedore==5.0.0
# via
# cliff
# dogpile-cache
# python-cinderclient
# python-keystoneclient
# python-novaclient
-tzdata==2022.7
- # via pytz-deprecation-shim
-tzlocal==4.2
+tzdata==2023.3
+ # via
+ # pandas
+ # pytz-deprecation-shim
+tzlocal==4.3
# via dateparser
ujson==5.7.0
# via gnocchiclient
unittest-xml-reporting==3.2.0
# via pyvcloud
-urllib3==1.26.14
+urllib3==2.0.2
# via requests
vcd-api-schemas-type==10.3.0.dev72
# via pyvcloud
wcwidth==0.2.6
# via cmd2
-wrapt==1.14.1
+wrapt==1.15.0
# via debtcollector
-zipp==3.12.0
+zipp==3.15.0
# via importlib-metadata
[testenv]
usedevelop = True
-basepython = python3.8
+basepython = python3.10
setenv = VIRTUAL_ENV={envdir}
PYTHONDONTWRITEBYTECODE = 1
deps = -r{toxinidir}/requirements.txt