Command line checking method and apparatus

By receiving, converting, and matching configuration commands input by users, the problem of repetitive checks under network device configuration delays is solved, achieving efficient configuration command checks and improving development efficiency.

CN114564182BActive Publication Date: 2025-11-07NEW H3C TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210111607.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-29
Publication Date
2025-11-07
Estimated Expiration
2042-01-29

AI Technical Summary

Technical Problem

In existing technologies, when network devices have configurations that take effect with a delay, service modules need to check configuration commands multiple times, resulting in a huge workload and repetitive tasks.

Method used

By receiving configuration commands input by the user, converting them into complete configuration commands under the view path, performing command rule matching, marking elements to be replaced, and replacing them with replaceable command elements, checking whether there is a match in the already issued text configuration files, and determining whether the configuration command can be issued.

Benefits of technology

This feature enables immediate checks on the deployability of configuration commands in delayed-effectiveness mode, reducing the workload of repetitive checks in business modules and improving development efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114564182B_ABST
    Figure CN114564182B_ABST
Patent Text Reader

Abstract

The application provides a command line checking method and device, the method comprising: receiving a configuration command input by a user through a command line interface, the configuration command comprising a command element; converting the configuration command into a complete configuration command under a view path, the complete configuration command comprising the command element input by the user; performing command rule matching on the complete configuration command, and obtaining a to-be-checked configuration command having a specified relationship type with the complete configuration command, and marking a to-be-replaced element in the to-be-checked configuration command; replacing the to-be-replaced element with the command element to obtain a replaced to-be-checked configuration command; searching for whether a text configuration file matching the replaced to-be-checked configuration command exists in a text configuration file that has been issued; if the text configuration file exists, determining that the replaced to-be-checked configuration command is a deliverable configuration command; and if the text configuration file does not exist, determining that the replaced to-be-checked configuration command is a non-deliverable configuration command, and displaying prompt information.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of communication, in particular to a command line checking method and device. BACKGROUND

[0002] A command line interface (CLI) is a text-based command interaction interface between a user and a network device. The user inputs a text-based command and presses the enter key, and the network device executes the corresponding command after receiving the text-based command, thereby realizing the configuration and management of the network device by the user, and the configuration result can be confirmed by viewing the output information.

[0003] The network device is configured and managed through the command line, including two effective modes, one of which is immediate effect of configuration, and the other is delayed effect of configuration. Immediate effect means that the configuration issued through the command line takes effect in real time. For example, after inputting the command line interface to create a VLAN or an interface, the user views that the specified VLAN or interface has been created in the network device by clicking the enter key after inputting the command. Delayed effect means that the configuration issued through the command line does not take effect immediately, and after multiple or a certain amount of configurations are issued, the user inputs a commit command to issue multiple or a certain amount of configurations in batches.

[0004] As shown in Figure 1 , Figure 2 , and Figure 1 is a flowchart of the existing command line configuration immediate effect issuing process; Figure 2 is a flowchart of the existing command line configuration delayed effect issuing process. The command line configuration delayed effect issuing can enable the user to check whether the configuration to be effective is correct and whether the configuration to be effective will have an impact on the currently running network, etc.

[0005] However, when issuing in batches by inputting the commit command, there may be conflicts, dependencies, locking restrictions or resource upper limit problems between the delayed effect configurations and the already effective configurations, resulting in actual issuing failure.

[0006] In the existing scheme, the mutual relationship between the delayed effect configurations can be checked by a candidate configuration library to avoid configuration failure when the commit command is actually issued. The candidate configuration library can transmit the delayed effect configurations to the corresponding business module, which performs unified checking, and feeds back the checking result to the candidate configuration library.

[0007] The above scheme has simple logic, but has huge workload. Since the service module also checks the delayed effective configuration again in the actual issuing process, after the candidate configuration library transmits the delayed effective configuration to the service module, the service module moves the original background processing logic of each feature forward and re-implements it, which has large workload and is repetitive work. SUMMARY

[0008] Therefore, the application provides a command line checking method and device to solve the problem that the service module checks the delayed effective configuration multiple times, resulting in huge workload and repetitive work of the service module.

