try cotyledon

Depends-On: Id4e3b9c866b867f9e9a1f03d05d22ac53c270b86
Change-Id: I928d6c570061afd1e684808e74cefca7672b31d1
This commit is contained in:
Eyal 2018-04-09 17:03:07 +03:00
parent 5c4bd36e80
commit 6acd8b2b8d
17 changed files with 157 additions and 164 deletions

View File

@ -139,3 +139,4 @@ WebOb==1.7.4
WebTest==2.0.29 WebTest==2.0.29
Werkzeug==0.14.1 Werkzeug==0.14.1
wrapt==1.10.11 wrapt==1.10.11
futures==3.0.0

View File

@ -2,48 +2,47 @@
# of appearance. Changing the order has an impact on the overall integration # of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later. # process, which may cause wedges in the gate later.
pbr!=2.1.0,>=2.0.0 # Apache-2.0 pbr>=3.1.1 # Apache-2.0
Babel!=2.4.0,>=2.3.4 # BSD Babel>=2.5.3 # BSD
lxml!=3.7.0,>=3.4.1 # BSD lxml>=4.1.1 # BSD
PyMySQL>=0.7.6 # MIT License PyMySQL>=0.8.0 # MIT License
aodhclient>=0.9.0 # Apache-2.0 aodhclient>=1.0.0 # Apache-2.0
python-ceilometerclient>=2.5.0 # Apache-2.0 python-ceilometerclient>=2.9.0 # Apache-2.0
python-cinderclient>=3.3.0 # Apache-2.0 python-cinderclient>=3.5.0 # Apache-2.0
python-dateutil>=2.5.3 # BSD python-dateutil>=2.7.0 # BSD
python-keystoneclient>=3.8.0 # Apache-2.0 python-keystoneclient>=3.15.0 # Apache-2.0
python-neutronclient>=6.7.0 # Apache-2.0 python-neutronclient>=6.7.0 # Apache-2.0
python-novaclient>=9.1.0 # Apache-2.0 python-novaclient>=10.1.0 # Apache-2.0
python-heatclient>=1.10.0 # Apache-2.0 python-heatclient>=1.14.0 # Apache-2.0
python-mistralclient!=3.2.0,>=3.1.0 # Apache-2.0 python-mistralclient>=3.3.0 # Apache-2.0
pyzabbix>=0.7.4 # LGPL pyzabbix>=0.7.4 # LGPL
networkx<2.0,>=1.10 # BSD networkx<2.0,>=1.11 # BSD
oslo.config>=5.2.0 # Apache-2.0 oslo.config>=5.2.0 # Apache-2.0
oslo.context>=2.19.2 # Apache-2.0 oslo.context>=2.20.0 # Apache-2.0
oslo.db>=4.27.0 # Apache-2.0 oslo.db>=4.35.0 # Apache-2.0
oslo.messaging>=5.29.0 # Apache-2.0 oslo.messaging>=5.36.0 # Apache-2.0
oslo.middleware>=3.31.0 # Apache-2.0 oslo.middleware>=3.35.0 # Apache-2.0
oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0 oslo.serialization>=2.25.0 # Apache-2.0
oslo.log>=3.36.0 # Apache-2.0 oslo.log>=3.37.0 # Apache-2.0
oslo.policy>=1.30.0 # Apache-2.0 oslo.policy>=1.34.0 # Apache-2.0
oslo.service!=1.28.1,>=1.24.0 # Apache-2.0 oslo.i18n>=3.20.0 # Apache-2.0
oslo.i18n>=3.15.3 # Apache-2.0 pecan>=1.2.1 # BSD
pecan!=1.0.2,!=1.0.3,!=1.0.4,!=1.2,>=1.0.0 # BSD PasteDeploy>=1.5.2 # MIT
PasteDeploy>=1.5.0 # MIT Werkzeug>=0.14.1 # BSD License
Werkzeug>=0.9 # BSD License keystonemiddleware>=4.21.0 # Apache-2.0
keystonemiddleware>=4.17.0 # Apache-2.0 stevedore>=1.28.0 # Apache-2.0
stevedore>=1.20.0 # Apache-2.0 voluptuous>=0.11.1 # BSD License
voluptuous>=0.8.9 # BSD License SQLAlchemy>=1.2.5 # MIT
SQLAlchemy!=1.1.5,!=1.1.6,!=1.1.7,!=1.1.8,>=1.0.10 # MIT sympy>=1.1.1 # BSD
sympy>=0.7.6 # BSD pysnmp>=4.4.4 # BSD
pysnmp>=4.2.3 # BSD PyJWT>=1.6.0 # MIT
PyJWT>=1.0.1 # MIT osprofiler>=2.0.0 # Apache-2.0
osprofiler>=1.4.0 # Apache-2.0
keystoneauth1>=3.4.0 # Apache-2.0 keystoneauth1>=3.4.0 # Apache-2.0
PyYAML>=3.12 # MIT PyYAML>=3.12 # MIT
requests>=2.14.2 # Apache-2.0 requests>=2.18.4 # Apache-2.0
WebOb>=1.7.1 # MIT WebOb>=1.7.4 # MIT
eventlet!=0.18.3,!=0.20.1,<0.21.0,>=0.18.2 # MIT eventlet!=0.20.1,>=0.20.0 # MIT
six>=1.10.0 # MIT six>=1.11.0 # MIT
debtcollector>=1.2.0 # Apache-2.0 debtcollector>=1.19.0 # Apache-2.0
cotyledon>=1.3.0 # Apache-2.0 cotyledon>=1.6.8 # Apache-2.0
futures>=3.0.0;python_version=='2.7' or python_version=='2.6' # BSD futures>=3.0.0;python_version=='2.7' or python_version=='2.6' # BSD

