Skip to content

Commit

Permalink
Merge branch 'w637-remove-ctid'
Browse files Browse the repository at this point in the history
  • Loading branch information
bloom1 committed Apr 16, 2019
2 parents 4a5f545 + 2c5d715 commit 6ad01a7
Show file tree
Hide file tree
Showing 102 changed files with 640 additions and 662 deletions.
18 changes: 8 additions & 10 deletions xivo_confd/plugins/agent/notifier.py
Expand Up @@ -17,30 +17,28 @@ def __init__(self, bus, sysconfd):
self.bus = bus
self.sysconfd = sysconfd

def send_sysconfd_handlers(self, ctibus_command, ipbx_command=None):
handlers = {'ctibus': [ctibus_command],
'ipbx': [ipbx_command] if ipbx_command else [],
'agentbus': []}
def send_sysconfd_handlers(self, ipbx_command=None):
handlers = {
'ipbx': [ipbx_command] if ipbx_command else [],
'agentbus': [],
}
self.sysconfd.exec_request_handlers(handlers)

def created(self, agent):
ctibus_command = 'xivo[agent,add,{agent_id}]'.format(agent_id=agent.id)
ipbx_command = 'module reload app_queue.so'
self.send_sysconfd_handlers(ctibus_command, ipbx_command)
self.send_sysconfd_handlers(ipbx_command)
event = CreateAgentEvent(agent.id)
self.bus.send_bus_event(event)

def edited(self, agent):
ctibus_command = 'xivo[agent,edit,{agent_id}]'.format(agent_id=agent.id)
ipbx_command = 'module reload app_queue.so'
self.send_sysconfd_handlers(ctibus_command, ipbx_command)
self.send_sysconfd_handlers(ipbx_command)
event = EditAgentEvent(agent.id)
self.bus.send_bus_event(event)

def deleted(self, agent):
ctibus_command = 'xivo[agent,delete,{agent_id}]'.format(agent_id=agent.id)
ipbx_command = 'module reload app_queue.so'
self.send_sysconfd_handlers(ctibus_command, ipbx_command)
self.send_sysconfd_handlers(ipbx_command)
event = DeleteAgentEvent(agent.id)
self.bus.send_bus_event(event)

Expand Down
9 changes: 4 additions & 5 deletions xivo_confd/plugins/agent/tests/test_notifier.py
Expand Up @@ -24,17 +24,16 @@ def setUp(self):

self.notifier = AgentNotifier(self.bus, self.sysconfd)

def _expected_handlers(self, ctibus_command, ipbx_command=None):
def _expected_handlers(self, ipbx_command=None):
return {
'ctibus': [ctibus_command],
'ipbx': [ipbx_command] if ipbx_command else [],
'agentbus': []
}

def test_when_agent_created_then_call_expected_handlers(self):
self.notifier.created(self.agent)

expected_handlers = self._expected_handlers('xivo[agent,add,1234]', 'module reload app_queue.so')
expected_handlers = self._expected_handlers('module reload app_queue.so')
self.sysconfd.exec_request_handlers.assert_called_once_with(expected_handlers)

def test_when_agent_created_then_event_sent_on_bus(self):
Expand All @@ -47,7 +46,7 @@ def test_when_agent_created_then_event_sent_on_bus(self):
def test_when_agent_edited_then_app_agent_reloaded(self):
self.notifier.edited(self.agent)

expected_handlers = self._expected_handlers('xivo[agent,edit,1234]', 'module reload app_queue.so')
expected_handlers = self._expected_handlers('module reload app_queue.so')
self.sysconfd.exec_request_handlers.assert_called_once_with(expected_handlers)

def test_when_agent_edited_then_event_sent_on_bus(self):
Expand All @@ -60,7 +59,7 @@ def test_when_agent_edited_then_event_sent_on_bus(self):
def test_when_agent_deleted_then_app_agent_reloaded(self):
self.notifier.deleted(self.agent)

