Network configuration file processing methods, devices, software products and electronic devices

By parsing the network configuration file of the YANG model, identifying leaf tags, and generating CLI commands that conform to the specifications, the problem of low efficiency in converting the YANG model to CLI commands is solved, thereby improving the efficiency and accuracy of network device configuration.

CN119520281BActive Publication Date: 2026-03-10CHINA TELECOM CORP LTD TECHNOLOGY INNOVATION CENTER +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-18
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

The lack of an efficient YANG model to CLI command conversion scheme in the existing technology leads to low efficiency and easy human error for operation and maintenance and R&D managers when handling network device configuration.

Method used

A method for processing network configuration files is provided. By parsing the network configuration file of the YANG model, leaf tags are identified, the first CLI command is obtained using the mapping rules between CLI commands and paths, and the target CLI command that conforms to the specification is generated through matching and filtering.

Benefits of technology

It achieves efficient conversion from YANG model to CLI commands, reduces manual operation, improves work efficiency, reduces human error, and is compatible with network devices from different manufacturers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119520281B_ABST
    Figure CN119520281B_ABST
Patent Text Reader

Abstract

This disclosure provides a network configuration file processing method, apparatus, program product, and electronic device, relating to the field of computer technology. The method includes: acquiring a network configuration file, the network configuration file including data based on a YANG model; parsing tags in the network configuration file, and if the path of a tag is a leaf path, then identifying the tag as a leaf tag; based on a CLI command and path mapping rule, acquiring a first CLI command corresponding to the leaf path of the leaf tag; determining a second CLI command from the first CLI commands by matching the first CLI command with the leaf tag; and determining a target CLI command corresponding to the network configuration file based on the data of the second CLI command and the leaf tag. This disclosure achieves efficient conversion from the YANG model to CLI commands.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the technical field of computer, and particularly relates to a network configuration file processing method, a network configuration file processing apparatus, a computer program product and an electronic device. BACKGROUND

[0002] The YANG model provides a standardized way to describe the data structure and operation of a network device. In the context of rapid increase of network devices, the YANG model provides convenience and better user experience for operation and maintenance and development management personnel. Therefore, most network configuration files currently adopt the YANG model as their data model.

[0003] However, in some cases, it is still necessary to use traditional CLI commands, such as some device scenarios have difficulties in applying the YANG model, or some staff are more accustomed to using CLI commands, etc. There is a lack of efficient conversion scheme from the YANG model to the CLI command in the industry. SUMMARY

[0004] The present disclosure provides a network configuration file processing method, a network configuration file processing apparatus, a computer program product and an electronic device to at least partially realize efficient conversion from the YANG model to the CLI command.

