A method, device and medium for converting a switch command line

By constructing a command-line configuration table and an automated conversion method, the translation difficulties caused by differences in configuration command lines between different switch manufacturers were resolved, achieving efficient and accurate configuration conversion.

CN118827351BActive Publication Date: 2025-11-28INSPUR NETWORK TECH (SHANDONG) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410983733.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-22
Publication Date
2025-11-28
Estimated Expiration
2044-07-22

AI Technical Summary

Technical Problem

The command lines for configuring switches from different manufacturers differ, which necessitates manual translation during network change operations, resulting in low efficiency and a high risk of errors.

Method used

A command-line configuration table is built, which maps command-line functions from different vendors to key-value pairs. The configuration files are automatically converted. The configuration files are obtained using network management tools and the command-line configuration table is built to achieve automatic mapping and conversion of command-line functions.

Benefits of technology

It improves the efficiency of switch configuration conversion, reduces the error rate, simplifies the operation process, and improves accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118827351B_ABST
    Figure CN118827351B_ABST
Patent Text Reader

Abstract

The application discloses a switch command line conversion method, device and medium, and relates to the technical field of computer networks, which comprises the following steps: obtaining configuration files of switches of various manufacturers, determining configuration command lines of the switches of various manufacturers and command line functions corresponding to the configuration command lines according to the configuration files, constructing key-value pairs of the command line functions and the configuration command lines, constructing a command line configuration table based on the key-value pairs, obtaining an original manufacturer and a target manufacturer, determining an original configuration file corresponding to the original manufacturer, iterating original command lines of the original configuration file, determining command line functions corresponding to the original command lines according to the command line configuration table, and querying target command lines corresponding to the target manufacturer in the command line configuration table based on the command line functions, and outputting the target command lines. By constructing the command line configuration table, the conversion efficiency can be greatly improved, and the error rate can be reduced by converting the configuration of different manufacturers in batches according to functions and implementation logic.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer networks, in particular to a switch command line conversion method, device and medium. BACKGROUND

[0002] Switches are network devices that work on the data link layer and are used for electrical (optical) signal forwarding, providing exclusive electrical signal paths for any two network nodes connected. With the expansion of network size and the increase of business demand, the application of switches is becoming more and more widespread, and the configuration workload of switches is also increasing. Different manufacturers will develop different configuration command specifications according to business needs and their own characteristics when producing switches, resulting in differences in configuration command lines of different switches.

[0003] When a running network or system is changed, different manufacturers' switches are replaced, and because the configuration command lines of different manufacturers' switches are different, the original manufacturer's switch configuration command line cannot be directly used, and the switch configuration needs to be converted. The traditional way is to manually translate the configuration command line by engineers. This method requires high dependence on engineers' experience and has a large workload, and is prone to errors in the translation process, with low efficiency and accuracy. SUMMARY

[0004] To solve the above problems, the present application provides a switch command line conversion method, which comprises: obtaining configuration files of switches of various manufacturers, determining configuration command lines of the switches of various manufacturers and command line functions corresponding to the configuration command lines according to the configuration files;

[0005] Building a key-value pair of the command line function and the configuration command line, and building a command line configuration table based on the key-value pair;

[0006] Obtaining the input original manufacturer and target manufacturer, determining the original configuration file corresponding to the original manufacturer, iteratively reading the original command line of the original configuration file, and determining the command line function corresponding to the original command line according to the command line configuration table;

[0007] Based on the command line function, querying the target command line corresponding to the target manufacturer in the command line configuration table, and outputting the target command line.

[0008] In one embodiment, in the command line configuration table, it is determined whether the original command line exists; if not, the execution is stopped and an exception prompt is returned to remind of supplementing the command; if yes, the key-value pair corresponding to the original command line is determined.

[0009] In one embodiment, a command line in the original configuration file is read, and a command line stem in the original command line is extracted; the command line stem is set as a query condition, and a query is performed in the command line configuration table to determine a key-value pair corresponding to the command line stem; and based on the key-value pair, a command line function corresponding to the original command line is determined.

[0010] In one embodiment, it is determined whether the original command line is a valid command line; if not, other command lines in the original configuration file are continuously read until the valid command line is read.

[0011] In one embodiment, all key-value pairs corresponding to the command line function are determined, and it is determined whether a target command line corresponding to the target vendor exists in the all key-value pairs; if so, the target command line is printed into a target file; and if not, the original command line is annotated based on a first preset annotation rule, and the annotated original command line is printed into the target file.

[0012] In one embodiment, a next original command line in the original configuration file is continuously read, the next original command line is converted, and a target command corresponding to the next original command is printed into the target file until an unread command line in the original configuration file is 0; and the target file is output in a document form into a preset file directory.