[0009] In a first aspect, the application provides a command line checking method, which comprises:

[0010] receiving a configuration command input by a user through a command line interface, the configuration command comprising a command element input by the user;

[0011] converting the configuration command into a complete configuration command under a view path, the complete configuration command comprising a replaceable command element and the command element input by the user;

[0012] performing command rule matching on the complete configuration command, obtaining a to-be-checked configuration command having a specified relationship type with the complete configuration command, and marking a to-be-replaced element from the to-be-checked configuration command;

[0013] replacing the to-be-replaced element with the replaceable command element and the command element input by the user to obtain a replaced to-be-checked configuration command;

[0014] checking whether a text configuration file matching the replaced to-be-checked configuration command exists in a text configuration file that has been issued;

[0015] if the text configuration file exists, determining that the replaced to-be-checked configuration command is a deliverable configuration command;

[0016] if the text configuration file does not exist, determining that the replaced to-be-checked configuration command is an undeliverable configuration command, and displaying prompt information.

[0017] In a second aspect, the application provides a command line checking device, which comprises:

[0018] a receiving unit configured to receive a configuration command input by a user through a command line interface, the configuration command comprising a command element input by the user;

[0019] a converting unit configured to convert the configuration command into a complete configuration command under a view path, the complete configuration command comprising the command element input by the user;

[0020] The acquisition unit is configured to perform command rule matching on the complete configuration command, and acquire a to-be-checked configuration command having a specified relationship type with the complete configuration command, and mark a to-be-replaced element from the to-be-checked configuration command;

[0021] The replacement unit is configured to replace the to-be-replaced element with the command element input by the user to obtain a replaced to-be-checked configuration command.

[0022] The finding unit is configured to find, from the already-downloaded text configuration file, whether there is a text configuration file matching the replaced to-be-checked configuration command.

[0023] The determination unit is configured to determine that the replaced to-be-checked configuration command is a down-loadable configuration command if there is.

[0024] The determination unit is further configured to determine that the replaced to-be-checked configuration command is a non-down-loadable configuration command if there is not, and display prompt information.

[0025] In a third aspect, the present application provides a network device, comprising a processor and a machine readable storage medium, the machine readable storage medium stores machine executable instructions capable of being executed by the processor, and the processor is prompted by the machine executable instructions to execute the method provided in the first aspect of the present application.

[0026] Therefore, by applying the command line checking method and device provided in the present application, the network device receives a configuration command input by a user through a command line interface, the configuration command comprising a replaceable command element and a command element input by the user; the network device converts the configuration command into a complete configuration command under a view path, the complete configuration command comprising the command element input by the user; the network device performs command rule matching on the complete configuration command, and acquires a to-be-checked configuration command having a specified relationship type with the complete configuration command, and marks a to-be-replaced element from the to-be-checked configuration command; the network device replaces the to-be-replaced element with the replaceable command element and the command element input by the user to obtain a replaced to-be-checked configuration command; the network device finds, from the already-downloaded text configuration file, whether there is a text configuration file matching the replaced to-be-checked configuration command; if there is, the network device determines that the replaced to-be-checked configuration command is a down-loadable configuration command; if there is not, the network device determines that the replaced to-be-checked configuration command is a non-down-loadable configuration command, and displays prompt information.

[0027] Thus, the network device can immediately check the configuration command input by the user after receiving the configuration command, without transmitting the configuration command to the service module, thereby solving the problem that the service module repeatedly checks the delayed effective configuration, resulting in a huge workload of the service module and repetitive work. The constraint relationship between different configuration commands is checked in the command line delayed configuration effective mode, the workload of the constraint relationship between different configuration commands developed in the original language (C language) is reduced, and the development efficiency is improved. BRIEF DESCRIPTION OF DRAWINGS

[0028] Figure 1 a flowchart of an existing command line issued configuration immediate effective process;

[0029] Figure 2 a flowchart of an existing command line issued configuration delayed effective process;

[0030] Figure 3 a flowchart of a command line checking method provided by an embodiment of the present application;

[0031] Figure 4 a structure diagram of a decision tree generation device provided by an embodiment of the present application;

