Network configuration file processing method and device, program product and electronic equipment
By analyzing network configuration files and matching CLI commands, efficient conversion from YANG model to CLI commands is realized, solving the problems of difficult conversion and frequent manual operations in the existing technology, improving operation and maintenance efficiency and compatibility with different devices.
Patent Information
- Application Number
- CN202411464991.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-18
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2044-10-18
AI Technical Summary
The lack of efficient YANG model to CLI command conversion scheme in the prior art makes it difficult to apply the YANG model in some device scenarios, and the need for manual operations increases the possibility of human error.
By obtaining network configuration files, parsing tags, and based on the mapping rules of CLI commands and paths, obtaining the corresponding CLI commands of leaf tags, and determining the target CLI commands by matching CLI commands and tags.
It realizes efficient conversion of YANG model to CLI commands, reduces manual operations, reduces human errors, improves work efficiency, and is compatible with equipment from different device manufacturers.
Smart Images

Figure CN119520281A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a network configuration file processing method, a network configuration file processing device, a computer program product, and an electronic device. Background Art
[0002] The YANG model provides a standardized way to describe the data structure and operation of network devices. With the rapid increase of network devices, the YANG model provides convenience and better user experience for operation and maintenance, R&D managers. Therefore, most network configuration files currently use the YANG model as their data model.
[0003] However, in some cases, traditional CLI commands are still needed, for example, some equipment scenarios have difficulty in applying YANG models, or some staff are more accustomed to using CLI commands, etc. The industry lacks an efficient conversion solution from YANG models to CLI commands. Summary of the invention
[0004] The present disclosure provides a network configuration file processing method, a network configuration file processing device, a computer program product and an electronic device, so as to realize efficient conversion from a YANG model to a CLI command at least to a certain extent.
[0005] According to a first aspect of the present disclosure, a network configuration file processing method is provided, the method comprising: obtaining a network configuration file, the network configuration file comprising data based on a YANG model; parsing a label in the network configuration file, and if the path of the label is a leaf path, determining the label as a leaf label; based on a mapping rule between CLI commands and paths, obtaining a first CLI command corresponding to a leaf path of the leaf label; determining a second CLI command from the first CLI command by matching the first CLI command with the leaf label; and determining a target CLI command corresponding to the network configuration file according to the second CLI command and the data of the leaf label.
[0006] According to a second aspect of the present disclosure, a network configuration file processing device is provided, the device comprising: a file acquisition module, configured to acquire a network configuration file, the network configuration file comprising data based on a YANG model; a file parsing module, configured to parse a label in the network configuration file, and if the path of the label is a leaf path, the label is determined as a leaf label; a first CLI command determination module, configured to acquire a first CLI command corresponding to a leaf path of the leaf label based on a mapping rule between CLI commands and paths; a second CLI command determination module, configured to determine a second CLI command from the first CLI command by matching the first CLI command with the leaf label; and a target CLI command determination module, configured to determine a target CLI command corresponding to the network configuration file based on the second CLI command and the data of the leaf label.
[0007] According to a third aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the method of the first aspect and possible implementations thereof are implemented.
[0008] According to a fourth aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the method of the above-mentioned first aspect and its possible implementation methods by executing the executable instructions.
[0009] The technical solution disclosed in this disclosure has the following beneficial effects:
[0010] It provides an efficient conversion solution from YANG model to CLI command, which can generate compliant CLI commands according to the data structure and constraints defined by YANG model, thereby helping operation and maintenance, R&D management personnel to batch process the configuration of network devices, reduce manual operations, reduce human errors, and improve work efficiency. It is also compatible with different equipment manufacturers to ensure that the converted target CLI command can be correctly executed on the target device. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] Figure 1 A flowchart showing a method for processing a network configuration file in this exemplary embodiment is shown.
[0012] Figure 2 A sub-flowchart of a network configuration file processing method in this exemplary embodiment is shown.
[0013] Figure 3 A schematic flow chart of a method for processing a network configuration file in this exemplary embodiment is shown.
[0014] Figure 4A schematic diagram of the structure of a network configuration file processing device in this exemplary embodiment is shown.
[0015] Figure 5 A schematic structural diagram of an electronic device in this exemplary embodiment is shown. DETAILED DESCRIPTION
[0016] Exemplary embodiments of the present disclosure will be described more fully hereinafter with reference to the accompanying drawings.
[0017] The accompanying drawings are schematic diagrams of the present disclosure and are not necessarily drawn to scale. Some of the block diagrams shown in the accompanying drawings may be functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or in hardware modules or integrated circuits, or in networks, processors or microcontrollers. The embodiments can be implemented in various forms and should not be construed as being limited to the examples set forth herein. The features, structures or characteristics described in the present disclosure may be combined in one or more embodiments in any suitable manner. In the description below, many specific details are provided to provide a full description of the embodiments of the present disclosure. However, those skilled in the art should appreciate that one or more specific details may be omitted when implementing the technical solution of the present disclosure, or one or more specific details may be replaced by other methods, components, devices, steps, etc.
[0018] The YANG model has advantages in terms of uniformity and standardization of data models, convenience of automated management, management efficiency, and user experience. However, the promotion and application of the YANG model also has limitations. For example, some network administrators have knowledge reserves of CLI commands but do not have relevant knowledge of the YANG model, or some device scenarios do not support the YANG model. Therefore, it is necessary to convert the YANG model into traditional CLI commands. At present, the industry lacks an efficient conversion solution from the YANG model to the CLI command.
[0019] In view of the above problems, an exemplary embodiment of the present disclosure provides a network configuration file processing method. Figure 1 An exemplary process of a method for processing a network configuration file is shown, which may include the following steps S110 to S150:
[0020] Step S110, obtaining a network configuration file, where the network configuration file includes data based on a YANG model;
[0021] Step S120, parsing the tag in the network configuration file, and if the path of the tag is a leaf path, determining the tag as a leaf tag;
[0022] Step S130, based on the mapping rule between CLI commands and paths, obtaining a first CLI command corresponding to the leaf path of the leaf label;
[0023] Step S140, determining a second CLI command from the first CLI command by matching the first CLI command with the leaf tag;
[0024] Step S150: Determine the target CLI command corresponding to the network configuration file according to the second CLI command and the data of the leaf tag.
[0025] based on Figure 1 The method provides an efficient conversion solution from YANG model to CLI command. It can generate CLI commands that meet the specifications according to the data structure and constraints defined by the YANG model, thereby helping operation and maintenance, R&D management personnel and other personnel to batch process the configuration of network devices, reduce manual operations, reduce human errors, and improve work efficiency. It is also compatible with different equipment manufacturers to ensure that the converted target CLI commands can be correctly executed on the target device.
[0026] Below Figure 1 Provide detailed instructions for each step.
[0027] refer to Figure 1 In step S110, a network configuration file is obtained, where the network configuration file includes data based on a YANG model.
[0028] Among them, the network configuration file can be a NETCONF (Network Configuration Protocol) file. The XML (Extensible Markup Language) format is generally used to describe the configuration information. The NETCONF file uses the YANG model to define and manage network configurations and is instance data of the YANG model. The YANG (Yet Another Next Generation) model defines a hierarchical structure of data and can be used for operations based on network configuration management protocols (such as NETCONF), such as configuration, status data, remote procedure calls, and notifications.
[0029] The following is an example of part of the content in a NETCONF file:
[0030]
[0031] Among them, data_a, data_b, etc. can be data based on the YANG model.
[0032] In one implementation, a network configuration file based on a target manufacturer may be obtained. The target manufacturer may be a provider of network equipment. Different manufacturers may define their own YANG models, so the data in the network configuration file may be data based on the YANG model of the target manufacturer.
[0033] Continue to refer Figure 1 In step S120, the tag in the network configuration file is parsed, and if the path of the tag is a leaf path, the tag is determined to be a leaf tag.
[0034] Among them, the label in the network configuration file can represent the path of the data, such as A1, A2, a, b, etc. in the above NETCONF file. Exemplarily, when parsing the network configuration file, the label, data, element, etc. in the network configuration file can be identified according to the data format of the network configuration file and the pre-set parsing rules. By identifying data, elements, etc., it can help to identify labels more accurately and can also be used in the subsequent target CLI command generation process.
[0035] The path of a label is usually used to represent an address. If a path does not have a next-level path, the path is a leaf path and the corresponding label is a leaf label. By parsing the network configuration file, all leaf paths in the file can be found.
[0036] In one implementation, the above-mentioned parsing of the tag in the network configuration file, if the path of the tag is a leaf path, determining the tag as a leaf tag may include the following steps:
[0037] The network configuration file is parsed line by line to extract the leaf tags in each line until the parsing of the network configuration file is completed.
[0038] In the process of parsing the network configuration file line by line, it is determined whether the parsing of the entire file is completed. If the parsing is completed, the subsequent steps are continued. If the parsing is not completed, the parsing is continued line by line. In this way, the entire file can be traversed to extract all leaf tags. This avoids information omission during the conversion of CLI commands.
[0039] Continue to refer Figure 1 In step S130, based on the mapping rule between CLI commands and paths, the first CLI command corresponding to the leaf path of the leaf label is obtained.
[0040] CLI (Command Line Interface) is a way of interacting with users through a text interface, allowing users to execute specific operations in computer programs or operating systems by entering commands. The commands entered by users based on CLI are called CLI commands.
[0041] The first CLI command is a CLI command preliminarily determined based on the leaf path of the leaf tag. These CLI commands may cover the data content described by the YANG model in the network configuration file, or may cover data content not covered by the network configuration file. When the first CLI command is obtained, further processing can be performed through subsequent steps to filter out data content not covered by the network configuration file.
[0042] The mapping rules between CLI commands and paths include the correspondence between CLI commands and paths. In one embodiment, in the mapping rules between CLI commands and paths, each path corresponds to one or more CLI commands. That is, the CLI command corresponding to each path may not be unique. In addition, there may be multiple paths corresponding to the same CLI command. This is because the way CLI commands and YANG models describe configurations is inconsistent, and a one-to-one correspondence cannot be guaranteed between the two. There is a situation where one YANG node corresponds to multiple CLI commands, or multiple YANG nodes correspond to one CLI command.
[0043] In one embodiment, the mapping rules between the above CLI commands and paths may be based on the mapping rules of the target manufacturer. The mapping rules may be provided directly by the target manufacturer, or may be obtained by the operation and maintenance personnel based on the YANG model of the target manufacturer. Table 1 shows an example of the mapping rules between CLI commands and paths. It can be seen that the path "A1 / A2 / a" corresponds to two CLI commands, namely "Cli1 "、"Cli2 ", the path "A1 / A2 / b" corresponds to a CLI command "Cli2 ", the path "A1 / A2 / c" corresponds to a CLI command "Cli3 <c>”.
[0044] Table 1
[0045]
[0046] In one implementation, the above-mentioned obtaining the first CLI command corresponding to the leaf path of the leaf label based on the mapping rule between the command line interface CLI command and the path may include the following steps:
[0047] Based on the mapping rule between CLI commands and paths, all CLI commands corresponding to the leaf path of the leaf label are searched to serve as the first CLI command.
[0048] For example, if the path of a leaf tag in the network configuration file is "A1 / A2 / a", based on the mapping rules shown in Table 1, all CLI commands corresponding to the path can be found, that is, "Cli1< / c> "、"Cli2 ". Similarly, for each leaf path of a leaf tag in the network configuration file, all corresponding CLI commands are found. Thus, the first CLI command is determined. This can avoid missing actual data content in the first CLI command.
[0049] Continue to refer Figure 1 In step S140, the second CLI command is determined from the first CLI command by matching the first CLI command with the leaf tag.
[0050] As described above, there may be redundant information in the first CLI command. By matching the first CLI command with the leaf tag, the redundant information is filtered out from the first CLI command, and the remaining is the second CLI command. The second CLI command corresponds to the data content described by the YANG model in the network configuration file and is the actually required CLI command.
[0051] In one embodiment, reference Figure 2 As shown, the above-mentioned determining the second CLI command from the first CLI command by matching the first CLI command with the leaf tag may include the following steps S210 and S230:
[0052] Step S210, extracting attributes from the first CLI command;
[0053] Step S230: If a combination of attributes in one or more first CLI commands matches all leaf tags in the network configuration file, the one or more first CLI commands are determined as second CLI commands.
[0054] The attributes in the CLI command may include the operation objects in the CLI command, as shown in Table 1. The attributes include , "Cli2 The attributes include 、 .
[0055] Attributes match leaf tags, which means that the attributes and leaf tags represent the same meaning or data object. Matches leaf label a.
[0056] In one embodiment, the combination of attributes in the one or more first CLI commands matches all leaf tags in the network configuration file, which may include: the attributes in the one or more first CLI commands match all leaf tags in the network configuration file one by one; wherein, there are no attributes in the one or more first CLI commands that do not match the leaf tags, and there are no tags in the leaf tags that do not match the attributes in the one or more first CLI commands. In other words, the attributes in the one or more first CLI commands are all matched to the corresponding leaf tags, and each leaf tag is also matched to the corresponding attributes, and the attributes and leaf tags form a one-to-one match. In this case, it can be considered that the one or more first CLI commands just cover the data content described by the YANG model in the network configuration file, and there is no redundant information. The one or more first CLI commands are determined as the second CLI commands, and the remaining first CLI commands can be discarded.
[0057] In one embodiment, reference Figure 2 As shown, the above-mentioned determining the second CLI command from the first CLI command by matching the first CLI command with the leaf tag may also include the following step S220:
[0058] Step S220: After extracting the attributes in the first CLI command, if there are attributes in the first CLI command that do not match the leaf tag, it is determined that the first CLI command is not the second CLI command.
[0059] For example, a first CLI command "Cli5 <d> <e>The properties of " include <d> 、 <e>,in <e>If the first CLI command does not match any leaf tag in the network configuration file, that is, the first CLI command contains attributes that do not match the leaf tags, then it is determined that the first CLI command is not the second CLI command and can be removed. In the subsequent step S230, the first CLI command can be ignored, thereby reducing the number of first CLI commands, which is conducive to more quickly determining the second CLI command by matching attributes with leaf tags.
[0060] In one implementation, the determining the second CLI command from the first CLI command by matching the first CLI command with the leaf tag may include the following steps:
[0061] After extracting the attributes in the first CLI command, if there are attributes in the first CLI command that do not match the leaf tag, it is determined that the first CLI command is not the second CLI command.
[0062] That is, the first CLI commands may be excluded. After all first CLI commands having attributes that do not match the leaf tags are excluded, the remaining first CLI commands may be used as second CLI commands, thereby improving processing efficiency.
[0063] Continue to refer Figure 1 In step S150, the target CLI command corresponding to the network configuration file is determined according to the second CLI command and the data of the leaf tag.
[0064] The data of the leaf tag can be obtained from the network configuration file. For example, referring to the NETCONF file above, the data of the leaf tag a is data_a, and the data of the leaf tag b is data_b. The second CLI command and the data of the leaf tag can be combined to form a target CLI command. The target CLI command is a CLI command with data, which can be the final CLI command corresponding to the network configuration file, and is the final result of converting the YANG model in the network configuration file into a CLI command.
[0065] In one implementation, the determining of the target CLI command corresponding to the network configuration file according to the second CLI command and the data of the leaf tag may include the following steps:
[0066] The data of the leaf tag is filled into the second CLI command to obtain the target CLI command corresponding to the network configuration file.
[0067] Exemplarily, the data of the leaf tag may be filled into the location of the attribute matching the leaf tag in the second CLI command to form the target CLI command, thereby achieving efficient conversion from the YANG model to the CLI command.
[0068] Combine the following Figure 3 And examples, further illustrate the network configuration file processing method. Figure 3 As shown, the schematic flow of the network configuration file processing method may include the following steps:
[0069] Step S301: input the NETCONF file of the target manufacturer.
[0070] Step S302: parse the NETCONF file line by line.
[0071] Step S303: construct a path according to the YANG model of the target manufacturer to determine the label and path in the NETCONF file.
[0072] Step S304, judging whether the label is a leaf label according to whether the label path is a leaf path. For example, referring to the above NETCONF file, the leaf label can be determined as shown in Table 2:
[0073] Table 2
[0074] Serial number Leaf Label Leaf Path 1 a A1 / A2 / a 2 b A1 / A2 / b 3 d A1 / A2 / d 4 f A1 / A2 / f
[0075] Step S305, according to the mapping rules of the target manufacturer's CLI commands and paths, obtain all CLI commands corresponding to the leaf path of the leaf tag as the first CLI command. For example, based on the mapping rules of Table 1 and the leaf tags of Table 2, the first CLI command can be obtained as shown in Table 3:
[0076] Table 3
[0077] Serial number Leaf Path First CLI Command 1 A1 / A2 / a Cli1 2 A1 / A2 / a Cli2 3 A1 / A2 / b Cli2 4 A1 / A2 / d Cli4 <d> < / d> 5 A1 / A2 / d Cli5 <d> <e> < / e> < / d> 6 A1 / A2 / f Cli6 <f> < / f>
[0078] Step S306, determining whether the parsing of the NETCONF file is completed.
[0079] Step S307: Remove CLI commands containing attributes that do not match the leaf tag from the first CLI command. <d> <e>" <e>The first CLI command does not match any leaf tag in the NETCONF file, so the first CLI command is removed. The remaining first CLI commands are shown in Table 4:
[0080] Table 4
[0081]
[0082]
[0083] Step S308: Select a set of first CLI commands whose attributes completely match all leaf tags from the remaining first CLI commands as the second CLI command. "、"Cli2 ”、"Cli4 <d>”、"Cli6 <f> The four first CLI command attributes include< / f> < / d> 、 、 、 <d> 、 <f> , compared to all leaf tags a, b, d, f, there is one more unmatched attribute< / f> < / d> , which is not a complete match; "Cli1 ”、"Cli4 <d>”、"Cli6 <f> "The first three CLI commands include the properties< / f> < / d> 、 <d> 、 <f> , the leaf tag b does not match any of its attributes, nor is it a complete match; "Cli2< / f> < / d> ”、"Cli4 <d>”、"Cli6 <f> "The first three CLI commands include properties< / f> < / d> 、 、 <d> 、 <f> , and all leaf tags a, b, d, and f are exactly matched one by one, which is a complete match. Therefore, it can be determined that the first CLI command "Cli2< / f> < / d> ”、"Cli4 <d>”、"Cli6 <f>" is the second CLI command, as shown in Table 5 below:
[0084] Table 5
[0085] Serial number Leaf Path Second CLI Command 1 A1 / A2 / a Cli2 2 A1 / A2 / b Cli2 3 A1 / A2 / d Cli4 <d> < / d> 4 A1 / A2 / f Cli6 <f> < / f>
[0086] Step S309, fill the leaf tag data into the second CLI command to form the target CLI command. For example, fill the leaf tag data in the NETCONF above into the second CLI command shown in Table 5 to form the target CLI command as follows:
[0087] Cli2 data_a data_b
[0088] Cli4 data_d
[0089] Cli6 data_f
[0090] Step S310: output the target CLI command, that is, the CLI command set after the YANG model is converted.
[0091] The exemplary embodiment of the present disclosure also provides a network configuration file processing device.< / f> < / d> Figure 4 As shown, the network configuration file processing device 400 may include:
[0092] The file acquisition module 410 is configured to acquire a network configuration file, wherein the network configuration file includes data based on a YANG model;
[0093] The file parsing module 420 is configured to parse the tag in the network configuration file, and if the path of the tag is a leaf path, determine the tag as a leaf tag;
[0094] A first CLI command determination module 430 is configured to obtain a first CLI command corresponding to the leaf path of the leaf label based on a mapping rule between CLI commands and paths;
[0095] A second CLI command determination module 440 is configured to determine a second CLI command from the first CLI command by matching the first CLI command with the leaf tag;
[0096] The target CLI command determination module 450 is configured to determine the target CLI command corresponding to the network configuration file according to the second CLI command and the data of the leaf tag.
[0097] In one embodiment, in the mapping rule between the CLI command and the path, each path corresponds to one or more CLI commands; the obtaining, based on the mapping rule between the command line interface CLI command and the path, the first CLI command corresponding to the leaf path of the leaf label includes:
[0098] Based on the mapping rule between the CLI command and the path, all CLI commands corresponding to the leaf path of the leaf label are searched to serve as the first CLI command.
[0099] In one embodiment, determining the second CLI command from the first CLI command by matching the first CLI command with the leaf tag includes:
[0100] Extracting attributes from the first CLI command;
[0101] If a combination of attributes in one or more first CLI commands matches all of the leaf tags in the network configuration file, the one or more first CLI commands are determined to be second CLI commands.
[0102] In one embodiment, the determining the second CLI command from the first CLI command by matching the first CLI command with the leaf tag further includes:
[0103] After extracting the attributes in the first CLI command, if there are attributes in the first CLI command that do not match the leaf tag, it is determined that the first CLI command is not the second CLI command.
[0104] In one embodiment, the combination of attributes in the one or more first CLI commands matches all of the leaf tags in the network configuration file, including:
[0105] The attributes in the one or more first CLI commands are matched one by one with all the leaf tags in the network configuration file; wherein, there are no attributes in the one or more first CLI commands that do not match the leaf tags, and there are no tags in the leaf tags that do not match the attributes in the one or more first CLI commands.
[0106] In one implementation, determining the target CLI command corresponding to the network configuration file according to the second CLI command and the data of the leaf tag includes:
[0107] The data of the leaf tag is filled into the second CLI command to obtain the target CLI command corresponding to the network configuration file.
[0108] In one implementation, parsing the tag in the network configuration file, if the path of the tag is a leaf path, determining the tag as a leaf tag includes:
[0109] The network configuration file is parsed line by line to extract the leaf tag in each line until the parsing of the network configuration file is completed.
[0110] The specific details of each part of the above-mentioned device have been described in detail in the implementation method of the method part. The undisclosed details can be found in the implementation method of the method part, so they will not be repeated here.
[0111] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the exemplary embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0112] The exemplary embodiments of the present disclosure also provide a computer program product, which includes a computer program, and when the computer program is executed by a processor, the above-mentioned named entity recognition method is implemented.
[0113] In one embodiment, the computer program product may be a tangible product containing a computer program, such as a computer-readable storage medium storing a computer program. The readable storage medium may be a storage medium based on electrical, magnetic, optical, electromagnetic, infrared, or other signals, including but not limited to: random access memory (RAM), read-only memory (ROM), magnetic tape, floppy disk, flash memory (Flash), mechanical hard disk (HDD), solid-state drive (SSD), and the like. Exemplarily, the computer program product may be implemented as a non-volatile storage medium storing a computer program, such as a read-only memory, a NAND flash memory, and the like.
[0114] In one embodiment, the computer program product may be an intangible product including a computer program. Exemplarily, the computer program product may be implemented as a virtual digital product, such as a digital file storing an executable file, an installation package, etc. of the computer program.
[0115] The code of the computer program can be written in one or more programming languages. Programming languages such as C language, Java, C++, etc. The program code can be executed entirely on the user computing device, or partially on the user computing device, or as a separate software package, or partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, such as a local area network (LAN), a wide area network (WAN), etc., or can be connected to an external computing device (e.g., an Internet connection provided by an operator).
[0116] Computer programs can be carried or transmitted through electrical, magnetic, optical, electromagnetic, infrared and other signals. Electronic devices can convert signals carrying computer programs into digital signals to run computer programs. When a computer program runs on an electronic device, its code is used to enable the electronic device to execute (more specifically, it can enable the processor of the electronic device to execute) the method steps of various exemplary embodiments of the present disclosure, such as the following steps: Step S110, obtain a network configuration file, the network configuration file includes data based on a YANG model; Step S120, parse the label in the network configuration file, if the path of the label is a leaf path, determine the label as a leaf label; Step S130, based on the mapping rule between CLI commands and paths, obtain the first CLI command corresponding to the leaf path of the leaf label; Step S140, determine the second CLI command from the first CLI command by matching the first CLI command with the leaf label; Step S150, determine the target CLI command corresponding to the network configuration file according to the data of the second CLI command and the leaf label.
[0117] Based on the computer program to execute the above method, an efficient conversion solution from YANG model to CLI command is provided, which can generate CLI commands that meet the specifications according to the data structure and constraints defined by the YANG model, thereby helping operation and maintenance, R&D management personnel and other personnel to batch process the configuration of network devices, reduce manual operations, reduce human errors, and improve work efficiency. It can also be compatible with different equipment manufacturers to ensure that the converted target CLI commands can be correctly executed on the target device.
[0118] The exemplary embodiments of the present disclosure also provide an electronic device. The electronic device may include a processor and a memory. The memory stores executable instructions of the processor, such as a computer program. The processor executes the method steps of various exemplary embodiments of the present disclosure by executing the executable instructions.
[0119] Reference below Figure 5 , the electronic device is exemplarily described in the form of a general-purpose computing device. It should be understood that Figure 5 The electronic device 500 shown is merely an example and should not limit the functions and scope of use of the embodiments of the present disclosure.
[0120] like Figure 5 As shown, the electronic device 500 may include: a processor 510 , a memory 520 , a bus 530 , an I / O (input / output) interface 540 , and a network adapter 550 .
[0121] The memory 520 may include a volatile memory, such as a RAM 521, a cache unit 522, and may also include a non-volatile memory, such as a ROM 523. The memory 520 may also include one or more program modules 524, such program modules 524 include but are not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or a combination thereof may include the implementation of a network environment. For example, the program module 524 may include each module in the above-mentioned device.
[0122] The processor 510 may include one or more processing units. For example, the processor 510 may include an AP (Application Processor), a modem processor, a GPU (Graphics Processing Unit), an ISP (Image Signal Processor), a controller, an encoder, a decoder, a DSP (Digital Signal Processor), a baseband processor and / or an NPU (Neural-Network Processing Unit), etc.
[0123] The processor 510 can be used to execute executable instructions stored in the memory 520, which may include method steps of various exemplary embodiments of the present disclosure, such as executing the following steps: Step S110, obtaining a network configuration file, the network configuration file includes data based on a YANG model; Step S120, parsing a label in the network configuration file, if the path of the label is a leaf path, determining the label as a leaf label; Step S130, based on a mapping rule between CLI commands and paths, obtaining a first CLI command corresponding to a leaf path of a leaf label; Step S140, determining a second CLI command from the first CLI command by matching the first CLI command with the leaf label; Step S150, determining a target CLI command corresponding to the network configuration file based on the second CLI command and the data of the leaf label.
[0124] Based on the execution of the above method by electronic devices, an efficient conversion solution from YANG model to CLI command is provided, which can generate CLI commands that meet the specifications according to the data structure and constraints defined by the YANG model, thereby helping operation and maintenance, R&D management personnel and other personnel to batch process the configuration of network devices, reduce manual operations, reduce human errors, and improve work efficiency. It can also be compatible with different equipment manufacturers to ensure that the converted target CLI command can be correctly executed on the target device.
[0125] The bus 530 is used to realize the connection between different components of the electronic device 500, and may include a data bus, an address bus, and a control bus.
[0126] The electronic device 500 can communicate with one or more external devices 600 (eg, a keyboard, a mouse, an external controller, etc.) through the I / O interface 540 .
[0127] The electronic device 500 can communicate with one or more networks through the network adapter 550. For example, the network adapter 550 can provide mobile communication solutions such as 3G / 4G / 5G, or provide wireless communication solutions such as wireless LAN, Bluetooth, near field communication, etc. The network adapter 550 can communicate with other modules of the electronic device 500 through the bus 530.
[0128] although Figure 5 Not shown, other hardware and / or software modules may also be provided in the electronic device 500, including but not limited to: a display, a microcode, a device driver, a redundant processor, an external disk drive array, a RAID system, a tape drive, and a data backup storage system.
[0129] As can be seen from the above, the technical solution of the present disclosure can be implemented as a method, an apparatus, a system, a computer program product, a storage medium, an electronic device, etc. Those skilled in the art can understand that various aspects of the present disclosure can be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or an implementation combining hardware and software, such as being respectively referred to as a "circuit", "module" or "system".
[0130] It should be understood that the present disclosure is not limited to the specific method steps or structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from the scope thereof. Those skilled in the art will easily think of other embodiments based on the specific embodiments provided by the present disclosure. Therefore, the specific embodiments provided by the present disclosure are only exemplary, and the scope and spirit of the present disclosure are indicated by the claims, and any variations, uses or adaptive changes of the present disclosure should be covered, which follow the general principles of the present disclosure and include common knowledge or customary technical means in the technical field that are not disclosed in the present disclosure. < / e> < / e> < / d> < / e> < / e> < / d> < / e> < / d>
Claims
1. A method for processing a network configuration file, characterized in that: The method comprises: Obtain a network configuration file, wherein the network configuration file includes data based on a YANG model; Parsing a tag in the network configuration file, and if a path of the tag is a leaf path, determining the tag as a leaf tag; Based on a mapping rule between a command line interface (CLI) command and a path, obtaining a first CLI command corresponding to the leaf path of the leaf label; Determining a second CLI command from the first CLI command by matching the first CLI command with the leaf tag; Determine the target CLI command corresponding to the network configuration file according to the second CLI command and the data of the leaf tag.
2. The method according to claim 1, characterized in that In the mapping rule between the CLI command and the path, each path corresponds to one or more CLI commands; the mapping rule between the command line interface CLI command and the path, obtaining the first CLI command corresponding to the leaf path of the leaf label, includes: Based on the mapping rule between the CLI command and the path, all CLI commands corresponding to the leaf path of the leaf label are searched to serve as the first CLI command.
3. The method according to claim 1, characterized in that The determining the second CLI command from the first CLI command by matching the first CLI command with the leaf tag includes: Extracting attributes from the first CLI command; If a combination of attributes in one or more first CLI commands matches all of the leaf tags in the network configuration file, the one or more first CLI commands are determined to be second CLI commands.
4. The method according to claim 3, characterized in that The determining the second CLI command from the first CLI command by matching the first CLI command with the leaf tag further includes: After extracting the attributes in the first CLI command, if there are attributes in the first CLI command that do not match the leaf tag, it is determined that the first CLI command is not the second CLI command.
5. The method according to claim 3, characterized in that: The combination of attributes in the one or more first CLI commands matches all of the leaf tags in the network configuration file, including: The attributes in the one or more first CLI commands are matched one by one with all the leaf tags in the network configuration file; wherein, there are no attributes in the one or more first CLI commands that do not match the leaf tags, and there are no tags in the leaf tags that do not match the attributes in the one or more first CLI commands.
6. The method according to claim 1, characterized in that The determining, according to the second CLI command and the data of the leaf tag, a target CLI command corresponding to the network configuration file includes: The data of the leaf tag is filled into the second CLI command to obtain the target CLI command corresponding to the network configuration file.
7. The method according to any one of claims 1 to 6, characterized in that: The parsing of the tag in the network configuration file, and if the path of the tag is a leaf path, determining the tag as a leaf tag, includes: The network configuration file is parsed line by line to extract the leaf tag in each line until the parsing of the network configuration file is completed.
8. A network configuration file processing device, characterized in that: The device comprises: A file acquisition module is configured to acquire a network configuration file, wherein the network configuration file includes data based on a YANG model; A file parsing module is configured to parse a tag in the network configuration file, and if a path of the tag is a leaf path, determine the tag as a leaf tag; A first CLI command determination module is configured to obtain a first CLI command corresponding to the leaf path of the leaf label based on a mapping rule between CLI commands and paths; a second CLI command determination module configured to determine a second CLI command from the first CLI command by matching the first CLI command with the leaf tag; The target CLI command determination module is configured to determine the target CLI command corresponding to the network configuration file according to the second CLI command and the data of the leaf tag.
9. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
10. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to perform the method of any one of claims 1 to 7 by executing the executable instructions.
Citation Information
Patent Citations
An automatic structuring and parsing method and system of command line interface command
CN101079737A
Test method and device for command line interface
CN101471826A
Method and device for converting network configuration protocol response message into command line
CN102447585A
Frequency division multiplexing ultrahigh frequency RFID tag and response method thereof
CN115515115A
Information conversion method of data modeling file, electronic equipment and storage medium
CN117312422A