Exemple #1
0
 def _report_state(self):
     LOG.debug("Report state task started")
     try:
         self.agent_state.get('configurations').update(
             self.cache.get_state())
         ctx = context.get_admin_context_without_session()
         agent_status = self.state_rpc.report_state(ctx, self.agent_state,
                                                    True)
         if agent_status == agent_consts.AGENT_REVIVED:
             LOG.info(_LI("Agent has just been revived. "
                          "Scheduling full sync"))
             self.schedule_full_resync(
                     reason=_("Agent has just been revived"))
     except AttributeError:
         # This means the server does not support report_state
         LOG.warning(_LW("Neutron server does not support state report. "
                         "State report for this agent will be disabled."))
         self.heartbeat.stop()
         self.run()
         return
     except Exception:
         LOG.exception(_LE("Failed reporting state!"))
         return
     if self.agent_state.pop('start_flag', None):
         self.run()
 def _report_state(self):
     LOG.debug("Report state task started")
     try:
         self.agent_state.get('configurations').update(
             self.cache.get_state())
         ctx = context.get_admin_context_without_session()
         agent_status = self.state_rpc.report_state(ctx, self.agent_state,
                                                    True)
         if agent_status == agent_consts.AGENT_REVIVED:
             LOG.info(_LI("Agent has just been revived. "
                          "Scheduling full sync"))
             self.schedule_full_resync(
                     reason=_("Agent has just been revived"))
     except AttributeError:
         # This means the server does not support report_state
         LOG.warning(_LW("Neutron server does not support state report. "
                         "State report for this agent will be disabled."))
         self.heartbeat.stop()
         self.run()
         return
     except Exception:
         LOG.exception(_LE("Failed reporting state!"))
         return
     if self.agent_state.pop('start_flag', None):
         self.run()
 def get_plugin(self):
     plugin = directory.get_plugin(bgp_ext.BGP_EXT_ALIAS)
     if not plugin:
         LOG.error(_LE('No plugin for BGP routing registered'))
         msg = _('The resource could not be found.')
         raise webob.exc.HTTPNotFound(msg)
     return plugin
Exemple #4
0
 def get_plugin(self):
     plugin = directory.get_plugin(bgp_ext.ALIAS)
     if not plugin:
         LOG.error(_LE('No plugin for BGP routing registered'))
         msg = _('The resource could not be found.')
         raise webob.exc.HTTPNotFound(msg)
     return plugin
 def get_plugin(self):
     plugin = manager.NeutronManager.get_service_plugins().get(
         bgp_ext.BGP_EXT_ALIAS)
     if not plugin:
         LOG.error(_LE('No plugin for BGP routing registered'))
         msg = _('The resource could not be found.')
         raise webob.exc.HTTPNotFound(msg)
     return plugin
Exemple #6
0
 def get_plugin(self):
     plugin = manager.NeutronManager.get_service_plugins().get(
         bgp_ext.BGP_EXT_ALIAS)
     if not plugin:
         LOG.error(_LE('No plugin for BGP routing registered'))
         msg = _('The resource could not be found.')
         raise webob.exc.HTTPNotFound(msg)
     return plugin
Exemple #7
0
def _validate_rt_list(data, valid_values=None):
    if data is None or data is "":
        return

    if not isinstance(data, list):
        msg = _("'%s' is not a list") % data
        LOG.debug(msg)
        return msg

    for item in data:
        msg = attr._validate_regex(item, RT_REGEX)
        if msg:
            LOG.debug(msg)
            return msg

    if len(set(data)) != len(data):
        msg = _("Duplicate items in the list: '%s'") % ', '.join(data)
        LOG.debug(msg)
        return msg
Exemple #8
0
class BgpPeerNotFound(n_exc.NotFound):
    message = _("BGP peer %(id)s could not be found.")
Exemple #9
0
class DrAgentAssociationError(n_exc.Conflict):
    message = _("BgpDrAgent %(agent_id)s is already associated "
                "to a BGP speaker.")