[0032] Figure 5 a network device hardware structure provided by an embodiment of the present application. DETAILED DESCRIPTION

[0033] The exemplary embodiments will be described in detail herein with reference to the attached drawings. In the following description, the same numbers are used to indicate the same components in different drawings. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of the present application as detailed in the appended claims.

[0034] The terms used in the present application are merely for the purpose of describing particular embodiments and are not intended to limit the present application. The singular forms "a," "an," and "the" used in the present application and the appended claims are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used in the present application means and includes any or all possible combinations of one or more corresponding listed items.

[0035] It should be understood that, although the terms first, second, third, etc. can be employed in this application to describe various information, these information should not be limited to these terms. These terms are only used to distinguish one type of information from another type of information. For example, without departing from the scope of the present application, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as the first information. Depending on the context, the word "if" as used herein can be interpreted as "when" or "upon determination" or "in response to determining".

[0036] The command line checking method provided by the embodiments of the present application will be described in detail below. Referring to Figure 3 , Figure 3 The flow chart of the command line checking method provided by the embodiments of the present application. The method is applied to a network device. The command line checking method provided by the embodiments of the present application can include the following steps.

[0037] Step 310, receiving a configuration command input by a user through a command line interface, the configuration command including a command element input by the user.

[0038] Specifically, the user inputs a configuration command to the network device through the command line interface. The configuration command includes a command element input by the user. The network device receives the configuration command.

[0039] For example, the user inputs opcode 1 end-dx2 xconnect-group name1 connection name2 through the command line interface. Wherein, name1, name2 can be specifically a command element input by the user.

[0040] Step 320, converting the configuration command into a complete configuration command under a view path, the complete configuration command including a replaceable command element and the command element input by the user.

[0041] Specifically, according to the description of step 320, after receiving the configuration command, the network device converts the configuration command into a complete configuration command under a view path. The complete configuration command includes a command element input by the user.

[0042] According to the foregoing example, after receiving opcode 1 end-dx2 xconnect-group name1 connection name2, the network device converts the configuration command into a complete configuration command under a view path:

[0043] Segment-routing ipv6;locator g;

[0044] opcode 1 end-dx2 xconnect-group name1 connection name2

[0045] In the complete view path, the paths are separated by a semicolon ';', and there must be spaces before and after the separator semicolon. Single spaces are strictly used to separate command elements. Otherwise, the subsequent python script cannot be parsed. The above complete configuration command indicates that under the segment-routing ipv6 view, the "opcode 1 end-dx2 xconnect-group name1 connection name2" command is under the locator view command.

[0046] As described above, the complete configuration command includes replaceable command elements g and user input command elements name1 and name2.

[0047] It should be noted that the process of converting the configuration command into the complete configuration command under the view path by the network device can refer to the existing conversion process, which is not repeated here.

[0048] Step 330, performing command rule matching on the complete configuration command, and obtaining a to-be-checked configuration command having a specified relationship type with the complete configuration command, and marking a to-be-replaced element from the to-be-checked configuration command.

[0049] Specifically, according to the description of step 320, after the network device obtains the complete configuration command, the network device performs command rule matching on the complete configuration command, and obtains a to-be-checked configuration command having a specified relationship type with the complete configuration command.

[0050] The network device marks the to-be-replaced element from the to-be-checked configuration command.

[0051] Further, the process of performing command rule matching on the complete configuration command by the network device is specifically: using a python script (a programming language), the network device performs string analysis on the complete configuration command, and determines the positions of the user input command elements and the replaceable command elements in the complete configuration command.

[0052] The process that the network device acquires the to-be-checked configuration command having the specified relationship type with the complete configuration command specifically includes: the network device acquires, by using a JS object notation (English: JavaScript Object Notation, referred to as: json) script, a plurality of rule files having the specified relationship type with the complete configuration command, and each rule file includes at least one to-be-checked configuration command. The specified relationship type specifically includes a dependency (depend on) relationship, a conflict (conflict) relationship, and a lock (locked) relationship, and the at least one to-be-checked configuration command includes specifically an and relationship and an or relationship.