[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 a path of the label is a leaf path, determining the label as a leaf label; obtaining a first CLI command corresponding to the leaf path of the leaf label based on a mapping rule between CLI commands and paths; determining a second CLI command from the first CLI command by matching the first CLI command and the leaf label; and determining a target CLI command corresponding to the network configuration file according to the second CLI command and data of the leaf label.

[0006] According to a second aspect of the present disclosure, a network configuration file processing apparatus is provided, the apparatus comprising: a file obtaining module configured to obtain a network configuration file, the network configuration file comprising data based on a YANG model; a file parsing module configured to parse a tag in the network configuration file, and determine the tag as a leaf tag if a path of the tag is a leaf path; a first CLI command determining module configured to obtain a first CLI command corresponding to the leaf path of the leaf tag based on a mapping rule of CLI commands and paths; a second CLI command determining module configured to determine a second CLI command from the first CLI command by matching the first CLI command and the leaf tag; and a target CLI command determining module configured to determine a target CLI command corresponding to the network configuration file according to the second CLI command and data of the leaf tag.

[0007] According to a third aspect of the present disclosure, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the method of the first aspect above and possible implementation manners thereof.

[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 first aspect above and possible implementation manners thereof via execution of the executable instructions.

[0009] The technical solution of the present disclosure has the following beneficial effects:

[0010] An efficient conversion scheme from YANG model to CLI command is provided, which can generate a CLI command conforming to a specification according to a data structure and constraints defined by a YANG model, thereby helping operation and maintenance, research and development management personnel, etc. to batch process configurations of network devices, reducing manual operations, reducing human errors, and improving work efficiency. And it can be compatible with different device manufacturers to ensure that the converted target CLI command can be executed correctly on the target device. BRIEF DESCRIPTION OF DRAWINGS

[0011] Figure 1 A flowchart of a network configuration file processing method in the present exemplary embodiment is shown.

[0012] Figure 2 A sub-flowchart of a network configuration file processing method in the present exemplary embodiment is shown.

[0013] Figure 3 A schematic flowchart of a network configuration file processing method in the present exemplary embodiment is shown.

[0014] Figure 4Fig. 1 shows a schematic diagram of a network configuration file processing device according to an example embodiment.

[0015] Figure 5 Fig. 1 shows a schematic diagram of a network configuration file processing device according to an example embodiment. DETAILED DESCRIPTION

[0016] Example embodiments of the present disclosure will be described more fully hereinafter with reference to the accompanying drawings.

[0017] The accompanying drawings, which are included to provide a further understanding of the disclosure and are incorporated in and constitute a part of this application, illustrate certain non-limiting embodiments of the disclosure. In the drawings, the same reference numerals are used to represent similar components in the various figures. The drawings provided are for purposes of illustration and description only. It is noted that all features of the drawings are not necessarily drawn to scale. Some of the blocks in the drawings can be functional blocks, which can be implemented in software, hardware, or a combination of both. Embodiments can be implemented in many ways, not just the examples described herein. The features, structures, or characteristics described in this disclosure can be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the disclosure. One skilled in the relevant art will recognize, however, that the various embodiments of the disclosure can be practiced without one or more of the specific details, or with other methods, components, materials, and so forth. In other instances, well-known structures, materials, or operations are not shown or described in detail.

[0018] The YANG model has advantages in the uniformity and standardization of data models, the convenience of automated management, management efficiency, and user experience. However, the promotion and application process of the YANG model also has limitations, such as some network management personnel 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 scheme from the YANG model to the CLI command.

[0019] In view of the above problems, an example embodiment of the present disclosure provides a network configuration file processing method. Figure 1 An example flow of the network configuration file processing method is shown, which can include the following steps S110 to S150:

[0020] Step S110, a network configuration file is obtained, and the network configuration file includes data based on a YANG model;

[0021] Step S120, a label in the network configuration file is parsed, and if a path of the label is a leaf path, the label is determined as a leaf label;

[0022] Step S130, based on the mapping rule of the CLI command and the path, the first CLI command corresponding to the leaf path of the leaf label is obtained;

[0023] Step S140, by matching the first CLI command and the leaf label, the second CLI command is determined from the first CLI command;

[0024] Step S150, according to the second CLI command and the data of the leaf label, the target CLI command corresponding to the network configuration file is determined.

[0025] Based on Figure 1 The method provides an efficient conversion scheme from YANG model to CLI command, which can generate a standard CLI command according to the data structure and constraints defined by the YANG model, thereby helping operation and maintenance, research and development management personnel and other batch processing of network device configuration, reducing manual operation, reducing human error, and improving work efficiency. And can be compatible with different equipment manufacturers, to ensure that the target CLI command after conversion can be executed correctly on the target device.

[0026] The following will be specifically described for each step in Figure 1 .

[0027] Referring to Figure 1 , in step S110, a network configuration file is obtained, and 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, network configuration protocol) file. Generally, the configuration information is described in XML(Extensible Markup Language, Extensible Markup Language) format. The NETCONF file uses the YANG model to define and manage network configuration, which is the instance data of the YANG model. The YANG(Yet Another Next Generation) model defines the hierarchical structure of data, which can be used for operations based on network configuration management protocols (such as NETCONF), such as configuration, state data, remote procedure call and notification, etc.

[0029] The following exemplary shows part of the content in the NETCONF file:

[0030]

[0031] Among them, data_a, data_b, etc. can be data based on the YANG model.

[0032] In an embodiment, a target vendor based network configuration file can be acquired. The target vendor can be a provider of the network device. Different vendors can define their own YANG model, and thus the data in the network configuration file can be data based on the YANG model of the target vendor.

[0033] With reference to the foregoing Figure 1 In step S120, a tag in the network configuration file is parsed, and if a path of the tag is a leaf path, the tag is determined as a leaf tag.

[0034] The tag in the network configuration file can represent a path of data, such as A1, A2, a, b, etc. in the foregoing NETCONF file. For example, in parsing the network configuration file, the tag, data, element, and other information in the network configuration file can be identified according to a data format of the network configuration file and a pre-set parsing rule, etc. By identifying the data, element, etc., the tag can be more accurately identified, and can also be used in a subsequent target CLI command generation process.

[0035] The path of the tag is generally used to represent an address, and if a path does not have a next level path, the path is a leaf path, and the corresponding tag is a leaf tag. By parsing the network configuration file, all leaf paths in the file can be found.

[0036] In an embodiment, the above parsing of the tag in the network configuration file, and if the path of the tag is a leaf path, the tag is determined as a leaf tag, can include the following steps:

[0037] The network configuration file is parsed line by line to extract the leaf tag in each line until the network configuration file is parsed completely.

[0038] In the process of parsing the network configuration file line by line, it is determined whether the entire file has been parsed, and if the parsing is completed, the subsequent steps are continued, and if the parsing is not completed, the line-by-line parsing is continued. In this way, the entire file can be traversed to extract all leaf tags. In this way, information omission in the process of converting the CLI command can be avoided.

[0039] With reference to the foregoing Figure 1 In step S130, a first CLI command corresponding to a leaf path of the leaf tag is acquired based on a mapping rule of the CLI command and the path.

[0040] A CLI (Command Line Interface) is a way of interacting with a user through a text interface, allowing the user to input commands to execute specific operations in a computer program or operating system. The commands input by the user based on the CLI are CLI commands.

[0041] The first CLI command is a CLI command preliminarily determined according to the leaf path of the leaf label, which can cover the data content described by the YANG model in the network configuration file, or can cover the data content not involved in the network configuration file. In the case of obtaining the first CLI command, further processing can be performed through subsequent steps to filter out the data content not involved in the network configuration file.

[0042] The mapping rule of the CLI command and the path contains the corresponding relationship between the CLI command and the path. In an embodiment, in the mapping rule of the CLI command and the path, each path corresponds to one or more CLI commands. That is, the CLI command corresponding to each path can not be unique. And there can be multiple paths corresponding to the same CLI command. This is because the CLI command and the YANG model describe the configuration in different ways, and there is no one-to-one correspondence between the two, and there can be a case where one YANG node corresponds to multiple CLI commands, or multiple YANG nodes correspond to one CLI command.

[0043] In an embodiment, the mapping rule of the CLI command and the path described above can be a mapping rule based on the target vendor. The mapping rule can be directly provided by the target vendor, or obtained by the operation and maintenance personnel according to the YANG model of the target vendor. Table 1 exemplarily shows the mapping rule of the CLI command and the path. It can be seen that the path "A1 / A2 / a" corresponds to two CLI commands, which are "Cli1 "Cli2 ", "Cli2 ", the path "A1 / A2 / c" corresponds to a CLI command "Cli3 <c>".

[0044] Table 1

[0045]

[0046] In one embodiment, the mapping rule of the CLI command and the path, and the first CLI command corresponding to the leaf path of the leaf label can include the following steps:

[0047] According to the mapping rule of the CLI command and the path, all CLI commands corresponding to the leaf path of the leaf label are found as the first CLI command.

[0048] For example, if the path of a certain leaf label in the network configuration file is "A1 / A2 / a", according to the mapping rule shown in Table 1, all CLI commands corresponding to the path can be found, that is, "Cli1< / c> " and the path "A1 / A2 / b" corresponds to a CLI command "Cli2 ". In the same way, for each leaf path of each leaf tag in the network configuration file, find out all the corresponding CLI commands. Thus, the first CLI command is determined. In this way, the actual data content is avoided to be missed in the first CLI command.

[0049] With continued reference " and the path "A1 / A2 / b" corresponds to a CLI command "Cli2 In step S140, the second CLI command is determined from the first CLI command by matching the first CLI command with the leaf labels.

[0050] As mentioned above, there can be redundant information in the first CLI command. The redundant information is filtered out from the first CLI command by matching the first CLI command with the leaf labels, 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 actual required CLI command.

[0051] In an embodiment, referring to FIG. 2, the above determining the second CLI command from the first CLI command by matching the first CLI command with the leaf labels can include the following steps S210 and S230. Figure 1

[0052] In step S210, the attributes in the first CLI command are extracted.

[0053] In step S230, if the combination of the attributes in one or more first CLI commands matches all the leaf labels in the network configuration file, the one or more first CLI commands are determined as the second CLI command.

[0054] The attributes in the CLI command can include the operation object in the CLI command, as shown in Table 1, "Cli1 Figure 2 " and the path "A1 / A2 / b" corresponds to a CLI command "Cli2 " and the path "A1 / A2 / b" corresponds to a CLI command "Cli2 、 .

[0055] An attribute matches a leaf tag if the attribute and the leaf tag represent the same meaning or data object. For example, an attribute "name" matches a leaf tag "name". Matched with the leaf label a.

[0056] In an embodiment, the combination of the attributes in the one or more first CLI commands matching all the leaf labels in the network configuration file can include: the attributes in the one or more first CLI commands one-to-one matching all the leaf labels in the network configuration file; wherein there is no attribute in the one or more first CLI commands that does not match a leaf label, and there is no leaf label that does not match an attribute in the one or more first CLI commands. That is, the attributes in the one or more first CLI commands are matched to the corresponding leaf labels, and each leaf label is also matched to the corresponding attribute, and the attributes and the leaf labels form one-to-one matching. In this case, it can be considered that the one or more first CLI commands exactly 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 command, and the remaining first CLI commands can be discarded.

[0057] In an embodiment, the reference Figure 2 As shown, the determining the second CLI command from the first CLI command by matching the first CLI command with the leaf tag can further include the following step S220:

[0058] Step S220, after extracting the attributes in the first CLI command, if there is an attribute in the first CLI command that does not match the leaf tag, it is determined that the first CLI command is not the second CLI command.

[0059] For example, a certain first CLI command "Cli5 <d> <e>The attributes of the " " include <d> 、 <e>wherein <e>If there is an attribute in the first CLI command that does not match any leaf tag in the network configuration file, it is determined that the first CLI command is not the second CLI command, and the first CLI command can be removed, and in the subsequent step S230, the first CLI command can not be considered, thereby reducing the number of first CLI commands, and facilitating more rapid determination of the second CLI command by matching the attributes and the leaf tags.

[0060] In an embodiment, the above determination of the second CLI command from the first CLI command by matching the first CLI command and the leaf tags can include the following steps:

[0061] After extracting the attributes in the first CLI command, if there is an attribute in the first CLI command that does not match any leaf tag, it is determined that the first CLI command is not the second CLI command.

[0062] That is, the first CLI command can be excluded, and after excluding all first CLI commands that have attributes that do not match any leaf tag, the remaining first CLI commands can be used as the second CLI command. This improves processing efficiency.

[0063] With reference to the above 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 tags.

[0064] The data of the leaf tags can be obtained from the network configuration file, such as the NETCONF file described 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 tags can be combined to form the 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 to a CLI command.

[0065] In an embodiment, the above determination of the target CLI command corresponding to the network configuration file according to the second CLI command and the data of the leaf tags can include the following steps:

[0066] The data of the leaf tags is filled into the second CLI command to obtain the target CLI command corresponding to the network configuration file.

[0067] For example, the data of the leaf tags can be filled into the second CLI command at the position of the attribute matching the leaf tag to form the target CLI command. This achieves efficient conversion of the YANG model to the CLI command.

[0068] The following will be described in combination with Figure 3 and examples. Referring to Figure 3 As shown in the figure, the schematic flow of the network configuration file processing method can include the following steps:

[0069] Step S301, input the NETCONF file of the target vendor.

[0070] Step S302, parse the NETCONF file line by line.

[0071] Step S303, according to the YANG model of the target vendor, construct the path to determine the label and its path in the NETCONF file.

[0072] Step S304, determine whether the label is a leaf label according to whether the path of the label is a leaf path. For example, referring to the NETCONF file in the foregoing, the leaf labels can be determined as shown in Table 2:

[0073] Table 2

[0074] 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 rule of the CLI command and the path of the target vendor, obtain all CLI commands corresponding to the leaf path of the leaf label as the first CLI command. For example, based on the mapping rule in Table 1 and the leaf labels in Table 2, the first CLI command can be obtained as shown in Table 3:

[0076] Table 3

[0077] 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, determine whether the NETCONF file parsing is completed.

[0079] Step S307, remove the CLI command containing the attribute not matched with the leaf label from the first CLI command. For example, the first CLI command "Cli5 <d> <e>Attributes in " <e>The first CLI command is removed, and the remaining first CLI command is shown in Table 4:

[0080] Table 4

[0081]

[0082]

[0083] In step S308, a group of first CLI commands in which all attributes are completely matched with all leaf labels are selected from the remaining first CLI commands as second CLI commands. For example, in the first CLI commands shown in Table 4, "Cli1 " and the path "A1 / A2 / b" corresponds to a CLI command "Cli2 " and "Cli4 <d>" and "Cli6 <f>" and the path "A1 / A2 / b" corresponds to a CLI command "Cli2< / f> < / d> 、 、 、 <d> 、 <f>" and the path "A1 / A2 / b" corresponds to a CLI command "Cli2< / f> < / d> " and the path "A1 / A2 / b" corresponds to a CLI command "Cli2 " and "Cli4 <d>" and "Cli6 <f>" and the path "A1 / A2 / b" corresponds to a CLI command "Cli2< / f> < / d> 、 <d> 、 <f>Number< / f> < / d> " and "Cli4 <d>" and "Cli6 <f>Leaf path< / f> < / d> 、 、 <d> 、 <f>Second CLI command< / f> < / d> " and "Cli4 <d>" and "Cli6 <f>" is a second CLI command, and refer to the following Table 5:

[0084] Table 5

[0085] A1 / A2 / a A1 / A2 / b A1 / A2 / d 1 A1 / A2 / f Cli2 2 Figure 4 Cli2 3 Figure 5 Cli4 <d> < / d> 4 Figure 5 Cli6 <f> < / f>

[0086] In step S309, data of the leaf tag is filled into the second CLI command to form a target CLI command. For example, data of the leaf tag in the above NETCONF is filled 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] In step S310, the target CLI command, i.e., the YANG model converted CLI command set, is output.