Exemple #10
0
class BgpPeerNotAdded(n_exc.BadRequest):
    message = _("BGP Peer %(peer_ip)s for remote_as=%(remote_as)s, running "
                "for BGP Speaker %(speaker_as)d not added yet.")
Exemple #11
0
class InvalidBgpPeerMd5Authentication(n_exc.BadRequest):
    message = _("A password must be supplied when using auth_type md5.")
Exemple #12
0
class DrAgentInvalid(agent.AgentNotFound):
    message = _("BgpDrAgent %(id)s is invalid or has been disabled.")
Exemple #13
0
class BgpSpeakerNetworkNotAssociated(n_exc.NotFound):
    message = _("Network %(network_id)s is not associated with "
                "BGP speaker %(bgp_speaker_id)s.")
Exemple #14
0
class NetworkNotBound(n_exc.NotFound):
    message = _("Network %(network_id)s is not bound to a BgpSpeaker.")
Exemple #15
0
class BgpSpeakerMaxScheduled(n_exc.BadRequest):
    message = _("Already hosting maximum number of BGP Speakers. "
                "Allowed scheduled count=%(count)d")
from neutron_dynamic_routing._i18n import _
from neutron_dynamic_routing._i18n import _LW
from neutron_dynamic_routing.extensions import bgp_dragentscheduler as bgp_dras_ext  # noqa
from neutron_dynamic_routing.services.bgp.common import constants as bgp_consts


LOG = logging.getLogger(__name__)


BGP_DRAGENT_SCHEDULER_OPTS = [
    cfg.StrOpt(
        'bgp_drscheduler_driver',
        default='neutron_dynamic_routing.services.bgp.scheduler'
                '.bgp_dragent_scheduler.ChanceScheduler',
        help=_('Driver used for scheduling BGP speakers to BGP DrAgent'))
]

cfg.CONF.register_opts(BGP_DRAGENT_SCHEDULER_OPTS)


class BgpSpeakerDrAgentBinding(model_base.BASEV2):
    """Represents a mapping between BGP speaker and BGP DRAgent"""

    __tablename__ = 'bgp_speaker_dragent_bindings'

    bgp_speaker_id = sa.Column(sa.String(length=36),
                               sa.ForeignKey("bgp_speakers.id",
                                             ondelete='CASCADE'),
                               nullable=False)
    dragent = orm.relation(agents_db.Agent)
Exemple #17
0
class InvaildAuthType(n_exc.BadRequest):
    message = _("Authentication type not supported. Requested "
                "type=%(auth_type)s.")
Exemple #18
0
class PasswordNotSpecified(n_exc.BadRequest):
    message = _("Password not specified for authentication "
                "type=%(auth_type)s.")
Exemple #19
0
class InvalidParamRange(n_exc.NeutronException):
    message = _("%(param)s must be in %(range)s range.")
Exemple #20
0
class InvalidParamType(n_exc.NeutronException):
    message = _("Parameter %(param)s must be of %(param_type)s type.")
Exemple #21
0
class RouteNotAdvertised(n_exc.BadRequest):
    message = _("Route %(cidr)s not advertised for BGP Speaker "
                "%(speaker_as)d.")
Exemple #22
0
class BgpPeerNotAuthenticated(n_exc.NotFound):
    message = _("BGP peer %(bgp_peer_id)s not authenticated.")
Exemple #23
0
class BgpSpeakerNotAdded(n_exc.BadRequest):
    message = _("BGP Speaker for local_as=%(local_as)s with "
                "router_id=%(rtid)s not added yet.")
Exemple #24
0
class BgpSpeakerPeerNotAssociated(n_exc.NotFound):
    message = _("BGP peer %(bgp_peer_id)s is not associated with "
                "BGP speaker %(bgp_speaker_id)s.")