View File

@ -3,36 +3,35 @@
# process, which may cause wedges in the gate later. # process, which may cause wedges in the gate later.
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0 hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
python-dateutil>=2.5.3 # BSD python-dateutil>=2.7.0 # BSD
coverage!=4.4,>=4.0 # Apache-2.0 coverage>=4.5.1 # Apache-2.0
lxml!=3.7.0,>=3.4.1 # BSD lxml>=4.1.1 # BSD
networkx<2.0,>=1.10 # BSD networkx<2.0,>=1.11 # BSD
PyMySQL>=0.7.6 # MIT License PyMySQL>=0.8.0 # MIT License
python-ceilometerclient>=2.5.0 # Apache-2.0 python-ceilometerclient>=2.9.0 # Apache-2.0
python-cinderclient>=3.3.0 # Apache-2.0 python-cinderclient>=3.5.0 # Apache-2.0
python-neutronclient>=6.7.0 # Apache-2.0 python-neutronclient>=6.7.0 # Apache-2.0
python-novaclient>=9.1.0 # Apache-2.0 python-novaclient>=10.1.0 # Apache-2.0
python-heatclient>=1.10.0 # Apache-2.0 python-heatclient>=1.14.0 # Apache-2.0
python-subunit>=1.0.0 # Apache-2.0/BSD python-subunit>=1.2.0 # Apache-2.0/BSD
pyzabbix>=0.7.4 # LGPL pyzabbix>=0.7.4 # LGPL
oslo.db>=4.27.0 # Apache-2.0 oslo.db>=4.35.0 # Apache-2.0
oslo.log>=3.36.0 # Apache-2.0 oslo.log>=3.37.0 # Apache-2.0
oslotest>=3.2.0 # Apache-2.0 oslotest>=3.3.0 # Apache-2.0
oslo.service!=1.28.1,>=1.24.0 # Apache-2.0
oslo.config>=5.2.0 # Apache-2.0 oslo.config>=5.2.0 # Apache-2.0
oslo.messaging>=5.29.0 # Apache-2.0 oslo.messaging>=5.36.0 # Apache-2.0
oslo.i18n>=3.15.3 # Apache-2.0 oslo.i18n>=3.20.0 # Apache-2.0
oslo.policy>=1.30.0 # Apache-2.0 oslo.policy>=1.34.0 # Apache-2.0
pecan!=1.0.2,!=1.0.3,!=1.0.4,!=1.2,>=1.0.0 # BSD pecan>=1.2.1 # BSD
requests-mock>=1.2.0 # Apache-2.0 requests-mock>=1.4.0 # Apache-2.0
testrepository>=0.0.18 # Apache-2.0/BSD testrepository>=0.0.20 # Apache-2.0/BSD
testscenarios>=0.4 # Apache-2.0/BSD testscenarios>=0.5.0 # Apache-2.0/BSD
testtools>=2.2.0 # MIT testtools>=2.3.0 # MIT
stestr>=1.0.0 # Apache-2.0 stestr>=2.0.0 # Apache-2.0
stevedore>=1.20.0 # Apache-2.0 stevedore>=1.28.0 # Apache-2.0
voluptuous>=0.8.9 # BSD License voluptuous>=0.11.1 # BSD License
sympy>=0.7.6 # BSD sympy>=1.1.1 # BSD
reno>=2.5.0 # Apache-2.0 reno>=2.7.0 # Apache-2.0
pysnmp>=4.2.3 # BSD pysnmp>=4.4.4 # BSD
osprofiler>=1.4.0 # Apache-2.0 osprofiler>=2.0.0 # Apache-2.0
SQLAlchemy!=1.1.5,!=1.1.6,!=1.1.7,!=1.1.8,>=1.0.10 # MIT SQLAlchemy>=1.2.5 # MIT