[0053] The process that the network device marks the to-be-replaced element from the to-be-checked configuration command specifically includes: according to the position of the command element input by the user in the complete configuration command and the position of the replaceable command element in the complete configuration command, the network device parses a string of the to-be-checked configuration command by using a python script, and marks the to-be-replaced element from the to-be-checked configuration command.

[0054] According to the foregoing example, the complete configuration command is:

[0055] Segment-routing ipv6;locator g;

[0056] opcode 1 end-dx2 xconnect-group name1 connection name2

[0057] The network device parses a string of the foregoing complete configuration command by using a python script. The network device determines the position of the command element name1, name2 input by the user in the complete configuration command and the position of the replaceable command element g in the complete configuration command. The network device indicates the positions of name1, name2 and g by using {*}. As follows:

[0058] Segment-routing ipv6;locator{*}{*$};

[0059] opcode*end-dx2 xconnect-group{*}connection{*}

[0060] The network device acquires, by using a json script, a rule file having a dependency relationship with the complete configuration command, a rule file having a conflict relationship with the complete configuration command, and a rule file having a lock relationship with the complete configuration command. Taking the rule file having the dependency relationship as an example for description.

[0061]

[0062] {"segment-routing ipv6; locator { *} ipv6-prefix static { *}": "Invalid opcode. Please specify a valid static length."}

[0063] {"xconnect-group {2*}; connection {3*}": "^% Wrong parameter found at '^' position."} are two to-be-checked configuration commands. Since the two to-be-checked configuration commands are referenced by the brackets "[]", it indicates that the locator command under the segment-routing ipv6 view depends on the two to-be-checked configuration commands, and the two to-be-checked configuration commands are in a with relationship.

[0064] According to the position of the user input command element in the complete configuration command and the position of the replaceable command element in the complete configuration command, the network device uses a python script to parse the string of the to-be-checked configuration command, marks the to-be-replaced element in the to-be-checked configuration command, and marks it as { *}, {2*} and {3*}.

[0065] Step 340, replacing the to-be-replaced element with the replaceable command element and the user input command element to obtain a replaced to-be-checked configuration command.

[0066] Specifically, according to the description of step 330, the network device marks the to-be-replaced element from the to-be-checked configuration command, and then replaces the to-be-replaced element with the replaceable command element and the user input command element.

[0067] According to the foregoing example, the network device replaces { *}, {2*} and {3*} marked in the two to-be-checked configuration commands with g, name1 and name2 respectively. As follows:

[0068] {"segment-routing ipv6; locator { *} ipv6-prefix static { *}": "Invalid opcode. Please specify a valid static length."}

[0069] {"xconnect-group name1; connection name2": "^% Wrong parameter found at '^' position."}

[0070] Further, the network device further marks the command elements that can be converted into regular expressions from the two to-be-checked configuration commands.

[0071] The network device converts the command elements that can be converted into regular expressions into regular expressions to obtain the replaced to-be-checked configuration commands. As follows:

[0072] {"segment-routing ipv6;locator g ipv6-prefix(\S+)(\S+)static{.*}":"Invalid opcode. Please specify a valid static length."}

[0073] {"xconnect-group name1;connection name2":"^\n%Wrong parameter foundat'^'position."}

[0074] The regular expression is a logical formula for string operation, that is, a "rule string" is composed of some specific characters and combinations of the specific characters, and the "rule string" is used to express a filtering logic for a string.

[0075] Step 350: Check whether there is a text configuration file matching the replaced to-be-checked configuration command from the text configuration files that have been issued.

[0076] Specifically, according to the description of step 340, after obtaining the replaced to-be-checked configuration command, the network device checks whether there is a matching text configuration file from the text configuration files that have been issued.

[0077] If there is a matching text configuration file, step 360 is performed; if there is no matching text configuration file, step 370 is performed.

[0078] Step 360: If there is, it is determined that the replaced to-be-checked configuration command is a configuration command that can be issued.

[0079] Specifically, according to the description of step 350, if there is a matching text configuration file in the text configuration files that have been issued, the network device determines that the replaced to-be-checked configuration command is a configuration command that can be issued.

[0080] Step 370, if not, determining that the replaced configuration command to be checked is a configuration command that cannot be issued, and displaying prompt information.

