Пример #1
0
    def GetPortConfig(self, port_num=0, lane=0):
        method_name = inspect.currentframe().f_code.co_name
        port_id = PortId(portNum=port_num, lane=lane)
        try:
            gb_srv_prp = self.gb_stub.GetPortConfig(port_id)
            logger.warning(gb_srv_prp)

        except grpc.RpcError as e:
            logger.warning(
                "%s.%s: Error getting config for GearBox port:%s/%s"
                % (self.class_name, method_name, port_num, lane)
            )
Пример #2
0
    def SetAN(self, port_num=0, lane=0, new_an=AN_OFF):
        method_name = inspect.currentframe().f_code.co_name
        port_id = PortId(portNum=port_num, lane=lane)
        an_info = ANInfo(portId=port_id, an=new_an)
        try:
            gb_srv_prp = self.gb_stub.SetAN(an_info)
            logger.warning(gb_srv_prp)

        except grpc.RpcError as e:
            logger.warning(
                "%s.%s: Error setting AN for GearBox port:%s/%s to new_an[%s]"
                % (self.class_name, method_name, port_num, lane, new_an)
            )
Пример #3
0
    def SetFc(self, port_num=0, lane=0, new_fc=FC_NONE):
        method_name = inspect.currentframe().f_code.co_name
        port_id = PortId(portNum=port_num, lane=lane)
        fc_info = FCInfo(portId=port_id, fc=new_fc)
        try:
            gb_srv_prp = self.gb_stub.SetFc(fc_info)
            logger.warning(gb_srv_prp)

        except grpc.RpcError as e:
            logger.warning(
                "%s.%s: Error setting FC for GearBox port:%s/%s to new_fc[%s]"
                % (self.class_name, method_name, port_num, lane, new_fc)
            )
Пример #4
0
    def GetSFPCInfo(self, port_num=0, lane=0):
        method_name = inspect.currentframe().f_code.co_name
        port_id = PortId(portNum=port_num, lane=lane)
        try:
            gb_srv_prp = self.gb_stub.GetSFPCInfo(port_id)
            logger.warning(gb_srv_prp)
            return(0)

        except grpc.RpcError as e:
            if e.code() == grpc.StatusCode.UNIMPLEMENTED:
                logger.warning("%s.%s: %s" % (self.class_name, method_name,
                        "UNIMPLEMENTED"))
            else:
                logger.warning(
                    "%s.%s: Error getting SFP Info from GearBox port:%s/%s"
                    % (self.class_name, method_name,
                        port_num, lane)
                )
Пример #5
0
    def SetSpeed(self, port_num=0, lane=0, new_speed=SPEED_1G):
        method_name = inspect.currentframe().f_code.co_name
        port_id = PortId(portNum=port_num, lane=lane)
        speed_info = SpeedInfo(portId=port_id, speed=new_speed)
        try:
            gb_srv_prp = self.gb_stub.SetSpeed(speed_info)
            logger.warning(gb_srv_prp)

        except grpc.RpcError as e:
            logger.warning(
                "%s.%s: Error setting speed for GearBox port:%s/%s to new_speed[%s]"
                % (
                    self.class_name,
                    method_name,
                    port_num,
                    lane,
                    new_speed,
                )
            )
Пример #6
0
    def EnablePort(self, port_num=0, lane=0, new_enb=True):
        method_name = inspect.currentframe().f_code.co_name
        port_id = PortId(portNum=port_num, lane=lane)
        enb_info = EnableInfo(portId=port_id, enb=new_enb)
        try:
            gb_srv_prp = self.gb_stub.EnablePort(enb_info)
            logger.warning(gb_srv_prp)
            return(0)

        except grpc.RpcError as e:
            logger.warning(
                "%s.%s: Error setting EnablePort for GearBox port:%s/%s to new_enb[%s]"
                % (
                    self.class_name,
                    method_name,
                    port_num,
                    lane,
                    new_enb,
                )
            )
Пример #7
0
    def AddPort(self, port_num=0, lane=0,
                      speed=SPEED_1G,
                      fec=FEC_NONE,
                      an=AN_OFF,
                      fc=FC_NONE,
                      enable=True,
                      up=True):
        method_name = inspect.currentframe().f_code.co_name
        port_id = PortId(portNum=port_num, lane=lane)
        port_config = PortConfig(
            speed=speed, fec=fec, an=an, fc=fc, enable=enable, up=up
        )
        port_info = PortInfo(portId=port_id, portConf=port_config)
        try:
            gb_srv_prp = self.gb_stub.AddPort(port_info)
            logger.warning(gb_srv_prp)

        except grpc.RpcError as e:
            logger.warning(
                "%s.%s: Error adding GearBox port:%s/%s"
                % (self.class_name, method_name, port_num, lane)
            )