View File

@ -12,13 +12,15 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import copy import copy
import sys import sys
import cotyledon
from futurist import periodics
from futurist import ThreadPoolExecutor
from oslo_log import log from oslo_log import log
import oslo_messaging import oslo_messaging
from oslo_service import service as os_service
from tools.load_generator.notification_info import * # noqa from tools.load_generator.notification_info import * # noqa
from vitrage.messaging import get_transport from vitrage.messaging import get_transport
from vitrage import service from vitrage import service
@ -59,9 +61,9 @@ to avoid Vitrage consistency deleting the created resources.
""" """
class StressNotificationsService(os_service.Service): class StressNotificationsService(cotyledon.Service):
def __init__(self, conf): def __init__(self, worker_id, conf):
super(StressNotificationsService, self).__init__() super(StressNotificationsService, self).__init__(worker_id)
self.oslo_notifier = None self.oslo_notifier = None
topics = conf.datasources.notification_topics topics = conf.datasources.notification_topics
self.oslo_notifier = oslo_messaging.Notifier( self.oslo_notifier = oslo_messaging.Notifier(
@ -69,16 +71,19 @@ class StressNotificationsService(os_service.Service):
driver='messagingv2', driver='messagingv2',
publisher_id='vitrage.stress', publisher_id='vitrage.stress',
topics=topics) topics=topics)
self.periodic = periodics.PeriodicWorker.create(
[], executor_factory=lambda: ThreadPoolExecutor(max_workers=10))
def start(self): def run(self):
super(StressNotificationsService, self).start()
self.tg.add_timer(RUN_EVERY_X_SECONDS, self.stress_notifications, )
LOG.info("StressNotificationsService - Started!") LOG.info("StressNotificationsService - Started!")
self.periodic.add(self.stress_notifications)
self.periodic.start()
def stop(self, graceful=False): def terminate(self):
super(StressNotificationsService, self).stop(graceful) self.periodic.stop()
LOG.info("StressNotificationsService - Stopped!") LOG.info("StressNotificationsService - Stopped!")
@periodics.periodic(spacing=RUN_EVERY_X_SECONDS)
def stress_notifications(self): def stress_notifications(self):
notifications = [] notifications = []
for i in range(EXISTING_COMPUTES_NUM * VMS_PER_COMPUTE): for i in range(EXISTING_COMPUTES_NUM * VMS_PER_COMPUTE):
@ -137,9 +142,9 @@ def create_vm(instance_num, compute_num):
def main(): def main():
conf = service.prepare_service() conf = service.prepare_service()
launcher = os_service.ServiceLauncher(conf) sm = cotyledon.ServiceManager()
launcher.launch_service(StressNotificationsService(conf)) sm.add(StressNotificationsService, args=(conf,))
launcher.wait() sm.run()
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -14,7 +14,6 @@
from oslo_log import log from oslo_log import log
import oslo_messaging import oslo_messaging
from oslo_service import service as os_service
from vitrage.common.utils import spawn from vitrage.common.utils import spawn
from vitrage.entity_graph import EVALUATOR_TOPIC from vitrage.entity_graph import EVALUATOR_TOPIC
@ -34,7 +33,7 @@ from vitrage import storage
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
class VitrageApiHandlerService(os_service.Service): class VitrageApiHandlerService(object):
def __init__(self, conf, e_graph): def __init__(self, conf, e_graph):
super(VitrageApiHandlerService, self).__init__() super(VitrageApiHandlerService, self).__init__()
@ -50,8 +49,6 @@ class VitrageApiHandlerService(os_service.Service):
def _start(self): def _start(self):
LOG.info("Vitrage Api Handler Service - Starting...") LOG.info("Vitrage Api Handler Service - Starting...")
super(VitrageApiHandlerService, self).start()
transport = messaging.get_rpc_transport(self.conf) transport = messaging.get_rpc_transport(self.conf)
rabbit_hosts = self.conf.oslo_messaging_rabbit.rabbit_hosts rabbit_hosts = self.conf.oslo_messaging_rabbit.rabbit_hosts
target = oslo_messaging.Target(topic=self.conf.rpc_topic, target = oslo_messaging.Target(topic=self.conf.rpc_topic,
@ -70,10 +67,3 @@ class VitrageApiHandlerService(os_service.Service):
server.start() server.start()
LOG.info("Vitrage Api Handler Service - Started!") LOG.info("Vitrage Api Handler Service - Started!")
def stop(self, graceful=False):
LOG.info("Vitrage Api Handler Service - Stopping...")
super(VitrageApiHandlerService, self).stop(graceful)
LOG.info("Vitrage Api Handler Service - Stopped!")

View File

@ -12,25 +12,41 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import cotyledon
import sys import sys
from oslo_service import service as os_service
from vitrage.cli import VITRAGE_TITLE from vitrage.cli import VITRAGE_TITLE
from vitrage.common import utils
from vitrage.datasources.listener_service import ListenerService from vitrage.datasources.listener_service import ListenerService
from vitrage.datasources.rpc_service import CollectorRpcHandlerService from vitrage.datasources.rpc_service import CollectorRpcHandlerService
from vitrage import service from vitrage import service
class CollectorService(cotyledon.Service):
def __init__(self, worker_id, conf):
super(CollectorService, self).__init__(worker_id)
self.csvc = CollectorRpcHandlerService(conf)
utils.spawn(self.csvc.start)
self.lsvc = ListenerService(conf)
utils.spawn(self.lsvc.start)
def terminate(self):
super(CollectorService, self).terminate()
self.lsvc.stop()
self.csvc.stop()
def main(): def main():
"""Starts all the datasources drivers services""" """Starts all the datasources drivers services"""
print(VITRAGE_TITLE) print(VITRAGE_TITLE)
conf = service.prepare_service() conf = service.prepare_service()
launcher = os_service.ServiceLauncher(conf) sm = cotyledon.ServiceManager()
launcher.launch_service(ListenerService(conf)) sm.add(CollectorService, args=(conf,))
launcher.launch_service(CollectorRpcHandlerService(conf)) sm.run()
launcher.wait()
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_service import service as os_service import cotyledon
import sys import sys
from vitrage.cli import VITRAGE_TITLE from vitrage.cli import VITRAGE_TITLE
@ -23,9 +23,9 @@ from vitrage import service
def main(): def main():
print(VITRAGE_TITLE) print(VITRAGE_TITLE)
conf = service.prepare_service() conf = service.prepare_service()
launcher = os_service.ServiceLauncher(conf) sm = cotyledon.ServiceManager()
launcher.launch_service(MachineLearningService(conf)) sm.add(MachineLearningService, args=(conf,))
launcher.wait() sm.run()
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -11,8 +11,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import cotyledon
from oslo_service import service as os_service
import sys import sys
from vitrage.cli import VITRAGE_TITLE from vitrage.cli import VITRAGE_TITLE
@ -23,9 +22,9 @@ from vitrage import service
def main(): def main():
print(VITRAGE_TITLE) print(VITRAGE_TITLE)
conf = service.prepare_service() conf = service.prepare_service()
launcher = os_service.ServiceLauncher(conf) sm = cotyledon.ServiceManager()
launcher.launch_service(VitrageNotifierService(conf)) sm.add(VitrageNotifierService, args=(conf,))
launcher.wait() sm.run()
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -14,8 +14,8 @@
import sys import sys
import cotyledon
from oslo_log import log from oslo_log import log
from oslo_service import service as os_service
from vitrage.cli import VITRAGE_TITLE from vitrage.cli import VITRAGE_TITLE
from vitrage.persistency.service import PersistorService from vitrage.persistency.service import PersistorService
from vitrage import service from vitrage import service
@ -28,9 +28,9 @@ def main():
print(VITRAGE_TITLE) print(VITRAGE_TITLE)
conf = service.prepare_service() conf = service.prepare_service()
db_connection = storage.get_connection_from_config(conf) db_connection = storage.get_connection_from_config(conf)
launcher = os_service.ServiceLauncher(conf) sm = cotyledon.ServiceManager()
launcher.launch_service(PersistorService(conf, db_connection)) sm.add(PersistorService, args=(conf, db_connection))
launcher.wait() sm.run()
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -14,7 +14,7 @@
import sys import sys
from oslo_service import service as os_service import cotyledon
from vitrage.cli import VITRAGE_TITLE from vitrage.cli import VITRAGE_TITLE
from vitrage import service from vitrage import service
from vitrage.snmp_parsing.service import SnmpParsingService from vitrage.snmp_parsing.service import SnmpParsingService
@ -23,9 +23,9 @@ from vitrage.snmp_parsing.service import SnmpParsingService
def main(): def main():
print(VITRAGE_TITLE) print(VITRAGE_TITLE)
conf = service.prepare_service() conf = service.prepare_service()
launcher = os_service.ServiceLauncher(conf) sm = cotyledon.ServiceManager()
launcher.launch_service(SnmpParsingService(conf)) sm.add(SnmpParsingService, args=(conf,))
launcher.wait() sm.run()
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -16,7 +16,6 @@ from collections import defaultdict
from oslo_log import log from oslo_log import log
import oslo_messaging import oslo_messaging
from oslo_service import service as os_service
from vitrage.datasources import utils from vitrage.datasources import utils
from vitrage import messaging from vitrage import messaging
@ -25,7 +24,7 @@ from vitrage.messaging import VitrageNotifier
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
class ListenerService(os_service.Service): class ListenerService(object):
def __init__(self, conf): def __init__(self, conf):
super(ListenerService, self).__init__() super(ListenerService, self).__init__()
@ -43,18 +42,16 @@ class ListenerService(os_service.Service):
def start(self): def start(self):
LOG.info("Vitrage data source Listener Service - Starting...") LOG.info("Vitrage data source Listener Service - Starting...")
super(ListenerService, self).start()
self.listener.start() self.listener.start()
LOG.info("Vitrage data source Listener Service - Started!") LOG.info("Vitrage data source Listener Service - Started!")
def stop(self, graceful=False): def stop(self):
LOG.info("Vitrage data source Listener Service - Stopping...") LOG.info("Vitrage data source Listener Service - Stopping...")
# Should it be here? # Should it be here?
# self.listener.stop() # self.listener.stop()
# self.listener.wait() # self.listener.wait()
super(ListenerService, self).stop(graceful)
LOG.info("Vitrage data source Listener Service - Stopped!") LOG.info("Vitrage data source Listener Service - Stopped!")

View File

@ -16,7 +16,6 @@ from concurrent import futures
import time import time
from oslo_log import log from oslo_log import log
from oslo_service import service as os_service
from vitrage.common.constants import DatasourceAction from vitrage.common.constants import DatasourceAction
from vitrage.datasources import utils from vitrage.datasources import utils
@ -26,7 +25,7 @@ from vitrage import rpc as vitrage_rpc
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
class CollectorRpcHandlerService(os_service.Service): class CollectorRpcHandlerService(object):
def __init__(self, conf): def __init__(self, conf):
super(CollectorRpcHandlerService, self).__init__() super(CollectorRpcHandlerService, self).__init__()
@ -39,13 +38,11 @@ class CollectorRpcHandlerService(os_service.Service):
def start(self): def start(self):
LOG.info("Collector Rpc Handler Service - Starting...") LOG.info("Collector Rpc Handler Service - Starting...")
super(CollectorRpcHandlerService, self).start()
self.server.start() self.server.start()
LOG.info("Collector Rpc Handler Service - Started!") LOG.info("Collector Rpc Handler Service - Started!")
def stop(self, graceful=False): def stop(self):
LOG.info("Collector Rpc Handler Service - Stopping...") LOG.info("Collector Rpc Handler Service - Stopping...")
super(CollectorRpcHandlerService, self).stop(graceful)
self.server.stop() self.server.stop()
LOG.info("Collector Rpc Handler Service - Stopped!") LOG.info("Collector Rpc Handler Service - Stopped!")

View File

@ -12,9 +12,10 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import cotyledon
from oslo_log import log from oslo_log import log
import oslo_messaging as oslo_m import oslo_messaging as oslo_m
from oslo_service import service as os_service
from oslo_utils import importutils from oslo_utils import importutils
from vitrage import messaging from vitrage import messaging
@ -23,10 +24,10 @@ from vitrage.opts import register_opts
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
class MachineLearningService(os_service.Service): class MachineLearningService(cotyledon.Service):
def __init__(self, conf): def __init__(self, worker_id, conf):
super(MachineLearningService, self).__init__() super(MachineLearningService, self).__init__(worker_id)
self.conf = conf self.conf = conf
self.machine_learning_plugins = self.get_machine_learning_plugins(conf) self.machine_learning_plugins = self.get_machine_learning_plugins(conf)
transport = messaging.get_transport(conf) transport = messaging.get_transport(conf)
@ -36,20 +37,18 @@ class MachineLearningService(os_service.Service):
transport, [target], transport, [target],
[VitrageEventEndpoint(self.machine_learning_plugins)]) [VitrageEventEndpoint(self.machine_learning_plugins)])
def start(self): def run(self):
LOG.info("Vitrage Machine Learning Service - Starting...") LOG.info("Vitrage Machine Learning Service - Starting...")
super(MachineLearningService, self).start()
self.listener.start() self.listener.start()
LOG.info("Vitrage Machine Learning Service - Started!") LOG.info("Vitrage Machine Learning Service - Started!")
def stop(self, graceful=False): def terminate(self):
LOG.info("Vitrage Machine Learning Service - Stopping...") LOG.info("Vitrage Machine Learning Service - Stopping...")
self.listener.stop() self.listener.stop()
self.listener.wait() self.listener.wait()
super(MachineLearningService, self).stop(graceful)
LOG.info("Vitrage Machine Learning Service - Stopped!") LOG.info("Vitrage Machine Learning Service - Stopped!")