[0081] Specifically, according to the description of step 350, if there is no matching text configuration file in the issued text configuration file, the network device determines that the replaced configuration command to be checked is a configuration command that cannot be issued, and displays prompt information. The specific content of the prompt information is in the replaced configuration command to be checked. The specific content of the prompt information is as follows.

[0082] "Invalid opcode. Please specify a valid static length.", "Wrong parameter found at '^' position."

[0083] Therefore, by applying the command line checking method provided in the present application, the network device receives a configuration command input by a user through a command line interface, the configuration command including a command element input by the user; the network device converts the configuration command into a complete configuration command under a view path, the complete configuration command including the command element input by the user; the network device performs command rule matching on the complete configuration command, and obtains a configuration command to be checked having a specified relationship type with the complete configuration command, and marks a replacement element in the configuration command to be checked; the network device replaces the replacement element with the command element input by the user to obtain a replaced configuration command to be checked; the network device searches from an issued text configuration file to find whether there is a text configuration file matching the replaced configuration command to be checked; if there is, the network device determines that the replaced configuration command to be checked is a configuration command that can be issued; if not, the network device determines that the replaced configuration command to be checked is a configuration command that cannot be issued, and displays prompt information.

[0084] In this way, after the network device receives a configuration command input by a user, the configuration command can be immediately checked, without being transmitted to a service module, thereby solving the problem that the service module repeatedly checks a configuration with a delay effect, resulting in a huge workload of the service module and repetitive work. The constraint relationship checking between different configuration commands in a delay configuration effect mode of a command line is implemented, the workload of developing the constraint relationship checking between different configuration commands in a native language (C language) is reduced, and the development efficiency is improved.

[0085] Optionally, in the embodiment of the present application, the foregoing steps 310-370 can be executed by a command static checking module included in the network device.

[0086] Optionally, in the embodiment of the present application, the foregoing steps 310-370 are executed under the following premise.

[0087] Specifically, 1) for configurations that have been actually issued and configurations with delayed effects, network devices can generate complete text configuration files; 2) the configuration commands to be checked must be reflected in the text configuration file, such as one or more specific configurations; 3) the command static checking module can use custom Python scripts or JSON scripts for checking, or rule files defined by the business module and checked through the framework. In practical applications, rule file checking is preferred. When rule files cannot be used for checking, custom Python scripts or JSON scripts can be used. When the framework checks, rule file checking is preferred; if the rule file does not exist or is not checked, custom Python scripts or JSON scripts are used for checking.

[0088] Optionally, in this embodiment, a Python script is used to parse the strings included in the command, and a JSON script defines a rule file.

[0089] Optionally, in this embodiment, the rule file uses the standard JSON format. The content is as follows:

[0090] "Relationship Type":

[0091]

[0092]

[0093] In the JSON format, all types and objects are separated by a colon ":".

[0094] "Relationship Type": Supports three types: "dependon", "conflict", and "locked", representing dependency, conflict, and locking relationship types, respectively. A rule file includes one relationship type. Configuration commands to be checked for the same relationship type are placed below that relationship type and enclosed in square brackets "[]". The "dependency" relationship type means that configuring command 'a' requires command 'b' to exist; the "conflict" relationship type means that configuring command 'a' will fail if command 'b' exists; the "locked" relationship type means that undoing command 'a' will fail if command 'b' exists.

[0095] "User Input Command" indicates that configuration commands are received from user input. The configuration commands under the subview are automatically populated with the complete view path name by the CLI framework, and separated by semicolons.

[0096] "Command depended by user input command" means the content depended by the user input configuration command to be checked, which can be found in the.cfg text configuration file. If the "command depended by user input command" contains multiple configuration commands to be checked, the multiple configuration commands to be checked are enclosed by square brackets. If the "command depended by user input command" contains only one configuration command to be checked, the square brackets are not needed.

[0097] "Prompt information of check failure" means the prompt information displayed to the user when the configuration command to be checked fails.

[0098] The following gives multiple rule files in json format.

[0099] Example 1:

[0100]

[0101] Among them, ① and ② are placed in the same square bracket "[]", indicating that the interface view isis ipv6 enable command depends on two configuration commands to be checked, and ① and ② are and relationship.