Exemple #25
0
class BgpSpeakerRescheduleError(n_exc.Conflict):
    message = _("Failed rescheduling %(bgp_speaker_id)s: "
                "%(failure_reason)s.")
Exemple #26
0
class BgpSpeakerNetworkBindingError(n_exc.Conflict):
    message = _("Network %(network_id)s is already bound to BgpSpeaker "
                "%(bgp_speaker_id)s.")
Exemple #27
0
from neutron.db import api as db_api
from neutron.db.models import agent as agent_model

from neutron_dynamic_routing._i18n import _
from neutron_dynamic_routing._i18n import _LW
from neutron_dynamic_routing.extensions import bgp_dragentscheduler as bgp_dras_ext  # noqa
from neutron_dynamic_routing.services.bgp.common import constants as bgp_consts

LOG = logging.getLogger(__name__)

BGP_DRAGENT_SCHEDULER_OPTS = [
    cfg.StrOpt(
        'bgp_drscheduler_driver',
        default='neutron_dynamic_routing.services.bgp.scheduler'
        '.bgp_dragent_scheduler.ChanceScheduler',
        help=_('Driver used for scheduling BGP speakers to BGP DrAgent'))
]

cfg.CONF.register_opts(BGP_DRAGENT_SCHEDULER_OPTS)


class BgpSpeakerDrAgentBinding(model_base.BASEV2):
    """Represents a mapping between BGP speaker and BGP DRAgent"""

    __tablename__ = 'bgp_speaker_dragent_bindings'

    bgp_speaker_id = sa.Column(sa.String(length=36),
                               sa.ForeignKey("bgp_speakers.id",
                                             ondelete='CASCADE'),
                               nullable=False)
    dragent = orm.relation(agent_model.Agent)
Exemple #28
0
class DuplicateBgpPeerIpException(n_exc.Conflict):
    _message = _("BGP Speaker %(bgp_speaker_id)s is already configured to "
                 "peer with a BGP Peer at %(peer_ip)s, it cannot peer with "
                 "BGP Peer %(bgp_peer_id)s.")
# Copyright 2016 Huawei Technologies India Pvt. Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# 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 oslo_config import cfg

from neutron_dynamic_routing._i18n import _

BGP_DRIVER_OPTS = [
    cfg.StrOpt('bgp_speaker_driver',
               help=_("BGP speaker driver class to be instantiated."))
]

BGP_PROTO_CONFIG_OPTS = [
    cfg.StrOpt('bgp_router_id',
               help=_("32-bit BGP identifier, typically an IPv4 address "
                      "owned by the system running the BGP DrAgent."))
]
Exemple #30
0
class NetworkNotBoundForIpVersion(NetworkNotBound):
    message = _("Network %(network_id)s is not bound to a IPv%(ip_version)s "
                "BgpSpeaker.")
 def agent_updated(self, context, payload):
     """Handle the agent_updated notification event."""
     self.schedule_full_resync(
             reason=_("BgpDrAgent updated: %s") % payload)
     LOG.info(_LI("agent_updated by server side %s!"), payload)
Exemple #32
0
class DrAgentNotHostingBgpSpeaker(n_exc.NotFound):
    message = _("BGP speaker %(bgp_speaker_id)s is not hosted "
                "by the BgpDrAgent %(agent_id)s.")
Exemple #33
0
class BgpSpeakerNotFound(n_exc.NotFound):
    message = _("BGP speaker %(id)s could not be found.")
Exemple #34
0
 def agent_updated(self, context, payload):
     """Handle the agent_updated notification event."""
     self.schedule_full_resync(
             reason=_("BgpDrAgent updated: %s") % payload)
     LOG.info(_LI("agent_updated by server side %s!"), payload)
Exemple #35
0
class BgpSpeakerAlreadyScheduled(n_exc.Conflict):
    message = _("Already hosting BGP Speaker for local_as=%(current_as)d with "
                "router_id=%(rtid)s.")