expected_handlers = self._expected_handlers('xivo[agent,delete,1234]', 'module reload app_queue.so')
expected_handlers = self._expected_handlers('module reload app_queue.so')
self.sysconfd.exec_request_handlers.assert_called_once_with(expected_handlers)

def test_when_agent_deleted_then_event_sent_on_bus(self):
Expand Down
1 change: 0 additions & 1 deletion xivo_confd/plugins/call_pickup/notifier.py
Expand Up @@ -19,7 +19,6 @@ def __init__(self, bus, sysconfd):

def send_sysconfd_handlers(self):
handlers = {
'ctibus': [],
'ipbx': ['module reload res_pjsip.so', 'module reload chan_sccp.so'],
'agentbus': [],
}
Expand Down
1 change: 0 additions & 1 deletion xivo_confd/plugins/call_pickup/tests/test_notifier.py
Expand Up @@ -15,7 +15,6 @@
from ..notifier import CallPickupNotifier

SYSCONFD_HANDLERS = {
'ctibus': [],
'ipbx': ['module reload res_pjsip.so', 'module reload chan_sccp.so'],
'agentbus': [],
}
Expand Down
1 change: 0 additions & 1 deletion xivo_confd/plugins/call_pickup_member/notifier.py
Expand Up @@ -20,7 +20,6 @@ def __init__(self, bus, sysconfd):

def send_sysconfd_handlers(self):
handlers = {
'ctibus': [],
'ipbx': ['module reload res_pjsip.so', 'module reload chan_sccp.so'],
'agentbus': [],
}
Expand Down
Expand Up @@ -19,7 +19,6 @@
from ..notifier import CallPickupMemberNotifier

SYSCONFD_HANDLERS = {
'ctibus': [],
'ipbx': ['module reload res_pjsip.so', 'module reload chan_sccp.so'],
'agentbus': [],
}
Expand Down
9 changes: 5 additions & 4 deletions xivo_confd/plugins/confbridge/notifier.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2017-2018 The Wazo Authors (see the AUTHORS file)
# Copyright 2017-2019 The Wazo Authors (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

