Disclosure of Invention
The method and the device for judging the access of the optical module are applied to a backbone network switch, the backbone network switch and a readable storage medium, and the purpose is to provide a mechanism for judging whether the optical module accessed to each port is the optical module allowed to be accessed or not for the backbone network switch, so that a series of problems possibly caused by non-adaptive optical modules are solved from the source, the backbone network switch is ensured to be in a continuous, efficient and stable working state, and the experience of a bottom layer user is ensured.
In order to achieve the above object, the present application first provides an optical module admission discrimination method applied to a backbone network switch, including:
reading device information from an optical module of the access port;
forming an equipment information file under a target directory according to the equipment information according to a preset mapping rule; the mapping rule records the corresponding relation between each port and each target directory;
extracting character strings from the equipment information file according to a preset offset to obtain an actual discrimination parameter;
judging whether the actual discrimination parameter appears in a preset admission discrimination parameter list or not; the admission judging parameter list records judging parameters meeting admission requirements;
and if the actual discrimination parameter does not appear in the admission discrimination parameter list, performing offline processing on the port accessed by the optical module.
Optionally, extracting a character string from the device information file according to a preset offset to obtain an actual discrimination parameter, including:
extracting a character string with a first preset length according to a first preset offset from the head subsection of the equipment information file to obtain an actual manufacturer name;
extracting a character string with a second preset length according to a second preset offset from the head subsection of the equipment information file to obtain an actual batch serial number;
and taking the combination of the actual manufacturer name and the actual batch serial number as the actual discrimination parameter.
Optionally, when the actual distinguishing parameter specifically consists of the actual manufacturer name and the serial number of the batch equipment, determining whether the actual distinguishing parameter appears in a preset admission distinguishing parameter list includes:
judging whether the admittance judging parameter list contains the actual manufacturer name;
if the actual manufacturer name is included, judging whether the admission judging parameter list includes the actual batch serial number;
if the actual batch serial number is contained, judging that the actual discrimination parameter appears in the admittance discrimination parameter list;
and if the actual manufacturer name or the actual batch serial number is not contained, judging that the actual discrimination parameter does not appear in the admission discrimination parameter list.
Optionally, before performing offline processing on the port accessed by the optical module, the method further includes:
acquiring a port number accessed by the optical module;
generating admittance rejection prompt information according to the port number and the actual discrimination parameters of the optical module;
displaying the access refusing prompt information through a preset path, and simultaneously recording the access refusing prompt information to an access judging log;
correspondingly, the off-line processing is performed on the port accessed by the optical module, and the off-line processing includes:
and performing offline processing on the corresponding port according to the port number.
Optionally, the offline processing performed by the port accessed by the optical module includes:
and executing down operation on the port accessed by the optical module, and simultaneously controlling a working indicator lamp of the port accessed by the optical module to be in a working state of indicating that the port is offline.
In order to achieve the above object, the present application further provides an optical module admission discrimination device applied to a backbone network switch, including:
the device information reading unit is used for reading the device information from the optical module of the access port;
the device information file forming unit is used for forming a device information file from the device information under a target directory according to a preset mapping rule; the mapping rule records the corresponding relation between each port and each target directory;
the actual discrimination parameter extraction unit is used for extracting character strings from the equipment information file according to a preset offset to obtain an actual discrimination parameter;
the discrimination parameter comparison unit is used for judging whether the actual discrimination parameter appears in a preset admittance discrimination parameter list or not; the admission judging parameter list records judging parameters meeting admission requirements;
and the admittance-refusing offline processing unit is used for offline processing the port accessed by the optical module if the actual discrimination parameter does not appear in the admittance discrimination parameter list.
Optionally, the actual discrimination parameter extracting unit includes:
the actual manufacturer name extracting subunit is used for extracting a character string with a first preset length from the head subsection of the equipment information file according to a first preset offset to obtain an actual manufacturer name;
the actual batch serial number extracting subunit is used for extracting a character string with a second preset length according to a second preset offset from the head subsection of the equipment information file to obtain an actual batch serial number;
and the actual judging parameter combining subunit is configured to use a combination of the actual manufacturer name and the actual batch serial number as the actual judging parameter.
Optionally, when the actual distinguishing parameter specifically consists of the actual manufacturer name and the serial number of the batch equipment, the distinguishing parameter comparing unit includes:
the factory name containing judging subunit is used for judging whether the admission judging parameter list contains the actual factory name or not;
the batch serial number containing judging subunit is used for judging whether the admission judging parameter list contains the actual batch serial number or not when the actual manufacturer name is contained;
the judging subunit is used for judging that the actual distinguishing parameter appears in the admittance distinguishing parameter list when the actual batch serial number is included;
and the non-included judging subunit is used for judging that the actual discrimination parameter does not appear in the admission discrimination parameter list when the actual manufacturer name or the actual batch serial number is not included.
Optionally, the optical module admission discriminating device further includes:
a port number obtaining unit, configured to obtain a port number accessed by the optical module before performing offline processing on the port accessed by the optical module;
the admittance rejection prompt information generating unit is used for generating admittance rejection prompt information according to the port number and the actual discrimination parameter of the optical module;
the prompt information display and log recording unit is used for displaying the admittance refusing prompt information through a preset path and simultaneously recording the admittance refusing prompt information to the admittance judging log;
correspondingly, the off-line processing unit for refusing to admit comprises:
and the admittance refusing offline processing subunit is used for offline processing the corresponding port according to the port number.
Optionally, the admittance rejection offline processing unit includes:
and the port and indicator light processing subunit is used for executing down operation on the port accessed by the optical module and simultaneously controlling the working indicator light of the port accessed by the optical module to be in a working state of indicating that the port is offline.
To achieve the above object, the present application also provides a backbone network switch, including:
a memory for storing a computer program;
and a processor, configured to implement the steps of the optical module admission discrimination method applied to the backbone switch as described in the foregoing when executing the computer program.
To achieve the above object, the present application further provides a readable storage medium, which stores thereon a computer program, and when the computer program is executed by a processor, the computer program implements the steps of the optical module admission discrimination method applied to the backbone network switch as described in the above.
The optical module admission judging method applied to the backbone network switch comprises the following steps: reading device information from an optical module of the access port; forming an equipment information file under a target directory according to the equipment information according to a preset mapping rule; the mapping rule records the corresponding relation between each port and each target directory; extracting character strings from the equipment information file according to a preset offset to obtain an actual discrimination parameter; judging whether the actual discrimination parameter appears in a preset admission discrimination parameter list or not; the admission judging parameter list records judging parameters meeting admission requirements; and if the actual discrimination parameter does not appear in the admission discrimination parameter list, performing offline processing on the port accessed by the optical module.
Obviously, in the present application, firstly, in order to distinguish different optical modules accessed from different ports, a mapping rule is preset, through the mapping rule, device information of different optical modules can be respectively formed into different device information files under corresponding file directories, and then, actual discrimination parameters extracted from different device information files are subsequently distinguished from a preset access discrimination parameter list, whether the corresponding optical module is an allowed-to-be-accessed optical module is obtained, and offline processing is performed on the corresponding port when the access is not allowed. It can be seen that all optical modules which are not produced and manufactured according to the access judgment mechanism can be screened out through the access judgment mechanism, and the adaptive optical modules are always subjected to availability verification before leaving a factory, so that the backbone network switch can be ensured to be in an efficient and stable working state for a long time.
The application also provides an optical module access judging device applied to the backbone network switch, the backbone network switch and a readable storage medium, and the optical module access judging device has the beneficial effects and is not repeated herein.
Detailed Description
The method and the device for judging the access of the optical module are applied to a backbone network switch, the backbone network switch and a readable storage medium, and the purpose is to provide a mechanism for judging whether the optical module accessed to each port is the optical module allowed to be accessed or not for the backbone network switch, so that a series of problems possibly caused by non-adaptive optical modules are solved from the source, the backbone network switch is ensured to be in a continuous, efficient and stable working state, and the experience of a bottom layer user is ensured.
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Referring to fig. 1, fig. 1 is a flowchart of an optical module admission discrimination method applied to a backbone switch according to an embodiment of the present application, where the method includes the following steps:
s101: reading device information from an optical module of the access port;
this step is intended to read the device information from the optical module connected to each port of the backbone network switch. The device information of the device in which the optical module is located is usually stored in a certain path of the optical module in order to be quickly acquired, and the device information includes various information related to the optical module, such as manufacturer information and product lot information of the optical module, and also includes some information related to the device model.
S102: forming an equipment information file under a target directory according to the preset mapping rule by the equipment information;
in other words, the mapping relationship can form the device information acquired from the optical module accessing different ports into independent device information files under the corresponding directories. The target directory may also be understood as a file path, that is to say a corresponding storage path is specified for the device information obtained from each optical module. It should be understood that it is meaningless to assign the same storage path to the optical modules accessed from different ports, because the purpose of this step is to distinguish the device information of different optical modules by different storage paths, so as to facilitate the extraction and discrimination of the following actual discrimination parameters.
Specifically, taking a common backbone switch with two types of ports as an example, which respectively has 25g ports and 100g ports, the mapping rule requires that the device information of an optical module accessing port 0 of the 25g port will form a device information file with number 0050 under a root directory, and then the corresponding relationship may be specifically recorded as "25 _ 0-0050", where "25 _ 0" represents port 0 of the 25g port, and similarly, "100 _ 1-0070" represents that the device information of an optical module accessing port 1 of the 100g port will form a device information file with number 0070 under the root directory. Of course, the mapping rule may be embodied as a corresponding relationship corresponding to each port, or may be a guiding rule that may embody multiple rules, which is not specifically limited herein.
S103: extracting character strings from the equipment information file according to a preset offset to obtain an actual discrimination parameter;
on the basis of S102, in this step, the backbone switch purposefully extracts a character string from each device information file according to a preset offset, so as to obtain an actual discrimination parameter for discriminating whether the corresponding optical module is allowed to be admitted.
It should be understood that, since the actual discrimination parameter is a parameter that can be used to discriminate whether the corresponding optical module is allowed to enter, it should be a parameter that can distinguish between the adapted optical module and the non-adapted optical module, and specifically, the corresponding parameter can be flexibly selected as the extraction object according to the type of the parameter selected as the criterion. And the offset is auxiliary information for guiding extraction operation to extract the character string at a specific position, if the character string is an adaptive optical module, the adaptive optical module should store a subsequent discrimination parameter for discriminating whether the character string can be admitted or not according to the standard, and correspondingly, the character string extracted subsequently is likely to have no practical significance because the non-adaptive optical module does not follow the standard, so that the character string cannot be judged as the non-adaptive optical module through subsequent discrimination.
One implementation, including but not limited to, may be seen in the flowchart shown in fig. 2, which includes the steps of:
s201: extracting a character string with a first preset length according to a first preset offset from a head subsection of the equipment information file to obtain an actual manufacturer name;
specifically, the first preset offset may be 20 bytes, the first preset length is 16 bytes, and the extracted actual manufacturer name applied may be a value named VendorName.
S202: extracting a character string with a second preset length according to a second preset offset from the head subsection of the equipment information file to obtain an actual batch serial number;
specifically, the second preset offset may be 40 bytes, the second preset length is 16 bytes, and the extracted application actual lot serial number may be a value named VendorPN.
S203: determining a corresponding target creation resource area and a corresponding amount of resources required for creation according to the target creation resource area information and the amount of resources required for creation;
s204: and taking the combination of the actual manufacturer name and the actual batch serial number as an actual discrimination parameter.
As can be seen from the flowchart shown in fig. 2, the solution specifically uses two parameters, namely, a manufacturer name and a batch serial number, to form the discrimination parameter, where the manufacturer name is used to identify a manufacturer of the optical module, and the batch serial number is used to identify specific generation information of the optical module, and specific information such as a model number, a generation signal, and the like can be derived from the specific generation information. The reason why the serial number of the batch is added on the basis of the manufacturer name is that the situation that different backbone network switches and different models and batches of optical modules are not adapted is considered.
Of course, other parameter types that may serve a similar purpose may also be obtained in the same manner.
S104: judging whether the actual discrimination parameter appears in a preset admission discrimination parameter list, if so, executing S106, otherwise, executing S105;
the admittance judging parameter list records judging parameters meeting admittance requirements, and the judging parameters are used as criteria.
On the basis of S103, this step is to determine whether the actual discrimination parameter appears in the preset admission discrimination parameter list, and obtain a conclusion whether the corresponding optical module is allowed to be admitted according to the determination result.
Taking the example that the actual discrimination parameter specifically includes the manufacturer name and the batch serial number as shown in fig. 2, that is, the manufacturer names and the batch serial numbers of the plurality of allowed optical modules are recorded in the preset admission discrimination parameter list in advance, and then the optical module having the manufacturer name and the batch serial number of the allowed optical module can be determined as the allowed optical module only by consistency comparison.
One implementation, including but not limited to, may be seen in the flowchart shown in fig. 3, which includes the steps of:
s301: the combination of the actual manufacturer name and the actual batch serial number is used as an actual discrimination parameter;
s302: judging whether the admittance judging parameter list contains the actual manufacturer name, if so, executing S303, otherwise executing S305;
s303: judging whether the admission judging parameter list contains the actual batch serial number, if so, executing S304, otherwise, executing S305;
s304: judging that the actual discrimination parameters appear in an admission discrimination parameter list;
s305: and judging that the actual discrimination parameter does not appear in the admission discrimination parameter list.
As can be seen from the steps shown in fig. 3, according to the present embodiment, only by passing through the manufacturer name and the batch serial number at the same time, the corresponding optical module is determined as an allowed optical module. Of course, in some scenarios, only one of the optical modules may be determined as an allowed-entry optical module, which is mainly used herein to prevent the missing determination as much as possible, and the determination strength may be automatically adjusted according to the difference in the actual application scenarios, and this is not particularly limited herein, and only one feasible example is given.
S105: off-line processing is carried out on a port accessed by the optical module;
in this step, on the basis that the determination result of S104 is that the actual discrimination parameter does not appear in the preset admission discrimination parameter list, it is described that the optical module belongs to an optical module that is not adapted to the backbone network switch, so in order to prevent the backbone network switch from being affected by using the non-adapted optical module, this step directly performs offline processing on the port to which the optical module is accessed, and thus the optical module is completely placed in a shielding state.
Further, before executing this step, related information may also be recorded as a certificate for tracing back at a later time, and one implementation manner including but not limited to:
acquiring a port number accessed by an optical module;
generating admittance rejection prompt information according to the port number and the actual discrimination parameters of the optical module;
and displaying the admission refusing prompt information through a preset path, and simultaneously recording the admission refusing prompt information to an admission judging log.
The preset path can be represented by short messages, mails, interface popup windows, various instant application programs and the like, so that the access refusing prompt message is presented to the manager in time.
Specifically, the offline processing may be embodied as:
and executing down operation on the port accessed by the optical module, and simultaneously controlling a working indicator lamp of the port accessed by the optical module to be in a working state of indicating that the port is offline.
S106: no treatment is done.
This step is based on the determination result of S104 being that the actual discrimination parameter appears in the preset admission discrimination parameter list, which indicates that the optical module belongs to the optical module adapted to the backbone network switch, and therefore, no other processing is required to be performed on the optical module.
According to the optical module access judgment method provided by the embodiment, firstly, in order to distinguish different optical modules accessed from different ports, a mapping rule is preset, different device information files can be formed by the device information of the different optical modules in corresponding file directories through the mapping rule, then, actual judgment parameters extracted from the different device information files are judged according to the existence between the actual judgment parameters and a preset access judgment parameter list, whether the corresponding optical module is an optical module allowed to be accessed is obtained, and offline processing is performed on the corresponding port when the access is not allowed. It can be seen that all optical modules which are not produced and manufactured according to the access judgment mechanism can be screened out through the access judgment mechanism, and the adaptive optical modules are always subjected to availability verification before leaving a factory, so that the backbone network switch can be ensured to be in an efficient and stable working state for a long time.
For convenience of understanding, the present application also provides a specific implementation manner in combination with a specific actual operation manner of a certain backbone network switch, please refer to a flowchart shown in fig. 4:
the mapping relation between the ports and I2C is the mapping rule in the above embodiment, because the optical module essentially serves as an I2C device, and the description of the upper layer is used here instead. The I2C device file is then correspondingly equivalent to the device information file described in the above embodiment. The defined verification list is consistent with the preset admission judgment parameters.
Because the situation is complicated and cannot be illustrated by a list, a person skilled in the art can realize that many examples exist according to the basic method principle provided by the application and the practical situation, and the protection scope of the application should be protected without enough inventive work.
Referring to fig. 5, fig. 5 is a block diagram of an optical module admission apparatus applied to a backbone switch according to an embodiment of the present application, where the apparatus may include:
a device information reading unit 100, configured to read device information from an optical module of the access port;
an equipment information file forming unit 200, configured to form an equipment information file from the equipment information in the target directory according to a preset mapping rule; the mapping rule records the corresponding relation between each port and each target directory;
an actual discrimination parameter extracting unit 300, configured to extract a character string from the device information file according to a preset offset to obtain an actual discrimination parameter;
a discrimination parameter comparison unit 400 configured to determine whether an actual discrimination parameter appears in a preset admission discrimination parameter list; wherein, the admittance judging parameter list records the judging parameter meeting the admittance requirement;
and an admittance refusing offline processing unit 500, configured to perform offline processing on a port to which the optical module is accessed if the actual discrimination parameter does not appear in the admittance discrimination parameter list.
The actual discrimination parameter extracting unit 300 includes:
the actual manufacturer name extracting subunit is used for extracting a character string with a first preset length from the head subsection of the equipment information file according to a first preset offset to obtain an actual manufacturer name;
the actual batch serial number extracting subunit is used for extracting a character string with a second preset length according to a second preset offset from the head subsection of the equipment information file to obtain an actual batch serial number;
and the actual judging parameter combining subunit is used for taking the combination of the actual manufacturer name and the actual batch serial number as the actual judging parameter.
When the actual determination parameter specifically consists of an actual manufacturer name and a batch equipment serial number, the determination parameter comparison unit 400 may include:
the factory name containing judging subunit is used for judging whether the admission judging parameter list contains the actual factory name or not;
the batch serial number comprises a judging subunit, which is used for judging whether the admission judging parameter list comprises the actual batch serial number when the actual factory name is included;
the system comprises a judging subunit, a judging unit and a judging unit, wherein the judging subunit is used for judging that the actual distinguishing parameter appears in an access distinguishing parameter list when the actual batch serial number is contained;
and the non-included judging subunit is used for judging that the actual judging parameter does not appear in the admittance judging parameter list when the actual manufacturer name or the actual batch serial number is not included.
Further, the optical module admission discriminating device may further include:
the port number acquisition unit is used for acquiring the port number accessed by the optical module before offline processing is carried out on the port accessed by the optical module;
the admittance rejection prompt information generating unit is used for generating admittance rejection prompt information according to the port number and the actual discrimination parameters of the optical module;
the prompting information display and log recording unit is used for displaying the admission refusing prompting information through a preset path and simultaneously recording the admission refusing prompting information to the admission judging log;
correspondingly, the admittance rejection offline processing unit can include:
and the admittance refusing offline processing subunit is used for offline processing the corresponding port according to the port number.
Wherein, the admittance rejection offline processing unit can include:
and the port and indicator light processing subunit is used for executing down operation on the port accessed by the optical module and controlling the working indicator light of the port accessed by the optical module to be in a working state of indicating that the port is off-line.
The present embodiment exists as an apparatus embodiment corresponding to the above method embodiment, and has all the beneficial effects of the method embodiment, and details are not repeated here.
The optical module access device can also be formed by another modularized structure, namely a basic information acquisition module and an adaptive verification module. The basic information acquisition module acquires eprom (non-volatile memory) information (namely, port number) of the port according to the position information corresponding to the port, and acquires manufacturer information and serial number information according to a specified offset address. The adaptive verification module defines the content of the adaptive list, compares the basic information, and assembles the port number and the basic information into prompt information when finding out the optical module which is not in the list. And prompting a user through a window, prompting the communication risk of the optical module, and simultaneously carrying out offline operation on the port.
The basic information acquisition module firstly defines the mapping relation between a port and an I2C channel path according to each physical port in the switch, wherein the mapping relation of 25g of the port is '33-0050' corresponding to the port 0, the mapping relation of '32-0050' corresponding to the port 1, and the like, the mapping relation of 100g of the port is '81-0050' corresponding to the port 48, the mapping relation of '80-0050' corresponding to the port 49, and the like. And then filling the data into a specific device file path for obtaining I2C according to the obtained mapping relation data, such as/sys/bus/I2 c/devices/I2 c-32/32-0050/eprom. Setting the offset of a factory name to be 20 according to the standard file definition of the optical module through the acquired path, acquiring 16 bytes of data, converting the data into a character string form and storing the character string form in VendorName, setting the offset of a serial number to be 40, acquiring 16 bytes of data, converting the data into the character string form and storing the character string form in VendorPN.
The adaptive verification module firstly defines a verified optical module list meeting the requirements of the switch, and the list comprises a plurality of manufacturer names and serial numbers meeting the standard. When VendorName and VendorPN are acquired, the optical module list is circulated. If the optical module information does not exist in the list, recombining the port number, the VendorName, the VendorPN and the list information which does not conform to the optical module, calling a display information function, displaying the warning information, and simultaneously recording the warning information into a/var/log/syslog file. And then adopting port offline processing, and indicating that the port is unavailable by configuring port down operation.
Based on the foregoing embodiments, the present application further provides a backbone network switch, which may include a memory and a processor, where the memory stores a computer program, and the processor, when calling the computer program in the memory, may implement the steps provided in the foregoing embodiments. Of course, the backbone switch may also include various necessary network interfaces, power supplies, and other components.
The present application also provides a readable storage medium, on which a computer program is stored, which when executed by an execution terminal or processor can implement the steps provided by the above-mentioned embodiments. The storage medium may include: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The embodiments are described in a progressive manner in the specification, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The principles and embodiments of the present application are explained herein using specific examples, which are provided only to help understand the method and the core idea of the present application. It will be apparent to those skilled in the art that various changes and modifications can be made in the present invention without departing from the principles of the invention, and these changes and modifications also fall within the scope of the claims of the present application.
It is further noted that, in the present specification, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.