View File

@ -11,10 +11,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import cotyledon
from oslo_log import log from oslo_log import log
import oslo_messaging import oslo_messaging
from oslo_service import service as os_service
from oslo_utils import importutils from oslo_utils import importutils
from vitrage import messaging from vitrage import messaging
@ -23,32 +22,29 @@ from vitrage.opts import register_opts
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
class VitrageNotifierService(os_service.Service): class VitrageNotifierService(cotyledon.Service):
def __init__(self, conf): def __init__(self, worker_id, conf):
super(VitrageNotifierService, self).__init__() super(VitrageNotifierService, self).__init__(worker_id)
self.conf = conf self.conf = conf
self.notifiers = self.get_notifier_plugins(conf) self.notifiers = self.get_notifier_plugins(conf)
self._init_listeners(self.conf) self._init_listeners(self.conf)
def start(self): def run(self):
LOG.info("Vitrage Notifier Service - Starting...") LOG.info("Vitrage Notifier Service - Starting...")
super(VitrageNotifierService, self).start()
for listener in self.listeners: for listener in self.listeners:
listener.start() listener.start()
LOG.info("Vitrage Notifier Service - Started!") LOG.info("Vitrage Notifier Service - Started!")
def stop(self, graceful=False): def terminate(self):
LOG.info("Vitrage Notifier Service - Stopping...") LOG.info("Vitrage Notifier Service - Stopping...")
for listener in self.listeners: for listener in self.listeners:
listener.stop() listener.stop()
listener.wait() listener.wait()
super(VitrageNotifierService, self).stop(graceful)
LOG.info("Vitrage Notifier Service - Stopped!") LOG.info("Vitrage Notifier Service - Stopped!")
@staticmethod @staticmethod

