示例#1
0
    def process_request(self, request):
        request.environ['HTTP_X_SERVICE_NAME'] = \
            self.service_name or request.host
        payload = {
            'request': self.environ_to_dict(request.environ),
        }

        api.notify(context.get_admin_context(),
                   api.publisher_id(os.path.basename(sys.argv[0])),
                   'http.request', api.INFO, payload)
示例#2
0
    def process_request(self, request):
        request.environ["HTTP_X_SERVICE_NAME"] = self.service_name or request.host
        payload = {"request": self.environ_to_dict(request.environ)}

        api.notify(
            context.get_admin_context(),
            api.publisher_id(os.path.basename(sys.argv[0])),
            "http.request",
            api.INFO,
            payload,
        )
示例#3
0
    def process_request(self, request):
        request.environ['HTTP_X_SERVICE_NAME'] = \
            self.service_name or request.host
        payload = {
            'request': self.environ_to_dict(request.environ),
        }

        api.notify(context.get_admin_context(),
                   api.publisher_id(os.path.basename(sys.argv[0])),
                   'http.request',
                   api.INFO,
                   payload)
示例#4
0
def notify(context, message):
    """Sends a notification via RPC."""
    if not context:
        context = req_context.get_admin_context()
    priority = message.get("priority", CONF.default_notification_level)
    priority = priority.lower()
    for topic in CONF.notification_topics:
        topic = "%s.%s" % (topic, priority)
        try:
            rpc.notify(context, topic, message)
        except Exception:
            LOG.exception(_("Could not send notification to %(topic)s. " "Payload=%(message)s"), locals())
示例#5
0
def notify(context, message):
    """Sends a notification via RPC"""
    if not context:
        context = req_context.get_admin_context()
    priority = message.get('priority', CONF.default_notification_level)
    priority = priority.lower()
    for topic in CONF.notification_topics:
        topic = '%s.%s' % (topic, priority)
        try:
            rpc.notify(context, topic, message)
        except Exception:
            LOG.exception(
                _("Could not send notification to %(topic)s. "
                  "Payload=%(message)s"), locals())
def notify(context, message):
    """Sends a notification via RPC."""
    if not context:
        context = req_context.get_admin_context()
    priority = message.get('priority',
                           CONF.default_notification_level)
    priority = priority.lower()
    for topic in CONF.rpc_notifier2.topics:
        topic = '%s.%s' % (topic, priority)
        try:
            rpc.notify(context, topic, message, envelope=True)
        except Exception:
            LOG.exception(_LE("Could not send notification to %(topic)s. "
                              "Payload=%(message)s"),
                          {"topic": topic, "message": message})
示例#7
0
    def process_response(self, request, response, exception=None, traceback=None):
        payload = {"request": self.environ_to_dict(request.environ)}

        if response:
            payload["response"] = {"status": response.status, "headers": response.headers}

        if exception:
            payload["exception"] = {"value": repr(exception), "traceback": tb.format_tb(traceback)}

        api.notify(
            context.get_admin_context(),
            api.publisher_id(os.path.basename(sys.argv[0])),
            "http.response",
            api.INFO,
            payload,
        )
示例#8
0
def notify(context, message):
    """Sends a notification via RPC."""
    if not context:
        context = req_context.get_admin_context()
    priority = message.get('priority', CONF.default_notification_level)
    priority = priority.lower()
    for topic in CONF.rpc_notifier2.topics:
        topic = '%s.%s' % (topic, priority)
        try:
            rpc.notify(context, topic, message, envelope=True)
        except Exception:
            LOG.exception(
                _LE("Could not send notification to %(topic)s. "
                    "Payload=%(message)s"), {
                        "topic": topic,
                        "message": message
                    })
示例#9
0
    def process_response(self, request, response,
                         exception=None, traceback=None):
        payload = {
            'request': self.environ_to_dict(request.environ),
        }

        if response:
            payload['response'] = {
                'status': response.status,
                'headers': response.headers,
            }

        if exception:
            payload['exception'] = {
                'value': repr(exception),
                'traceback': tb.format_tb(traceback)
            }

        api.notify(context.get_admin_context(),
                   api.publisher_id(os.path.basename(sys.argv[0])),
                   'http.response',
                   api.INFO,
                   payload)
示例#10
0
    def process_response(self, request, response,
                         exception=None, traceback=None):
        payload = {
            'request': self.environ_to_dict(request.environ),
        }

        if response:
            payload['response'] = {
                'status': response.status,
                'headers': response.headers,
            }

        if exception:
            payload['exception'] = {
                'value': repr(exception),
                'traceback': tb.format_tb(traceback)
            }

        api.notify(context.get_admin_context(),
                   api.publisher_id(os.path.basename(sys.argv[0])),
                   'http.response',
                   api.INFO,
                   payload)
示例#11
0
#    License for the specific language governing permissions and limitations
#    under the License.

from oslo.config import cfg

from openstack.common import context
from openstack.common import log
from openstack.common.notifier import api as notifier_api
from openstack.common.notifier import log_notifier
from openstack.common.notifier import no_op_notifier
from openstack.common.notifier import rabbit_notifier
from openstack.common import rpc
from tests import utils as test_utils


ctxt = context.get_admin_context()
ctxt2 = context.get_admin_context()


class NotifierTestCase(test_utils.BaseTestCase):
    """Test case for notifications"""

    def setUp(self):
        super(NotifierTestCase, self).setUp()
        notification_driver = ["openstack.common.notifier.no_op_notifier"]
        self.config(notification_driver=notification_driver)
        self.config(default_publisher_id="publisher")
        self.addCleanup(notifier_api._reset_drivers)

    def test_send_notification(self):
        self.notify_called = False
示例#12
0
#    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.

from openstack.common import cfg
from openstack.common import context
from openstack.common import log
from openstack.common.notifier import api as notifier_api
from openstack.common.notifier import log_notifier
from openstack.common.notifier import no_op_notifier
from openstack.common.notifier import rabbit_notifier
from openstack.common import rpc
from tests import utils as test_utils

ctxt = context.get_admin_context()
ctxt2 = context.get_admin_context()


class NotifierTestCase(test_utils.BaseTestCase):
    """Test case for notifications"""
    def setUp(self):
        super(NotifierTestCase, self).setUp()
        notification_driver = ['openstack.common.notifier.no_op_notifier']
        self.config(notification_driver=notification_driver)
        self.config(default_publisher_id='publisher')

    def tearDown(self):
        notifier_api._reset_drivers()
        super(NotifierTestCase, self).tearDown()
示例#13
0
 def test_admin_context_show_deleted_flag_default(self):
     ctx = context.get_admin_context()
     self.assertFalse(ctx.show_deleted)
示例#14
0
 def test_admin_context_show_deleted_flag_default(self):
     ctx = context.get_admin_context()
     self.assertFalse(ctx.show_deleted)