from xivo_bus.resources.confbridge.event import (
Expand All @@ -17,9 +17,10 @@ def __init__(self, bus, sysconfd):
self.sysconfd = sysconfd

def send_sysconfd_handlers(self, ipbx):
handlers = {'ctibus': [],
'ipbx': ipbx,
'agentbus': []}
handlers = {
'ipbx': ipbx,
'agentbus': [],
}
self.sysconfd.exec_request_handlers(handlers)

def edited(self, section_name, confbridge):
Expand Down
9 changes: 5 additions & 4 deletions xivo_confd/plugins/confbridge/tests/test_notifier.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2017-2018 The Wazo Authors (see the AUTHORS file)
# Copyright 2017-2019 The Wazo Authors (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

import unittest
Expand All @@ -13,9 +13,10 @@
from ..notifier import ConfBridgeConfigurationNotifier


SYSCONFD_HANDLERS = {'ctibus': [],
'ipbx': ['module reload app_confbridge.so'],
'agentbus': []}
SYSCONFD_HANDLERS = {
'ipbx': ['module reload app_confbridge.so'],
'agentbus': [],
}


class TestConfBridgeConfigurationNotifier(unittest.TestCase):
Expand Down
9 changes: 5 additions & 4 deletions xivo_confd/plugins/conference/notifier.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2018 The Wazo Authors (see the AUTHORS file)
# Copyright 2016-2019 The Wazo Authors (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

from xivo_bus.resources.conference.event import (
Expand All @@ -18,9 +18,10 @@ def __init__(self, bus, sysconfd):
self.sysconfd = sysconfd

def send_sysconfd_handlers(self):
handlers = {'ctibus': [],
'ipbx': ['module reload app_confbridge.so'],
'agentbus': []}
handlers = {
'ipbx': ['module reload app_confbridge.so'],
'agentbus': [],
}
self.sysconfd.exec_request_handlers(handlers)

def created(self, conference):
Expand Down
9 changes: 5 additions & 4 deletions xivo_confd/plugins/conference/tests/test_notifier.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2017 The Wazo Authors (see the AUTHORS file)
# Copyright 2016-2019 The Wazo Authors (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

import unittest
Expand All @@ -13,9 +13,10 @@

from ..notifier import ConferenceNotifier

EXPECTED_HANDLERS = {'ctibus': [],
'ipbx': ['module reload app_confbridge.so'],
'agentbus': []}
EXPECTED_HANDLERS = {
'ipbx': ['module reload app_confbridge.so'],
'agentbus': [],
}


class TestConferenceNotifier(unittest.TestCase):
Expand Down
9 changes: 5 additions & 4 deletions xivo_confd/plugins/conference_extension/notifier.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2018 The Wazo Authors (see the AUTHORS file)
# Copyright 2016-2019 The Wazo Authors (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

from xivo_bus.resources.conference_extension.event import (
Expand All @@ -17,9 +17,10 @@ def __init__(self, bus, sysconfd):
self.sysconfd = sysconfd

def send_sysconfd_handlers(self):
handlers = {'ctibus': [],
'ipbx': ['dialplan reload'],
'agentbus': []}
handlers = {
'ipbx': ['dialplan reload'],
'agentbus': [],
}
self.sysconfd.exec_request_handlers(handlers)

def associated(self, conference, extension):
Expand Down
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2017 The Wazo Authors (see the AUTHORS file)
# Copyright 2016-2019 The Wazo Authors (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

import unittest
Expand All @@ -15,9 +15,10 @@

from ..notifier import ConferenceExtensionNotifier

SYSCONFD_HANDLERS = {'ctibus': [],
'ipbx': ['dialplan reload'],
'agentbus': []}
SYSCONFD_HANDLERS = {
'ipbx': ['dialplan reload'],
'agentbus': [],
}


class TestConferenceExtensionNotifier(unittest.TestCase):
Expand Down
17 changes: 4 additions & 13 deletions xivo_confd/plugins/configuration/notifier.py
@@ -1,30 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright 2013-2018 The Wazo Authors (see the AUTHORS file)
# Copyright 2013-2019 The Wazo Authors (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

from xivo_bus.resources.configuration.event import LiveReloadEditedEvent

from xivo_confd import bus, sysconfd
from xivo_confd import bus


class LiveReloadNotifier(object):

def __init__(self, bus, sysconfd):
def __init__(self, bus):
self.bus = bus
self.sysconfd = sysconfd

def send_sysconfd_handlers(self, cti_commands):
handlers = {'ctibus': cti_commands,
'ipbx': [],
'agentbus': []}
self.sysconfd.exec_request_handlers(handlers)

def edited(self, live_reload):
event = LiveReloadEditedEvent(live_reload['enabled'])
self.bus.send_bus_event(event)
if live_reload['enabled']:
self.send_sysconfd_handlers(['xivo[cticonfig,update]'])


def build_notifier():
return LiveReloadNotifier(bus, sysconfd)
return LiveReloadNotifier(bus)
22 changes: 2 additions & 20 deletions xivo_confd/plugins/configuration/tests/test_notifier.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2013-2017 The Wazo Authors (see the AUTHORS file)
# Copyright 2013-2019 The Wazo Authors (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

import unittest
Expand All @@ -14,31 +14,13 @@ class TestLiveReloadNotifier(unittest.TestCase):

def setUp(self):
self.bus = Mock()
self.sysconfd = Mock()
self.device_db = Mock()
self.live_reload = {'enabled': True}
self.notifier = LiveReloadNotifier(self.bus, self.sysconfd)
self.notifier = LiveReloadNotifier(self.bus)

def test_when_live_reload_edited_then_event_sent_on_bus(self):
expected_event = LiveReloadEditedEvent(self.live_reload['enabled'])

self.notifier.edited(self.live_reload)

self.bus.send_bus_event.assert_called_once_with(expected_event)

def test_when_live_reload_enabled_then_sysconfd_called(self):
expected_handlers = {'ctibus': ['xivo[cticonfig,update]'],
'ipbx': [],
'agentbus': []}
live_reload = {'enabled': True}

self.notifier.edited(live_reload)

self.sysconfd.exec_request_handlers.assert_called_once_with(expected_handlers)

def test_when_live_reload_disabled_then_sysconfd_not_called(self):
live_reload = {'enabled': False}

self.notifier.edited(live_reload)

self.sysconfd.exec_request_handlers.assert_not_called()
7 changes: 4 additions & 3 deletions xivo_confd/plugins/context/notifier.py
Expand Up @@ -27,9 +27,10 @@ def __init__(self, bus, sysconfd):
self.sysconfd = sysconfd

def send_sysconfd_handlers(self):
handlers = {'ctibus': [],
'ipbx': ['dialplan reload'],
'agentbus': []}
handlers = {
'ipbx': ['dialplan reload'],
'agentbus': [],
}
self.sysconfd.exec_request_handlers(handlers)

def created(self, context):
Expand Down
7 changes: 4 additions & 3 deletions xivo_confd/plugins/context/tests/test_notifier.py
Expand Up @@ -13,9 +13,10 @@

from ..notifier import ContextNotifier

EXPECTED_HANDLERS = {'ctibus': [],
'ipbx': ['dialplan reload'],
'agentbus': []}
EXPECTED_HANDLERS = {
'ipbx': ['dialplan reload'],
'agentbus': [],
}


class TestContextNotifier(unittest.TestCase):
Expand Down
9 changes: 5 additions & 4 deletions xivo_confd/plugins/context_context/notifier.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2018 The Wazo Authors (see the AUTHORS file)
# Copyright 2018-2019 The Wazo Authors (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

from xivo_bus.resources.context_context.event import ContextContextsAssociatedEvent
Expand All @@ -14,9 +14,10 @@ def __init__(self, bus, sysconfd):
self.sysconfd = sysconfd

def send_sysconfd_handlers(self):
handlers = {'ctibus': [],
'ipbx': ['dialplan reload'],
'agentbus': []}
handlers = {
'ipbx': ['dialplan reload'],
'agentbus': [],
}
self.sysconfd.exec_request_handlers(handlers)

def associated_contexts(self, context, contexts):
Expand Down
3 changes: 1 addition & 2 deletions xivo_confd/plugins/context_context/tests/test_notifier.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2018 The Wazo Authors (see the AUTHORS file)
# Copyright 2018-2019 The Wazo Authors (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

import unittest
Expand All @@ -12,7 +12,6 @@
from ..notifier import ContextContextNotifier

EXPECTED_HANDLERS = {
'ctibus': [],
'ipbx': ['dialplan reload'],
'agentbus': [],
}
Expand Down
9 changes: 5 additions & 4 deletions xivo_confd/plugins/endpoint_iax/notifier.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2018 The Wazo Authors (see the AUTHORS file)
# Copyright 2018-2019 The Wazo Authors (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

from xivo_bus.resources.endpoint_iax.event import (
Expand All @@ -18,9 +18,10 @@ def __init__(self, sysconfd, bus):
self.bus = bus

def send_sysconfd_handlers(self):
handlers = {'ctibus': [],
'ipbx': ['iax2 reload'],
'agentbus': []}
handlers = {
'ipbx': ['iax2 reload'],
'agentbus': [],
}
self.sysconfd.exec_request_handlers(handlers)

def created(self, line):
Expand Down

0 comments on commit 6ad01a7

Please sign in to comment.