[0091] An exemplary embodiment of the present disclosure also provides a network configuration file processing device. Refer to the following description of the network configuration file processing device.< / f> < / d> Figure 5 As shown, the network configuration file processing apparatus 400 can include:

[0092] A file obtaining module 410 configured to obtain a network configuration file, the network configuration file comprising data based on a YANG model;

[0093] A file parsing module 420 configured to parse a tag in the network configuration file, and determine the tag as a leaf tag if a path of the tag is a leaf path;

[0094] A first CLI command determining module 430 configured to obtain a first CLI command corresponding to a leaf path of the leaf tag based on a mapping rule of CLI commands and paths;

[0095] A second CLI command determining module 440 configured to determine a second CLI command from the first CLI command by matching the first CLI command with the leaf tag;

[0096] A target CLI command determining module 450 configured to determine a target CLI command corresponding to the network configuration file according to the second CLI command and data of the leaf tag.

[0097] In an embodiment, in the mapping rule of CLI commands and paths, each path corresponds to one or more CLI commands; and the obtaining of the first CLI command corresponding to the leaf path of the leaf tag based on the mapping rule of CLI commands and paths comprises:

[0098] Finding all CLI commands corresponding to the leaf path of the leaf tag based on the mapping rule of CLI commands and paths, as the first CLI command.