View File

@ -14,11 +14,11 @@
from __future__ import print_function from __future__ import print_function
import cotyledon
import dateutil.parser import dateutil.parser
import oslo_messaging as oslo_m import oslo_messaging as oslo_m
from oslo_log import log from oslo_log import log
from oslo_service import service as os_service
from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import GraphAction from vitrage.common.constants import GraphAction
from vitrage import messaging from vitrage import messaging
@ -28,9 +28,9 @@ from vitrage.storage.sqlalchemy import models
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
class PersistorService(os_service.Service): class PersistorService(cotyledon.Service):
def __init__(self, conf, db_connection): def __init__(self, worker_id, conf, db_connection):
super(PersistorService, self).__init__() super(PersistorService, self).__init__(worker_id)
self.conf = conf self.conf = conf
self.db_connection = db_connection self.db_connection = db_connection
transport = messaging.get_transport(conf) transport = messaging.get_transport(conf)
@ -40,20 +40,18 @@ class PersistorService(os_service.Service):
transport, [target], transport, [target],
[VitragePersistorEndpoint(self.db_connection)]) [VitragePersistorEndpoint(self.db_connection)])
def start(self): def run(self):
LOG.info("Vitrage Persistor Service - Starting...") LOG.info("Vitrage Persistor Service - Starting...")
super(PersistorService, self).start()
self.listener.start() self.listener.start()
LOG.info("Vitrage Persistor Service - Started!") LOG.info("Vitrage Persistor Service - Started!")
def stop(self, graceful=False): def terminate(self):
LOG.info("Vitrage Persistor Service - Stopping...") LOG.info("Vitrage Persistor Service - Stopping...")
self.listener.stop() self.listener.stop()
self.listener.wait() self.listener.wait()
super(PersistorService, self).stop(graceful)
LOG.info("Vitrage Persistor Service - Stopped!") LOG.info("Vitrage Persistor Service - Stopped!")

