Beispiel #1
0
    def __init__(self):
        """Initialize Brocade Plugin.

        Specify switch address and db configuration.
        """

        super(BrocadePluginV2, self).__init__()
        self.supported_extension_aliases = [
            "binding", "security-group", "external-net", "router",
            "extraroute", "agent", "l3_agent_scheduler", "dhcp_agent_scheduler"
        ]

        self.physical_interface = (
            cfg.CONF.PHYSICAL_INTERFACE.physical_interface)
        self.base_binding_dict = self._get_base_binding_dict()
        portbindings_base.register_port_dict_function()
        self.ctxt = context.get_admin_context()
        self.ctxt.session = db.get_session()
        self._vlan_bitmap = vbm.VlanBitmap(self.ctxt)
        self._setup_rpc()
        self.network_scheduler = importutils.import_object(
            cfg.CONF.network_scheduler_driver)
        self.router_scheduler = importutils.import_object(
            cfg.CONF.router_scheduler_driver)
        self.brocade_init()
Beispiel #2
0
    def __init__(self):
        """Initialize Brocade Plugin.

        Specify switch address and db configuration.
        """

        self.supported_extension_aliases = ["binding", "security-group",
                                            "router", "extraroute",
                                            "agent", "l3_agent_scheduler",
                                            "dhcp_agent_scheduler"]

        self.physical_interface = (cfg.CONF.PHYSICAL_INTERFACE.
                                   physical_interface)
        self.base_binding_dict = self._get_base_binding_dict()
        portbindings_base.register_port_dict_function()
        db.configure_db()
        self.ctxt = context.get_admin_context()
        self.ctxt.session = db.get_session()
        self._vlan_bitmap = vbm.VlanBitmap(self.ctxt)
        self._setup_rpc()
        self.network_scheduler = importutils.import_object(
            cfg.CONF.network_scheduler_driver
        )
        self.router_scheduler = importutils.import_object(
            cfg.CONF.router_scheduler_driver
        )
        self.brocade_init()
Beispiel #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)
Beispiel #4
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)
Beispiel #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())
Beispiel #6
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(_("Could not send notification to %(topic)s. "
                            "Payload=%(message)s"), locals())
    def setUp(self):

        def mocked_brocade_init(self):
            LOG.debug("brocadeSVIPlugin::mocked_brocade_init()")

            self._switch = {'address': cfg.CONF.ml2_brocade.address,
                            'username': cfg.CONF.ml2_brocade.username,
                            'password': cfg.CONF.ml2_brocade.password,
                            'rbridge_id': cfg.CONF.ml2_brocade.rbridge_id
                            }
            LOG.info(_("rbridge id %s"), self._switch['rbridge_id'])
            self._driver = mock.MagicMock()

        self.context = context.get_admin_context()
        self.context.session = db.get_session()
        self.l3_plugin = importutils.import_object(L3_SVC_PLUGIN)
        with mock.patch.object(self.l3_plugin,
                               'brocade_init', new=mocked_brocade_init):
            super(BrocadeSVIPlugin_TestCases, self).setUp()
Beispiel #8
0
    def setUp(self):
        def mocked_brocade_init(self):
            LOG.debug("brocadeSVIPlugin::mocked_brocade_init()")

            self._switch = {
                'address': cfg.CONF.ml2_brocade.address,
                'username': cfg.CONF.ml2_brocade.username,
                'password': cfg.CONF.ml2_brocade.password,
                'rbridge_id': cfg.CONF.ml2_brocade.rbridge_id
            }
            LOG.info(_("rbridge id %s"), self._switch['rbridge_id'])
            self._driver = mock.MagicMock()

        self.context = context.get_admin_context()
        self.context.session = db.get_session()
        self.l3_plugin = importutils.import_object(L3_SVC_PLUGIN)
        with mock.patch.object(self.l3_plugin,
                               'brocade_init',
                               new=mocked_brocade_init):
            super(BrocadeSVIPlugin_TestCases, self).setUp()
Beispiel #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)
Beispiel #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)
Beispiel #11
0
 def setUp(self):
     super(TestVlanBitmap, self).setUp()
     self.context = context.get_admin_context()
     self.context.session = db.get_session()
 def setUp(self):
     super(TestVlanBitmap, self).setUp()
     db.configure_db()
     self.addCleanup(db.clear_db)
     self.context = context.get_admin_context()
     self.context.session = db.get_session()
Beispiel #13
0
 def setUp(self):
     super(TestVlanBitmap, self).setUp()
     self.context = context.get_admin_context()
     self.context.session = db.get_session()