[0099] In an embodiment, the determining of the second CLI command from the first CLI command by matching the first CLI command with the leaf tag comprises:

[0100] Extracting an attribute in the first CLI command;

[0101] If a combination of the attribute in one or more first CLI commands matches all the leaf tags in the network configuration file, determining the one or more first CLI commands as the second CLI command.

[0102] In an embodiment, the determining of the second CLI command from the first CLI command by matching the first CLI command with the leaf tag further comprises:

[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 labels, it is determined that the first CLI command is not a second CLI command.

[0104] In an embodiment, the combination of the attributes in the one or more first CLI commands matches all the leaf labels in the network configuration file, including:

[0105] The attributes in the one or more first CLI commands one-to-one match all the leaf labels in the network configuration file; wherein there are no attributes in the one or more first CLI commands that do not match the leaf labels, and there are no labels in the leaf labels that do not match the attributes in the one or more first CLI commands.

[0106] In an embodiment, the determining, according to the second CLI command and the data of the leaf labels, of the target CLI command corresponding to the network configuration file includes:

[0107] Filling the data of the leaf labels into the second CLI command to obtain the target CLI command corresponding to the network configuration file.

[0108] In an embodiment, the parsing of the labels in the network configuration file, if the path of the label is a leaf path, determining the label as a leaf label includes:

[0109] The network configuration file is parsed line by line to extract the leaf labels in each line until the network configuration file is parsed completely.

[0110] The specific details of each part of the above device have been described in detail in the method part embodiment, and the undisclosed details can be referred to the embodiment content of the method part, thus no longer elaborated.

[0111] It should be noted that although several modules or units of the device for action execution are mentioned in the above detailed description, such division is not mandatory. In fact, according to the example embodiment 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 embodied by multiple modules or units.

[0112] The example embodiment of the present disclosure also provides a computer program product. The computer program product includes a computer program which, when executed by a processor, implements the above-mentioned named entity recognition method.

[0113] In an embodiment, the computer program product can be a tangible product including the computer program, such as a computer-readable storage medium storing the computer program. The computer-readable storage medium can be a storage medium based on an electrical, magnetic, optical, electromagnetic, infrared, or the like signal, including but not limited to random access memory (RAM), read-only memory (ROM), magnetic tape, a floppy disk, Flash memory (Flash), a mechanical hard disk (HDD), a solid-state hard disk (SSD), and the like. For example, the computer program product can be implemented as a non-volatile storage medium, such as a read-only memory (ROM), a Nand Flash, or the like, storing the computer program.

[0114] In an embodiment, the computer program product can be an intangible product including the computer program. For example, the computer program product can be implemented as a virtual digital product, such as an executable file, an installation package, or the like, storing the computer program.

[0115] The code of the computer program can be written in one or more programming languages. The programming language can be, for example, C, Java, C++, or the like. 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 kind of network, such as a local area network (LAN), a wide area network (WAN), or the like, or can be connected to an external computing device (for example, through an Internet connection provided by an operator).

[0116] The computer program can be carried or transmitted by an electrical, magnetic, optical, electromagnetic, infrared, or the like signal. The electronic device can convert the signal carrying the computer program into a digital signal, and then run the computer program. When the computer program is running on the electronic device, its code is used to make the electronic device perform (more specifically, can make the processor of the electronic device perform) the method steps of various exemplary embodiments of the present disclosure, such as the following steps: step S110, obtaining a network configuration file, the network configuration file including data based on a YANG model; step S120, parsing a tag in the network configuration file, and if the path of the tag is a leaf path, determining the tag as a leaf tag; step S130, based on a mapping rule of a CLI command and a path, obtaining a first CLI command corresponding to the leaf path of the leaf tag; step S140, determining a second CLI command from the first CLI command by matching the first CLI command and the leaf tag; and step S150, determining a target CLI command corresponding to the network configuration file according to the second CLI command and the data of the leaf tag.

[0117] Based on the computer program, the above method is executed, and an efficient conversion scheme from a YANG model to a CLI command is provided. According to the data structure and constraints defined by the YANG model, a standard CLI command can be generated, thereby helping operation and maintenance, research and development management personnel and the like to batch process the configuration of network equipment, reducing manual operation, reducing human errors, and improving work efficiency. Different device manufacturers can be compatible, and the converted target CLI command can be correctly executed on the target device.

[0118] Exemplary embodiments of the present disclosure also provide an electronic device. The electronic device can 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] The following will be described with reference to Figure 5 Exemplary embodiments of the present disclosure are described in the form of a general computing device. It should be understood that ​ The electronic device 500 shown is merely an example and should not limit the function and use range of the embodiments of the present disclosure.