View File

@ -14,9 +14,10 @@
from datetime import datetime from datetime import datetime
import json import json
import cotyledon
from oslo_log import log from oslo_log import log
import oslo_messaging import oslo_messaging
from oslo_service import service as os_service
from oslo_utils import uuidutils from oslo_utils import uuidutils
from pyasn1.codec.ber import decoder from pyasn1.codec.ber import decoder
from pysnmp.carrier.asyncore.dgram import udp from pysnmp.carrier.asyncore.dgram import udp
@ -35,18 +36,17 @@ from vitrage.utils.file import load_yaml_file
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
class SnmpParsingService(os_service.Service): class SnmpParsingService(cotyledon.Service):
RUN_FOREVER = 1 RUN_FOREVER = 1
def __init__(self, conf): def __init__(self, worker_id, conf):
super(SnmpParsingService, self).__init__() super(SnmpParsingService, self).__init__(worker_id)
self.conf = conf self.conf = conf
self.listening_port = conf.snmp_parsing.snmp_listening_port self.listening_port = conf.snmp_parsing.snmp_listening_port
self._init_oslo_notifier() self._init_oslo_notifier()
def start(self): def run(self):
LOG.info("Vitrage SNMP Parsing Service - Starting...") LOG.info("Vitrage SNMP Parsing Service - Starting...")
super(SnmpParsingService, self).start()
transport_dispatcher = AsyncoreDispatcher() transport_dispatcher = AsyncoreDispatcher()
transport_dispatcher.registerRecvCbFun(self.callback_func) transport_dispatcher.registerRecvCbFun(self.callback_func)
@ -71,11 +71,8 @@ class SnmpParsingService(os_service.Service):
transport_dispatcher.closeDispatcher() transport_dispatcher.closeDispatcher()
raise raise
def stop(self, graceful=False): def terminate(self):
LOG.info("Vitrage SNMP Parsing Service - Stopping...") LOG.info("Vitrage SNMP Parsing Service - Stopping...")
super(SnmpParsingService, self).stop(graceful)
LOG.info("Vitrage SNMP Parsing Service - Stopped!") LOG.info("Vitrage SNMP Parsing Service - Stopped!")
# noinspection PyUnusedLocal # noinspection PyUnusedLocal