[0013] In one embodiment, the target file is called, a target command line in the target file is executed, and it is determined whether the target command line is correct according to an execution effect; if not, the target command line is deleted, and the original command line corresponding to the target command line is continuously converted.

[0014] In one embodiment, a network management tool is connected with a switch of each vendor, a corresponding configuration file is queried through a command line interface, a storage location of the configuration file is acquired, a corresponding configuration path is generated based on the storage location, and the corresponding configuration file is acquired through the configuration path.

[0015] On the other hand, the application further provides a conversion device for a switch command line, comprising:

[0016] at least one processor; and

[0017] a memory in communication connection with the at least one processor; wherein

[0018] the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform a conversion method for a switch command line as described in the above examples.

[0019] In another aspect, the application further provides a non-volatile computer storage medium, which stores computer executable instructions configured to implement the method for converting a switch command line.

[0020] The method for converting a switch command line can bring the following advantages:

[0021] By constructing a command line configuration table, mapping relationships between command lines of different manufacturers can be established according to functions and implementation logic, and different manufacturer configurations can be converted in batches according to the mapping relationships, thereby greatly improving conversion efficiency and reducing error rate. BRIEF DESCRIPTION OF DRAWINGS

[0022] The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and serve to explain the principles of the application. In the drawings:

[0023] Figure 1 FIG. 1 is a flowchart of a method for converting a switch command line according to an embodiment of the application;

[0024] Figure 2 FIG. 2 is a schematic diagram of a device for converting a switch command line according to an embodiment of the application. DETAILED DESCRIPTION

[0025] To make the objectives, technical solutions and advantages of the application clearer, the technical solutions of the application will be described below in detail with reference to the embodiments of the application and the accompanying drawings. Obviously, the described embodiments are only some of the embodiments of the application, but not all the embodiments of the application. Based on the embodiments of the application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the application.

[0026] The technical solutions provided by the embodiments of the application will be described in detail below with reference to the accompanying drawings.

[0027] As shown in FIG. 1, the method for converting a switch command line provided by the embodiments of the application includes the following steps. Figure 1

[0028] S101: Obtain configuration files of switch machines of different manufacturers, and determine configuration command lines of the switch machines of different manufacturers and command line functions corresponding to the configuration command lines according to the configuration files.

[0029] ​It should be noted that, due to the different systems used by various manufacturers, the switches produced and used by them are also different, so the command lines of the switches produced by different manufacturers are also different. In the use of the switch, if the command line of the switch is not familiar, the switch cannot be used. Therefore, in the implementation of the present network cut-off, the situation of replacing the switch of manufacturer A with the switch of manufacturer B is often encountered, at this time, the business function needs to be kept unchanged, but the command line style of different manufacturers is different, so the configuration of the original manufacturer cannot be directly used, and needs to be converted.

[0030] Specifically, the configuration files of the switches of various manufacturers are obtained, the configuration files are analyzed, the configuration files include interface settings, routing protocols, VLAN configurations and command lines, the configuration command lines in the configuration files are determined, and the command line functions corresponding to each configuration command line are determined.

[0031] More specifically, the network management tool (such as CLI tool) is connected with the switches of various manufacturers, and the corresponding configuration files are queried through the command line interface, the storage location of the configuration files is obtained, the corresponding configuration path is generated based on the storage location, and the corresponding configuration file is obtained through the configuration path.

[0032] S102: Build the key-value pair of the command line function and the command line, and build the command line configuration table based on the key-value pair.

[0033] Specifically, the key-value pair is built with the command line function as the index and the corresponding configuration command line as the key value, the key-value pair set is obtained after the construction is completed, the constructed key-value pair set is obtained, the key-value pair set is traversed, all the command line functions and the corresponding configuration command lines are obtained, the command line function is set as the data column, and the corresponding configuration command line is set as the data value. According to the preset data structure, the command line configuration table is constructed and stored in the database for direct calling, wherein the preset data structure is a dictionary structure, and the command line configuration table includes the command lines of various manufacturers and the functions corresponding to the command lines.

[0034] The command line configuration table is constructed in a dictionary structure, and each dictionary element exists in the form of a key-value pair, the format is key:value, Key is the function of the command line, and value is a list, each list element is the command line of each manufacturer corresponding to the function.

[0035] It should be noted that the key-value pair of the command line function and the command line can arrange and store the configuration information of the switch in a unified format, which is convenient for management and maintenance. When the command lines of switches of different manufacturers are converted, the command line configuration table can be directly queried, which is convenient, fast and accurate.

[0036] S103: Obtain the input original manufacturer and target manufacturer, determine the original configuration file corresponding to the original manufacturer, iteratively read the original command line of the original configuration file, and determine the command line function corresponding to the original command line according to the command line configuration table.

