Esempio n. 1
0
 def test_iterations(self):
     test_items, set_frame = self.setup_iterations()
     traceback.print_exc = Mock()
     for tset in test_items:
         message = tset.message
         errno = tset.errno
         details = tset.details
         exc = tset.exception
         fr = tset.frame
         read_lines = 'debug = true\n'
         m_open = mock_open(read_data=read_lines)
         with patch(self.open_name, m_open, create=True):
             exception = \
                 exceptions.F5MissingDependencies(*details, message=message,
                                                  errno=errno,
                                                  exception=exc, frame=fr)
         assert traceback.print_exc.called
         with pytest.raises(exceptions.F5MissingDependencies):
             if errno:
                 assert errno == exception.errno, "Errno Set Test"
             else:
                 assert exceptions.F5MissingDependencies.default_errno == \
                     exception.errno, "Errno Not Set Test"
             if details and not exc:
                 for item in details:
                     assert str(item) in str(exception), \
                         "Details Inclusion Test"
             elif exc:
                 assert str(exc) in str(exception), \
                     "Exception Inclusion Test"
             if fr:
                 assert str(set_frame.lineno) in str(exception) and \
                     fr.filename in str(exception), "Frame Inclusion Test"
             raise exception
Esempio n. 2
0
    def test_debug_false(self):
        traceback.print_exc = Mock()

        read_lines = 'debug = false\n'
        m_open = mock_open(read_data=read_lines)
        with patch(self.open_name, m_open, create=True):
            exceptions.F5MissingDependencies()
        assert not traceback.print_exc.called, 'debug negative test'
Esempio n. 3
0
#

import errno
import inspect
import sys

import f5_openstack_agent.lbaasv2.drivers.bigip.exceptions as exceptions

try:
    from oslo_config import cfg
    from oslo_log import log as oslo_logging
    from oslo_service import service
except ImportError as CriticalError:
    frame = inspect.getframeinfo(inspect.currentframe())
    CriticalError = \
        exceptions.F5MissingDependencies(message=str(CriticalError),
                                         frame=frame)
    sys.exit(CriticalError.errno)

try:
    from neutron.common import config as common_config
    from neutron.common import rpc as n_rpc
    try:
        from neutron.conf.agent import common as config
    except Exception:
        from neutron.agent.common import config
    # for openstack backward compatible
    try:
        # q version
        from neutron.conf.agent.common import INTERFACE_OPTS
    except Exception:
        # m/n/o/p version