Control method, device, equipment, storage medium and computer program product
By introducing command template database and graphical definition interface in network equipment operation and maintenance, automated control based on command templates is achieved, which solves the problem that network engineers need to master complex development skills, and improves operation and maintenance efficiency and operation simplicity.
Patent Information
- Application Number
- CN202311319442.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-11
- Publication Date
- 2025-04-11
AI Technical Summary
In the prior art, network engineers need to master complex development skills when operating and maintaining network equipment, resulting in low operation and maintenance efficiency, high skill threshold and difficult operation.
By providing a control method and device, using the command template database and graphical definition interface, automated control based on the command template is realized, and the operation and maintenance process of network equipment is simplified.
It improves the control efficiency of network equipment, reduces the operation complexity of network engineers, and makes the operation and maintenance process simpler and more efficient.
Smart Images

Figure CN119814565A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a control method, a control device, a computer equipment, a computer-readable storage medium, and a computer program product. Background Art
[0002] In the field of network management, network engineers are mainly responsible for the operation and maintenance of network equipment. At present, the efficiency of network engineers in operating and maintaining network equipment is low. For example, network engineers use the full-code operation and maintenance method to implement network equipment operation and maintenance. The full-code operation and maintenance method opens all the orchestration capabilities to network engineers. The platform only provides the ability to connect to network devices. All parameters or command line assembly, command line echo parsing, and business logic orchestration are all implemented by network engineers writing code. However, the full-code operation and maintenance method requires network engineers to understand not only network operation and maintenance business, but also development skills (not only writing business logic with simple syntax, but also considering the performance, stability, deployment, scalability, etc. of the system). For most traditional network engineers, it is usually no problem to understand network operation and maintenance business, but it is more difficult to have proficient development skills. It can be seen that the full-code operation and maintenance method has a series of problems such as high skill threshold requirements and difficult operation for most traditional network engineers, which makes the operation and maintenance efficiency of network equipment low. Summary of the invention
[0003] The embodiments of the present application provide a control method, apparatus, device, storage medium and computer program product, which can realize automated control of network devices based on command templates, effectively improve control efficiency, and realize a method based on graphical definition of command templates, which is simple and efficient to operate.
[0004] On the one hand, an embodiment of the present application provides a control method, the method comprising:
[0005] Get the device ID and command template ID;
[0006] Acquire a target command template corresponding to the command template identifier from a command template database; the command template database includes one or more command templates, the command template is generated according to definition content input in a command template definition interface; the command template definition interface includes a matching definition area, the definition content includes matching information input for each matching definition area in one or more matching definition areas, the matching information includes device feature information and command line instructions; the device feature information and command line instructions corresponding to the same matching definition area have an associated relationship;
[0007] Determining, from the target command template, matching device feature information that matches the device identifier, and acquiring associated command line instructions associated with the matching device feature information;
[0008] A control command is generated according to the associated command line instruction, and the control command is sent to the network device corresponding to the device identifier, so that the network device executes the network action indicated by the control command.
[0009] In one aspect, an embodiment of the present application provides a control device, the device comprising:
[0010] An acquisition unit, used to acquire a device identifier and a command template identifier;
[0011] The acquisition unit is further used to acquire a target command template corresponding to the command template identifier from a command template database; the command template database includes one or more command templates, and the command template is generated according to the definition content input in the command template definition interface; the command template definition interface includes a matching definition area, and the definition content includes matching information input for each matching definition area in one or more matching definition areas, and the matching information includes device feature information and command line instructions; the device feature information and command line instructions corresponding to the same matching definition area have an associated relationship;
[0012] A processing unit, configured to determine, from the target command template, matching device feature information that matches the device identifier, and to obtain associated command line instructions associated with the matching device feature information;
[0013] The processing unit is further configured to generate a control command according to the associated command line instruction;
[0014] The communication unit is used to send the control command to the network device corresponding to the device identifier, so that the network device executes the network action indicated by the control command.
[0015] On the one hand, an embodiment of the present application provides a computer device, comprising: a processor, a communication interface and a memory, wherein the processor, the communication interface and the memory are interconnected, wherein the memory stores an executable program code, and the processor is used to call the executable program code to implement the control method provided in the embodiment of the present application.
[0016] Accordingly, an embodiment of the present application further provides a computer-readable storage medium, in which instructions are stored. When the computer-readable storage medium is executed on a computer, the computer implements the control method provided by the embodiment of the present application.
[0017] Accordingly, an embodiment of the present application further provides a computer program product, which includes a computer program or computer instructions, and when the computer program or computer instructions are executed by a processor, the control method provided in the embodiment of the present application is implemented.
[0018] In an embodiment of the present application, on the one hand, a command template is obtained from a command template database, command line instructions corresponding to the network device are obtained from the command template, a control command is generated according to the command line instruction, and the network device is controlled by the control command to perform corresponding network actions, thereby realizing automatic control of the network device based on the command template, which can improve the control efficiency; on the other hand, the command template in the command template database is generated according to the definition content entered in the command template definition interface, and the command template definition interface includes a supporting definition area, and the definition content includes supporting information entered for each supporting definition area in one or more supporting definition areas, and the supporting information includes device feature information and command line instructions, thereby realizing a method based on graphical definition of command templates, which is simple and efficient to operate. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0020] Figure 1 It is a schematic diagram of the architecture of a control system provided in an embodiment of the present application;
[0021] Figure 2 It is a flowchart of a command template definition method provided in an embodiment of the present application;
[0022] Figure 3a is a schematic diagram of a command template definition interface provided in an embodiment of the present application;
[0023] Figure 3b is a schematic diagram of a parameter specification element configuration interface provided in an embodiment of the present application;
[0024] Figure 3c This is a schematic diagram of an interface of a supporting definition area provided in an embodiment of the present application;
[0025] Figure 3d This is a schematic diagram of another interface of a supporting definition area provided in an embodiment of the present application;
[0026] Figure 4a This is a schematic diagram of an interface for an echo processing definition area provided in an embodiment of the present application;
[0027] Figure 4b This is another interface schematic diagram of an echo processing definition area provided in an embodiment of the present application;
[0028] Figure 4c This is another interface schematic diagram of an echo processing definition area provided in an embodiment of the present application;
[0029] Figure 4d This is another interface schematic diagram of an echo processing definition area provided in an embodiment of the present application;
[0030] Figure 4e This is another interface schematic diagram of an echo processing definition area provided in an embodiment of the present application;
[0031] Figure 4f is a schematic diagram of an echo information display interface provided in an embodiment of the present application;
[0032] Figure 5 It is a flowchart of a command template publishing method provided in an embodiment of the present application;
[0033] Figure 6 It is a flow chart of a control method provided in an embodiment of the present application;
[0034] Figure 7 is a flow chart of another control method provided in an embodiment of the present application;
[0035] Figure 8 is a structural schematic diagram of a control device provided in an embodiment of the present application;
[0036] Fig. 9 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0037] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0038] The following is an explanation of some terms involved in the embodiments of the present application:
[0039] CLI: Command Line Interface, also known as command line, is a human-computer interaction command provided by equipment manufacturers. It is used to view the status of network devices and modify device configurations. It is mostly used in network device operation and maintenance scenarios.
[0040] Network engineer: can be referred to as a network engineer for short, responsible for the operation and maintenance of network equipment.
[0041] Network management: The embodiments of the present application specifically refer to data communication network equipment management and do not involve access networks, transmission networks, core networks and wireless network equipment.
[0042] BGP: Border Gateway Protocol, also known as Border Gateway Protocol, is an application layer protocol.
[0043] UI: User Interface, also known as user interface.
[0044] JSON: Java Script Object Notation, also known as JS object notation, is a lightweight data exchange format.
[0045] SSH: Secure Shell, a security protocol based on the application layer.
[0046] Telnet is the standard protocol and main method of Internet remote login service. It is a protocol in the TCP (Transmission Control Protocol) / IP (Internet Protocol) protocol family.
[0047] The embodiment of the present application provides a control method to realize the automatic control of network devices based on command templates, thereby improving the control efficiency of network devices, and to realize the way of defining command templates based on graphics, thereby simplifying the definition operation of command templates and improving the definition efficiency of command templates. The control method provided in the embodiment of the present application can be implemented based on cloud technology and other technologies. Cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software, and networks in a wide area network or a local area network to realize the calculation, storage, processing, and sharing of data. The control method provided in the embodiment of the present application may specifically involve one or more of cloud storage, big data, and database in cloud technology. For example, the data (such as command templates, etc.) involved in or generated by executing the control method is stored in a database.
[0048] Cloud storage is a new concept that extends and develops from the concept of cloud computing. A distributed cloud storage system refers to a storage system that uses cluster applications, grid technology, and distributed storage file systems to bring together a large number of storage devices of various types (or storage nodes) in the network to work together through application software or application interfaces to provide data storage and business access functions. Big data refers to a collection of data that cannot be captured, managed, and processed by conventional software tools within a certain time frame. It is a massive, high-growth, and diversified information asset that requires new processing models to have stronger decision-making power, insight discovery, and process optimization capabilities. With the advent of the cloud era, big data has also attracted more and more attention. Big data requires special technologies to effectively process a large amount of data within a tolerable time. Technologies applicable to big data include large-scale parallel processing databases, data mining, distributed file systems, distributed databases, cloud computing platforms, the Internet, and scalable storage systems. In short, a database can be regarded as an electronic file cabinet (a place to store electronic files), and users can add, query, update, and delete data in the file. The so-called "database" is a collection of data that is stored together in a certain way, can be shared with multiple users, has as little redundancy as possible, and is independent of the application.
[0049] The control method provided in the embodiment of the present application can be applied to Figure 1 The control system shown in the figure includes: a control platform 10, a command template database 11 and a network device 12. The control platform 10 and the network device 12 are connected via a network. The control platform 10 can be a terminal device such as a smart phone, a tablet computer, a laptop computer, a desktop computer, etc. The command template database 11 can be a local database of the control platform 10, or it can be a cloud database independent of the control platform 10 and the network device 12. The network device 12 can be a network device that a network engineer is responsible for operating and maintaining, and specifically can be a network device that can execute command line instructions, such as a network switch, a network router, etc. The control method provided in the embodiment of the present application includes the following steps:
[0050] The control platform 10 obtains a device identifier and a command template identifier, wherein the device identifier is used to indicate a network device that needs to be controlled (or maintained), and the command template identifier is used to indicate a command template used to control the network device. The control platform 10 obtains a target command template corresponding to the command template identifier from the command template database 11. The command template database 11 includes one or more command templates, and the command template is generated according to the definition content entered in the command template definition interface. The command template definition interface includes a matching definition area, and the definition content includes matching information entered for each matching definition area in one or more matching definition areas. The matching information includes device feature information and command line instructions. The device feature information and command line instructions corresponding to the same matching definition area have an associated relationship, and the device feature information includes feature information of a network device that can execute the command line instructions. The control platform 10 determines the matching device feature information that matches the device identifier from the target command template, and obtains the associated command line instructions associated with the matching device feature information. The control platform 10 generates a control command according to the associated command line instructions, and sends the control command to the network device 12 corresponding to the device identifier. The network device 12 receives the control command sent by the control platform 10 and executes the network action indicated by the control command, such as opening a port, closing a port, establishing a BGP neighbor, disconnecting a BGP neighbor, etc.
[0051] In an embodiment of the present application, on the one hand, a command template is obtained from a command template database, command line instructions corresponding to the network device are obtained from the command template, a control command is generated according to the command line instruction, and the network device is controlled by the control command to perform corresponding network actions, thereby realizing automatic control of the network device based on the command template, which can improve the control efficiency; on the other hand, the command template in the command template database is generated according to the definition content entered in the command template definition interface, and the command template definition interface includes a supporting definition area, and the definition content includes supporting information entered for each supporting definition area in one or more supporting definition areas, and the supporting information includes device feature information and command line instructions, thereby realizing a method based on graphical definition of command templates, which is simple and efficient to operate.
[0052] It should be noted that in the specific implementation of this application, related data such as device identification, command template identification, command template, device feature information, command line instructions, etc. are involved. When the embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data need to comply with relevant regulations and standards in relevant regions.
[0053] The above briefly introduces the control method provided in the embodiment of the present application. In order to better understand the control method provided in the embodiment of the present application, the method based on graphically defined command templates involved in the control method is first described in detail below.
[0054] In the embodiment of the present application, the command template definition is to define what kind of function this command template implements, such as: opening or closing a port, configuring a BGP neighbor, etc. A command template can correspond to a specific device function. After a command template is defined, it can be executed (or called) by an upper-layer application (such as an automated control application based on a control code). There are several key points in the command template definition:
[0055] 1. Provide structured input and output definitions
[0056] The purpose of writing command templates is to connect with upper-level applications and realize complete automated operation and maintenance applications from business process orchestration to device implementation. To achieve docking with upper-level applications, command templates should be similar to functions written in development languages, with structured inputs and outputs.
[0057] 2. Shield the differences in command lines between manufacturers
[0058] For the same network behavior, the command line syntax of different vendors is not completely consistent. For example, for enabling port gigabitethernet1 / 1, the command line of one vendor is: no shutdown gigabitethernet1 / 1, while the command line of another vendor is undo shutdown gigabitethernet1 / 1. Based on cost and security considerations, enterprises usually adopt a multi-vendor strategy, which forces network engineers to face the command line syntax of multiple vendors. Considering the complexity of upper-layer applications, command templates should shield the differences in vendor command lines and provide unified input and output parameters to the upper layer, so that the upper-layer application does not need to pay attention to the specific implementation of the lower layer.
[0059] 3. Write command line instructions
[0060] 4. Process command line echo
[0061] As a human-computer interaction UI, the command line will generate an echo for the input commands for network engineers to process further. The command template is implemented based on the command line, so it also needs to have the ability to process the echo accordingly.
[0062] Based on the above-mentioned key points of command template definition, the embodiment of the present application provides a command template definition method, which can be implemented by a command template definition platform. The command template definition platform can be Figure 1The control platform in the control system shown can also be other devices different from the control platform, such as Figure 2 As shown, the command template definition method described in the embodiment of the present application includes but is not limited to the following steps:
[0063] S201. Display a command template definition interface, wherein the command template definition interface includes a parameter definition area and a supporting definition area, wherein the supporting definition area includes a device feature definition area, a command line definition area, and an echo processing definition area.
[0064] See also Figure 3a , is a schematic diagram of a command template definition interface provided in an embodiment of the present application. Figure 3a As shown, the command template definition interface includes a parameter definition area 31 and one or more supporting definition areas 32. The parameter definition area 31 includes an input parameter definition area and an output parameter definition area. The input parameter definition area is used to define the relevant information of the input parameter, which includes the parameter name, data type, etc. of the input parameter; the output parameter definition area is used to define the relevant information of the output parameter, which includes the parameter name, data type, etc. of the output parameter. It should be noted that the defined input parameter can be one or more, and the defined output parameter can also be one or more. The parameter definition area 31 is used to implement structured input and output definitions.
[0065] In order to realize the ability to shield manufacturer differences when defining command templates, a package can be defined according to one or more dimensions of manufacturer, model, OS (operating system) version, specific device, device group (or supporting group). In this package, the specific command line syntax is defined, and the echo of the network device is defined. Based on this, the supporting definition area 32 in the command template definition interface provided in the embodiment of the present application is used to define a package, such as Figure 3a As shown, the supporting definition area 32 includes a device feature definition area 321, a command line definition area 322, and an echo processing definition area 323. The device feature definition area 321 is used to define the device feature information of the network device that can execute the command line instructions defined in the supporting area. The command line definition area 322 is used to define the command line instructions executable by the network device corresponding to the device feature information defined in the supporting area. For the same command template, multiple supporting areas can be defined, and the command line instructions in each supporting area are different. The echo processing definition area 323 is used to define the processing method for the echo information returned by the network device executing the command line instructions.
[0066] S202, acquiring parameter definition information input into the parameter definition area, device feature information input into the device feature definition area, command line instructions input into the command line definition area, and echo processing indication information input into the echo processing definition area. The device feature information, the command line instructions, and the echo processing indication information constitute the supporting information of the supporting definition area, and the device feature information includes feature information of a network device that can execute the command line instructions.
[0067] Gets the parameter definition information entered in the parameter definition area. Figure 3a For example, an input parameter is defined in the parameter definition area 31 in the command template definition interface, the parameter name is slot_number, the data type is a string, and two output parameters are defined at the same time, the parameter names are PN and SN, and the data type is also a string. This indicates that when the upper-level application calls the defined command template, it is necessary to assign a value to the parameter slot_number. After the command template is executed, the data corresponding to the two parameters PN and SN will be returned. In one embodiment, in order to standardize input and output parameters and prevent abnormal situations from affecting business logic, in addition to defining the parameter type in the parameter definition area, verification specifications can also be provided for the parameters to verify the legitimacy of the parameters in subsequent applications. The following scenarios can be verified: whether the parameter is within a certain numerical range, whether the parameter belongs to one of the enumerations, the parameter is not empty, and the parameter complies with the IP address specification (such as dotted fraction). In addition, you can flexibly define regular expressions to perform customized verification of the legitimacy of the parameters. Please refer to Figure 3b , is a schematic diagram of a parameter specification element configuration interface provided in an embodiment of the present application. Figure 3b As shown, in Figure 3b The parameter specification element configuration interface shown in the figure defines two specifications: slot number range and port number range. The slot number range and port number range are defined as integers from 0 to 15 and 1 to 48 respectively. After defining the verification specification, bind it to a parameter so that the parameter has the verification capability. Figure 3a and Figure 3b For example, the parameter slot_number is bound to the verification specification "slot number range", so that when the parameter is actually assigned a value later, it will be checked whether the input value is an integer between 0 and 15, and an error will be reported if it does not meet the requirements. In a feasible implementation, when a trigger operation is detected on the editing area corresponding to the verification specification element in the parameter definition area 31, the parameter specification element configuration interface is displayed, so as to complete the definition of the verification specification element of the corresponding input or output parameter in the parameter specification element configuration interface. The above-defined information constitutes the parameter definition information.
[0068] In an embodiment of the present application, matching information input for each matching definition area in one or more matching definition areas is obtained, and the matching information includes device feature information input for a device feature definition area in the matching definition area, command line instructions input for a command line definition area in the matching definition area, and echo processing instruction information input for an echo processing definition area in the matching definition area. The device feature information in the matching includes feature information of a network device that can execute the command line instructions in the matching.
[0069] In one embodiment, a package can be defined based on one or more dimensions of manufacturer, model, OS version, and a specific device. At this time, the device feature information input into the device feature definition area includes one or more of the following information of the network device: manufacturer information, standard model information, OS version information, address information (such as Internet Protocol IP address). Figure 3a As shown, this method can be used to input device feature information in the editing area corresponding to “directly fill in” in the device feature definition area 321 .
[0070] In another embodiment, considering that different manufacturers, different series of devices of the same manufacturer, and different OS may have different command lines, when defining the matching, it supports definition to manufacturer, model, OS, and even specific device level, but conversely, the command lines of some series of network devices are exactly the same, for example: DP manufacturer's DP20S series, DP50S series, DP300S series, the command lines are exactly the same, but the command lines supported by these series of network devices and DP manufacturer's E series network devices are not quite the same, so there is no way to define only one manufacturer as the matching of DP, but it is too much to define a matching for each model of network device, so this application can also define a matching according to the device group (or matching group) dimension. A device group refers to a combination of multiple models of network devices. Since they use the same command line, they can be summarized as the same device group. At this time, the device feature information input into the device feature definition area includes the identification information of the device group, and the identification information can be, for example, name information.
[0071] Table 1:
[0072] Device Group Name Manufacturer Standard Models H3C DP DP20S, DP50S, DP300S, DP20H, DP30H, DP50H
[0073] As shown in Table 1 above, Table 1 shows the definition and management of device groups. Taking the H3C device group as an example, it currently corresponds to 6 types of network devices: DP20S, DP50S, DP300S, DP20H, DP30H, and DP50H. Figure 3c As shown, a method of defining matching based on a device group is shown. This method can input device feature information in the editing area corresponding to "Use matching group" in the device feature definition area. Figure 3c The H3C matching group is selected, indicating that the six network devices, DP20S, DP50S, DP300S, DP20H, DP30H, and DP50H, only need to write the matching command line instructions and echo processing instructions once. If a new model is introduced later, and the command line is consistent with the network devices in this device group, you only need to add the model to the matching group without modifying each command template. This method can effectively improve the definition efficiency of command templates, which is conducive to improving the operation and maintenance efficiency of network devices.
[0074] In the embodiment of the present application, in addition to supporting direct input of command line instructions in the command line definition area included in the supporting definition area, it also supports the use of parameter names to replace variables when entering command line instructions in the command line definition area. In the subsequent process of executing (or calling) the command template, the variable is replaced with the actual input value, which can simplify the writing complexity of the command template and improve efficiency. Among them, it can support the use of special characters "[" and "]" to reference variables, such as Figure 3d As shown in the figure, enter "display device manuinfo slot [slot_number]" in the command line definition area. "[slot_number]" indicates that this is a variable. In the subsequent actual operation, you need to replace [slot_number] in this line with the actual value of the variable slot_number. If the value of the variable slot_number is 2, the command generated during the operation is: display device manuinfo slot 2. The advantage of using the method of supporting the use of parameter names to replace variables is that there is no need to enumerate all possible command line instructions, which can simplify operations and improve efficiency. For example, if the slot_number range of a network device is an integer from 0 to 15, if parameter replacement is not supported, you need to enumerate all 16 commands from "display device manuinfo slot 0" to "display device manuinfo slot15".
[0075] In the embodiment of the present application, it is possible to define in the echo processing definition area included in the supporting definition area that the echo information does not need to be processed, such as Figure 3a , Figure 3c and Figure 3d As shown, in the echo processing definition area, you can check the option of "No processing required", so that the echo processing indication information obtained indicates that the echo information does not need to be processed; you can also define the specific processing method of the echo information in the echo processing definition area included in the supporting definition area, so that the echo processing indication information obtained indicates the specific processing method of the echo information, such as Figure 4a-4e As shown, you can select an echo processing method in the editing area corresponding to "Mode" in the echo processing definition area, display the echo processing template content corresponding to the selected echo processing method, enter the corresponding key content for the displayed echo processing template content, and then complete the definition of the echo processing method. The echo processing instruction information includes the corresponding key content entered for the displayed echo processing template content. Figure 4a As shown in the figure, several common echo processing methods are shown, including:
[0076] 1. When the echo contains ××, enter the specified command
[0077] For some important operations, the command line provides a second confirmation capability. For example, if you enter the "reboot (restart)" command, the device will give an echo "continue? [Y / N]". At this time, you need to enter "Y" to continue the reboot operation, and enter "N" to cancel the execution of the command. Figure 4a and Figure 4b As shown in the figure, the echo processing definition mode "When the echo contains ××, enter the specified command" is provided. You can define in advance which command should be automatically entered for this scenario in the echo processing definition area. Figure 4b With the echo processing mode defined as shown, when the command template is subsequently executed, if the network device displays "continue? [Y / N]", Y is automatically entered to ensure that the reboot continues without manual intervention.
[0078] 2. If the echo contains ××, the task fails and exits
[0079] Sometimes, the command execution will report an error. At this time, you need to terminate the command template to continue execution. If you do it manually, you will see various error prompts, so you can manually terminate the command template according to the error prompts. When executing automatically, you need to define the error keyword in the command template in advance. If the echo information contains the error keyword, the command template will be automatically terminated and an error will be reported. Figure 4a and Figure 4c As shown in the figure, the echo processing definition mode "When the echo contains ××, the task fails and exits" is provided. The error keywords corresponding to this scenario can be defined in advance in the echo processing definition area. Figure 4c As shown in the echo processing mode definition, during the subsequent execution of the command template, if the echo information of the network device contains "error message", it is determined that the task has failed, and the execution of the command template is automatically terminated.
[0080] 3. If the echo does not contain ××, the task fails and exits
[0081] This is similar to the above echo processing method "When the echo contains ××, the task fails and exits". Figure 4a and Figure 4d As shown in the figure, the echo processing definition mode "When the echo does not contain ××, the task fails and exits" is provided. The keywords corresponding to this scenario can be defined in advance in the echo processing definition area. Figure 4d According to the echo processing mode definition shown, during the subsequent execution of the command template, if the echo information of the network device does not contain "finish", it is determined that the task has failed, and the execution of the command template is automatically terminated.
[0082] 4. Extract data from the ×× echo and return:
[0083] Sometimes you need to extract some information from the echo information of the network device and use it as the output parameter of the command template for the upper-layer application to do the next step of processing. In this case, you can use the echo processing method of "extracting data from ×× echo and returning it". Figure 4a and Figure 4e As shown, the echo processing definition mode of "extracting data from ×× echo and returning" is provided, and the key information corresponding to the scenario can be defined in advance in the echo processing definition area. The key information can include the following: Figure 4e The matching pattern shown is "DEVICE_SERIAL NUMBER:[%SN%]", etc. Figure 4e If the echo processing method is defined as shown, when the command template is subsequently executed (or called), if the echo information of the network device contains the string "DEVICE_SERIAL_NUMBER:", the content after it will be automatically assigned to the parameter SN. Here, the writing of [% variable name %] means that the extracted value is assigned to the variable name defined in [% %]. In the example of [% SN %], it is assigned to the variable SN. For example, if the actual echo information of the network device is as follows Figure 4f As shown in the figure, the content "210231A2UGH220C000Y" included in the string "DEVICE_SERIAL NUMBER: 210231A2UGH220C000Y" in the echo information is automatically assigned to the parameter SN.
[0084] In a feasible embodiment, for complex echo, it is also possible to support matching by defining regular expressions. Figure 4e As shown, if the "Use regular expression" option is checked, you can enter a regular expression in the editing area corresponding to "Matching formula" so that when the command template is subsequently executed, data can be extracted and returned from the echo information of the network device according to the regular expression.
[0085] 5. Set the return value according to the echo information
[0086] This method is similar to the above echo processing method "Extracting data from ×× echo and returning it", but it does not need to extract content from the echo information. Instead, after hitting the keyword (or key information), you can directly specify the value (or data) to be returned.
[0087] 6. Return the echo information directly as a parameter
[0088] This method is similar to the above echo processing method "Set the return value according to the echo information", but it does not need to pay attention to whether the keyword is hit. All the echo information is directly put into the return value. This method is generally used in scenarios with complex echoes, and the upper-layer application needs to write code for parsing.
[0089] 7. Set the return value directly
[0090] Similar to the above echo processing methods, but you do not need to pay attention to any echo information. You can directly set the value (or data) to be returned in the echo processing definition area.
[0091] 8. Perform full-text regular search and replacement on the echo information
[0092] The echo information may contain some special characters, which will affect subsequent processing. You can use regular matching to search for these special characters and replace them. You can define the special characters to be replaced and the characters to be replaced in the echo processing definition area.
[0093] 9. Disconnection
[0094] Some commands may make the device inaccessible, such as reboot or power off. If you continue to try to connect until the set timeout period is reached, the automation efficiency will be affected. If the "disconnection" echo processing method is defined, the command template will automatically close the connection with the network device and end the task after issuing a command line instruction (or control command) to the network device during subsequent execution of the command template. There is no need to wait for the timeout period to expire and the automation application will continue to be implemented without interruption. If you need to continue to issue command line instructions to the network device, you need to execute another command template and re-establish the connection.
[0095] S203 generates a command template according to the parameter definition information, the device feature information, the command line instruction and the echo processing instruction information.
[0096] In an embodiment of the present application, after the command template definition based on the command template definition interface is completed, if a save trigger operation is detected, a command template is generated based on the parameter definition information entered into the parameter definition area and the supporting information (including device feature information, command line instructions, and echo processing indication information) entered into each supporting definition area in one or more supporting definition areas. That is, a command template is generated based on the definition content entered into the command template definition interface.
[0097] In one embodiment, the definition content input into the command template definition interface may be converted into a specific structured text (or data structure), for example, into a json in a specific format, to generate a command template.
[0098] S204 generates a template identifier of the command template, and stores the command template and the template identifier of the command template in a command template database.
[0099] In an embodiment of the present application, the template identifier of the command template may include a command template name and a command template ID (identification number). The command template name may be generated based on the control function that can be implemented by the command template. For example, if the control function that can be implemented by the command template is to open a port, then the command template name may be "open port command template"; the command template ID may be generated according to the generation order of the command template.
[0100] The command templates may be stored in a command template database, and a mapping relationship between the command templates and the template identifiers of the command templates may be stored in the command template database.
[0101] In one embodiment, in order to ensure the development quality of command templates, similar to code release, command templates may also have the concepts of version and release. The initial state of the command templates stored in the command template database is the debugging state (i.e., the default is the debugging state), and cannot be called by upper-level applications. The command template can be used by modifying the state of the command template to the released state. In a feasible implementation, the command template is sent to a test device so that the test device tests the command template to obtain the test result of the command template. If the test result of the command template is approved, the state of the command template stored in the command template database can be adjusted to the released state, and the command template in the released state can be used. Figure 5 As shown, the entire process of command template release is shown, including a series of processes such as creating a release process, command template testing, associating test results, approval, and modifying command template status.
[0102] At this point, the definition and release of a command template is completed. The released command template can be called by the upper-layer application. From the above process, it can be seen that all supported command lines can be converted into command templates, and the command template definition is based on graphics. Network engineers do not need a good programming foundation to complete the command template definition, and it is more efficient.
[0103] The above is a detailed description of the method based on graphical definition of command templates. The following is a detailed description of the method of operating and maintaining network devices using defined command templates, that is, the control method provided in the embodiment of the present application.
[0104] See also Figure 6 , Figure 6 A flow chart of a control method provided in an embodiment of the present application. The control method described in the embodiment of the present application can be Figure 1 The control platform in the control system shown is implemented, and the control method includes but is not limited to the following steps:
[0105] S601: Obtain a device identifier and a command template identifier.
[0106] In the embodiment of the present application, the obtained device identification is used to indicate the network device that needs to be controlled (or maintained), and the obtained command template identification is used to indicate the command template used to control the network device. The device identification can be the address information of the network device, such as the Internet Protocol IP address, etc. The command template identification can be the command template name or command template ID of the command template.
[0107] In one embodiment, the control platform may be responsive to a command template call request of an automation application, obtain the device identifier and command template identifier carried in the command template call request (it may also obtain the input parameters required by the command template corresponding to the command template identifier carried in the command template call request), and execute subsequent steps according to the obtained device identifier and command template identifier and other data. The command template call request is used to request that the network device corresponding to the device identifier be controlled according to the target command template corresponding to the command template identifier. Among them, the automation application may be an automation control application implemented based on the control code, which is an upper-layer application. When a network engineer needs to operate and maintain a network device, he may write a control code and write relevant codes about the command template call in the control code, so that when the relevant code is executed, the control task interface of the control platform will be called to specify which network device (reflected by the incoming device identifier) to execute, which command template (reflected by the incoming command template identifier), and the input parameters required by the command template may be passed in, thereby triggering the command template execution and completing the control of the network device.
[0108] In another embodiment, the control platform can display a task creation interface, obtain the device identification and command template identification input for the task creation interface (the input parameters required by the command template corresponding to the command template identification can also be input), generate a command template call request based on the input device identification and command template identification and other data, respond to the command template call request, obtain the device identification and command template identification and other data carried in the command template call request, and execute subsequent steps based on the obtained device identification and command template identification and other data. The command template call request is used to request control of the network device corresponding to the device identification according to the target command template corresponding to the command template identification. This method does not require network engineers to write code. They only need to enter the data required to call the command template in the task creation interface to automatically trigger the call of the control task interface of the control platform, and then automatically trigger the command template execution to complete the control of the network device. This process can also be regarded as an implementation method for uploading an application to call the command template execution.
[0109] S602. Obtain a target command template corresponding to the command template identifier from a command template database; the command template database includes one or more command templates, and the command template is generated according to definition content input in a command template definition interface; the command template definition interface includes a supporting definition area, and the definition content includes supporting information input for each supporting definition area in one or more supporting definition areas, and the supporting information includes device feature information and command line instructions; the device feature information and command line instructions corresponding to the same supporting definition area have an associated relationship.
[0110] In the embodiment of the present application, as described above, a matching definition area in the command template definition interface corresponds to a matching, and a matching definition area (or a matching) corresponds to a set of matching information. Each matching definition area includes a device feature definition area and a command line definition area. The device feature information is input for the device feature definition area, and the command line instruction is input for the command line definition area. It should be noted that one or more command templates included in the command template database are defined using the command template definition method described above. The specific definition method can refer to the relevant description in the above text, which will not be repeated here.
[0111] In one embodiment, the control platform obtains the state of the target command template corresponding to the command template identifier from the command template database. If the state of the target command template is the published state, the target command template is obtained from the command template database, and subsequent steps are performed. If the state of the target command template is the debugging state, the target command template is released. The release process of the command template can refer to the relevant description in the previous text, which will not be repeated here. When the state of the target command template is changed to the published state, the target command template is obtained from the command template database, and subsequent steps are performed.
[0112] S603: Determine, from the target command template, matching device feature information that matches the device identifier, and obtain associated command line instructions associated with the matching device feature information.
[0113] In the embodiment of the present application, as described above, the command template is generated according to one or more defined supporting information, and the command line instructions included in different supporting information are different, but the same control function is realized, such as opening a port, etc.; the device feature information included in different supporting information is also different. The device feature information may include one or more of the following information: manufacturer information, standard model information, OS version information, address information (such as Internet Protocol IP address), and may also include identification information of a device group (or supporting group), and the identification information may be name information, for example. The control platform obtains the target device feature information of the network device corresponding to the device identification from the database, such as the manufacturer information, standard model information, OS version information, address information of the network device, or the identification information of the device group to which it belongs, and then determines the matching device feature information that matches the target device feature information from the various supporting device feature information included in the target command template, and obtains the associated command line instruction associated with the matching device feature information from the command template, that is, the command line instruction that belongs to the same supporting device feature information as the matching device feature information.
[0114] For example, the target command template is generated according to the matching information of the defined matching set 1 and matching set 2. The matching information of matching set 1 includes: device characteristic information "manufacturer DP" and command line instruction 1; the matching information of matching set 2 includes: device characteristic information "manufacturer AH" and command line instruction 2. If it is found out according to the device identification that the manufacturer to which the network device corresponding to the device identification belongs is DP, the device characteristic information "manufacturer DP" is determined to be the matching device characteristic information, and command line instruction 1 is determined to be the associated command line instruction, that is, command line instruction 1 needs to be used to control the network device corresponding to the device identification.
[0115] S604: Generate a control command according to the associated command line instruction.
[0116] In one embodiment, if the associated command line instruction does not use parameter names to replace variables but includes actual variable values, the associated command line instruction may be directly determined as a control command.
[0117] In another embodiment, as described above, the command template definition interface also includes a parameter definition area, and the definition content also includes parameter definition information input for the parameter definition area, the parameter definition information includes input parameter definition information and output parameter definition information, and the input parameter definition information includes the name of the input parameter (that is, the input parameter name) and data type and other information. In addition, the input parameter name is used to replace the variable in the command line instruction. In this case, the method of generating a control command according to the associated command line instruction can be: obtaining input parameter information associated with the target command template, the input parameter information includes the value of the input parameter, and the input parameter information can be passed in by the above-mentioned automation application or input for the task creation interface; replacing the input parameter name in the associated command line instruction with the input parameter value, and generating a control command according to the associated command line instruction after the replacement process.
[0118] In a feasible implementation, as described above, the parameter definition information also includes verification information of the input parameter (or input parameter). After obtaining the value of the input parameter, the value of the input parameter can be verified according to the verification information. If the verification result indicates that the value of the input parameter has passed the verification, the above-mentioned step of replacing the input parameter name in the associated command line instruction with the input parameter value and generating a control command according to the associated command line instruction after the replacement is executed.
[0119] S605: Send the control command to the network device corresponding to the device identifier, so that the network device executes the network action indicated by the control command.
[0120] In the embodiment of the present application, after the control command is generated, the control platform establishes a connection with the network device corresponding to the device identifier, for example, establishing an SSH encrypted connection or a Telnet connection. The control command is sent to the network device corresponding to the device identifier through the established connection. After receiving the control command, the network device executes the network action indicated by the control command, for example, opening or closing a port, configuring a BGP neighbor, etc.
[0121] In one embodiment, as described above, a supporting definition area in the command template definition interface corresponds to a supporting, and a supporting definition area (or a supporting) corresponds to a group of supporting information. In addition to the device feature definition area and the command line definition area, each supporting definition area also includes an echo processing definition area. In addition to the device feature information and the command line instructions, the supporting information input in each supporting definition area also includes echo processing indication information, and the echo processing indication information is input for the echo processing definition area. The command line instructions and echo processing indication information corresponding to the same supporting definition area have an associated relationship. After the control platform sends the control command to the network device corresponding to the device identifier, it starts to monitor the connection and obtains the echo information returned by the network device for the control command; from the target command template, the associated echo processing indication information associated with the associated command line instruction (or the control command) is obtained, and the echo information is processed according to the echo processing method indicated by the associated echo processing indication information.
[0122] For example, if the control command is a "reboot (restart)" command, and the network device gives an echo "continue? [Y / N]", if the echo processing method indicated by the associated echo processing instruction information is as follows Figure 4b The echo processing mode defined in the figure will automatically send instruction Y to the network device, that is, instruct it to continue the reboot operation. In this way, the echo information can be automatically processed without manual intervention.
[0123] In a feasible embodiment, as described above, the command template definition interface also includes a parameter definition area, and the definition content also includes parameter definition information input for the parameter definition area, the parameter definition information includes input parameter definition information and output parameter definition information, and the output parameter definition information includes information such as the name and data type of the output parameter. After the target command template is executed, the output parameters can be obtained, and the assembled output parameters can be returned to the upper-level application. The upper-level application can continue to write automation logic for the output parameters to achieve fully automatic operation and maintenance, effectively improving operation and maintenance efficiency. It should be noted that returning the output parameters to the upper-level application can support both push and pull modes. Pulling refers to supporting the upper-level application to poll the task status and task results, and pushing refers to providing a registration mechanism to actively push after the task is completed.
[0124] The control method provided in the embodiment of the present application and the command template definition method involved in the control method are described in detail above. In general, the embodiment of the present application provides a method for graphically defining network device interactions based on CLI, which is suitable for developing network automation tool scenarios based on CLI. As a human-computer interaction interface, CLI is vigorously promoted by equipment manufacturers due to its low learning cost and flexible expansion. It is widely used in manual operation and maintenance of network equipment and has become a de facto industry standard. However, with the increasing demand for automated operation and maintenance brought about by the continuous increase in network scale, CLI has many bottlenecks in automated interaction (such as automated interaction between network management servers (or control platforms) and network devices) due to its flexibility or unstructured plain text interaction.
[0125] The method of graphically defining network device interactions based on CLI (command line, or command line instructions) provided in the embodiment of the present application allows network engineers with poor programming skills to quickly get started and easily define CLI-based command templates, thereby easily writing automation scripts. The CLI can also be well structured so that it can be recognized and called by upper-level applications, thereby achieving end-to-end automation from the business logic of network operations to device interactions, reducing automation development costs, and improving development efficiency and network operation quality.
[0126] For example: if a server needs to be reinstalled, the network side needs to first switch the VLAN (virtual LAN) port of the network device (such as a switch) on the opposite side of the server from 999 to 2. Only then can the network be deployed and the server reinstallation proceed normally. VLAN switching is a kind of operation and maintenance scenario. VLAN switching includes the following actions: Step 1, called by the upper-layer application to create a VLAN switching task; Step 2, obtain the SNMP (Simple Network Management Protocol) traffic of the port of the network device on the opposite side of the server through the network management interface; Step 3, if the traffic is less than the threshold, you can continue to step 4, otherwise it is considered that there may be business traffic, and exit with an error. Step 4, log in to the network device through SSH or Telnet connection, execute the command to open VLAN2 and prohibit VLAN999 on the corresponding port, if successful, continue to step 5, otherwise exit with an error; Step 5, return the success information to the upper-layer application.
[0127] These five steps are the complete business logic, among which step four is the device interaction part (the device interaction part involved in the control method provided in the embodiment of this application). The business logic can be implemented by writing code. If the device interaction can also be implemented in an automated way, end-to-end full automation can be achieved. Using the CLI-based graphical definition method for network device interaction provided in the embodiment of this application, the device interaction part in the business logic can be fully automatically generated as a script through a graphical definition, which can then be recognized and called by the upper-level application. Combined with the above description and the following Figure 7 As shown in the figure, the automation implementation of the device interaction part mainly includes the following steps:
[0128] Command template definition:
[0129] Network engineers and network devices mainly interact through command lines, so the network device interaction part mainly solves the problem of command line encapsulation and how to convert the interaction of command lines, such as UI, into recognizable structured data using natural language programming. The ability for network engineers to define network device interactions and convert such definitions into actual device interactions (based on CLI) can be called command templates. A command template usually completes a basic network action, such as opening a port, closing a port, establishing a BGP neighbor, disconnecting a BGP neighbor, etc. The command template definition mainly involves: parameter definition (including input parameter definition and output parameter definition), supporting definition (including device feature definition, command line definition, and echo processing definition). As mentioned above, after the command template definition is completed, it needs to be published before it can be used. The specific definition and publishing methods of command templates can be referred to the relevant descriptions in the previous article, which will not be repeated here.
[0130] Command template execution:
[0131] After the command template is defined, it can be called by upper-level applications (such as automation applications) to trigger the command template execution. This action includes the following steps:
[0132] Data input: The upper-layer application specifies which network device to execute which command template, and inputs the input parameters required by the command template. Command template parsing and assembly of command line instructions: The control platform retrieves the corresponding command template from the command template database according to the command template identifier passed in by the upper-layer application, parses the command template in a specific format, extracts the input parameter name and command line instructions defined in the command template, and then replaces the parameters with the same name in the command line instructions with the input parameter value in combination with the input parameter name and input parameter value passed in by the upper-layer application, thus completing the assembly of command line instructions and generating a complete control command. The control platform sends the control command to the network device so that the network device executes the network action indicated by the control command. The control platform obtains the echo information of the network device for the control command, parses the echo information, and processes the echo information of the network device according to the echo processing method defined in the command template. For specific scenarios and processing methods, please refer to the relevant descriptions in the previous text, which will not be repeated here. The control platform obtains the output parameters and returns the assembled output parameters to the upper-layer application. The upper-layer application can continue to write automation logic for the output parameters to achieve fully automatic operation and maintenance.
[0133] By executing the above steps, the automated processing of the device interaction part is realized. Based on this, end-to-end automation from the business logic of network operation to device interaction can be achieved, thereby effectively reducing the cost of automation development and improving development efficiency and network operation quality.
[0134] It should be noted that the execution entity for executing each step in the above method embodiment may be composed of hardware, software, or a combination of hardware and software.
[0135] See 8, Figure 8 A schematic diagram of the structure of a control device provided in an embodiment of the present application. The control device described in the embodiment of the present application corresponds to the control platform described in the method embodiment above, and the device includes:
[0136] An acquisition unit 801 is used to acquire a device identifier and a command template identifier;
[0137] The acquisition unit 801 is further used to acquire a target command template corresponding to the command template identifier from a command template database; the command template database includes one or more command templates, and the command template is generated according to the definition content input in the command template definition interface; the command template definition interface includes a supporting definition area, and the definition content includes supporting information input for each supporting definition area in one or more supporting definition areas, and the supporting information includes device feature information and command line instructions; the device feature information and command line instructions corresponding to the same supporting definition area have an associated relationship;
[0138] The processing unit 802 is used to determine the matching device feature information that matches the device identifier from the target command template, and obtain the associated command line instruction associated with the matching device feature information;
[0139] The processing unit 802 is further configured to generate a control command according to the associated command line instruction;
[0140] The communication unit 803 is used to send the control command to the network device corresponding to the device identifier, so that the network device executes the network action indicated by the control command.
[0141] In one embodiment, the supporting information further includes echo processing instruction information, and the command line instructions and the echo processing instruction information corresponding to the same supporting definition area have an associated relationship;
[0142] The acquisition unit 801 is further used to: acquire the echo information returned by the network device for the control command; acquire the associated echo processing instruction information associated with the associated command line instruction from the target command template;
[0143] The processing unit 802 is further configured to process the echo information according to the echo processing manner indicated by the associated echo processing indication information.
[0144] In one embodiment, the command template definition interface further includes a parameter definition area, the definition content further includes parameter definition information input for the parameter definition area, the parameter definition information includes an input parameter name, and the command line instruction includes the input parameter name;
[0145] The acquisition unit 801 is further configured to acquire input parameter information associated with the target command template, wherein the input parameter information includes the value of an input parameter;
[0146] The processing unit 802 is further configured to replace the input parameter name in the associated command line instruction with the input parameter value, and generate a control command according to the associated command line instruction after the replacement process.
[0147] In one embodiment, the parameter definition information also includes verification information of the input parameter, and the processing unit 802 is also used to: verify the value of the input parameter according to the verification information; if the verification result indicates that the value verification of the input parameter passes, then replace the input parameter name in the associated command line instruction with the value of the input parameter, and generate a control command according to the associated command line instruction after the replacement processing.
[0148] In one embodiment, the control device further includes a display unit 804, and the display unit 804 is used to display a command template definition interface, wherein the command template definition interface includes a parameter definition area and a matching definition area, and the matching definition area includes a device feature definition area, a command line definition area, and an echo processing definition area;
[0149] The acquisition unit 801 is further used to acquire parameter definition information input into the parameter definition area, device feature information input into the device feature definition area, command line instructions input into the command line definition area, and echo processing indication information input into the echo processing definition area; the device feature information, the command line instructions, and the echo processing indication information constitute the supporting information; the device feature information includes feature information of a network device that can execute the command line instructions;
[0150] The processing unit 802 is also used to: generate a command template according to the parameter definition information, the device feature information, the command line instruction and the echo processing indication information; generate a template identifier of the command template, and store the command template and the template identifier of the command template in the command template database.
[0151] In one embodiment, the initial state of the command template stored in the command template database is a debugging state, and the communication unit 803 is further used to send the command template to a test device so that the test device tests the command template to obtain a test result of the command template;
[0152] The processing unit 802 is further configured to adjust the status of the command template stored in the command template database to a published status if the test result of the command template is approved; the command template in the published status can be used.
[0153] In one embodiment, the acquisition unit 801 is specifically used to respond to a command template call request of an automation application, and obtain a device identifier and a command template identifier carried by the command template call request; wherein the command template call request is used to request control of a network device corresponding to the device identifier according to a target command template corresponding to the command template identifier.
[0154] In another embodiment, the display unit 804 is also used to display a task creation interface;
[0155] The acquisition unit 801 is further used to acquire the device identifier and the command template identifier inputted into the task creation interface;
[0156] The processing unit 802 is also used to generate a command template call request based on the input device identifier and command template identifier, and the acquisition unit 801 is specifically used to respond to the command template call request and obtain the device identifier and command template identifier carried by the command template call request; wherein the command template call request is used to request control of the network device corresponding to the device identifier according to the target command template corresponding to the command template identifier.
[0157] It can be understood that the functions of each functional unit of the control device provided in the embodiment of the present application can be specifically implemented according to the relevant methods in the above-mentioned control method embodiment and the command template definition method embodiment. The specific implementation process can refer to the relevant description in the previous embodiment and will not be repeated here.
[0158] In a feasible embodiment, the control device provided in the embodiment of the present application can be implemented in software. The control device can be stored in a memory. It can be software in the form of programs and plug-ins, and includes a series of units, including an acquisition unit, a processing unit, a communication unit and a display unit; wherein the acquisition unit, the processing unit, the communication unit and the display unit are used to implement the control method provided in the embodiment of the present application and the command template definition method involved in the control method.
[0159] In other feasible embodiments, the control device provided in the embodiment of the present application may also be implemented in a combination of software and hardware. As an example, the control device provided in the embodiment of the present application may be a processor in the form of a hardware decoding processor, which is programmed to execute the control method provided in the embodiment of the present application and the command template definition method involved in the control method. For example, the processor in the form of a hardware decoding processor may adopt one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs) or other electronic components.
[0160] In an embodiment of the present application, on the one hand, a command template is obtained from a command template database, command line instructions corresponding to the network device are obtained from the command template, a control command is generated according to the command line instruction, and the network device is controlled by the control command to perform corresponding network actions, thereby realizing automatic control of the network device based on the command template, which can improve the control efficiency; on the other hand, the command template in the command template database is generated according to the definition content entered in the command template definition interface, and the command template definition interface includes a supporting definition area, and the definition content includes supporting information entered for each supporting definition area in one or more supporting definition areas, and the supporting information includes device feature information and command line instructions, thereby realizing a method based on graphical definition of command templates, which is simple and efficient to operate.
[0161] See also Fig. 9 , Fig. 9 A schematic diagram of the structure of a computer device provided in an embodiment of the present application. The computer device described in the embodiment of the present application corresponds to the control platform or control device described in the previous embodiment, and the computer device includes: a processor 901, a communication interface 902, a memory 903, and a user interface 904. Among them, the processor 901, the communication interface 902, the memory 903, and the user interface 904 can be connected via a bus or other means, and the embodiment of the present application takes the connection via a bus as an example.
[0162] Among them, the processor 901 (or CPU (Central Processing Unit)) is the computing core and control core of the computer device, which can parse various instructions in the computer device and process various data of the computer device. For example, the CPU can be used to parse the power on and off instructions sent by the user to the computer device, and control the computer device to perform power on and off operations; for another example, the CPU can transmit various interactive data between the internal structures of the computer device, and so on. The communication interface 902 can optionally include a standard wired interface, a wireless interface (such as Wi-Fi, a mobile communication interface, etc.), which is controlled by the processor 901 to send and receive data. The memory 903 (Memory) is a memory device in the computer device for storing programs and data. It can be understood that the memory 903 here can include both the built-in memory of the computer device and the extended memory supported by the computer device. The memory 903 provides a storage space, which stores the operating system of the computer device, which may include but is not limited to: Android system, iOS system, Windows Phone system, etc., and this application does not limit this. The user interface 904 is a medium for realizing interaction and information exchange between the user and the terminal, and its specific embodiment may include a display screen (Display) for output and a keyboard (Keyboard) for input, etc.
[0163] In the embodiment of the present application, the processor 901 performs the following operations by running the executable program code in the memory 903:
[0164] The device identification and command template identification are obtained through the communication interface 902; the target command template corresponding to the command template identification is obtained from the command template database; the command template database includes one or more command templates, and the command template is generated according to the definition content entered in the command template definition interface; the command template definition interface includes a supporting definition area, and the definition content includes supporting information entered for each supporting definition area in one or more supporting definition areas, and the supporting information includes device feature information and command line instructions; the device feature information and command line instructions corresponding to the same supporting definition area have an associated relationship; from the target command template, the matching device feature information matching the device identification is determined, and the associated command line instructions associated with the matching device feature information are obtained; a control command is generated according to the associated command line instructions, and the control command is sent to the network device corresponding to the device identification through the communication interface 902, so that the network device executes the network action indicated by the control command.
[0165] In one embodiment, the supporting information also includes echo processing indication information, and the command line instructions and echo processing indication information corresponding to the same supporting definition area have an associated relationship. The processor 901 is also used to: obtain the echo information returned by the network device for the control command through the communication interface 902; obtain the associated echo processing indication information associated with the associated command line instructions from the target command template; and process the echo information according to the echo processing method indicated by the associated echo processing indication information.
[0166] In one embodiment, the command template definition interface further includes a parameter definition area, the definition content further includes parameter definition information input for the parameter definition area, the parameter definition information includes an input parameter name, the command line instruction includes the input parameter name, and the processor 901 is further used to: obtain input parameter information associated with the target command template, the input parameter information includes the value of the input parameter;
[0167] When the processor 901 generates a control command according to the associated command line instruction, it is specifically used to: replace the input parameter name in the associated command line instruction with the input parameter value, and generate a control command according to the associated command line instruction after the replacement process.
[0168] In one embodiment, the parameter definition information also includes verification information of the input parameter, and the processor 901 is also used to: verify the value of the input parameter according to the verification information; if the verification result indicates that the value verification of the input parameter passes, then replace the input parameter name in the associated command line instruction with the value of the input parameter, and generate a control command according to the associated command line instruction after the replacement processing.
[0169] In one embodiment, the processor 901 is also used to: display a command template definition interface through a user interface 904, the command template definition interface including a parameter definition area and a supporting definition area, the supporting definition area including a device feature definition area, a command line definition area and an echo processing definition area; obtain parameter definition information input for the parameter definition area, device feature information input for the device feature definition area, command line instructions input for the command line definition area, and echo processing indication information input for the echo processing definition area; the device feature information, the command line instructions and the echo processing indication information constitute the supporting information; the device feature information includes feature information of a network device that can execute the command line instructions; generate a command template according to the parameter definition information, the device feature information, the command line instructions and the echo processing indication information; generate a template identifier of the command template, and store the command template and the template identifier of the command template in the command template database.
[0170] In one embodiment, the initial state of the command template stored in the command template database is a debugging state, and the processor 901 is also used to: send the command template to a test device through a communication interface 902, so that the test device tests the command template to obtain a test result of the command template; if the test result of the command template is approved, the state of the command template stored in the command template database is adjusted to a published state; the command template in the published state can be used.
[0171] In one embodiment, when the processor 901 obtains the device identifier and the command template identifier, it is specifically used to: respond to the command template call request of the automation application, obtain the device identifier and the command template identifier carried in the command template call request, and execute subsequent steps; or, display the task creation interface through the user interface 904, obtain the device identifier and the command template identifier input for the task creation interface, generate a command template call request according to the input device identifier and command template identifier, respond to the command template call request, obtain the device identifier and the command template identifier carried in the command template call request, and execute subsequent steps; wherein the command template call request is used to request to control the network device corresponding to the device identifier according to the target command template corresponding to the command template identifier.
[0172] In a specific implementation, the processor 901, communication interface 902, memory 903 and user interface 904 described in the embodiments of the present application can execute the implementation method of the control platform described in the control method provided in the embodiments of the present application, and can also execute the implementation method described in the control device provided in the embodiments of the present application, which will not be repeated here.
[0173] In an embodiment of the present application, on the one hand, a command template is obtained from a command template database, command line instructions corresponding to the network device are obtained from the command template, a control command is generated according to the command line instruction, and the network device is controlled by the control command to perform corresponding network actions, thereby realizing automatic control of the network device based on the command template, which can improve the control efficiency; on the other hand, the command template in the command template database is generated according to the definition content entered in the command template definition interface, and the command template definition interface includes a supporting definition area, and the definition content includes supporting information entered for each supporting definition area in one or more supporting definition areas, and the supporting information includes device feature information and command line instructions, thereby realizing a method based on graphical definition of command templates, which is simple and efficient to operate.
[0174] The embodiment of the present application also provides a computer-readable storage medium, in which computer instructions are stored, and when the computer-readable storage medium is run on a computer, the computer implements the control method provided by the embodiment of the present application. The specific implementation method can be referred to the above description, and will not be repeated here.
[0175] The embodiment of the present application also provides a computer program product, which includes a computer program or a computer instruction, and the computer program or the computer instruction is stored in a computer-readable storage medium. The processor of the computer device reads the computer program or the computer instruction from the computer-readable storage medium, and the processor executes the computer program or the computer instruction, so that the computer device implements the control method provided in the embodiment of the present application. The specific implementation method can be referred to the above description, which will not be repeated here.
[0176] It should be noted that the collection and processing of relevant data in this application should be strictly in accordance with the requirements of relevant laws and regulations when applied in examples, and the informed consent or separate consent of the personal information subject should be obtained, and subsequent data use and processing should be carried out within the scope of authorization of laws and regulations and the personal information subject.
[0177] It should be noted that, for the above-mentioned various method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this application.
[0178] A person skilled in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0179] The above disclosure is only part of the embodiments of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A control method, characterized in that: The method comprises: Get the device ID and command template ID; Acquire a target command template corresponding to the command template identifier from a command template database; the command template database includes one or more command templates, the command template is generated according to definition content input in a command template definition interface; the command template definition interface includes a matching definition area, the definition content includes matching information input for each matching definition area in one or more matching definition areas, the matching information includes device feature information and command line instructions; the device feature information and command line instructions corresponding to the same matching definition area have an associated relationship; Determining, from the target command template, matching device feature information that matches the device identifier, and acquiring associated command line instructions associated with the matching device feature information; A control command is generated according to the associated command line instruction, and the control command is sent to the network device corresponding to the device identifier, so that the network device executes the network action indicated by the control command.
2. The method according to claim 1, characterized in that The supporting information also includes echo processing instruction information, and the command line instructions and the echo processing instruction information corresponding to the same supporting definition area have an associated relationship. The method also includes: Obtaining the echo information returned by the network device in response to the control command; Acquire, from the target command template, associated echo processing instruction information associated with the associated command line instruction; The echo information is processed according to the echo processing mode indicated by the associated echo processing indication information.
3. The method according to claim 2, characterized in that The command template definition interface also includes a parameter definition area, the definition content also includes parameter definition information input for the parameter definition area, the parameter definition information includes an input parameter name, the command line instruction includes the input parameter name, and the method further includes: Acquire input parameter information associated with the target command template, the input parameter information including the value of the input parameter; The step of generating a control command according to the associated command line instruction includes: The input parameter name in the associated command line instruction is replaced with the input parameter value, and a control command is generated according to the associated command line instruction after the replacement process.
4. The method according to claim 3, characterized in that The parameter definition information also includes verification information of the input parameters, and the method further includes: Verifying the value of the input parameter according to the verification information; If the verification result indicates that the value verification of the input parameter passes, the step of replacing the input parameter name in the associated command line instruction with the input parameter value and generating a control command according to the associated command line instruction after the replacement is executed.
5. The method according to claim 3 or 4, characterized in that The method further comprises: Display a command template definition interface, wherein the command template definition interface includes a parameter definition area and a supporting definition area, wherein the supporting definition area includes a device feature definition area, a command line definition area, and an echo processing definition area; Acquire parameter definition information input into the parameter definition area, device feature information input into the device feature definition area, command line instructions input into the command line definition area, and echo processing indication information input into the echo processing definition area; the device feature information, the command line instructions, and the echo processing indication information constitute the supporting information; the device feature information includes feature information of a network device that can execute the command line instructions; Generate a command template according to the parameter definition information, the device feature information, the command line instruction and the echo processing instruction information; A template identifier of the command template is generated, and the command template and the template identifier of the command template are stored in the command template database.
6. The method according to claim 5, characterized in that The initial state of the command template stored in the command template database is a debugging state, and the method further includes: Sending the command template to a test device so that the test device tests the command template and obtains a test result of the command template; If the test result of the command template is approved, the state of the command template stored in the command template database is adjusted to a published state; the command template in the published state can be used.
7. The method according to claim 1, characterized in that The obtaining of the device identifier and the command template identifier includes: In response to a command template call request of an automation application, obtaining a device identifier and a command template identifier carried in the command template call request, and executing subsequent steps; or, Displaying a task creation interface, obtaining a device identifier and a command template identifier inputted in the task creation interface, generating a command template call request according to the input device identifier and command template identifier, responding to the command template call request, obtaining the device identifier and command template identifier carried in the command template call request, and executing subsequent steps; The command template calling request is used to request to control the network device corresponding to the device identifier according to the target command template corresponding to the command template identifier.
8. A control device, characterized in that: The device comprises: An acquisition unit, used for acquiring a device identifier and a command template identifier; The acquisition unit is further used to acquire a target command template corresponding to the command template identifier from a command template database; the command template database includes one or more command templates, and the command template is generated according to the definition content input in the command template definition interface; the command template definition interface includes a matching definition area, and the definition content includes matching information input for each matching definition area in one or more matching definition areas, and the matching information includes device feature information and command line instructions; the device feature information and command line instructions corresponding to the same matching definition area have an associated relationship; A processing unit, configured to determine, from the target command template, matching device feature information that matches the device identifier, and to obtain associated command line instructions associated with the matching device feature information; The processing unit is further configured to generate a control command according to the associated command line instruction; The communication unit is used to send the control command to the network device corresponding to the device identifier, so that the network device executes the network action indicated by the control command.
9. A computer device, characterized in that: include: A processor, a communication interface and a memory, wherein the processor, the communication interface and the memory are interconnected, wherein the memory stores an executable program code, and the processor is used to call the executable program code to implement the control method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, which, when executed on a computer, enable the computer to implement the control method according to any one of claims 1 to 7.
11. A computer program product, characterized in that The computer program product comprises a computer program or a computer instruction, and when the computer program or the computer instruction is executed by a processor, the control method according to any one of claims 1 to 7 is implemented.