[0102] Example 2:

[0103]

[0104]

[0105] Among them, ① and ② are placed in the same curly bracket "{}", indicating that the interface view isis command depends on any one of the two configuration commands to be checked, and ① and ② are or relationship. The ① and ② are separated by a comma.

[0106] "interface{*};isis{*$}" indicates that "{*}" in "interface{*}" needs to be replaced by the interface name in the user input configuration command; "{*$}" in "isis{*$}" indicates matching any isis command starting from the "isis" position.

[0107] Example 3:

[0108]

[0109] Among them, the above rule file includes three configuration commands to be checked. ①a, ①b and ②, ① and ② are and relationship; ①a and ①b are or relationship.

[0110] Example 4:

[0111]

[0112]

[0113] Among the above rule files, 3 elements to be replaced are included, numbered as 1, 2 and 3 from front to back.

[0114] The second and third elements to be replaced in the following to-be-checked configuration command corresponding to "segment-routing ipv6;locator{*}{*$};opcode*end-dx2 xconnect-group{*}connection{*}" need to be replaced:

[0115] "xconnect-group{2*};connection{3*}"

[0116] The following to-be-checked configuration command does not specify a number, and the replacement starts from the first element to be replaced:

[0117] "segment-routing ipv6;locator{*}ipv6-prefix**static{*$}"

[0118] Example 5:

[0119]

[0120] Among them, "opcode*(end-dt4|end-dt46|end-dt6)vpn-instance{*}" indicates that it can match multiple to-be-checked configuration commands at the same time, and can match the following to-be-checked configuration commands:

[0121] opcode id end-dt4 vpn-instance vpn-name

[0122] opcode id end-dt46 vpn-instance vpn-name

[0123] opcode id end-dt6 vpn-instance vpn-name

[0124] Based on the same inventive concept, the embodiments of the present application also provide a command line checking method corresponding to the command line checking method. Referring to Figure 4 , Figure 4 The command line checking device provided by the embodiments of the present application comprises:

[0125] The receiving unit 410 is configured to receive a configuration command input by a user through a command line interface, wherein the configuration command comprises command elements input by the user.

[0126] The conversion unit 420 is configured to convert the configuration command into a complete configuration command under a view path, the complete configuration command comprising replaceable command elements and the user-input command elements;

[0127] The acquisition unit 430 is configured to perform command rule matching on the complete configuration command, and acquire a to-be-checked configuration command having a specified relationship type with the complete configuration command, and mark a to-be-replaced element from the to-be-checked configuration command.

[0128] The replacement unit 440 is configured to replace the to-be-replaced element with the replaceable command elements and the user-input command elements, to obtain a replaced to-be-checked configuration command.

[0129] The searching unit 450 is configured to search, from the already-downloaded text configuration file, whether there is a text configuration file matching the replaced to-be-checked configuration command.

[0130] The determination unit 460 is configured to determine that the replaced to-be-checked configuration command is a down-loadable configuration command if there is.

[0131] The determination unit 460 is further configured to determine that the replaced to-be-checked configuration command is a non-down-loadable configuration command if there is not, and display prompt information.

[0132] Optionally, the acquisition unit 430 is specifically configured to parse a string of the complete configuration command by using a python script, and determine a position of the user-input command elements in the complete configuration command and a position of the replaceable command elements in the complete configuration command.

[0133] Optionally, the acquisition unit 430 is further configured to acquire, by using a json script, a rule file having a specified relationship type with the complete configuration command, each rule file comprising at least one to-be-checked configuration command.

[0134] The specified relationship type specifically comprises a dependency relationship, a conflict relationship and a lock relationship, and the at least one to-be-checked configuration command comprises a specific and relationship and an or relationship.

[0135] Optionally, the acquisition unit 430 is further configured to parse a string of the to-be-checked configuration command by using a python script according to the position of the user-input command elements in the complete configuration command and the position of the replaceable command elements in the complete configuration command, and mark a to-be-replaced element from the to-be-checked configuration command.

[0136] Optionally, the replacing unit 440 is further configured to mark the command element that can be converted into a regular expression from the to-be-checked configuration command.