View File

@ -126,12 +126,12 @@ class TestSnmpParsing(base.BaseTest):
cls.conf.register_opts(cls.OPTS, group='snmp_parsing') cls.conf.register_opts(cls.OPTS, group='snmp_parsing')
def test_convert_binds_to_dict(self): def test_convert_binds_to_dict(self):
parsing_service = SnmpParsingService(self.conf) parsing_service = SnmpParsingService(1, self.conf)
dict_converted = parsing_service._convert_binds_to_dict(BINDS_REPORTED) dict_converted = parsing_service._convert_binds_to_dict(BINDS_REPORTED)
self.assertEqual(dict_converted, DICT_EXPECTED) self.assertEqual(dict_converted, DICT_EXPECTED)
def test_get_event_type(self): def test_get_event_type(self):
parsing_service = SnmpParsingService(self.conf) parsing_service = SnmpParsingService(1, self.conf)
event_type = parsing_service._get_event_type(DICT_EXPECTED) event_type = parsing_service._get_event_type(DICT_EXPECTED)
self.assertEqual(event_type, 'vitrage.snmp.event') self.assertEqual(event_type, 'vitrage.snmp.event')
@ -139,6 +139,6 @@ class TestSnmpParsing(base.BaseTest):
converted_trap_diff_sys = copy.copy(DICT_EXPECTED) converted_trap_diff_sys = copy.copy(DICT_EXPECTED)
converted_trap_diff_sys.update( converted_trap_diff_sys.update(
{u'1.3.6.1.4.1.3902.4101.1.3.1.12': u'Different System'}) {u'1.3.6.1.4.1.3902.4101.1.3.1.12': u'Different System'})
parsing_service = SnmpParsingService(self.conf) parsing_service = SnmpParsingService(1, self.conf)
event_type = parsing_service._get_event_type(converted_trap_diff_sys) event_type = parsing_service._get_event_type(converted_trap_diff_sys)
self.assertIsNone(event_type) self.assertIsNone(event_type)