A General Configuration Difference Comparison Method and Device
By abstracting the configuration file into a tree structure and applying alignment, comparison, ignorance and summary rules, the problem of configuration differences verification in network management system upgrade is solved, and fast and accurate differences comparison and summary is achieved, supporting the engineering upgrade of the network management system.
Patent Information
- Application Number
- CN202210004512.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-04
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2042-01-04
AI Technical Summary
During the upgrade process of existing network management systems, it is difficult to check configuration differences, it is difficult to confirm the impact of upgrades, the configuration volume is large and the structure is complex, making it difficult for operation and maintenance personnel to effectively control the upgrade risks.
Abstract the configuration file into a tree structure, adopt alignment rules, comparison rules, ignoring rules and summary rules for differences comparison, generate a difference summary table, and provide flexible rule definitions to handle configuration compatibility scenarios.
It realizes fast, accurate and efficient configuration differences verification, which can filter invalid differences, helps engineering upgraders quickly determine important influencing factors, and is suitable for upgrading scenarios of network management systems and other scenarios that require comparison of tree structure configuration differences.
Smart Images

Figure CN114489723B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of network engineering operation and maintenance, and particularly to a general configuration difference comparison method and device. Background Art
[0002] With the development of the information age, higher and higher requirements are put forward for the network. The existing network operation and maintenance also encounter difficult challenges. Especially in the scenario of network management system upgrade, how to ensure forward compatibility of configurations and upgrade risk control is a very important matter. These scenarios are characterized by a large amount of configurations, complex configuration structures, complex compatibility solutions, etc. It is difficult for operation and maintenance personnel to confirm the impact of upgrade by checking the configuration differences before and after upgrade or configuration change. Based on the above situation, it is inevitable to develop a configuration verification tool to replace manual configuration verification.
[0003] In view of this, how to overcome the defects of the existing technology and solve the above technical problems is a difficult problem to be solved in this technical field. Summary of the Invention
[0004] In view of the above-mentioned defects or improvement requirements of the existing technology, the present invention provides a general configuration difference comparison method and device. The method classifies and abstracts common configuration formats into a tree structure, and then quickly, accurately, and efficiently verifies the tree structure configuration. The method provides flexible rule definitions to handle configuration compatibility scenarios, and also provides a difference summary table aimed at focusing on key differences.
[0005] The embodiments of the present invention adopt the following technical solutions:
[0006] In a first aspect, the present invention provides a general configuration difference comparison method, including:
[0007] Initialize the thread pool thread capacity and the comparison task queue, and regard each pair of original configurations to be compared as a comparison task;
[0008] Poll the number of idle threads in the thread pool, and use the idle threads to execute the comparison tasks;
[0009] After detecting that all the comparison tasks in the comparison task queue have been executed, output a difference summary table.
[0010] Further, it further includes reading comparison rules from a configuration file, and executing according to the comparison rules when using idle threads to execute comparison tasks, where the comparison rules include alignment rules, comparison rules, ignore rules, and summary rules.
[0011] Further, the use of idle threads to execute comparison tasks specifically includes:
[0012] Parse a pair of original configurations to be compared to generate a corresponding pair of configuration trees;
[0013] Execute alignment rules on two configuration trees to determine the matching nodes of the two configuration trees;
[0014] Execute comparison rules on the matched nodes;
[0015] Execute ignore rules on the unmatched nodes;
[0016] Output the differences between the two configuration trees being compared, and generate a difference summary table for the differences of each pair of configuration trees that have completed the comparison task according to the summary rules.
[0017] Furthermore, the parsing of a pair of original configurations to be compared to generate a corresponding pair of configuration trees specifically includes:
[0018] Parse the first original configuration into the first configuration tree;
[0019] Parse the second original configuration into the second configuration tree;
[0020] Wherein, each configuration tree includes a root node, child nodes, grandchild nodes, and any lower-level nodes.
[0021] Furthermore, the execution of alignment rules on two configuration trees to determine the matching nodes of the two configuration trees specifically includes:
[0022] Process the first configuration tree according to the alignment rules to generate sorting keys for all nodes of this configuration tree;
[0023] Process the second configuration tree according to the alignment rules to generate sorting keys for all nodes of this configuration tree;
[0024] Sort the nodes of the two configuration trees according to the sorting keys;
[0025] Alignment operation steps: Obtain an unprocessed node A on the first configuration tree and an unprocessed node B at the same depth as node A on the second configuration tree, and compare the sorting keys of node A and node B: A key and B key. If A key > B key, take the node immediately following node B as the new node B and repeat the comparison; if A key < B key, take the node immediately following node A as the new node A and repeat the comparison; if A key = B key, mark its matching node in node A as B, and mark its matching node in node B as A;
[0026] If A key = B key, take the subtrees of node A and node B and repeat the alignment operation steps, otherwise, the alignment process is completed until it fails to obtain an unprocessed node A or node B.
[0027] Further, the execution of the comparison rule on the matched nodes specifically includes:
[0028] Traverse the matched node A in the first configuration tree or the matched node B in the second configuration tree;
[0029] Use the method defined by the comparison rule to compare node A and its matched node B, and mark the comparison result; wherein, the method defined by the comparison rule includes: defining which fields in the node information are to be ignored during comparison, and all fields other than these fields will participate in the comparison.
[0030] Further, the execution of the ignore rule on the unmatched nodes specifically includes:
[0031] Process the nodes in the configuration tree that are not matched. Nodes that are not marked as matched will be marked as ignorable differences if they meet the definition of the ignore rule, otherwise they will be marked as differences that need attention. Ignorable differences will not be shown in the final summary, while differences that need attention will be shown in the final summary.
[0032] Further, the comparison rule further includes a fuzzy matching rule based on the alignment rule. The execution steps of the fuzzy matching rule specifically include:
[0033] Divide the first configuration tree into several node sets Set1N according to the matched nodes processed by the alignment rule, and divide the second configuration tree into several node sets Set2N, where node 1N and node 2N are matched nodes, and N is a natural number;
[0034] Fuzzy matching step: Obtain an unprocessed node A in Set1N and an unprocessed node B in Set2N, and perform a fuzzy matching algorithm on node A and node B. If the fuzzy matching is successful, mark the matched node of node A as B in node A, and mark the matched node of node B as A in node B;
[0035] Repeat the fuzzy matching step. When obtaining node A or node B fails, set N = N + 1 and re-execute until Set1N or Set2N is the last set.
[0036] Further, the definition of the summary rule includes: achieving summary by classifying the sorting key, and the difference summary table output by the summary rule is in html format.
[0037] On the other hand, the present invention provides a general configuration difference comparison device, specifically including: at least one processor and a memory. The at least one processor and the memory are connected through a data bus. The memory stores instructions that can be executed by the at least one processor. After the instructions are executed by the processor, they are used to complete the general configuration difference comparison method in the first aspect.
[0038] Compared with the prior art, the beneficial effects of the present invention are as follows: by abstracting the original configuration message into a configuration tree structure and then comparing the differences through various comparison rules, the configuration of the tree structure can be checked quickly, accurately and efficiently. The present invention can provide the ability to filter out invalid differences for the configuration tree structure through the ignore rule. In addition, it also provides the ability to summarize differences, which can quickly determine the most important influencing factors for engineering upgrades for engineering upgrade personnel. The present invention can provide strong support for the engineering upgrade application scenario of the network management system, and can also be applied to any scenario that requires comparing the configuration differences of tree structures. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the drawings required to be used in the embodiments of the present invention. Obviously, the following described drawings are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0040] Figure 1 It is a flowchart of a general configuration difference comparison method provided in Embodiment 1 of the present invention;
[0041] Figure 2 It is a specific flowchart of executing the comparison task with an idle thread provided in Embodiment 1 of the present invention;
[0042] Figure 3 It is an extended flowchart of step 202 provided in Embodiment 1 of the present invention;
[0043] Figure 4 It is a flowchart of the execution steps of the fuzzy matching rule provided in Embodiment 1 of the present invention;
[0044] Figure 5 It is an extended flowchart of step 203 provided in Embodiment 2 of the present invention;
[0045] Figure 6 It is an extended flowchart of step 205 provided in Embodiment 2 of the present invention;
[0046] Figure 7 It is a schematic structural diagram of a general configuration difference comparison device provided in Embodiment 3 of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0047] In order to make the objectives, technical solutions and advantages of the present invention clearer, the following further describes the present invention in detail with reference to the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0048] The present invention is an architecture of a specific function system. Therefore, in specific embodiments, the functional logic relationships of each structural module are mainly described, and the specific software and hardware implementation manners are not limited.
[0049] In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other. The present invention will be described in detail below with reference to the drawings and embodiments.
[0050] Embodiment 1:
[0051] As Figure 1 shown, the embodiment of the present invention provides a general method for comparing configuration differences, which is mainly used to abstract the configurations to be compared into a tree, and then apply alignment rules, comparison rules, and ignore rules to control the comparison process and filter out the invalid differences that do not need to be concerned about during the comparison of the two trees, and mark the key differences through the summary rule. The method includes the following steps.
[0052] Step 100: Initialize the thread capacity of the thread pool and the comparison task queue, and use each pair of original configurations to be compared as a comparison task. In this step, it is necessary to first read the number of logical CPUs of the current operating system, and the initialized thread capacity of the thread pool is the same as the number of CPUs to achieve the maximum parallelism.
[0053] Step 200: Poll the number of idle threads in the thread pool and use the idle threads to execute the comparison tasks. This step of this embodiment also has a pre-step: read the comparison rules from the configuration file so that when using the idle threads to execute the comparison tasks, they are executed according to the comparison rules. Among them, the comparison rules include alignment rules, comparison rules, ignore rules, and summary rules.
[0054] Step 300: After detecting that all the comparison tasks in the comparison task queue have been executed, output a difference summary table. This step is based on the polling comparison in Step 200 to detect the comparison task queue in real time. When all the comparison tasks in Step 200 are completed, this step detects that all the comparison tasks in the comparison task queue have been executed.
[0055] Through the above steps, this preferred embodiment can provide the ability to filter out invalid differences for the original configurations to be compared through the comparison rules. In addition, it also provides the ability to summarize differences, which can quickly determine the most important influencing factors for the engineering upgrade for the engineering upgrade personnel. This preferred embodiment can provide strong support for the engineering upgrade application scenario of the network management system.
[0056] As Figure 2 shown, in this preferred embodiment, the step of using the idle threads to execute the comparison tasks in Step 200 specifically includes the following steps.
[0057] Step 201: Parse a pair of original configurations to be compared to generate a corresponding pair of configuration trees.
[0058] Step 202: Execute alignment rules on the two configuration trees to determine the matching nodes of the two configuration trees. The alignment rules in this step are used to align the nodes at the same depth of the two trees to facilitate comparing the aligned nodes together.
[0059] Step 203: Execute comparison rules on the matched nodes. This step is mainly used to handle the problem of partial information masking in the nodes. The comparison rules are used for the aligned nodes.
[0060] Step 204: Execute ignore rules on the unmatched nodes. The ignore rules in this step are applied when no aligned node can be found for the left configuration or the right configuration.
[0061] Step 205: Output the differences between the two configuration trees being compared, and generate a difference summary table for the differences of each pair of configuration trees that have completed the comparison task according to the summary rules. The summary rules in this step are used to determine which differences to output in one difference report and to mark the differences that need to be focused on.
[0062] For the above Step 201, this step needs to first parse the original configuration, which may be any configuration with a tree structure, or binary data or text data. If it is text data, it is usually xml data or tree-shaped data organized by indentation. If it is binary, it is usually TLV data (Tag length value) or other defined private protocol data with a tree structure form. After parsing, the original configuration will generate a configuration tree. For example, parse the first original configuration into the first configuration tree; parse the second original configuration into the second configuration tree; where each configuration tree includes a root node, child nodes, grandchild nodes, and any lower-level nodes.
[0063] The configuration tree of this preferred embodiment has the following structure (Root represents the root node, C represents the child node, G represents the grandchild node):
[0064]
[0065] ……
[0066] The above configuration tree has the following characteristics: there is only one root node (Root). The root node has three child nodes, each child node has two grandchild nodes, and there can be any number of lower-level nodes under the grandchild nodes. We define the depth of the Root node as 0, the depth of the C1 - C3 nodes as 1, the depth of the G1 - G6 nodes as 2, and so on... Nodes with the same depth are called sibling nodes, and 1, 2, 3, 4, 5, 6... are the serial numbers of the sibling nodes. According to the above rules, we can use (node depth, node serial number) to describe the position of a node in the tree.
[0067] For step 202, which is the step of executing the alignment rule, we can set a unified root node for the configuration tree and consider that the root nodes of the two trees are aligned and equal. Then, when comparing two configuration trees, we usually hope to compare nodes with the same depth and whose parent nodes are already aligned together. For example: compare the child nodes (C1, C2, C3, with the parent node being Root) of the first configuration tree with the child nodes (C1, C2, C3, with the parent node being Root) of the second configuration tree, and compare the grandchild nodes (G3, G4, with the parent node being C2) of the first configuration tree with the grandchild nodes (G3, G4, with the parent node being C2) of the second configuration tree. However, there are usually multiple child and grandchild nodes in the two configuration trees, so an alignment rule is needed to specify which child and grandchild nodes from the two trees should be taken and compared together. For example, we can choose to align the C2 node of the first configuration tree with the C3 node of the second configuration tree, and the other nodes of the two trees are left unaligned. Usually, the alignment rule should specify on which node in the configuration tree it is applied and how to generate a sorting key based on the node information.
[0068] As Figure 3 shown, in this preferred embodiment, the above step 202 (executing the alignment rule on two configuration trees to determine the matching nodes) specifically includes the following steps.
[0069] Step 202 - 1: Process the first configuration tree according to the alignment rule to generate sorting keys for all nodes of this configuration tree.
[0070] Step 202 - 2: Process the second configuration tree according to the alignment rule to generate sorting keys for all nodes of this configuration tree.
[0071] Step 202 - 3: Sort the nodes of the two configuration trees according to the sorting keys. That is, adjust the order of sibling nodes on each tree in the order of the sorting key size.
[0072] Step 202-4 (Alignment operation step): Obtain an unprocessed node A on the first configuration tree and an unprocessed node B at the same depth as node A on the second configuration tree. Compare the sorting keys of node A and node B: A key and B key. If A key > B key, take the node immediately following node B as the new node B and repeat the comparison; if A key < B key, take the node immediately following node A as the new node A and repeat the comparison; if A key = B key, mark the matching node of node A as B and the matching node of node B as A in node A.
[0073] If A key = B key, take the subtree of node A and the subtree of node B and repeat the alignment operation step; otherwise, the alignment process is completed until the failure to obtain an unprocessed node A or node B. In the above process, since there is only one root node for each configuration tree, the root nodes of the two configuration trees are naturally aligned. For the child nodes below the root node, the alignment operation step is started. When the child nodes of the root node are aligned (i.e., A key = B key), take the child nodes of the aligned child nodes (i.e., the grandchildren of the root node) to continue the alignment operation step, and so on. In addition, for the unaligned child nodes, grandchildren, and other lower-level nodes below the root node, they are left empty and no further processing is performed. That is to say, only when the parent nodes are aligned, the child nodes of the parent nodes need to perform the alignment operation.
[0074] If the above step 202-4 of this preferred embodiment is described in terms of the specific process to be implemented, it is as follows:
[0075] Step 202-4-1: Obtain an unprocessed child node A of the root node of the first tree tree1. If the acquisition fails, stop step 202-4.
[0076] Step 202-4-2: Obtain an unprocessed child node B of the root node of the second tree tree2. If the acquisition fails, stop step 202-4.
[0077] Step 202-4-3: Compare the sorting keys of Node A and Node B. When A key > B key, take the node immediately following Node B as Node B and repeat this step; when A key < B key, take the node immediately following Node A as Node A and repeat this step; when A key == B key, mark the matching node in Node A as B, and mark the matching node in Node B as A. Then, select the subtree with A as the root node as tree1 and the subtree with B as the root node as tree2, and recursively execute steps 202-4-1 to 202-4-3. After the alignment operation between subtree tree1 and subtree tree2 is completed, restart the execution of step 202-4-1 (note that Node A / B is the unprocessed node selected, that is, the next sibling node, so this restart of the execution step is not a repeated operation).
[0078] In this preferred embodiment, the comparison rule further includes a fuzzy matching rule based on the alignment rule, and this fuzzy matching rule is an optional rule in this embodiment. Since in the process of algorithm implementation, we always hope to define as few alignment rules as possible to improve the tool efficiency, so we may hope to perform alignment operations on two nodes only when they are very similar.
[0079] Here is a classic example. The configuration of the network devices commonly used in the PTN network currently adopts the telnet command line format, and its configuration format is a standard hierarchical structure. After abstracting it into a configuration tree, each node is a standard English sentence. After passing through step 202, have all the nodes of the two configuration trees formed by the telnet command line been aligned? The answer is no. The reason is that for the algorithm to consider two nodes to be aligned, in addition to their parent nodes must be aligned, it is also necessary to compare the English sentences of the two nodes. Either the English sentences of the two nodes are the same, or the key information of the two nodes calculated through the alignment rule is the same. Two unaligned English nodes will give two differences instead of one difference, which will cause great interference when the two configuration differences are large.
[0080] Illustrate with Example D-1:
[0081] The information of node node1 with a depth of 2 in tree1 is: ip address 10.12.13.45 / 32.
[0082] The information of node node2 with a depth of 2 in tree2 is: ip address 10.56.13.45 / 32.
[0083] By defining alignment rules, the algorithm calculates that the key of node1 is "ip address" and the key of node2 is "ipaddress", so the algorithm considers node1 and node2 to be aligned. We must define alignment rules to handle the fuzzy alignment of these English sentences. And entering alignment rules is a complicated task. In practical applications, it is always hoped to enter fewer common alignment rules. Therefore, we provide another default alignment processing method, that is, the fuzzy matching method. Still using example D-1 to illustrate, if we do not define alignment rules but adopt the fuzzy matching method. We calculate the same words of node1 and node2, using the Longest common string algorithm, and the result is "ip address", with a length of 2 words. Both node1 and node2 have 3 words, and 2 / 3 > 50%, so the fuzzy matching is successful.
[0084] Based on the above description, as Figure 4 shown, the execution steps of the fuzzy matching rule of this preferred embodiment specifically include:
[0085] Step S1: Divide the first configuration tree into several node sets Set1N according to the matching nodes processed by the alignment rules, and divide the second configuration tree into several node sets Set2N. Among them, node 1N and node 2N are matching nodes, and N is a natural number. This step is based on that after step 202, the child nodes of any configuration tree node will be divided into several regions AreaSet by the aligned nodes, and each region is a node set Set (excluding the aligned nodes). So the child nodes of the root node of the first tree are divided into Set11 (aligned node 11), Set12 (aligned node 12)... Set1N (aligned node 1N, there may not be such a node), and the child nodes of the root node of the second tree are divided into Set21 (aligned node 21), Set22 (aligned node 22)... Set2N (aligned node 2N, there may not be such a node). Since node 1N and node 2N are in an alignment relationship, Set1N and Set2N are corresponding node sets. The subtrees with node 1N and node 2N as the root nodes still conform to the above rules. A traversal operation can be performed on all aligned nodes, and respectively take AreaSet1 (i.e., Set1N|N = 0,1,2...) and AreaSet2 (i.e., Set2N|N = 0,1,2...) of the currently traversed aligned nodes of the two trees.
[0086] Step S2 (Fuzzy Matching Step): Obtain an unprocessed node A in Set1N and an unprocessed node B in Set2N, and perform a fuzzy matching algorithm on node A and node B. If the fuzzy matching is successful, mark the matching node of node A as B in node A, and mark the matching node of node B as A in node B. Repeat this fuzzy matching step. When the acquisition of node A or node B fails, set N = N + 1 and then re - execute until Set1N or Set2N is the last set.
[0087] If the above step S2 of this preferred embodiment is described in terms of the specific process to be implemented, it is as follows:
[0088] S2 - 1: Obtain an unprocessed node A in Set1N. If the acquisition is successful, execute step S2 - 2; if the acquisition fails, set N = N + 1, and repeat this step until Set1N is the last set, then exit step S2.
[0089] S2 - 2: Obtain an unprocessed node B in Set2N. If the acquisition is successful, execute step S2 - 3; if the acquisition fails, set N = N + 1, and jump to step S2 - 1 until Set2N is the last set, then exit step S2.
[0090] S2 - 3: Perform a fuzzy matching algorithm on nodes A and B. If the fuzzy matching is successful, mark the matching node of node A as B in node A, and mark the matching node of node B as A in node B. Then jump to step S2 - 1 to continue recursive execution.
[0091] As Figure 5 shown, in this preferred embodiment, the above step 203 (Perform comparison rules on the matched nodes) specifically includes the following steps.
[0092] Step 203 - 1: Traverse the matched node A in the first configuration tree or the matched node B in the second configuration tree. The traversal method used is the post - order traversal method.
[0093] Step 203 - 2: Compare node A and its matched node B using the method defined by the comparison rules, and mark the comparison result (equal / not equal). Among them, the method defined by the comparison rules includes: defining which fields in the node information are to be ignored during comparison, and all fields other than these fields will participate in the comparison.
[0094] In this preferred embodiment, the above step 204 (executing the ignore rule on unmatched nodes) specifically includes: processing the nodes in the configuration tree that are not matched. Nodes without a marked match, if they meet the definition of the ignore rule, will be marked as ignorable differences, otherwise they will be marked as differences that need attention. Ignorable differences will not be shown in the final summary, while differences that need attention will be shown in the final summary. The definition method of the ignore rule includes: for the nodes that are not aligned in the two trees, after the ignore rule is defined, it will no longer be output in the final difference summary.
[0095] As Figure 6 shown, in this preferred embodiment, the above step 205 (outputting the differences between the two configuration trees being compared and generating a difference summary table for the differences of each pair of configuration trees that have completed the comparison task) specifically includes the following steps.
[0096] Step 205-1: Print the differences between the two trees being compared in a user-friendly manner according to the sorting key from largest to smallest. In this step, we can choose to output the differences in html format.
[0097] Step 205-2: For a large number of configurations to be compared, the differences of each pair of configuration trees will be output as a difference summary according to the summary rule. The summary rule in this step is for the sorting key generated by the sorting rule, and its definition method includes: achieving summarization by classifying the sorting key.
[0098] The above is the detailed description of this preferred embodiment. It should also be noted that for the format of the rule definitions selected in this embodiment, all the rule definitions are in xml format, using the same tree structure as the original configuration to specify the tree nodes to which the rules apply. The positioning information of each level of nodes can use a fuzzy matching algorithm. In addition, the alignment rule, comparison rule, and summary rule can use any custom algorithm. The fuzzy matching algorithm and these custom algorithms of the rules can all be implemented using regular expressions.
[0099] In summary, the embodiment of the present invention abstracts the original configuration message into a configuration tree structure, and then performs difference comparison through various comparison rules, which can quickly, accurately, and efficiently check the tree structure configuration. The present invention can provide the ability to filter out invalid differences for the configuration tree structure through the ignore rule. In addition, it also provides the ability to summarize differences, which can quickly determine the most important influencing factors for engineering upgrades for engineering upgrade personnel. The present invention can provide strong support for the engineering upgrade application scenario of the network management system, and can also be applicable to any scenario that needs to compare the differences in tree structure configurations.
[0100] Embodiment 2:
[0101] Based on the general configuration difference comparison method provided in Embodiment 1, in this Embodiment 2, a specific example is used to illustrate the comparison and summary output of differences.
[0102] In this embodiment, it is assumed that there are an original configuration config1 (file name: 690_1) and an original configuration config2 (file name: 690_1), and their contents are as follows:
[0103] Config1:
[0104] interface GE0 / 1 / 0 / 6 ---- No alignment rule is defined, and its key is itself
[0105] ip address 10.12.13.56 ---- An alignment rule is defined, and its key is ip address
[0106] as am alarm mask 123456 ---- No alignment rule is defined, and its key is itself
[0107] List in table
[0108] config2:
[0109] alarm mask HTENGKL ---- No alignment rule is defined, and its key is itself
[0110] as am alarm mask 89262 ---- No alignment rule is defined, and its key is itself
[0111] arp interface GE2 ---- No alignment rule is defined, and its key is itself
[0112] interface GE0 / 1 / 0 / 6 ---- No alignment rule is defined, and its key is itself
[0113] ip address 10.12.13.89 ---- An alignment rule is defined, and its key is ip address
[0114] After the above pair of original configurations are abstracted into a configuration tree and alignment operations, they are as follows:
[0115] After fuzzy matching, the results are as follows:
[0116]
[0117] If we define an ignore rule to not display the differences in "List in table" (the differences can be divided into those unique to the left, those unique to the right, and those present on both sides; here, it belongs to the differences unique to the left), then this will not display "List in table" in the file comparison results.
[0118] If we define a comparison rule to ignore the parameters after "ip address" (i.e., not check for differences in the XX.XX.XX.XX ip addresses), then this will not display "ip address" in the file comparison results.
[0119] The final result is:
[0120]
[0121] Table 1: Differences in the first pair of configuration files (the names of each pair of files are the same)
[0122] The above are the differences output from the comparison of a pair of original configurations. Similarly, the differences for the comparison of each other pair of original configurations can be output in the above manner.
[0123] Taking the differences in the second pair of configuration files as an example, assume the differences are as follows:
[0124]
[0125] Table 2: Differences in the second pair of configuration files (the names of each pair of files are the same)
[0126] Finally, we can obtain a summary table from Table 1 and Table 2. Now assume we define the following summary rules:
[0127] (1) The alarm mask commands of the 690 device are counted as one category.
[0128] (2) The as am alarm mask commands of the 690 device are counted as one category.
[0129] (3) The Interface commands are counted as one category.
[0130] Then the summary table we can obtain is as follows:
[0131]
[0132]
[0133] Table 3: Statistical summary table (the names of each pair of files are the same)
[0134] The above is an example description of this embodiment. It can be seen that this embodiment provides the ability to summarize differences, which can quickly determine the most important influencing factors for engineering upgrades for engineering upgrade personnel. And this embodiment can provide the ability to filter out invalid differences for the configuration tree structure through the ignore rule.
[0135] Embodiment 3:
[0136] Based on the general configuration difference comparison method provided in Embodiment 1 above, the present invention further provides a general configuration difference comparison device that can be used to implement the above method and system, as Figure 7 shown, which is a schematic diagram of the device architecture of an embodiment of the present invention. The general configuration difference comparison device of this embodiment includes one or more processors 21 and a memory 22. Among them, Figure 7 Take one processor 21 as an example.
[0137] The processor 21 and the memory 22 can be connected through a bus or other means, Figure 7 Take the connection through the bus as an example.
[0138] The memory 22, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as the general configuration difference comparison method in Embodiment 1. The processor 21 executes various functional applications and data processing of the general configuration difference comparison device by running the non-volatile software programs, instructions, and modules stored in the memory 22, that is, implements the general configuration difference comparison method of Embodiment 1.
[0139] The memory 22 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other non-volatile solid-state storage devices. In some embodiments, the memory 22 may optionally include a memory remotely provided with respect to the processor 21, and these remote memories may be connected to the processor 21 through a network. Examples of the above networks include but are not limited to the Internet, enterprise intranets, local area networks, mobile communication networks, and combinations thereof.
[0140] The program instructions / modules are stored in the memory 22 and, when executed by one or more processors 21, execute the general configuration difference comparison method in Embodiment 1 above. For example, execute the Figures 1-6 each step shown above.
[0141] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the embodiments can be completed by instructing relevant hardware through a program, and the program can be stored in a computer-readable storage medium. The storage medium can include: Read Only Memory (abbreviated as ROM), Random Access Memory (abbreviated as RAM), magnetic disks, optical disks, etc.
[0142] The above are only the preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.
Claims
1. A general method for comparing configuration differences, characterized in that, Including: Initialize the thread pool thread capacity and the comparison task queue, and regard each pair of original configurations to be compared as a comparison task; Poll the number of idle threads in the thread pool and use the idle threads to execute the comparison tasks; After detecting that all comparison tasks in the comparison task queue have been executed, output a difference summary table; The method further includes reading comparison rules from a configuration file and executing according to the comparison rules when using idle threads to execute comparison tasks. Among them, the comparison rules include alignment rules, comparison rules, ignore rules, and summary rules; The specific process of using idle threads to execute comparison tasks includes: parsing the first original configuration into the first configuration tree; parsing the second original configuration into the second configuration tree; where each configuration tree includes a root node, sub-nodes, grandchild nodes, and any lower-level nodes; process the first configuration tree according to the alignment rule to generate a sorting key for all nodes of this configuration tree; process the second configuration tree according to the alignment rule to generate a sorting key for all nodes of this configuration tree; sort the nodes of the two configuration trees according to the sorting key; execute the comparison rule on the matched nodes; execute the ignore rule on the unmatched nodes; output the differences between the two configuration trees being compared, and generate a difference summary table for the differences of each pair of configuration trees that have completed the comparison task according to the summary rule. Among them, the definition method of the ignore rule includes: for the nodes that are not aligned in the two trees, no output will be made in the final difference summary table after the ignore rule is defined.
2. The general configuration difference comparison method according to claim 1, characterized in that Alignment operation steps: Obtain an unprocessed node A on the first configuration tree and an unprocessed node B at the same depth as node A on the second configuration tree, and compare the sorting keys of node A and node B: A key and B key. If A key > B key, take the node after node B as the new node B and repeat the comparison; if A key < B key, take the node after node A as the new node A and repeat the comparison; if A key = B key, mark its matching node as B in node A and mark its matching node as A in node B; If A key = B key, take the subtree of node A and the subtree of node B and repeat the alignment operation steps, otherwise, the alignment process is completed until the acquisition of unprocessed node A or node B fails.
3. The general configuration difference comparison method according to claim 1, wherein The specific execution of the comparison rule on the matched nodes includes: Traverse the matched node A in the first configuration tree or the matched node B in the second configuration tree; Compare node A and its matched node B using the method defined by the comparison rule and mark the comparison result; among them, the method defined by the comparison rule includes: defining which fields in the node information are to be ignored during comparison, and all fields other than these fields will participate in the comparison.
4. The general configuration difference comparison method according to claim 1, wherein The specific execution of the ignore rule on the unmatched nodes includes: Nodes that do not match in the processing configuration tree. Nodes without marked matches, if they meet the definition of the ignore rule, will be marked as ignorable differences, otherwise they will be marked as differences that need attention. Ignorable differences will not be shown in the final summary, while differences that need attention will be shown in the final summary.
5. The general configuration difference comparison method according to claim 1, characterized in that The comparison rule further includes a fuzzy matching rule based on the alignment rule. The specific execution steps of the fuzzy matching rule are as follows: Divide the first configuration tree into several node sets Set1N according to the matching nodes processed by the alignment rule, and divide the second configuration tree into several node sets Set2N, where node 1N and node 2N are matching nodes, and N is a natural number; Fuzzy matching step: Obtain an unprocessed node A in Set1N and an unprocessed node B in Set2N, and perform a fuzzy matching algorithm on node A and node B. If the fuzzy matching is successful, mark its matching node as B in node A, and mark its matching node as A in node B; Repeat the fuzzy matching step. When obtaining node A or node B fails, set N = N + 1 and execute again until Set1N or Set2N is the last set.
6. The general configuration difference comparison method according to any one of claims 1-5, characterized in that The definition of the summary rule includes: realizing the summary by classifying the sorting key, and the difference summary table output by the summary rule is in html format.
7. A general configuration difference comparison device, characterized in that: It includes at least one processor and a memory. The at least one processor and the memory are connected through a data bus. The memory stores instructions executable by the at least one processor. After the instructions are executed by the processor, they are used to complete the general configuration difference comparison method described in any one of claims 1-6.
Citation Information
Patent Citations
Concurrent task processing method and device, computer equipment and storage medium
CN110990142A
Line trace batch comparison system based on multi-strategy mode
CN111639664A