[0137] convert the command element that can be converted into a regular expression into a regular expression to obtain the replaced to-be-checked configuration command.

[0138] Therefore, by applying the command line checking apparatus provided in the present application, the network device receives a configuration command input by a user through a command line interface, the configuration command including a replaceable command element and a user input command element; the network device converts the configuration command into a complete configuration command under a view path, the complete configuration command including the user input command element; the network device performs command rule matching on the complete configuration command and acquires a to-be-checked configuration command having a specified relationship type with the complete configuration command, and marks a to-be-replaced element from the to-be-checked configuration command; the network device replaces the to-be-replaced element with the replaceable command element and the user input command element to obtain a replaced to-be-checked configuration command; the network device checks whether a text configuration file matching the replaced to-be-checked configuration command exists in a text configuration file that has been issued; if the text configuration file exists, the network device determines that the replaced to-be-checked configuration command is a deliverable configuration command; if the text configuration file does not exist, the network device determines that the replaced to-be-checked configuration command is an undeliverable configuration command, and displays prompt information.

[0139] In this way, after the network device receives the configuration command input by the user, the network device can immediately check the configuration command, and no longer transmits the configuration command to a service module, thereby solving the problem that the service module repeatedly checks the delayed effective configuration, resulting in a huge workload of the service module and repetitive work. The constraint relationship checking between different configuration commands in the delayed configuration effective mode of the command line is implemented, the workload of developing the constraint relationship checking between different configuration commands in the original language (C language) is reduced, and the development efficiency is improved.

[0140] Based on the same inventive concept, the present application also provides a network device, as shown in Figure 5 The network device includes a processor 510, a transceiver 520, and a machine readable storage medium 530. The machine readable storage medium 530 stores machine executable instructions that can be executed by the processor 510. The processor 510 is prompted by the machine executable instructions to perform the command line checking method provided in the present application. The aforementioned Figure 4 The command line checking apparatus can be implemented by using the network device hardware structure as shown in Figure 5

[0141] ​The computer readable storage medium 530 can include a random access memory (RAM) and can also include a non-volatile memory (NVM), such as at least one disk storage. Optionally, the computer readable storage medium 530 can also be at least one storage device that is located remotely from the aforementioned processor 510.

[0142] The processor 510 can be a general processor, including a central processing unit (CPU), a network processor (NP), etc., and can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components.

[0143] In the embodiments of the present application, the processor 510 reads the machine executable instructions stored in the machine readable storage medium 530, and the machine executable instructions enable the processor 510 itself and the transceiver 520 to execute the command line checking method described in the foregoing embodiments of the present application.

[0144] In addition, the embodiments of the present application provide a machine readable storage medium 530, which stores machine executable instructions. When the processor 510 calls and executes the machine executable instructions, the machine executable instructions enable the processor 510 itself and the transceiver 520 to execute the command line checking method described in the foregoing embodiments of the present application.

[0145] The implementation processes of the functions and roles of the units in the apparatus are specifically described in the implementation processes of the corresponding steps in the foregoing method, and will not be described here.

[0146] For the device embodiment, since it basically corresponds to the method embodiment, the relevant part can be seen from the part of the method embodiment. The device embodiment described above is only illustrative, wherein the units described as separate components can or can not be physically separated, and the components displayed as units can or can not be physical units, i.e., can be located in one place or distributed to multiple network units. Part or all of the modules can be selected to achieve the purpose of the scheme of the present application according to actual needs. Those skilled in the art can understand and implement it without creative labor.

[0147] For the command line checking device and machine readable storage medium embodiment, since the method content involved is basically similar to the foregoing method embodiment, the description is relatively simple, and the relevant part can be seen from the part of the method embodiment.