[0120] As ​ The electronic device 500 can include a processor 510, a memory 520, a bus 530, an I / O (input / output) interface 540, and a network adapter 550, as shown.

[0121] The memory 520 can include a volatile memory, such as a RAM 521, a cache unit 522, and a non-volatile memory, such as a ROM 523. The memory 520 can also include one or more program modules 524, such as an operating system, one or more application programs, other program modules, and program data, each of which or some combination thereof can include the implementation of a network environment. For example, the program modules 524 can include the modules in the above-described apparatus.

[0122] The processor 510 can include one or more processing units, such as an AP (Application Processor, application processor), a modem processor, a GPU (Graphics Processing Unit, graphics processor), an ISP (Image Signal Processor, image signal processor), a controller, an encoder, a decoder, a DSP (Digital Signal Processor, digital signal processor), a baseband processor, and / or an NPU (Neural-Network Processing Unit, neural network processor), etc.

[0123] The processor 510 can be configured to execute executable instructions stored in the memory 520, which can include method steps of various exemplary embodiments of the present disclosure, such as performing the following steps: step S110, obtaining a network configuration file, the network configuration file including data based on a YANG model; step S120, 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; step S130, based on a mapping rule of a CLI command and a path, obtaining a first CLI command corresponding to the leaf path of the leaf tag; step S140, determining a second CLI command from the first CLI command by matching the first CLI command and the leaf tag; and step S150, determining a target CLI command corresponding to the network configuration file according to the second CLI command and data of the leaf tag.

