Ejemplo n.º 1
0
    def __init__(self):

        self.args = args = parse_args()
        self.config = load_config(args)

        verbosity_adjust = (args.verbose or 0) - (args.quiet or 0)
        self.log = setup_logging(self.config.get('logging', {}),
                                 args.instance_id,
                                 verbosity_adjust=verbosity_adjust)
        self.log.info('container-number-extractor',
                      regex=args.container_name_regex)

        self.ponsim_olt_adapter_version = self.get_version()
        self.log.info('Ponsim-ONU-Adapter-Version',
                      version=self.ponsim_olt_adapter_version)

        if not args.no_banner:
            print_banner(self.log)

        self.adapter = None
        # Create a unique instance id using the passed-in instance id and
        # UTC timestamp
        current_time = arrow.utcnow().timestamp
        self.instance_id = self.args.instance_id + '_' + str(current_time)

        self.core_topic = args.core_topic
        self.listening_topic = args.name
        self.startup_components()

        if not args.no_heartbeat:
            self.start_heartbeat()
            self.start_kafka_cluster_heartbeat(self.instance_id)
Ejemplo n.º 2
0
    def __init__(self):

        self.args = args = parse_args()
        self.config = load_config(args)

        # log levels in python are:
        # 1 - DEBUG => verbosity_adjust = 10
        # 2 - INFO => verbosity_adjust = 20
        # 3 - WARNING => verbosity_adjust = 30
        # 4 - ERROR => verbosity_adjust = 40
        # 5 - CRITICAL => verbosity_adjust = 50

        verbosity_adjust = string_to_int(str(args.log_level))

        if verbosity_adjust == 0:
            raise ValueError("Invalid loglevel is given: " + str(args.log_level))
            sys.exit(1)

        self.log = setup_logging(self.config.get('logging', {}),
                                 args.instance_id,
                                 verbosity_adjust=verbosity_adjust)
        self.log.info('container-number-extractor',
                      regex=args.container_name_regex)

        self.build_info = get_build_info()
        self.log.info('OpenONU-Adapter-Version', build_version=self.build_info)

        if not args.no_banner:
            print_banner(self.log)

        self.etcd_host = str(args.etcd).split(':')[0]
        self.etcd_port = str(args.etcd).split(':')[1]

        self.controller = LogController(self.etcd_host, self.etcd_port)

        self.adapter = None
        # Create a unique instance id using the passed-in instance id and
        # UTC timestamp
        current_time = arrow.utcnow().timestamp
        self.instance_id = self.args.instance_id + '_' + str(current_time)

        self.core_topic = str(args.core_topic)
        self.adapter_topic = str(args.adapter_topic)
        self.event_topic = str(args.event_topic)
        self.listening_topic = "%s_%s" % (args.name, args.current_replica)
        self.id = "%s_%s" % (args.name, args.current_replica)
        self.startup_components()

        if not args.no_heartbeat:
            self.start_kafka_cluster_heartbeat(self.instance_id)
Ejemplo n.º 3
0
    def __init__(self):

        self.args = args = parse_args()
        self.config = load_config(args)

        # log levels in python are:
        # 1 - DEBUG => verbosity_adjust = 0
        # 2 - INFO => verbosity_adjust = 1
        # 3 - WARNING => verbosity_adjust = 2
        # 4 - ERROR
        # 5 - CRITICAL
        # If no flags are set we want to stick with INFO,
        # if verbose is set we want to go down to DEBUG
        # if quiet is set we want to go up to WARNING
        # if you set both, you're doing something non-sense and you'll be back at INFO

        verbosity_adjust = self.string_to_int(str(args.log_level))
        if verbosity_adjust == -1:
            print("Invalid loglevel is given: " + str(args.log_level))
            sys.exit(0)

        self.log = setup_logging(self.config.get('logging', {}),
                                 args.instance_id,
                                 verbosity_adjust=verbosity_adjust)
        self.log.info('container-number-extractor',
                      regex=args.container_name_regex)

        self.build_info = get_build_info()
        self.log.info('OpenONU-Adapter-Version', build_version=self.build_info)

        if not args.no_banner:
            print_banner(self.log)

        self.adapter = None
        # Create a unique instance id using the passed-in instance id and
        # UTC timestamp
        current_time = arrow.utcnow().timestamp
        self.instance_id = self.args.instance_id + '_' + str(current_time)

        self.core_topic = str(args.core_topic)
        self.event_topic = str(args.event_topic)
        self.listening_topic = str(args.name)
        self.startup_components()

        if not args.no_heartbeat:
            self.start_kafka_cluster_heartbeat(self.instance_id)
Ejemplo n.º 4
0
    def __init__(self):

        self.args = args = parse_args()
        self.config = load_config(args)
        self.grpc_timeout = int(self.args.grpc_timeout)

        verbosity_adjust = (args.verbose or 0) - (args.quiet or 0)
        self.log = setup_logging(self.config.get('logging', {}),
                                 args.instance_id,
                                 verbosity_adjust=verbosity_adjust)

        # components
        self.connection_manager = None

        self.exiting = False

        if not args.no_banner:
            print_banner(self.log)

        self.startup_components()
Ejemplo n.º 5
0
    def __init__(self):
        try:
            self.args = args = parse_args()
            self.config = load_config(args)

            verbosity_adjust = (args.verbose or 0) - (args.quiet or 0)
            self.log = setup_logging(self.config.get('logging', {}),
                                     args.instance_id,
                                     verbosity_adjust=verbosity_adjust)
            self.log.info('container-number-extractor',
                          regex=args.container_name_regex)

            if args.debug_enabled:
                setup_remote_debug(args.debug_host, args.debug_port, self.log)

            self.adtran_olt_adapter_version = self.get_version()
            self.log.info('ADTRAN-OLT-Adapter-Version',
                          version=self.adtran_olt_adapter_version)

            if not args.no_banner:
                print_banner(self.log)

            self.adapter = None

            # Create a unique instance id using the passed-in instance id and
            # UTC timestamp
            current_time = arrow.utcnow().timestamp
            self.instance_id = self.args.instance_id + '_' + str(current_time)

            self.core_topic = args.core_topic
            self.listening_topic = args.name
            self.startup_components()

            if not args.no_heartbeat:
                self.start_heartbeat()
                self.start_kafka_cluster_heartbeat(self.instance_id)

        except Exception as e:
            self.log.exception('unhandled-exception', e=e)
            raise