Esempio n. 1
0
)
from magma.pipelined.metrics import (
    ENFORCEMENT_RULE_INSTALL_FAIL,
    ENFORCEMENT_STATS_RULE_INSTALL_FAIL,
)
from magma.pipelined.ng_manager.session_state_manager_util import PDRRuleEntry
from magma.pipelined.policy_converters import (
    convert_ip_str_to_ip_proto,
    convert_ipv4_str_to_ip_proto,
    convert_ipv6_bytes_to_ip_proto,
)

grpc_msg_queue = queue.Queue()
DEFAULT_CALL_TIMEOUT = 5

enable_sentry_wrapper = get_sentry_status(
    "pipelined") == SentryStatus.SEND_SELECTED_ERRORS


class PipelinedRpcServicer(pipelined_pb2_grpc.PipelinedServicer):
    """
    gRPC based server for Pipelined.
    """
    def __init__(
        self,
        loop,
        gy_app,
        enforcer_app,
        enforcement_stats,
        dpi_app,
        ue_mac_app,
        check_quota_app,
Esempio n. 2
0
)
from .ip_allocator_base import (
    DuplicatedIPAllocationError,
    DuplicateIPAssignmentError,
    IPBlockNotFoundError,
    NoAvailableIPError,
    OverlappedIPBlocksError,
)
from .ipv6_allocator_pool import MaxCalculationError
from .subscriberdb_client import (
    SubscriberDBConnectionError,
    SubscriberDBMultiAPNValueError,
    SubscriberDBStaticIPValueError,
)

enable_sentry_wrapper = get_sentry_status("mobilityd") == SentryStatus.SEND_SELECTED_ERRORS


class MobilityServiceRpcServicer(MobilityServiceServicer):
    """ gRPC based server for the IPAllocator. """

    def __init__(
        self, ip_address_manager: IPAddressManager,
        print_grpc_payload: bool = False,
    ):
        """Initialize mobilityd GRPC endpoints."""
        self._ip_address_man = ip_address_manager
        self._print_grpc_payload = print_grpc_payload

        if self._print_grpc_payload:
            logging.info("Printing GRPC messages")
Esempio n. 3
0
from magma.common.sentry import (
    SentryStatus,
    get_sentry_status,
    send_uncaught_errors_to_monitoring,
)
from orc8r.protos.directoryd_pb2 import AllDirectoryRecords, DirectoryField
from orc8r.protos.directoryd_pb2_grpc import (
    GatewayDirectoryServiceServicer,
    add_GatewayDirectoryServiceServicer_to_server,
)
from redis.exceptions import LockError, RedisError

DIRECTORYD_REDIS_TYPE = "directory_record"
LOCATION_MAX_LEN = 5

enable_sentry_wrapper = get_sentry_status("directoryd") == SentryStatus.SEND_SELECTED_ERRORS


class DirectoryRecord:
    """
    DirectoryRecord holds a location history of up to five gateway hwids
    and a dict of identifiers for the record.
    """
    __slots__ = ['location_history', 'identifiers']

    def __init__(
            self, location_history: List[str], identifiers: Dict[str, str],
    ):
        self.location_history = location_history
        self.identifiers = identifiers
Esempio n. 4
0
from typing import Any, Dict

import grpc
import jsonschema
from magma.common.rpc_utils import return_void
from magma.common.sentry import (
    SentryStatus,
    get_sentry_status,
    send_uncaught_errors_to_monitoring,
)
from magma.eventd.event_validator import EventValidator
from orc8r.protos import eventd_pb2, eventd_pb2_grpc

RETRY_ON_FAILURE = 'retry_on_failure'

enable_sentry_wrapper = get_sentry_status(
    "eventd") == SentryStatus.SEND_SELECTED_ERRORS


class EventDRpcServicer(eventd_pb2_grpc.EventServiceServicer):
    """
    gRPC based server for EventD.
    """
    def __init__(self, config: Dict[str, Any], validator: EventValidator):
        self._fluent_bit_port = config['fluent_bit_port']
        self._tcp_timeout = config['tcp_timeout']
        self._event_registry = config['event_registry']
        self._validator = validator

    def add_to_server(self, server):
        """
        Add the servicer to a gRPC server
Esempio n. 5
0
import grpc
from lte.protos import subscriberdb_pb2, subscriberdb_pb2_grpc
from magma.common.rpc_utils import print_grpc, return_void
from magma.common.sentry import (
    SentryStatus,
    get_sentry_status,
    send_uncaught_errors_to_monitoring,
)
from magma.subscriberdb.sid import SIDUtils
from magma.subscriberdb.store.base import (
    DuplicateSubscriberError,
    SubscriberNotFoundError,
)

enable_sentry_wrapper = get_sentry_status(
    "subscriberdb") == SentryStatus.SEND_SELECTED_ERRORS
suci_profile_data = NamedTuple(
    'suci_profile_data',
    [
        ('protection_scheme', int),
        ('home_net_public_key', bytes),
        ('home_net_private_key', bytes),
    ],
)


class SubscriberDBRpcServicer(subscriberdb_pb2_grpc.SubscriberDBServicer):
    """
    gRPC based server for the SubscriberDB.
    """
    def __init__(self, store, print_grpc_payload: bool = False):