[0037] Specifically, during configuration conversion, the system obtains the name of the original manufacturer and the name of the target manufacturer input by the user. Based on the name of the original manufacturer, the system determines the corresponding original configuration file in the configuration file library and calls the original configuration file using the path corresponding to that original configuration file.

[0038] Furthermore, in an iterative manner, an original command line from the original configuration file is read, and the corresponding command line function is determined based on the command line configuration table.

[0039] Specifically, read an original command line from the original configuration file and determine whether it is a valid command line. If not, continue reading other command lines from the original configuration file until a valid command line is found. If it is, extract the command line trunk from the original command line, set the command line trunk as the query condition, and query the command line configuration table to determine whether the original command line exists.

[0040] If not, it means that the original command line is not included in the command line configuration table. In this case, the conversion of the original configuration file is stopped, and an exception for missing command line is generated and output to remind the user to supplement the command. If yes, it means that the original command line is included in the command line configuration table. The key-value pair corresponding to the original command line is determined in the command line configuration table, and the command line function corresponding to the original command line is determined based on the key-value pair.

[0041] The main body of the command line is divided into parts other than parameters. For example, when configuring static routes, vendor A's configuration command line is "ip route 10.0.0.0 / 24 20.0.0.2", where the main body is "ip route" and "10.0.0.0 / 24 20.0.0.2" are vendor A's configuration parameters, including IP address, subnet mask length, etc.

[0042] S104: Based on the command line function, query the target command line corresponding to the target manufacturer in the command line configuration table, and output the target command line.

[0043] Specifically, based on the command-line function corresponding to the original command line, all key-value pairs corresponding to the command-line function are queried in the command-line configuration table. Among all key-value pairs, the target command line corresponding to the target manufacturer is queried, and the queried target command line is printed to the target file. If the target command line does not exist, the original command line is annotated according to the first preset annotation rule, and the annotated original command line is printed to the target file.

[0044] Further, the next original command line in the original configuration file is continuously read, the next original command line is converted, and the target command corresponding to the next original command is printed into the target file until the unread command in the original configuration file is 0. The target file is output in the form of a document to a preset file directory.

[0045] Further, the target file is called, the target command line in the target file is executed, and whether the target command line is correct is judged according to the execution effect. If not, the incorrect target command line is marked according to the second preset marking rule, and the marked incorrect target command line is returned to the target file to facilitate subsequent manual confirmation.

[0046] It should be noted that the first preset marking rule and the second preset marking rule are both to add a prominent style to the command line, such as bold, italic, highlight, etc. The styles added by them are different, which can make the command line more eye-catching in the target file, easy to identify, and can facilitate the user to quickly locate the part that needs to be operated in the target file.

[0047] It should be noted that for the case that the command line function implementation logic of different manufacturers is different, for example, the function of A manufacturer needs only 1 command to implement, and the function of B manufacturer needs to configure multiple commands to implement, then during the conversion, it is also converted according to one-to-many or many-to-one.

[0048] By constructing the command line configuration table, a mapping relationship between the command lines of different manufacturers can be established according to the function and implementation logic, and different manufacturer configurations can be converted in batches according to the mapping relationship, which greatly improves the conversion efficiency and reduces the error rate.

[0049] As shown in Figure 2 The embodiment of the application further provides a switch command line conversion device, which comprises:

[0050] at least one processor; and

[0051] a memory in communication connection with the at least one processor; wherein

[0052] The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the switch command line conversion method of any of the above embodiments.

[0053] The embodiment of the application further provides a non-volatile computer storage medium storing computer executable instructions, which are configured to execute the switch command line conversion method of any of the above embodiments.

[0054] The various embodiments in the present application are described in a progressive manner, and the same or similar parts among the various embodiments can be referred to each other. Each embodiment focuses on the difference from other embodiments. In particular, the device and medium embodiments are described simply because they are substantially similar to the method embodiments.

[0055] The device and medium provided by the embodiments of the present application are one-to-one corresponding to the method, and therefore, the device and medium also have similar beneficial technical effects to the method. Since the beneficial technical effects of the method have been described in detail above, the beneficial technical effects of the device and medium will not be described here again.

[0056] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage, etc.) containing computer-usable program code.

[0057] The present application is described with reference to flowcharts and / or block diagrams of the method, device (system), and computer program product according to the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of the flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing apparatus to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing apparatus generate a means for implementing the functions specified in the flowcharts and / or block diagrams. Figure 1 one or more flows and / or blocks Figure 1 means for carrying out the functions specified in one or more flows and / or blocks.

[0058] These computer program instructions can also be stored in a computer-readable memory that can direct the computer or other programmable data processing apparatus to work in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including instruction means, which implements the functions specified in the flowcharts and / or block diagrams. Figure 1 one or more flows and / or blocks Figure 1 means for carrying out the functions specified in one or more flows and / or blocks.

[0059] These computer program instructions can also be loaded into a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks. Figure 1 Figure 1