[0148] The above is only the preferred embodiment of the present application, and is not used to limit the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A command line check method, characterized by, The method comprises: receiving a user-input configuration command through a command line interface, the configuration command comprising a user-input command element; converting the configuration command into a complete configuration command under a view path, the complete configuration command comprising a replaceable command element and the user-input command element; performing command rule matching on the complete configuration command, obtaining at least one to-be-checked configuration command having a specified relationship type with the complete configuration command, and marking a to-be-replaced element from the to-be-checked configuration command; replacing the to-be-replaced element with the replaceable command element and the user-input command element to obtain a replaced to-be-checked configuration command; checking whether a text configuration file matching the replaced to-be-checked configuration command exists in a text configuration file that has been issued; if the text configuration file exists, determining that the replaced to-be-checked configuration command is an issuable configuration command; if the text configuration file does not exist, determining that the replaced to-be-checked configuration command is a non-issuable configuration command, and displaying prompt information; wherein the specified relationship type specifically comprises a dependency relationship, a conflict relationship, and a locking relationship, and the at least one to-be-checked configuration command comprises an and relationship and an or relationship.

2. The method of claim 1, wherein, The command rule matching on the complete configuration command specifically comprises: performing string analysis on the complete configuration command by using a python script, and determining the position of the user-input command element in the complete configuration command and the position of the replaceable command element in the complete configuration command.

3. The method of claim 1, wherein, The obtaining of the to-be-checked configuration command having the specified relationship type with the complete configuration command specifically comprises: obtaining a plurality of rule files having the specified relationship type with the complete configuration command by using a json script, each rule file comprising at least one to-be-checked configuration command.

4. The method of claim 2, wherein, The marking of the to-be-replaced element from the to-be-checked configuration command specifically comprises: performing string analysis on the to-be-checked configuration command by using a python script according to the position of the user-input command element in the complete configuration command and the position of the replaceable command element in the complete configuration command, and marking the to-be-replaced element from the to-be-checked configuration command.

5. The method of claim 1, wherein, After the replacing of the to-be-replaced element with the replaceable command element and the user-input command element, the method further comprises: marking a regular conversion-permissible command element from the to-be-checked configuration command; converting the regular conversion-permissible command element into a regular expression to obtain a replaced to-be-checked configuration command.

6. A command line checking apparatus characterized by comprising: The device comprises: a receiving unit configured to receive a user-input configuration command through a command line interface, the configuration command comprising a user-input command element; a converting unit configured to convert the configuration command into a complete configuration command under a view path, the complete configuration command comprising a replaceable command element and the user-input command element; An acquisition unit is configured to perform command rule matching on the complete configuration command, acquire at least one to-be-checked configuration command having a specified relationship type with the complete configuration command, and mark a to-be-replaced element from the to-be-checked configuration command; A replacement unit is configured to replace the to-be-replaced element with the replaceable command element and the user-input command element to obtain a replaced to-be-checked configuration command; A search unit is configured to search, from the already-downloaded text configuration file, whether there is a text configuration file matching the replaced to-be-checked configuration command; A determination unit is configured to determine that the replaced to-be-checked configuration command is a down-loadable configuration command if there is; The determination unit is further configured to determine that the replaced to-be-checked configuration command is a non-down-loadable configuration command if there is not, and display prompt information. The specified relationship type specifically includes a dependency relationship, a conflict relationship, and a lock relationship, and the at least one to-be-checked configuration command includes an and relationship and an or relationship.

7. The apparatus of claim 6, wherein, The acquisition unit is specifically configured to parse a string of the complete configuration command by using a python script, and determine a position of the user-input command element in the complete configuration command and a position of the replaceable command element in the complete configuration command.

8. The apparatus of claim 6, wherein, The acquisition unit is further configured to acquire, by using a json script, one rule file having the specified relationship type with the complete configuration command, and each rule file includes at least one to-be-checked configuration command.

9. The apparatus of claim 7, wherein, The acquisition unit is further configured to parse a string of the to-be-checked configuration command by using the python script according to the position of the user-input command element in the complete configuration command and the position of the replaceable command element in the complete configuration command, and mark the to-be-replaced element from the to-be-checked configuration command.

10. The apparatus of claim 6, wherein, The replacement unit is further configured to mark a command element that can be converted by using a regular expression from the to-be-checked configuration command; The command element that can be converted by using the regular expression is converted into a regular expression to obtain the replaced to-be-checked configuration command.

Citation Information

Patent Citations

  • Configuration command management method and apparatus, and machine-readable storage medium

    CN108259214A

  • Method and system for transmitting order to lower levels

    CN1787459A