[0124] Based on the electronic device performing the above method, an efficient conversion scheme from a YANG model to a CLI command is provided, which can generate a CLI command conforming to a specification according to a data structure and constraints defined by the YANG model, thereby helping operation and maintenance, research and development management personnel, and the like to batch process configurations of network devices, reducing manual operations, reducing human errors, and improving work efficiency. And it can be compatible with different device manufacturers to ensure that the converted target CLI command can be executed correctly on the target device.

[0125] The bus 530 is configured to implement a connection between different components of the electronic device 500, and can 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 (such as 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, such as a network adapter 550 that can provide a mobile communication solution such as 3G / 4G / 5G, or provide a wireless communication solution such as a wireless local area network, 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 ​ Other hardware and / or software modules can also be provided in the electronic device 500, including but not limited to: a display, microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.

[0129] From the above, it can be seen that the technical solutions of the present disclosure can be implemented as a method, device, system, computer program product, storage medium, 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: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or an implementation combining hardware and software aspects, such as can be referred to as "circuitry", "module" or "system" respectively.

[0130] It should be understood that the present disclosure is not limited to the specific methods steps or structural aspects described above and illustrated in the drawings, and various modifications and changes can be made without departing from the scope thereof. Based on the specific embodiments provided by the present disclosure, those skilled in the art will easily think of other embodiments. 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 should cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or conventional technical means in the technical field not disclosed by the present disclosure. < / e> < / e> < / d> < / e> < / e> < / d> < / e> < / d> ​

Claims

1. A network configuration file processing method characterized by, The method comprises: 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 determining the label as a leaf label if a path of the label is a leaf path; obtaining a first command line interface (CLI) command corresponding to a leaf path of the leaf label based on a mapping rule of CLI commands and paths; determining a second CLI command from the first CLI command by matching the first CLI command and the leaf label; determining a target CLI command corresponding to the network configuration file according to the second CLI command and data of the leaf label; wherein the determining of the second CLI command from the first CLI command by matching the first CLI command and the leaf label comprises: extracting attributes in the first CLI command; and determining one or more first CLI commands as the second CLI command if a combination of attributes in the one or more first CLI commands matches all the leaf labels in the network configuration file; wherein 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 label comprises: filling the data of the leaf label into the second CLI command to obtain the target CLI command corresponding to the network configuration file.

2. The method of claim 1, wherein, In the mapping rule of CLI commands and paths, each path corresponds to one or more CLI commands; and the obtaining of the first CLI command corresponding to the leaf path of the leaf label based on the mapping rule of CLI commands and paths comprises: finding all CLI commands corresponding to the leaf path of the leaf label based on the mapping rule of CLI commands and paths, as the first CLI command.

3. The method of claim 1, wherein, The determining of the second CLI command from the first CLI command by matching the first CLI command and the leaf label further comprises: after the extraction of the attributes in the first CLI command, if there are attributes in the first CLI command that do not match the leaf label, determining that the first CLI command is not the second CLI command.

4. The method of claim 1, wherein, The combination of the attributes in the one or more first CLI commands matches all the leaf labels in the network configuration file, comprising: the attributes in the one or more first CLI commands one-to-one match all the leaf labels in the network configuration file; wherein there are no attributes in the one or more first CLI commands that do not match the leaf labels, and there are no labels in the leaf labels that do not match the attributes in the one or more first CLI commands.

5. The method according to any one of claims 1 to 4, characterized in that, The parsing of the label in the network configuration file, and the determination of the label as the leaf label if the path of the label is the leaf path, comprises: performing line-by-line parsing on the network configuration file to extract the leaf label in each line until the parsing of the network configuration file is completed.

6. A network profile processing apparatus characterized by comprising: The apparatus comprises: a file obtaining module configured to obtain a network configuration file, the network configuration file comprising data based on a YANG model; The file parsing module is configured to parse a label in the network configuration file, and determine the label as a leaf label if a path of the label is a leaf path. The first CLI command determining module is configured to obtain a first CLI command corresponding to a leaf path of the leaf label based on a mapping rule of CLI commands and paths. The second CLI command determining module is configured to determine a second CLI command from the first CLI command by matching the first CLI command and the leaf label. The target CLI command determining module is configured to determine a target CLI command corresponding to the network configuration file according to the second CLI command and data of the leaf label. The determining of the second CLI command from the first CLI command by matching the first CLI command and the leaf label includes: extracting attributes in the first CLI command; and determining one or more first CLI commands as the second CLI command if a combination of attributes in the one or more first CLI commands matches all the leaf labels in the network configuration file. 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 label includes: filling the data of the leaf label into the second CLI command to obtain the target CLI command corresponding to the network configuration file.

7. A computer program product comprising a computer program, characterized in that, The computer program, when executed by a processor, implements the method of any one of claims 1-5.

8. An electronic device, comprising: The computer program product comprises: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to implement the method of any one of claims 1-5 by executing the executable instructions. The computer program product comprises: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to implement the method of any one of claims 1-5 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