Ejemplo n.º 1
0
    def __init__(self, db=None):

        # Load database config files
        load_db_config()
        if db is None:
            self.port_dict = multi_asic.get_port_table()
        else:
            self.config_db = db.cfgdb
            self.port_dict = self.config_db.get_table('PORT')
        self.alias_max_length = 0

        if not self.port_dict:
            click.echo(
                message="Warning: failed to retrieve PORT table from ConfigDB!",
                err=True)
            self.port_dict = {}

        for port_name in self.port_dict:
            try:
                if self.alias_max_length < len(
                        self.port_dict[port_name]['alias']):
                    self.alias_max_length = len(
                        self.port_dict[port_name]['alias'])
            except KeyError:
                break
Ejemplo n.º 2
0
 def __init__(self,
              display_option=constants.DISPLAY_ALL,
              namespace_option=None,
              db=None):
     # Load database config files
     load_db_config()
     self.namespace_option = namespace_option
     self.display_option = display_option
     self.current_namespace = None
     self.is_multi_asic = multi_asic.is_multi_asic()
     self.db = db
Ejemplo n.º 3
0
    def __init__(self):
        self.yang_acl = None
        self.requested_session = None
        self.mirror_stage = None
        self.current_table = None
        self.tables_db_info = {}
        self.rules_db_info = {}
        self.rules_info = {}

        # Load database config files
        load_db_config()

        self.sessions_db_info = {}
        self.configdb = ConfigDBConnector()
        self.configdb.connect()
        self.statedb = SonicV2Connector(host="127.0.0.1")
        self.statedb.connect(self.statedb.STATE_DB)

        # For multi-npu architecture we will have both global and per front asic namespace.
        # Global namespace will be used for Control plane ACL which are via IPTables.
        # Per ASIC namespace will be used for Data and Everflow ACL's.
        # Global Configdb will have all ACL information for both Ctrl and Data/Evereflow ACL's
        # and will be used as souurce of truth for ACL modification to config DB which will be done to both Global DB and
        # front asic namespace

        self.per_npu_configdb = {}

        # State DB are used for to get mirror Session monitor port.
        # For multi-npu platforms each asic namespace can have different monitor port
        # dependinding on which route to session destination ip. So for multi-npu
        # platforms we get state db for all front asic namespace in addition to

        self.per_npu_statedb = {}

        # Getting all front asic namespace and correspding config and state DB connector

        namespaces = multi_asic.get_all_namespaces()
        for front_asic_namespaces in namespaces['front_ns']:
            self.per_npu_configdb[front_asic_namespaces] = ConfigDBConnector(
                use_unix_socket_path=True, namespace=front_asic_namespaces)
            self.per_npu_configdb[front_asic_namespaces].connect()
            self.per_npu_statedb[front_asic_namespaces] = SonicV2Connector(
                use_unix_socket_path=True, namespace=front_asic_namespaces)
            self.per_npu_statedb[front_asic_namespaces].connect(
                self.per_npu_statedb[front_asic_namespaces].STATE_DB)

        self.read_tables_info()
        self.read_rules_info()
        self.read_sessions_info()
        self.read_policers_info()
Ejemplo n.º 4
0
def cli(ctx):
    """
    Utility entry point.
    """
    # Use the db object if given as input.
    db = None if ctx.obj is None else ctx.obj.cfgdb

    # Load database config files
    load_db_config()

    context = {
        "crm": Crm(db)
    }

    ctx.obj = context
Ejemplo n.º 5
0
    def __init__(self, db=None):

        # Load database config files
        load_db_config()
        if db is None:
            self.port_dict = multi_asic.get_port_table()
        else:
            self.config_db = db.cfgdb
            self.port_dict = self.config_db.get_table('PORT')
        self.alias_max_length = 0

        if not self.port_dict:
            self.port_dict = {}

        for port_name in self.port_dict:
            try:
                if self.alias_max_length < len(
                        self.port_dict[port_name]['alias']):
                    self.alias_max_length = len(
                        self.port_dict[port_name]['alias'])
            except KeyError:
                break
Ejemplo n.º 6
0
    def __init__(self, db=None):

        # Load database config files
        load_db_config()
        if db is None:
            self.port_dict = multi_asic.get_port_table()
        else:
            self.config_db = db.cfgdb
            self.port_dict = self.config_db.get_table('PORT')
        self.alias_max_length = 0

        if not self.port_dict:
            if not device_info.is_supervisor():
                click.echo(message="Configuration database contains no ports")
            self.port_dict = {}

        for port_name in self.port_dict:
            try:
                if self.alias_max_length < len(
                        self.port_dict[port_name]['alias']):
                    self.alias_max_length = len(
                        self.port_dict[port_name]['alias'])
            except KeyError:
                break
Ejemplo n.º 7
0
def cli():
    """ SONiC PFC Watchdog """
    load_db_config()