A method and apparatus for mutual conversion between CLI scripts and NETCONF configuration templates.
By defining the mapping relationship between CLI commands and NETCONF templates and designing a parsing and conversion rule engine, the automatic conversion between CLI scripts and NETCONF configuration templates is achieved, solving the efficiency problem for network configurers in different usage scenarios and improving the accuracy and efficiency of configuration.
Patent Information
- Application Number
- CN202411623707.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-14
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2044-11-14
AI Technical Summary
In existing technologies, CLI scripts and NETCONF configuration templates cannot be automatically converted, forcing network configurers to manually verify the two configuration methods, which is time-consuming, labor-intensive, error-prone, and inefficient.
Define the mapping relationship between CLI commands and NETCONF templates, design the parsing engine and conversion rule engine, and realize the mutual conversion between CLI scripts and NETCONF configuration templates. Through the mapping table, parse the syntax structure of CLI commands and convert them into NETCONF format, and vice versa.
It improves the work efficiency of network configuration personnel, realizes the automatic conversion between CLI scripts and NETCONF configuration templates, reduces the need for manual verification, and improves the accuracy and efficiency of configuration.
Smart Images

Figure CN119743367B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of network configuration, and in particular to a method and apparatus for converting between CLI scripts and NETCONF configuration templates. Background Technology
[0002] CLI: Command-line interface (CLI) refers to the process of issuing configuration commands via command-line scripts when configuring devices.
[0003] To configure L3VPN service on a Huawei router, you need to execute the following CLI script:
[0004]
[0005]
[0006] NETCONF: The Network Configuration Protocol (NETCONF) provides a set of protocols for communication between network administrators and network devices. Network administrators use NETCONF to distribute, modify, and delete configurations on remote devices. Network devices provide standardized Application Programming Interfaces (APIs), which network administrators can use to manage network devices via NETCONF.
[0007] To configure L3VPN service on a Huawei router, you need to execute the following NETCONF configuration template:
[0008]
[0009]
[0010]
[0011]
[0012] Configuring network devices via the CLI command line is a traditional method. Its advantage is that everything is visible and directly configured; the command lines typed are the instructions to be configured on the device. After execution, whether the configuration was successful or correct is immediately apparent. The disadvantage is that you must log in to the network device before configuration can be performed. Furthermore, the network administrator needs a strong understanding of the business requirements and specific configuration commands and parameters to complete the configuration, resulting in relatively low overall efficiency.
[0013] Configuring network devices using NETCONF configuration templates is a relatively new method that has emerged in recent years. NETCONF is a network configuration and management protocol based on Extensible Markup Language (XML). By filling in the configuration parameters according to the protocol requirements, the configuration process is complete. The advantages are that configuration can be completed without needing to understand the specific configuration commands for the business logic, and device login is not required when distributing configurations, significantly improving efficiency. The disadvantages are that it's unclear whether the configuration is correct or if any configuration errors have occurred.
[0014] CLI scripts and NETCONF configuration templates are two completely different configuration systems. They are unrelated and therefore cannot be automatically converted.
[0015] The two configuration methods are not enabled simultaneously in certain situations. Enabling the NETCONF configuration channel will disable the CLI script configuration channel, which creates a need for converting CLI scripts to NETCONF configuration templates.
[0016] After configuring the device using the NETCONF configuration template, it is necessary to manually or automatically verify whether the configuration is correct, check whether the relevant keywords are configured, and provide a clear and concise configuration result. This has led to the need to convert the NETCONF configuration template into a CLI script.
[0017] Currently, the configuration results of the two methods can only be verified manually. This requires network configuration personnel to have a deep understanding of both methods, which is time-consuming, labor-intensive, inefficient, and prone to errors, putting a lot of pressure on network configuration personnel. Summary of the Invention
[0018] To address the problems existing in the prior art, this invention provides a method and apparatus for mutual conversion between CLI scripts and NETCONF configuration templates. By defining the mapping relationship between CLI commands and NETCONF templates, designing a parsing engine, and a conversion rule engine, the mutual conversion between CLI scripts and NETCONF configuration templates is completed. This solves the problem of network configuration personnel using CLI scripts and NETCONF configuration templates according to different usage scenarios, thereby improving work efficiency.
[0019] To achieve the above objectives, the present invention adopts the following technical solution:
[0020] In one embodiment of the present invention, a method for mutual conversion between CLI scripts and NETCONF configuration templates is proposed, the method comprising:
[0021] S01. Define the mapping relationship between CLI commands and NETCONF templates;
[0022] Further, S01 includes:
[0023] S011, CLI command structure recognition: Analyze the syntax of CLI commands based on known CLI command-line scripts to identify the commands;
[0024] Furthermore, the components of the command in S011 include: command keyword, parameters, options, and values.
[0025] S012, NETCONF template structure analysis: Based on the existing XML structure of the NETCONF template, analyze the elements, attributes, and hierarchical structure represented by the network device configuration;
[0026] S013, Command Dependency Identification: Identify the dependencies between CLI commands, maintain these dependencies during the conversion process, and ensure correct configuration.
[0027] S014. Configuration item data extraction: The first three steps of analysis abstract the command line script into configuration item data.
[0028] To configure L3VPN service, the following configuration items are required: ACL rule creation, QoS policy creation, VPN instance creation, etc.
[0029] S015. Process data types and formats. Through the nested format of the NETCONF template, determine the correspondence between CLI commands and data types in the NETCONF template, and define format conversion rules.
[0030] For example, some configurations are represented as a character type (enable) in CLI command-line scripts and as a boolean type (true) in NETCONF templates.
[0031] S016. Reverse mapping design: Simultaneously design the reverse mapping rules from NETCONF templates to CLI commands, and generate CLI scripts from XML configuration;
[0032] S017. Create a mapping table to map the various components of the CLI command to the corresponding XML elements and attributes of the NETCONF template;
[0033] Furthermore, the fields in the mapping table in S017 include: manufacturer, model, level, node, configuration item, CLI command, CLI data type, NETCONF template, and NETCONF data type.
[0034] S018. Define conversion rules. Conversion rules convert each part of the CLI command into the NETCONF template format.
[0035] S02. Design a parsing engine to parse the syntax structure of CLI commands and convert it into the corresponding NETCONF format;
[0036] Further, S02 includes:
[0037] S021. Enter CLI command: Enter the CLI command to be converted, define the syntax rules of the CLI command, and use regular expressions or a syntax analyzer to identify the various parts of the CLI command.
[0038] Furthermore, the syntax rules in S021 include the structure and hierarchy of keywords, parameters, and commands.
[0039] S022. Syntax analysis: Decompose the input CLI command string into tokens, including: command keywords, parameters, and values;
[0040] S023. Semantic analysis: Based on the grammar rules, the tokens generated by the grammar analysis are transformed into an abstract syntax tree; and semantic analysis is implemented to ensure the semantic validity of the grammatical structure of CLI commands, such as checking the validity of command parameters.
[0041] For example, IPv4 address checking involves checking that an IPv4 address consists of four groups of decimal numbers, each ranging from 0 to 255, separated by dots. The validity of an IPv4 address can be verified using regular expressions or string splitting. For instance, a regular expression for an IPv4 address could be: ^(\d{1,3}\.){3}\d{1,3}$.
[0042] S024, Mapping logic: Based on predefined mapping rules, the nodes in the abstract syntax tree are converted into the corresponding structures of the NETCONF template;
[0043] S025, NETCONF construction, generates configuration data in NETCONF format according to the mapping logic;
[0044] S026. Output NETCONF template, encapsulate the generated NETCONF format configuration data, and supplement namespaces according to manufacturer and model;
[0045] S027. Verification mechanism: Verify that the generated NETCONF template conforms to the syntax requirements and can correctly reflect the intent of the CLI command.
[0046] S03, Design conversion rule engine, used to convert NETCONF templates back to CLI scripts;
[0047] Further, S03 includes:
[0048] S031. Analyze the NETCONF template, analyze the XML structure of the NETCONF template, and parse the configuration of the network device corresponding to the elements and attributes;
[0049] S032. Design the conversion logic to convert XML elements and attributes into components of CLI commands based on the mapping table in S017;
[0050] S033. Handle data type conversion, converting the data type in the NETCONF template to the data type in the CLI command;
[0051] S034. Construct CLI commands: Based on the conversion logic, construct a complete CLI command script;
[0052] S035. Optimize command order; optimize the execution order of CLI commands.
[0053] For example, configuration operations can only be performed after entering configuration mode. This means that some commands depend on the execution of other commands. The mapping table is used to optimize and adjust hierarchy and node parameters.
[0054] S036. Verification and testing: Verify that the generated CLI commands meet the syntax requirements and test whether the device can be configured correctly.
[0055] S04. Implement a user interface that allows users to input CLI commands or NETCONF templates.
[0056] In one embodiment of the present invention, a device for converting between CLI scripts and NETCONF configuration templates is also provided, the device comprising:
[0057] The mapping definition module defines the mapping relationship between CLI commands and NETCONF templates;
[0058] Design a parsing engine module to parse the syntax structure of CLI commands and convert them into the corresponding NETCONF format;
[0059] Design a conversion rule engine module to convert NETCONF templates back to CLI scripts;
[0060] The user interface module allows users to input CLI commands or NETCONF templates.
[0061] In one embodiment of the present invention, a computer device is also proposed, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the aforementioned method for converting between CLI scripts and NETCONF configuration templates.
[0062] In one embodiment of the present invention, a computer-readable storage medium is also provided, which stores a computer program for executing a method of converting between CLI scripts and NETCONF configuration templates.
[0063] This invention provides a method and apparatus for mutual conversion between CLI scripts and NETCONF configuration templates. By defining the mapping relationship between CLI commands and NETCONF templates, designing a parsing engine, and implementing a conversion rule engine, it achieves the mutual conversion between CLI scripts and NETCONF configuration templates. This solves the problem of network configuration engineers using CLI scripts and NETCONF configuration templates according to different usage scenarios, improving work efficiency and offering the following beneficial effects:
[0064] (1) Abstract the command-line script into configuration item data;
[0065] (2) Implement the mapping between CLI commands and NETCONF templates as two configuration methods;
[0066] (3) Design a parsing engine that can understand the syntax structure of CLI commands;
[0067] (4) Design a conversion rule engine that can understand CLI commands and NETCONF templates. Attached Figure Description
[0068] Figure 1 This is a schematic diagram of the method for converting between CLI scripts and NETCONF configuration templates according to the present invention;
[0069] Figure 2 yes Figure 1 A schematic diagram of the user interface of S04;
[0070] Figure 3 This is a schematic diagram of the device structure for converting between CLI scripts and NETCONF configuration templates according to the present invention;
[0071] Figure 4 This is a schematic diagram of a computer device structure according to an embodiment of the present invention. Detailed Implementation
[0072] The principles and spirit of the present invention will now be described with reference to several exemplary embodiments. It should be understood that these embodiments are provided merely to enable those skilled in the art to better understand and implement the present invention, and are not intended to limit the scope of the present invention in any way. Rather, these embodiments are provided to make this disclosure more thorough and complete, and to fully convey the scope of this disclosure to those skilled in the art.
[0073] Those skilled in the art will recognize that embodiments of the present invention can be implemented as a system, apparatus, device, method, or computer program product. Therefore, this disclosure can be specifically implemented in the following forms: entirely hardware, entirely software (including firmware, resident software, microcode, etc.), or a combination of hardware and software.
[0074] According to an embodiment of the present invention, a method and apparatus for mutual conversion between CLI scripts and NETCONF configuration templates are proposed. By defining the mapping relationship between CLI commands and NETCONF templates, designing a parsing engine and a conversion rule engine, the mutual conversion between CLI scripts and NETCONF configuration templates is completed, solving the problem of network configuration personnel using CLI scripts and NETCONF configuration templates according to different usage scenarios, and improving work efficiency.
[0075] The principles and spirit of the present invention will be explained in detail below with reference to several representative embodiments.
[0076] like Figure 1 As shown, the present invention relates to a method for mutual conversion between CLI scripts and NETCONF configuration templates, the method comprising:
[0077] S01. Define the mapping relationship between CLI commands and NETCONF templates;
[0078] S01 includes:
[0079] S011, CLI command structure recognition: Analyze the syntax of CLI commands based on known CLI command-line scripts to identify the commands;
[0080] The components of the command in S011 include: command keyword, parameters, options, and values.
[0081] S012, NETCONF template structure analysis: Based on the existing XML structure of the NETCONF template, analyze the elements, attributes, and hierarchical structure represented by the network device configuration;
[0082] S013, Command Dependency Identification: Identify the dependencies between CLI commands, maintain these dependencies during the conversion process, and ensure correct configuration.
[0083] S014. Configuration item data extraction: The first three steps of analysis abstract the command line script into configuration item data.
[0084] To configure L3VPN service, the following configuration items are required: ACL rule creation, QoS policy creation, VPN instance creation, etc.
[0085] S015. Process data types and formats. Through the nested format of the NETCONF template, determine the correspondence between CLI commands and data types in the NETCONF template, and define format conversion rules.
[0086] For example, some configurations are represented as a character type (enable) in CLI command-line scripts and as a boolean type (true) in NETCONF templates.
[0087] S016. Reverse mapping design: Simultaneously design the reverse mapping rules from NETCONF templates to CLI commands, and generate CLI scripts from XML configuration;
[0088] S017. Create a mapping table to map the various components of the CLI command to the corresponding XML elements and attributes of the NETCONF template;
[0089] The fields in the mapping table in S017 include: manufacturer, model, level, node, configuration item, CLI command, CLI data type, NETCONF template, and NETCONF data type.
[0090] S018. Define conversion rules. Conversion rules convert each part of the CLI command into the NETCONF template format.
[0091] S02. Design a parsing engine to parse the syntax structure of CLI commands and convert it into the corresponding NETCONF format;
[0092] The S02 includes:
[0093] S021. Enter CLI command: Enter the CLI command to be converted, define the syntax rules of the CLI command, and use regular expressions or a syntax analyzer to identify the various parts of the CLI command.
[0094] The syntax rules in S021 include the structure and hierarchy of keywords, parameters, and commands.
[0095] S022. Syntax analysis: Decompose the input CLI command string into tokens, including: command keywords, parameters, and values;
[0096] S023. Semantic analysis: Based on the grammar rules, the tokens generated by the grammar analysis are transformed into an abstract syntax tree; and semantic analysis is implemented to ensure the semantic validity of the grammatical structure of CLI commands, such as checking the validity of command parameters.
[0097] For example, IPv4 address checking involves checking that an IPv4 address consists of four groups of decimal numbers, each ranging from 0 to 255, separated by dots. The validity of an IPv4 address can be verified using regular expressions or string splitting. For instance, a regular expression for an IPv4 address could be: ^(\d{1,3}\.){3}\d{1,3}$.
[0098] S024, Mapping logic: Based on predefined mapping rules, the nodes in the abstract syntax tree are converted into the corresponding structures of the NETCONF template;
[0099] S025, NETCONF construction, generates configuration data in NETCONF format according to the mapping logic;
[0100] S026. Output NETCONF template, encapsulate the generated NETCONF format configuration data, and supplement namespaces according to manufacturer and model;
[0101] S027. Verification mechanism: Verify that the generated NETCONF template conforms to the syntax requirements and can correctly reflect the intent of the CLI command.
[0102] S03, Design conversion rule engine, used to convert NETCONF templates back to CLI scripts;
[0103] S03 includes:
[0104] S031. Analyze the NETCONF template, analyze the XML structure of the NETCONF template, and parse the configuration of the network device corresponding to the elements and attributes;
[0105] S032. Design the conversion logic to convert XML elements and attributes into components of CLI commands based on the mapping table in S017;
[0106] S033. Handle data type conversion, converting the data type in the NETCONF template to the data type in the CLI command;
[0107] S034. Construct CLI commands: Based on the conversion logic, construct a complete CLI command script;
[0108] S035. Optimize command order; optimize the execution order of CLI commands.
[0109] For example, configuration operations can only be performed after entering configuration mode. This means that some commands depend on the execution of other commands. The mapping table is used to optimize and adjust hierarchy and node parameters.
[0110] S036. Verification and testing: Verify that the generated CLI commands meet the syntax requirements and test whether the device can be configured correctly.
[0111] like Figure 2 As shown, S04, implement the user interface to allow users to input CLI commands or NETCONF templates.
[0112] It should be noted that although the operation of the method of the present invention has been described in a specific order in the above embodiments and figures, this does not require or imply that the operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.
[0113] To provide a clearer explanation of the method for converting between CLI scripts and NETCONF configuration templates, specific embodiments are described below. However, it is worth noting that these embodiments are only for better illustrating the present invention and do not constitute an improper limitation of the present invention.
[0114] S01. Define the mapping relationship between CLI commands and NETCONF templates;
[0115] S01 includes:
[0116] S011, CLI command structure recognition: Analyze the syntax of CLI commands based on known CLI command-line scripts to identify the commands;
[0117] The components of the command in S011 include: command keyword, parameters, options, and values.
[0118] S012, NETCONF template structure analysis: Based on the existing XML structure of the NETCONF template, analyze the elements, attributes, and hierarchical structure represented by the network device configuration;
[0119] S013, Command Dependency Identification: Identify the dependencies between CLI commands, maintain these dependencies during the conversion process, and ensure correct configuration.
[0120] S014. Configuration item data extraction: The first three steps of analysis abstract the command line script into configuration item data.
[0121] To configure L3VPN service, the following configuration items are required: ACL rule creation, QoS policy creation, VPN instance creation, etc.
[0122] S015. Process data types and formats. Through the nested format of the NETCONF template, determine the correspondence between CLI commands and data types in the NETCONF template, and define format conversion rules.
[0123] For example, some configurations are represented as a character type (enable) in CLI command-line scripts and as a boolean type (true) in NETCONF templates.
[0124] S016. Reverse mapping design: Simultaneously design the reverse mapping rules from NETCONF templates to CLI commands, and generate CLI scripts from XML configuration;
[0125] S017. Create a mapping table to map the various components of the CLI command to the corresponding XML elements and attributes of the NETCONF template;
[0126] The fields in the mapping table in S017 include: manufacturer, model, level, node, configuration item, CLI command, CLI data type, NETCONF template, and NETCONF data type.
[0127] S018. Define conversion rules. Conversion rules convert each part of the CLI command into the NETCONF template format.
[0128] Examples are shown in Table 1 below:
[0129]
[0130] Table 1
[0131] S02. Design a parsing engine to parse the syntax structure of CLI commands and convert it into the corresponding NETCONF format;
[0132] The S02 includes:
[0133] S021. Enter CLI command: Enter the CLI command to be converted, define the syntax rules of the CLI command, and use regular expressions or a syntax analyzer to identify the various parts of the CLI command.
[0134] The syntax rules in S021 include the structure and hierarchy of keywords, parameters, and commands.
[0135] S022. Syntax analysis: Decompose the input CLI command string into tokens, including: command keywords, parameters, and values;
[0136] interface GigabitEthernet0 / 0 / 0
[0137] IP address 10.1.1.1255.255.255.0
[0138] Command keyword: interface, corresponding value: GigabitEthernet0 / 0 / 0
[0139] Command keyword: IP address, corresponding value: 10.1.1.1255.255.255.0
[0140] According to the definition of NETCONF, IP address can be further subdivided:
[0141] IP address 10.1.1.1255.255.255.0
[0142] Command keyword: IP, corresponding value: 10.1.1.1
[0143] Command keyword: Mask, corresponding value: 255.255.255.0
[0144] S023. Semantic analysis: Based on the grammar rules, the tokens generated by the grammar analysis are transformed into an abstract syntax tree; and semantic analysis is implemented to ensure the semantic validity of the grammatical structure of CLI commands, such as checking the validity of command parameters.
[0145] For example, IPv4 address checking involves checking that an IPv4 address consists of four groups of decimal numbers, each ranging from 0 to 255, separated by dots. The validity of an IPv4 address can be verified using regular expressions or string splitting. For instance, a regular expression for an IPv4 address could be: ^(\d{1,3}\.){3}\d{1,3}$.
[0146] S024, Mapping logic: Based on predefined mapping rules, the nodes in the abstract syntax tree are converted into the corresponding structures of the NETCONF template;
[0147] S025, NETCONF construction, generates configuration data in NETCONF format according to the mapping logic;
[0148] S026. Output NETCONF template, encapsulate the generated NETCONF format configuration data, and supplement namespaces according to manufacturer and model;
[0149] <xmlns="http: / / www.huawei.com / NETCONF / vrp"
[0150] content-version="1.0" format-version="1.0">
[0151] S027. Verification mechanism: Verify that the generated NETCONF template conforms to the syntax requirements and can correctly reflect the intent of the CLI command.
[0152] S03, Design conversion rule engine, used to convert NETCONF templates back to CLI scripts;
[0153] S03 includes:
[0154] S031. Analyze the NETCONF template, analyze the XML structure of the NETCONF template, and parse the configuration of the network device corresponding to the elements and attributes;
[0155] like:
[0156]
[0157]
[0158] S032. Design the conversion logic to convert XML elements and attributes into components of CLI commands based on the mapping table in S017;
[0159] S033. Handle data type conversion, converting the data type in the NETCONF template to the data type in the CLI command;
[0160] S034. Construct CLI commands: Based on the conversion logic, construct a complete CLI command script;
[0161] S035. Optimize command order; optimize the execution order of CLI commands.
[0162] For example, configuration operations can only be performed after entering configuration mode. This means that some commands depend on the execution of other commands. The mapping table is used to optimize and adjust hierarchy and node parameters.
[0163] S036. Verification and testing: Verify that the generated CLI commands meet the syntax requirements and test whether the device can be configured correctly.
[0164] S04. Implement a user interface that allows users to input CLI commands or NETCONF templates.
[0165] Click the "Convert" button to perform the conversion and display the result. Click the "Check" button below to complete the syntax check of the corresponding CLI script and NETCONF template. Normal: Check passed; Abnormal: Indicates the line containing the error.
[0166] Based on the same inventive concept, this invention also proposes an apparatus for converting between CLI scripts and NETCONF configuration templates. The implementation of this apparatus can refer to the implementation of the methods described above, and repeated details will not be repeated. The term "module" as used below can refer to a combination of software and / or hardware that implements a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0167] Figure 3 This is a schematic diagram of the device structure for converting between CLI scripts and NETCONF configuration templates according to the present invention. Figure 3 As shown, the device includes:
[0168] The mapping relationship definition module 110 defines the mapping relationship between CLI commands and NETCONF templates;
[0169] Design a parsing engine module 120 to parse the syntax structure of CLI commands and convert them into the corresponding NETCONF format;
[0170] Design a conversion rule engine module 130 to convert NETCONF templates back to CLI scripts;
[0171] User interface implementation module 140 allows users to input CLI commands or NETCONF templates.
[0172] It should be noted that although several modules of the apparatus for converting between CLI scripts and NETCONF configuration templates have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of the present invention, the features and functions of two or more modules described above can be embodied in a single module. Conversely, the features and functions of a single module described above can be further divided and embodied by multiple modules.
[0173] Based on the aforementioned inventive concept, such as Figure 4 As shown, the present invention also proposes a computer device 200, including a memory 210, a processor 220, and a computer program 230 stored in the memory 210 and executable on the processor 220. When the processor 220 executes the computer program 230, it implements the aforementioned method for converting between CLI scripts and NETCONF configuration templates.
[0174] Based on the aforementioned inventive concept, the present invention also proposes a computer-readable storage medium storing a computer program that executes the aforementioned method for converting between CLI scripts and NETCONF configuration templates.
[0175] This invention provides a method and apparatus for mutual conversion between CLI scripts and NETCONF configuration templates. By defining the mapping relationship between CLI commands and NETCONF templates, designing a parsing engine, and implementing a conversion rule engine, it achieves the mutual conversion between CLI scripts and NETCONF configuration templates. This solves the problem of network configuration engineers using CLI scripts and NETCONF configuration templates according to different usage scenarios, improving work efficiency and offering the following beneficial effects:
[0176] (1) Abstract the command-line script into configuration item data;
[0177] (2) Implement the mapping between CLI commands and NETCONF templates as two configuration methods;
[0178] (3) Design a parsing engine that can understand the syntax structure of CLI commands;
[0179] (4) Design a conversion rule engine that can understand CLI commands and NETCONF templates.
[0180] While the spirit and principles of the invention have been described with reference to several specific embodiments, it should be understood that the invention is not limited to the disclosed specific embodiments, and the division of aspects does not imply that features in these aspects cannot be combined for benefit; such division is merely for ease of description. The invention is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.
[0181] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0182] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0183] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0184] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0185] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0186] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.
[0187] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0188] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
[0189] Regarding the limitation of the scope of protection of this invention, those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solution of this invention are still within the scope of protection of this invention.
Claims
1. A method for converting CLI scripts and NETCONF configuration templates, characterized in that, The method comprises: S01, defining the mapping relationship between CLI commands and NETCONF templates, comprising: S011, CLI command structure recognition, analyzing the syntax of CLI commands according to known CLI command line scripts, and identifying the commands; S012, NETCONF template structure analysis, analyzing the elements and attributes represented by the network device configuration and the hierarchical structure according to the existing XML structure of the NETCONF template; S013, command dependency recognition, recognizing the dependency relationship between CLI commands, maintaining the dependency relationship in the conversion process, and achieving the requirement of correct configuration; S014, configuration item data extraction, the first three steps of analysis, abstracting the command line script into configuration item data; S015, processing data types and formats, determining the correspondence between data types in the CLI command and the NETCONF template through the nested format of the NETCONF template, and defining the format conversion rule; S016, reverse mapping design, synchronously designing the reverse mapping rule from the NETCONF template to the CLI command, and generating the CLI script from the XML configuration; S017, creating a mapping table, mapping each component of the CLI command to the corresponding XML element and attribute of the NETCONF template; S018, defining the conversion rule, which converts each part of the CLI command into the format of the NETCONF template; S02, designing a parsing engine to parse the syntax structure of the CLI command and convert it into the corresponding NETCONF format; S03, designing a conversion rule engine for converting the NETCONF template back to the CLI script; S04, implementing a user interface to allow users to input CLI commands or NETCONF templates.
2. The method for converting CLI script and NETCONF configuration template according to claim 1, characterized in that, The components of the command in S011 include: command keyword, parameter, option, value.
3. The method for converting CLI script and NETCONF configuration template according to claim 1, characterized in that, The fields in the mapping table in S017 include: manufacturer, model, level, node, belonging configuration item, CLI command, CLI data type, NETCONF template, NETCONF data type.
4. The method for converting CLI script and NETCONF configuration template according to claim 1, characterized in that, S02 comprises: S021, inputting the CLI command, inputting the CLI command to be converted, defining the syntax rule of the CLI command, and using regular expressions or syntax analyzers to identify each part of the CLI command; S022, syntax analysis, decomposing the input CLI command string into tokens, including: command keyword, parameter, value; S023, semantic analysis, converting the tokens generated by syntax analysis into an abstract syntax tree according to the syntax rule; and implementing semantic analysis to ensure the legality of the syntax structure of the CLI command in semantics; S024, mapping logic, converting the nodes in the abstract syntax tree into the corresponding structure of the NETCONF template according to the predefined mapping rule; S025, NETCONF construction, generating configuration data in the format of NETCONF according to the mapping logic; S026, outputting the NETCONF template, encapsulating the generated configuration data in the format of NETCONF, and supplementing the namespace according to the manufacturer and model; S027, a verification mechanism, verifying that the generated NETCONF template is syntactically correct and can correctly reflect the intention of the CLI command.
5. The method for converting CLI script and NETCONF configuration template according to claim 4, characterized in that, The syntax rules in S021 include keywords, parameters, the structure and hierarchy of commands.
6. The method for converting CLI script and NETCONF configuration template according to claim 1, characterized in that, S03 includes: S031, analyzing the NETCONF template, analyzing the XML structure of the NETCONF template, parsing the elements and attributes corresponding to the configuration of the network device; S032, designing conversion logic, converting XML elements and attributes to components of CLI commands according to the mapping table in S017; S033, processing data type conversion, converting data types in the NETCONF template and data types in the CLI command; S034, building CLI commands, building complete CLI command scripts according to the conversion logic; S035, optimizing command order, optimizing the execution order of the CLI command; S036, verification and testing, verifying whether the generated CLI command meets the syntax requirements and testing whether it can correctly configure the device.
7. A device for converting CLI scripts and NETCONF configuration templates, characterized in that, The device includes: A mapping relationship definition module defines the mapping relationship between the CLI command and the NETCONF template, including: CLI command structure recognition, analyzing the syntax of the CLI command according to the known CLI command line script, and identifying the command; NETCONF template structure analysis, analyzing the elements and attributes represented by the network device configuration and the hierarchical structure according to the existing XML structure of the NETCONF template; Command dependency recognition, identifying the dependency relationship between CLI commands, maintaining the dependency relationship during the conversion process, and meeting the correct configuration requirements; Configuration item data extraction, the first three steps of analysis, abstracting the command line script into configuration item data; Processing data types and formats, determining the correspondence between data types in the CLI command and the NETCONF template through the nested format of the NETCONF template, and defining format conversion rules; Reverse mapping design, synchronously designing reverse mapping rules from the NETCONF template to the CLI command to generate CLI scripts from XML configurations; Creating a mapping table, mapping each component of the CLI command to the corresponding XML element and attribute of the NETCONF template; Defining conversion rules, converting each part of the CLI command to the format of the NETCONF template; Designing a parsing engine module to parse the syntax structure of the CLI command and convert it to the corresponding NETCONF format; Designing a conversion rule engine module for converting the NETCONF template back to the CLI script; A user interface implementation module allows users to input CLI commands or NETCONF templates.
8. A computer device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the computer program to implement the method of any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program for executing the method of any one of claims 1-6.
Citation Information
Patent Citations
Information conversion method of data modeling file, electronic equipment and storage medium
CN117312422A
Data modeling method and device for command line interface of network device and storage medium
CN117633071A