[0060] In one typical configuration, the computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.

[0061] The memory can include non-persistent memory and / or volatile memory, such as random access memory (RAM) about which the processor can execute instructions. The memory can also include non-volatile memory, such as read only memory (ROM), electrically programmable read only memory (EPROM), electrically erasable programmable read only memory (EEPROM), programmable read only memory (PROM), erasable programmable read only memory (EPROM), flash memory, or a combination of non-volatile memories in different types. The memory is an example of computer readable storage media.

[0062] Computer readable media includes permanent and non-permanent, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory (ROM), electrically programmable read only memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital versatile disc (DVD), or other optical storage, magnetic cassette, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible to computing devices. According to the definition herein, computer readable media does not include transitory media, such as modulated data signals and carrier waves.

[0063] It should also be noted that the terms "comprising", "containing", or any other variant thereof are intended to encompass a non-exclusive inclusion, such that a process, method, article or apparatus that comprises a list of elements does not include only those elements recited, but can also include other elements not expressly listed or inherent to such process, method, article or apparatus. Without further limitation, an element defined by the statement "comprising a" does not exclude the presence of additional identical elements in the process, method, article or apparatus that includes the element.

[0064] ​​The above merely provides an example of the present application, but is not intended to limit the present application. Any modification, equivalent replacement, improvement, etc. within the spirit and principle of the present application should be included in the scope of claims of the present application.

Claims

1. A method for converting a switch command line, characterized by, The method comprises the following steps: obtaining configuration files of switches of various manufacturers, determining configuration command lines of the switches of various manufacturers according to the configuration files, and command line functions corresponding to the configuration command lines; building key-value pairs of the command line functions and the configuration command lines, and building a command line configuration table based on the key-value pairs; obtaining an original manufacturer and a target manufacturer, determining an original configuration file corresponding to the original manufacturer, iteratively reading original command lines of the original configuration file, and determining command line functions corresponding to the original command lines according to the command line configuration table; the iteratively reading the original command lines of the original configuration file and the determining the command line functions corresponding to the original command lines according to the command line configuration table specifically comprise: reading an original command line in the original configuration file, and extracting a command line stem in the original command line; setting the command line stem as a query condition, and querying in the command line configuration table to determine a key-value pair corresponding to the command line stem; determining the command line functions corresponding to the original command line based on the key-value pair; based on the command line functions, querying a target command line corresponding to the target manufacturer in the command line configuration table, and outputting the target command line; the querying the target command line corresponding to the target manufacturer and the outputting the target command line specifically comprise: determining all key-value pairs corresponding to the command line functions, and judging whether a target command line corresponding to the target manufacturer exists in the all key-value pairs; if yes, printing the target command line into a target file; if no, labeling the original command line based on a first preset labeling rule, and printing the labeled original command line into the target file; the method further comprises: continuing to read a next original command line in the original configuration file, converting the next original command line, and printing a target command corresponding to the next original command into the target file until an unread command line in the original configuration file is 0; outputting the target file in the form of a document into a preset file directory; the method further comprises: calling the target file, executing a target command line in the target file, and judging whether the target command line is correct according to an execution effect; if no, labeling the target command line according to a second preset labeling rule, and returning the labeled target command line to the target file.

2. The method of claim 1, wherein, before the determining the command line functions corresponding to the original command line according to the command line configuration table, the method further comprises: judging whether the original command line exists in the command line configuration table; if no, stopping execution and returning an exception prompt to remind of supplementing a command; if yes, determining a key-value pair corresponding to the original command line.

3. The method of claim 1, wherein the obtaining the configuration files of the switches of various manufacturers specifically comprises: connecting various manufacturers' switches through a network management tool, and querying corresponding configuration files through a command line interface to obtain storage positions of the configuration files; generating corresponding configuration paths based on the storage positions, and obtaining the corresponding configuration files through the configuration paths.

4. The method of claim 1, wherein the building the command line configuration table based on the key-value pairs specifically comprises: Obtaining the constructed key-value pair set, traversing the key-value pair set, obtaining all command line functions and corresponding configuration command lines in the key-value pair set; Taking the command line functions as data columns and the configuration command lines as data values, constructing a command line configuration table according to a preset data structure.

5. A translation device for switch command lines, characterized in that Comprise: At least one processor; And, The memory is in communication connection with the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute a switch command line conversion method as claimed in any one of claims 1-4.

6. A non-transitory computer storage medium storing computer-executable instructions that, when executed, cause a computer to perform: The computer executable instructions are configured to implement the switch command line conversion method as claimed in any one of claims 1-4.

Citation Information

Patent Citations

  • Unit test result exporting method and device and electronic equipment

    CN111104318A

  • Instruction conversion method and device, equipment and computer storage medium

    CN116684427A