# 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
-# Copyright 2017 Intel Research and Development Ireland Limited
-# *************************************************************
-
-# This file is part of OSM Monitoring module
-# All Rights Reserved to Intel Corporation
-
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-
-# http://www.apache.org/licenses/LICENSE-2.0
-
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-# For those usages not covered by the Apache License, Version 2.0 please
-# contact: prithiv.mohan@intel.com or adrian.hoban@intel.com
-
-#__author__ = "Prithiv Mohan"
-#__date__ = "25/Sep/2017"
-
-
#!/bin/sh
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#######################################################################################
rm -rf pool
rm -rf dists
mkdir -p pool/MON
mv deb_dist/*.deb pool/MON/
-mkdir -p dists/unstable/MON/binary-amd64/
-apt-ftparchive packages pool/MON > dists/unstable/MON/binary-amd64/Packages
-gzip -9fk dists/unstable/MON/binary-amd64/Packages
-echo 'dists/**,pool/MON/*.deb'
\ No newline at end of file
# 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=paas
# 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=paas
# kubernetes
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=paas
# cryptography
# pynacl
-charset-normalizer==3.0.1
+charset-normalizer==3.1.0
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=paas
# -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=paas
# requests
-cryptography==39.0.1
+cryptography==40.0.2
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=paas
# paramiko
dataclasses==0.6
# via -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=paas
-google-auth==2.16.1
+dnspython==2.3.0
+ # via
+ # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=paas
+ # -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=paas
+ # pymongo
+google-auth==2.17.3
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=paas
# kubernetes
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=paas
# juju
-motor==1.3.1
+ # theblues
+motor==3.1.2
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=paas
# -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=paas
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=paas
# 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=paas
# aiokafka
# -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=paas
# macaroonbakery
# temporalio
-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=paas
# 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=paas
# google-auth
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=paas
# 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=paas
# -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=paas
# -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=paas
# kubernetes
# temporalio
-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=paas
# pyrfc3339
# -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=paas
# juju
# 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=paas
# hvac
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=paas
# 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=paas
# kubernetes
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=paas
# kubernetes
-websockets==8.1
+websockets==11.0.3
# via
# -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=paas
# juju
# contact: helena.mcgough@intel.com or adrian.hoban@intel.com
##
certifi
-charset-normalizer<4 # Required by aiohttp in LCM via N2VC
+charset-normalizer
coverage
mock
nose2
# 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
-charset-normalizer==3.0.1
+charset-normalizer==3.1.0
# via
# -r requirements-test.in
# requests
-coverage==7.2.1
+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
aiokafka
certifi
cffi
-charset-normalizer<4 # Required by aiohttp in LCM via N2VC
+charset-normalizer
cryptography
gnocchiclient
humanfriendly
# 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
# cryptography
-charset-normalizer==3.0.1
+charset-normalizer==3.1.0
# via
# -r requirements.in
# requests
-cliff==4.2.0
+cliff==4.3.0
# via
# gnocchiclient
# osc-lib
# via cliff
contourpy==1.0.7
# via matplotlib
-cryptography==39.0.1
+cryptography==40.0.2
# via
# -r requirements.in
# openstacksdk
cycler==0.11.0
# via matplotlib
-dateparser==1.1.7
+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
# pyvcloud
idna==3.4
# via requests
-importlib-metadata==6.0.0
+importlib-metadata==6.6.0
# via cliff
importlib-resources==5.12.0
# via matplotlib
# -r requirements.in
# pyvcloud
# unittest-xml-reporting
-matplotlib==3.7.0
+matplotlib==3.7.1
# via prometheus-api-client
-msgpack==1.0.4
+msgpack==1.0.5
# via oslo-serialization
netaddr==0.8.0
# via
# via
# openstacksdk
# oslo-utils
-numpy==1.24.2
+numpy==1.24.3
# via
# contourpy
# matplotlib
# pandas
# prometheus-api-client
-openstacksdk==1.0.1
+openstacksdk==1.1.0
# via
# os-client-config
# osc-lib
+ # python-neutronclient
os-client-config==2.1.0
# via python-neutronclient
os-service-types==1.7.0
# via
# keystoneauth1
# openstacksdk
-osc-lib==2.7.0
+osc-lib==2.8.0
# via python-neutronclient
oslo-config==9.1.1
# via
# python-keystoneclient
# python-neutronclient
# python-novaclient
-oslo-log==5.1.0
+oslo-log==5.2.0
# via python-neutronclient
oslo-serialization==5.1.1
# via
# 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
# python-neutronclient
# python-novaclient
# stevedore
-pillow==9.4.0
+pillow==9.5.0
# via matplotlib
prettytable==0.7.2
# via
# 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
# via
# -r requirements.in
# python-neutronclient
-python-neutronclient==9.0.0
+python-neutronclient==10.0.0
# via -r requirements.in
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.3
+simplejson==3.19.1
# via
# osc-lib
# python-cinderclient
# python-cinderclient
# python-keystoneclient
# python-novaclient
-tzdata==2022.7
- # via pytz-deprecation-shim
-tzlocal==4.2
+tzdata==2023.3
+ # via pandas
+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
[testenv]
usedevelop = True
-basepython = python3.8
+basepython = python3.10
setenv = VIRTUAL_ENV={envdir}
PYTHONDONTWRITEBYTECODE = 1
deps = -r{toxinidir}/requirements.txt
coverage report --omit='*tests*'
coverage html -d ./cover --omit='*tests*'
coverage xml -o coverage.xml --omit=*tests*
-whitelist_externals = sh
+allowlist_externals = sh
#######################################################################################
[testenv:pip-compile]
deps = pip-tools==6.6.2
skip_install = true
-whitelist_externals = bash
+allowlist_externals = bash
[
commands =
- bash -c "for file in requirements*.in ; do \
[testenv:dist]
deps = {[testenv]deps}
-r{toxinidir}/requirements-dist.txt
-
+allowlist_externals = sh
# In the commands, we copy the requirements.txt to be presented as a source file (.py)
# so it gets included in the .deb package for others to consume
commands =
python3 setup.py --command-packages=stdeb.command sdist_dsc
sh -c 'cd deb_dist/osm-mon*/ && dpkg-buildpackage -rfakeroot -uc -us'
sh -c 'rm osm_mon/requirements.txt'
-whitelist_externals = sh
#######################################################################################
[flake8]