Operation method and device based on state machine, electronic equipment and storage medium
By abstracting the operation and maintenance process into a three-layer structure managed by a state machine, the problems of low reuse, low efficiency and low security in the existing technology are solved, and efficient and secure operation and maintenance operations are achieved.
Patent Information
- Application Number
- CN201910630833.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-07-12
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2039-07-12
AI Technical Summary
Existing operation and maintenance operating systems have problems such as low operation reuse, low execution efficiency, and low security. In particular, the execution success rate of a single Shell script is not high in complex scenarios, and the correctness of the script is difficult to guarantee.
A state machine-based operation and maintenance method is adopted to abstract the operation and maintenance operation process into a three-layer structure of operation flow, operation steps and atomic operations. The operation process is managed through state machine nodes, and retry and skipping of atomic operations are supported. Automated checks are added to ensure safety.
It improves the reusability, execution efficiency and security of operation and maintenance operations, reduces the occurrence of large-scale failures, and achieves efficient and safe execution of operations.
Smart Images

Figure CN110362346B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of computer technology, and in particular to a state machine-based operation and maintenance method, device, electronic device, and storage medium. Background Art
[0002] In the field of online operations and maintenance, there are two major categories of operations: program deployment and maintenance. For the continued development of program deployment platforms, operations and maintenance still face significant efficiency and security challenges. On the one hand, manual operations account for a high proportion of overall operations, resulting in a high labor burden for daily operations and maintenance. On the other hand, operations and maintenance carry inherent risks, often leading to large-scale online outages due to operational errors. Therefore, the operations and maintenance development team needs to develop an operations and maintenance execution system to converge operations through a platform-based approach, improving both efficiency and security.
[0003] Existing operation and maintenance execution systems generally support the following functions: First, they provide a storage and management mechanism for daily operations, encouraging users to upload their frequently used operation scripts (usually Shell scripts) to the system, and then users can directly select existing scripts to initiate operations; second, they provide remote execution capabilities, supporting sending scripts to a group of remote machines and executing them; third, they provide feedback on execution results, generally judging whether the execution is successful and returning the results through the script's return code; fourth, they provide query of operation execution history; and fifth, they provide a web interface to facilitate users to operate the above functions.
[0004] In the process of implementing the present invention, the inventors discovered that the prior art has at least the following problems:
[0005] First, the operation reuse rate is low: each Shell script is often written for a specific operation and maintenance scenario. Each Shell script is highly personalized and generally difficult to reuse. In some cases, only the script uploader will use it, resulting in an increasing number of Shell scripts for system maintenance. Second, the operation execution efficiency is low: although traditional operation and maintenance systems can support automated remote execution, due to the complex logic of a single Shell script, the execution success rate is not high when it comes to complex operation scenarios. Moreover, after each execution failure, even if the problem that caused the failure is solved, it needs to be executed again from the beginning. In addition, the operation security is low: using system execution scripts instead of manual operations can largely avoid manual errors, but because the scripts are also written manually and lack a unified verification mechanism, the correctness of the scripts cannot be fully guaranteed. Summary of the Invention
[0006] In view of this, an embodiment of the present invention provides a state machine-based operation and maintenance method, device, electronic device and storage medium, which can not only improve operation multiplexing, but also improve operation execution efficiency and operation execution security.
[0007] In a first aspect, an embodiment of the present invention provides an operation and maintenance method based on a state machine, the method comprising:
[0008] Receive a trigger message from the user to start the state machine corresponding to the operation flow;
[0009] Determine, according to the trigger message, each operation step included in the operation flow and each atomic operation included in each operation step; and use the first operation step included in the operation flow as the current operation step;
[0010] Executing the current operation step on the state machine node corresponding to the current operation step according to each atomic operation included in the current operation step;
[0011] According to the execution result of the current operation step, the next operation step of the current operation step is determined, the next operation step is used as the current operation step, and the above operation is repeatedly performed until the last operation step included in the operation flow is completed.
[0012] In the above embodiment, determining the various operation steps included in the operation flow and the various atomic operations included in each operation step according to the trigger message includes:
[0013] Determining an operation template corresponding to the state machine according to the trigger message;
[0014] The various operation steps included in the operation flow and the various atomic operations included in each operation step are determined according to the operation template.
[0015] In the above embodiment, determining the operation steps included in the operation flow and the atomic operations included in each operation step according to the operation template includes:
[0016] Parsing the operation template according to the data format corresponding to each operation step predefined in the operation template, and determining each operation step corresponding to the operation flow in the operation template;
[0017] Each operation step is parsed according to the data format corresponding to each atomic operation pre-defined in each operation step, and each atomic operation corresponding to each operation step is determined in each operation step.
[0018] In the above embodiment, executing the current operation step on the state machine node corresponding to the current operation step according to each atomic operation included in the current operation step includes:
[0019] The first atomic operation included in the current operation step is used as the current atomic operation;
[0020] Execute each operation command corresponding to the current atomic operation on the state machine node corresponding to the current operation step according to each operation command corresponding to the current atomic operation determined in advance;
[0021] According to the execution result of the current atomic operation, the next atomic operation of the current atomic operation is determined, and the next atomic operation is used as the current atomic operation. The above operation is repeatedly performed until the last atomic operation included in the current operation step is completed.
[0022] In the above embodiment, determining the next operation step of the current operation step according to the execution result of the current operation step includes:
[0023] If the current operation step is successfully executed on the corresponding state machine node, determining the operation step adjacent to the current operation step as the next operation step;
[0024] If the current operation step fails to be executed on the corresponding state machine node, the current operation step itself is used as the next operation step; or, the operation step determined according to the execution strategy of the current operation step is determined as the next operation step.
[0025] In a second aspect, an embodiment of the present invention provides an operation and maintenance device based on a state machine, the device comprising: a receiving module, a determining module and an executing module; wherein,
[0026] The receiving module is configured to receive a trigger message from a user for starting a state machine corresponding to an operation flow;
[0027] The determining module is configured to determine, according to the trigger message, each operation step included in the operation flow and each atomic operation included in each operation step; and to use the first operation step included in the operation flow as the current operation step;
[0028] The execution module is used to execute the current operation step on the state machine node corresponding to the current operation step according to the atomic operations contained in the current operation step; determine the next operation step of the current operation step according to the execution result of the current operation step, take the next operation step as the current operation step, and repeat the above operation until the last operation step contained in the operation flow is executed.
[0029] In the above embodiment, the determination module is specifically used to determine the operation template corresponding to the state machine according to the trigger message; and determine the various operation steps included in the operation flow and the various atomic operations included in each operation step according to the operation template.
[0030] In the above embodiment, the determination module is specifically used to parse the operation template according to the data format corresponding to each operation step pre-defined in the operation template, and determine the various operation steps corresponding to the operation flow in the operation template; parse each operation step according to the data format corresponding to each atomic operation pre-defined in each operation step, and determine the various atomic operations corresponding to each operation step in each operation step.
[0031] In the above embodiment, the execution module includes: an execution submodule and a determination submodule; wherein,
[0032] The execution submodule is configured to take the first atomic operation included in the current operation step as the current atomic operation; and execute the respective operation commands corresponding to the current atomic operation on the state machine node corresponding to the current operation step according to the respective operation commands corresponding to the current atomic operation determined in advance;
[0033] The determination submodule is used to determine the next atomic operation of the current atomic operation based on the execution result of the current atomic operation, take the next atomic operation as the current atomic operation, and repeatedly perform the above operations until the last atomic operation included in the current operation step is completed.
[0034] In the above embodiment, the execution module is specifically used to determine the operation step adjacent to the current operation step as the next operation step if the current operation step is successfully executed on the corresponding state machine node; if the current operation step fails to be executed on the corresponding state machine node, the current operation step itself as the next operation step; or, determine the operation step determined according to the execution strategy of the current operation step as the next operation step.
[0035] In a third aspect, an embodiment of the present invention provides an electronic device, including:
[0036] one or more processors;
[0037] a memory for storing one or more programs,
[0038] When the one or more programs are executed by the one or more processors, the one or more processors implement the state machine-based operation and maintenance method described in any embodiment of the present invention.
[0039] In a fourth aspect, an embodiment of the present invention provides a storage medium on which a computer program is stored. When the program is executed by a processor, the state machine-based operation and maintenance method described in any embodiment of the present invention is implemented.
[0040] The embodiment of the present invention proposes an operation and maintenance method, device, electronic device and storage medium based on a state machine, which first receives a trigger message of a state machine corresponding to a start operation flow sent by a user; then, according to the trigger message, determines the various operation steps contained in the operation flow and the various atomic operations contained in each operation step; takes the first operation step contained in the operation flow as the current operation step; executes the current operation step on the state machine node corresponding to the current operation step according to the various atomic operations contained in the current operation step; then, according to the execution result of the current operation step, determines the next operation step of the current operation step, takes the next operation step as the current operation step, and repeats the above operation until the last operation step contained in the operation flow is completed. That is, in the technical solution of the present invention, the operation and maintenance operation process is abstracted into the following three layers: operation flow, operation steps and atomic operations; wherein, the operation flow corresponds to a state machine; the operation step corresponds to a state machine node; and the atomic operation includes multiple operation commands. The operation flows, operation steps, and atomic operations in the embodiments of the present invention can all be reused on different operation and maintenance objects; moreover, after a single operation step fails to execute, it supports retrying the state machine node and skipping the state machine node, which can effectively improve the efficiency of operation execution; in addition, when operating batch objects, it will force an automatic check, and terminate the execution after the check fails, which can effectively reduce the scope of abnormal impact and avoid the occurrence of large-scale failures. Therefore, compared with the existing technology, the state machine-based operation and maintenance operation method, device, electronic device, and storage medium proposed in the embodiments of the present invention can not only improve the operation reuse, but also improve the operation execution efficiency and operation execution security; moreover, the technical solution of the embodiments of the present invention is simple and convenient to implement, easy to popularize, and has a wider range of applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 A schematic diagram of a flow chart of an operation and maintenance method based on a state machine provided in the first embodiment of the present invention;
[0042] Figure 2 A hierarchical diagram of the service expansion and maintenance operations provided in Example 1 of the present invention;
[0043] Figure 3 A schematic diagram of a flow chart of a state machine-based operation and maintenance method provided in the second embodiment of the present invention;
[0044] Figure 4 A schematic diagram of the structure of a state machine provided in the second embodiment of the present invention;
[0045] Figure 5 A first structural diagram of an operation and maintenance device based on a state machine provided in the third embodiment of the present invention;
[0046] Figure 6 A second structural diagram of the state machine-based operation and maintenance device provided in the third embodiment of the present invention;
[0047] Figure 7 This is a structural diagram of an electronic device provided in Example 4 of the present invention. DETAILED DESCRIPTION
[0048] The present invention will be further described in detail below with reference to the accompanying drawings and examples. It will be understood that the specific embodiments described herein are intended only to illustrate the present invention and are not intended to limit the present invention. It should also be noted that, for ease of description, the accompanying drawings only illustrate portions relevant to the present invention and not all of the present invention.
[0049] Example 1
[0050] Figure 1 This is a flow chart of the state machine-based operation and maintenance method provided in the first embodiment of the present invention. This method can be performed by a state machine-based operation and maintenance device or electronic device. The device or electronic device can be implemented in software and / or hardware. The device or electronic device can be integrated into any smart device with network communication function. Figure 1 As shown, the state machine-based operation and maintenance method may include the following steps:
[0051] S101: Receive a trigger message from a user to start a state machine corresponding to an operation flow.
[0052] In a specific embodiment of the present invention, an electronic device can receive a trigger message sent by a user to start a state machine corresponding to an operation flow. Specifically, one operation flow can correspond to one state machine, and different operation flows can start different state machines. The user can send a trigger message to the backend server through the platform page, and the platform page passes the trigger message to the backend server to start the state machine. The trigger message may include an operation template and other descriptive information. Most operation and maintenance operations in actual operation and maintenance scenarios are not just executing a single line of command or a single script, but a collection of a series of operations and judgments. Therefore, the machines, services, network nodes, etc. operated by this collection of operations and judgments can be uniformly defined as operation and maintenance objects. If the operation flow execution process is observed from the perspective of the operation and maintenance object, the entire execution process can be transformed into a process of state change of the operated operation and maintenance object. Each operation flow is represented by a jump in each operation step, and the direction of the jump is determined by the execution result of the current operation step.
[0053] Figure 2 This is a hierarchical diagram of the service expansion and maintenance operations provided in the first embodiment of the present invention. Figure 2 As shown, the service expansion operation flow corresponding to the service expansion operation and maintenance operation includes at least the following operation steps: screening machines, initializing machines, deploying services, starting services, accessing traffic, etc., and after each operation step is completed, it is necessary to judge whether the operation step meets expectations. For example, before executing the operation step of accessing traffic, it must be ensured that the operation step of starting the service has been executed normally. The traditional solution is to write a logically complex operation script, which needs to consider the handling of a large number of abnormal situations, and once it fails halfway, it often needs to start over. The embodiment of the present invention abstracts the operation and maintenance operations into an operation flow, facilitates reuse by reducing the granularity, and supports the continuation of the operation flow breakpoint. Electronic devices can describe the actual operation process through the following three layers of abstraction, which include, from top to bottom: a) Operation flow: An operation flow corresponds to a complete operation in the actual operation and maintenance scenario. The operation flow is composed of multiple operation steps, and the target of the operation is a single or multiple operation and maintenance objects; b) Operation step: An operation step corresponds to a single meaningful operation in the operation and maintenance operation process, such as initializing the machine and starting the service in the service expansion operation and maintenance operation. The operation step consists of a series of commands; c) Atomic operation: Many operation commands are universal, such as: calling BNS, calling the RMS platform, executing remote commands, calling BFE to cut traffic, etc. These commands can be encapsulated into atomic operations, and then the calls are executed using a unified operation interface layer.
[0054] S102: Determine, according to the trigger message, each operation step included in the operation flow and each atomic operation included in each operation step; and use the first operation step included in the operation flow as the current operation step.
[0055] In a specific embodiment of the present invention, the electronic device can determine the various operation steps included in the operation flow and the various atomic operations included in each operation step based on the trigger message. Specifically, the trigger message can include an operation template corresponding to the state machine and can also include other descriptive information. Therefore, the electronic device can determine the operation template corresponding to the state machine based on the trigger message; then, based on the operation template, determine the various operation steps included in the operation flow and the various atomic operations included in each operation step. In this step, the electronic device can use the first operation step included in the operation flow as the current operation step.
[0056] S103. Execute the current operation step on the state machine node corresponding to the current operation step according to each atomic operation included in the current operation step.
[0057] In a specific embodiment of the present invention, the electronic device can execute the current operation step on the state machine node corresponding to the current operation step according to the various atomic operations included in the current operation step. Specifically, the electronic device can use the first atomic operation included in the current operation step as the current atomic operation; then, based on the various operation commands corresponding to the current atomic operation determined in advance, execute the various operation commands corresponding to the current atomic operation on the state machine node corresponding to the current operation step; then, based on the execution result of the current atomic operation, determine the next atomic operation of the current atomic operation, use the next atomic operation as the current atomic operation, and repeat the above operations until the last atomic operation included in the current operation step is completed.
[0058] S104. Determine whether the current operation step is the last operation step included in the operation flow; if so, execute S105; otherwise, execute S106.
[0059] In a specific embodiment of the present invention, the electronic device can determine whether the current operation step is the last operation step included in the operation flow; if the current operation step is the last operation step included in the operation flow, execute S105; if the current operation step is not the last operation step included in the operation flow, execute S106.
[0060] S105: End the state machine-based operation and maintenance process.
[0061] In a specific embodiment of the present invention, if the current operation step is the last operation step included in the operation flow, the state machine-based operation and maintenance operation process is terminated.
[0062] S106. Determine the next operation step of the current operation step according to the execution result of the current operation step, take the next operation step as the current operation step, and return to execute S103.
[0063] In a specific embodiment of the present invention, if the current operation step is not the last operation step included in the operation flow, the electronic device may determine the next operation step of the current operation step based on the execution result of the current operation step, set the next operation step as the current operation step, and return to execution S103. Specifically, if the current operation step is successfully executed on the corresponding state machine node, the electronic device may determine the operation step adjacent to the current operation step as the next operation step; if the current operation step fails to execute on the corresponding state machine node, the electronic device may determine the current operation step itself as the next operation step; or, alternatively, determine the operation step determined according to the execution policy of the current operation step as the next operation step.
[0064] The state machine-based operation and maintenance method proposed in the embodiment of the present invention first receives a trigger message from the user to start the state machine corresponding to the operation flow; then determines the various operation steps contained in the operation flow and the various atomic operations contained in each operation step based on the trigger message; takes the first operation step contained in the operation flow as the current operation step; executes the current operation step on the state machine node corresponding to the current operation step based on the various atomic operations contained in the current operation step; then determines the next operation step of the current operation step based on the execution result of the current operation step, takes the next operation step as the current operation step, and repeats the above operations until the last operation step contained in the operation flow is completed. That is to say, in the technical solution of the present invention, the operation and maintenance operation process is abstracted into the following three layers: operation flow, operation steps and atomic operations; wherein, the operation flow corresponds to a state machine; the operation step corresponds to a state machine node; and the atomic operation includes multiple operation commands. The operation flows, operation steps, and atomic operations in the embodiments of the present invention can all be reused on different operation and maintenance objects; moreover, after a single operation step fails to execute, it supports retrying the state machine node and skipping the state machine node, which can effectively improve the efficiency of operation execution; in addition, when operating batch objects, it will force an automatic check, and terminate the execution after the check fails, which can effectively reduce the scope of abnormal impact and avoid the occurrence of large-scale failures. Therefore, compared with the existing technology, the state machine-based operation and maintenance operation method proposed in the embodiment of the present invention can not only improve the reuse of operations, but also improve the efficiency and security of operation execution; moreover, the technical solution of the embodiment of the present invention is simple and convenient to implement, easy to popularize, and has a wider range of applications.
[0065] Example 2
[0066] Figure 3 The flowchart of the state machine-based operation and maintenance method provided in the second embodiment of the present invention is as follows. Figure 3 As shown, the state machine-based operation and maintenance method may include the following steps:
[0067] S301: Receive a trigger message from a user to start a state machine corresponding to an operation flow.
[0068] In a specific embodiment of the present invention, an electronic device can receive a trigger message sent by a user to activate a state machine corresponding to an operation flow. Specifically, one operation flow can correspond to one state machine, and different operation flows can activate different state machines. The user can send a trigger message to the backend server through a platform page. The platform page transmits the trigger message to the backend server to activate the state machine. The trigger message may include an operation template and other descriptive information.
[0069] S302: Determine an operation template corresponding to the state machine according to the trigger message.
[0070] In a specific embodiment of the present invention, the electronic device can determine the operation template corresponding to the state machine based on the trigger message. Specifically, the trigger message can carry an identifier of the operation template; the electronic device can first obtain the identifier of the operation template in the trigger message, and then determine the operation template corresponding to the state machine based on the identifier of the trigger template.
[0071] Preferably, in a specific embodiment of the present invention, the electronic device can use a python file to describe the operation flow, and the user only needs to formulate the initial operation steps, so that different operation steps can be implemented. Specifically, the electronic device can parse the definition of each operation step in the operation template, for example, the definition of operation step A (Step A); the definition of operation step B (Step B); ...; the definition of operation step N (Step N); wherein N is a natural number greater than or equal to 1. In the definition of each operation step, the electronic device can also parse the operation object and operation parameters, so as to perform the operation of each operation step according to the parsed operation correspondence and operation parameters. Here, the electronic device can receive the trigger message of the state machine corresponding to the start operation flow through the message sensor; then create an operation or intervene in the operation through the decision maker, and can parse the operation template when creating the operation; and parse the operation command when intervening in the operation; and then execute the operation of each operation step through the executor.
[0072] Figure 4 This is a schematic diagram of the structure of the state machine provided in the second embodiment of the present invention. Figure 4As shown, it is assumed that the operation and maintenance operation includes five operation steps, namely: operation step A, operation step B, operation step, operation step D, and operation step E. In this embodiment, the electronic device can start from operation step A; then, based on the execution result of operation step A, determine that the next operation step is operation step B; then execute operation step B; assuming that operation step B fails to execute on the corresponding state machine node, operation step B is used as the next operation step and operation step B is re-executed; if operation step B is successfully executed on the corresponding state machine node, the next operation step is determined to be operation step C based on the execution result of operation step B; if operation step B fails to execute on the corresponding state machine node again, operation step B can be skipped and operation step C can be directly executed; then, based on the execution result of operation step C, it is selected to pause or continue to execute operation step D; then, based on the execution result of operation step D, it is determined that the next operation step is operation step E; finally, operation step E is executed.
[0073] S303: Determine the operation steps included in the operation flow and the atomic operations included in each operation step according to the operation template; and use the first operation step included in the operation flow as the current operation step.
[0074] In a specific embodiment of the present invention, the electronic device can determine the various operation steps included in the operation flow and the various atomic operations included in each operation step based on the trigger message. Specifically, the trigger message can include an operation template corresponding to the state machine and can also include other descriptive information. Therefore, the electronic device can determine the operation template corresponding to the state machine based on the trigger message; then, based on the operation template, determine the various operation steps included in the operation flow and the various atomic operations included in each operation step. In this step, the electronic device can use the first operation step included in the operation flow as the current operation step.
[0075] S304: Execute the current operation step on the state machine node corresponding to the current operation step according to each atomic operation included in the current operation step.
[0076] In a specific embodiment of the present invention, the electronic device can execute the current operation step on the state machine node corresponding to the current operation step according to the various atomic operations included in the current operation step. Specifically, the electronic device can use the first atomic operation included in the current operation step as the current atomic operation; then, based on the various operation commands corresponding to the current atomic operation determined in advance, execute the various operation commands corresponding to the current atomic operation on the state machine node corresponding to the current operation step; then, based on the execution result of the current atomic operation, determine the next atomic operation of the current atomic operation, use the next atomic operation as the current atomic operation, and repeat the above operations until the last atomic operation included in the current operation step is completed.
[0077] S305. Determine whether the current operation step is the last operation step included in the operation flow; if so, execute S306; otherwise, execute S307.
[0078] In a specific embodiment of the present invention, the electronic device can determine whether the current operation step is the last operation step included in the operation flow; if the current operation step is the last operation step included in the operation flow, execute S306; if the current operation step is not the last operation step included in the operation flow, execute S307.
[0079] S306: End the state machine-based operation and maintenance process.
[0080] In a specific embodiment of the present invention, if the current operation step is the last operation step included in the operation flow, the state machine-based operation and maintenance operation process is terminated.
[0081] S307. Determine the next operation step of the current operation step according to the execution result of the current operation step, take the next operation step as the current operation step, and return to execute S304.
[0082] In a specific embodiment of the present invention, if the current operation step is not the last operation step included in the operation flow, the electronic device may determine the next operation step of the current operation step based on the execution result of the current operation step, set the next operation step as the current operation step, and return to execution S304. Specifically, if the current operation step is successfully executed on the corresponding state machine node, the electronic device may determine the operation step adjacent to the current operation step as the next operation step; if the current operation step fails to execute on the corresponding state machine node, the electronic device may determine the current operation step itself as the next operation step; or, alternatively, determine the operation step determined according to the execution policy of the current operation step as the next operation step.
[0083] Preferably, in a specific embodiment of the present invention, the execution efficiency can be improved through operation abstraction and execution mode, but the problem of high operation risk is still not solved. Our core idea here is not to eliminate abnormal operations from the root too ideally, but to minimize the impact of failures. The specific idea is to divide the operation execution of batch operation and maintenance objects into steps, and insert mandatory automated checks to ensure that the operation meets expectations. The implementation points of batch operation grading include the following three points: 1. Split operation steps: If multiple operation and maintenance objects are operated at one time, the multiple operation and maintenance objects are forced to be divided into multiple groups of operation and maintenance objects according to the grading requirements (each group is called a grading step), and each group of operation and maintenance objects is strictly executed in series; 2. Automatic execution check: After each operation and maintenance object group is executed, the check action is automatically executed, and the user-defined monitoring items or check scripts are called to ensure that the operation does not cause unexpected effects; 3. Strengthen process management: pre-operation audit to reduce the occurrence of low-level errors; record operation history for problem backtracking and historical auditing.
[0084] In a specific embodiment of the present invention, state machine-based O&M operations offer the following advantages over traditional approaches: 1. High operational reuse: Compared to traditional single shell scripts, the operation templates in the embodiments of the present invention provide a three-level abstraction: operation flow, operation steps, and atomic operations. Specifically, 1) Atomic operations abstract daily single-step operations, including platform calls and domain name resolution functions. Operational operators (OPs) from different product lines can use these templates. 2) Operation templates address specific O&M scenario requirements, incorporating extensive operational operator experience. Carefully crafted operation templates can be applied to the same scenarios across multiple product lines, such as traffic scheduling and disk cleanup. 3) Even templates closely related to business operations, such as capacity expansion, can reuse many of their steps. Different product lines may only need to modify the installation template and program version. This allows the reuse of the same operation template across different O&M targets. 2. High operational execution efficiency: In the embodiments of the present invention, a complete O&M operation consists of multiple steps, and the next execution strategy can be dynamically determined during execution. If a single operation step fails, the template can be retried or skipped, effectively improving execution success rates and avoiding repeated restarts. 3. Operation execution safety: When operating batch objects, the embodiment of the present invention will force an automated check and terminate the execution if the check fails, which can effectively reduce the scope of control anomalies and avoid the occurrence of large-scale failures.
[0085] The state machine-based operation and maintenance method proposed in the embodiment of the present invention first receives a trigger message from the user to start the state machine corresponding to the operation flow; then determines the various operation steps contained in the operation flow and the various atomic operations contained in each operation step based on the trigger message; takes the first operation step contained in the operation flow as the current operation step; executes the current operation step on the state machine node corresponding to the current operation step based on the various atomic operations contained in the current operation step; then determines the next operation step of the current operation step based on the execution result of the current operation step, takes the next operation step as the current operation step, and repeats the above operations until the last operation step contained in the operation flow is completed. That is to say, in the technical solution of the present invention, the operation and maintenance operation process is abstracted into the following three layers: operation flow, operation steps and atomic operations; wherein, the operation flow corresponds to a state machine; the operation step corresponds to a state machine node; and the atomic operation includes multiple operation commands. The operation flows, operation steps, and atomic operations in the embodiments of the present invention can all be reused on different operation and maintenance objects; moreover, after a single operation step fails to execute, it supports retrying the state machine node and skipping the state machine node, which can effectively improve the efficiency of operation execution; in addition, when operating batch objects, it will force an automatic check, and terminate the execution after the check fails, which can effectively reduce the scope of abnormal impact and avoid the occurrence of large-scale failures. Therefore, compared with the existing technology, the state machine-based operation and maintenance operation method proposed in the embodiment of the present invention can not only improve the reuse of operations, but also improve the efficiency and security of operation execution; moreover, the technical solution of the embodiment of the present invention is simple and convenient to implement, easy to popularize, and has a wider range of applications.
[0086] Example 3
[0087] Figure 5 This is a first structural diagram of the state machine-based operation and maintenance device provided in the third embodiment of the present invention. Figure 5 As shown, the state machine-based operation and maintenance device according to the embodiment of the present invention may include: a receiving module 501, a determining module 502 and an executing module 503; wherein,
[0088] The receiving module 501 is configured to receive a trigger message from a user to start a state machine corresponding to an operation flow;
[0089] The determining module 502 is configured to determine, according to the trigger message, each operation step included in the operation flow and each atomic operation included in each operation step; and to use the first operation step included in the operation flow as the current operation step;
[0090] The execution module 503 is used to execute the current operation step on the state machine node corresponding to the current operation step according to the various atomic operations contained in the current operation step; determine the next operation step of the current operation step according to the execution result of the current operation step, take the next operation step as the current operation step, and repeat the above operation until the last operation step contained in the operation flow is executed.
[0091] Furthermore, the determination module 502 is specifically configured to determine the operation template corresponding to the state machine according to the trigger message; and determine the operation steps included in the operation flow and the atomic operations included in the operation steps according to the operation template.
[0092] Furthermore, the determination module 502 is specifically used to parse the operation template according to the data format corresponding to each operation step pre-defined in the operation template, and determine each operation step corresponding to the operation flow in the operation template; parse each operation step according to the data format corresponding to each atomic operation pre-defined in each operation step, and determine each atomic operation corresponding to each operation step in each operation step.
[0093] Figure 6 This is a schematic diagram of the second structure of the state machine-based operation and maintenance device provided in the third embodiment of the present invention. Figure 6 As shown, the execution module 503 includes: an execution submodule 5031 and a determination submodule 5032; wherein,
[0094] The execution submodule 5031 is configured to use the first atomic operation included in the current operation step as the current atomic operation; and execute the operation commands corresponding to the current atomic operation on the state machine node corresponding to the current operation step according to the predetermined operation commands corresponding to the current atomic operation;
[0095] The determination submodule 5032 is used to determine the next atomic operation of the current atomic operation based on the execution result of the current atomic operation, take the next atomic operation as the current atomic operation, and repeat the above operation until the last atomic operation included in the current operation step is completed.
[0096] Furthermore, the execution module 503 is specifically used to determine the operation step adjacent to the current operation step as the next operation step if the current operation step is successfully executed on the corresponding state machine node; if the current operation step fails to be executed on the corresponding state machine node, determine the current operation step itself as the next operation step; or, determine the operation step determined according to the execution strategy of the current operation step as the next operation step.
[0097] The above-mentioned state machine-based operation and maintenance operation device can execute the method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method. For technical details not fully described in this embodiment, please refer to the state machine-based operation and maintenance operation method provided by any embodiment of the present invention.
[0098] Example 4
[0099] Figure 7 This is a structural diagram of an electronic device provided in Example 4 of the present invention. Figure 7 A block diagram is shown of an exemplary electronic device suitable for implementing embodiments of the present invention. Figure 7 The electronic device 12 shown is only an example and should not limit the functionality and scope of use of the embodiments of the present invention.
[0100] like Figure 7 As shown, electronic device 12 is implemented as a general-purpose computing device. Components of electronic device 12 may include, but are not limited to, one or more processors or processing units 16, system memory 28, and a bus 18 that connects various system components (including system memory 28 and processing unit 16).
[0101] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures. Examples of these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.
[0102] The electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 12, including volatile and non-volatile media, removable and non-removable media.
[0103] The system memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be configured to read and write non-removable, non-volatile magnetic media ( Figure 7 Not shown, often called a "hard drive"). Although Figure 7 Not shown, a magnetic disk drive for reading and writing to a removable non-volatile magnetic disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 via one or more data media interfaces. Memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of various embodiments of the present invention.
[0104] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data, each of which, or some combination thereof, may include an implementation of a network environment. Program modules 42 generally implement the functions and / or methods of the embodiments described herein.
[0105] The electronic device 12 may also communicate with one or more external devices 14 (e.g., a keyboard, a pointing device, a display 24, etc.), one or more devices that enable a user to interact with the electronic device 12, and / or any device that enables the electronic device 12 to communicate with one or more other computing devices (e.g., a network card, a modem, etc.). Such communication may be performed through an input / output (I / O) interface 22. Furthermore, the electronic device 12 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 20. As shown, the network adapter 20 communicates with the other modules of the electronic device 12 via the bus 18. It should be understood that although Figure 7 Not shown, other hardware and / or software modules may be used in conjunction with the electronic device 12, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0106] The processing unit 16 executes various functional applications and data processing by running programs stored in the system memory 28, such as implementing the state machine-based operation and maintenance method provided in an embodiment of the present invention.
[0107] Example 5
[0108] A fifth embodiment of the present invention provides a computer storage medium.
[0109] The computer-readable storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device.
[0110] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0111] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0112] Computer program code for performing the operations of the present invention may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0113] Note that the above are only preferred embodiments of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments, and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments and may include many other equivalent embodiments without departing from the concept of the present invention. The scope of the present invention is determined by the scope of the appended claims.
Claims
1. A state machine-based operation and maintenance method, characterized in that: The method comprises: Receive a trigger message from a user to start a state machine corresponding to an operation flow; the trigger message carries an identifier of the operation template; Determine an operation template according to the identifier of the operation template, and determine each operation step included in the operation flow and each atomic operation included in each operation step according to the operation template; and use the first operation step included in the operation flow as the current operation step; Executing the current operation step on the state machine node corresponding to the current operation step according to each atomic operation included in the current operation step; Determine the next operation step of the current operation step according to the execution result of the current operation step, take the next operation step as the current operation step, and repeat the above operation until the last operation step included in the operation flow is completed; The operation flow corresponds to a state machine; the current operation step corresponds to a state machine node; after a single operation step fails, it supports retrying the state machine node and skipping the state machine node; The operation flow, operation steps and atomic operations can be reused on different operation and maintenance objects; if multiple operation and maintenance objects are operated at one time, the multiple operation and maintenance objects are divided into multiple groups of operation and maintenance objects according to the grading requirements; after each operation and maintenance object group is executed, the inspection action is automatically performed, and the user-defined monitoring items or inspection scripts are called to ensure that the operation does not cause unexpected impacts.
2. The method according to claim 1, characterized in that Determining the various operation steps included in the operation flow and the various atomic operations included in each operation step according to the operation template includes: Parsing the operation template according to the data format corresponding to each operation step predefined in the operation template, and determining each operation step corresponding to the operation flow in the operation template; Each operation step is parsed according to the data format corresponding to each atomic operation pre-defined in each operation step, and each atomic operation corresponding to each operation step is determined in each operation step.
3. The method according to claim 1, characterized in that Executing the current operation step on a state machine node corresponding to the current operation step according to each atomic operation included in the current operation step includes: The first atomic operation included in the current operation step is used as the current atomic operation; Execute each operation command corresponding to the current atomic operation on the state machine node corresponding to the current operation step according to each operation command corresponding to the current atomic operation determined in advance; According to the execution result of the current atomic operation, the next atomic operation of the current atomic operation is determined, and the next atomic operation is used as the current atomic operation. The above operation is repeatedly performed until the last atomic operation included in the current operation step is completed.
4. The method according to claim 1, wherein The step of determining the next operation step of the current operation step according to the execution result of the current operation step includes: If the current operation step is successfully executed on the corresponding state machine node, determining the operation step adjacent to the current operation step as the next operation step; If the current operation step fails to be executed on the corresponding state machine node, the current operation step itself is used as the next operation step; or, the operation step determined according to the execution strategy of the current operation step is determined as the next operation step.
5. An operation and maintenance device based on a state machine, characterized in that: The device includes: a receiving module, a determining module and an executing module; wherein, The receiving module is configured to receive a trigger message sent by a user to start a state machine corresponding to an operation flow; the trigger message carries an identifier of the operation template; The determining module is configured to determine an operation template according to the identifier of the operation template, and determine, according to the operation template, each operation step included in the operation flow and each atomic operation included in each operation step; and set the first operation step included in the operation flow as the current operation step; The execution module is configured to execute the current operation step on the state machine node corresponding to the current operation step according to each atomic operation included in the current operation step; determine the next operation step of the current operation step according to the execution result of the current operation step, take the next operation step as the current operation step, and repeatedly execute the above operation until the last operation step included in the operation flow is completed; The operation flow corresponds to a state machine; the current operation step corresponds to a state machine node; after a single operation step fails, it supports retrying the state machine node and skipping the state machine node; The operation flow, operation steps and atomic operations can be reused on different operation and maintenance objects; if multiple operation and maintenance objects are operated at one time, the multiple operation and maintenance objects are divided into multiple groups of operation and maintenance objects according to the grading requirements; after each operation and maintenance object group is executed, the inspection action is automatically performed, and the user-defined monitoring items or inspection scripts are called to ensure that the operation does not cause unexpected impacts.
6. The device according to claim 5, characterized in that: The determining module is specifically configured to parse the operation template according to the data format corresponding to each operation step predefined in the operation template, and determine each operation step corresponding to the operation flow in the operation template; Each operation step is parsed according to the data format corresponding to each atomic operation pre-defined in each operation step, and each atomic operation corresponding to each operation step is determined in each operation step.
7. The device according to claim 5, characterized in that The execution module includes: an execution submodule and a determination submodule; wherein, The execution submodule is configured to take the first atomic operation included in the current operation step as the current atomic operation; and execute the respective operation commands corresponding to the current atomic operation on the state machine node corresponding to the current operation step according to the respective operation commands corresponding to the current atomic operation determined in advance; The determination submodule is used to determine the next atomic operation of the current atomic operation based on the execution result of the current atomic operation, take the next atomic operation as the current atomic operation, and repeatedly perform the above operations until the last atomic operation included in the current operation step is completed.
8. The device according to claim 5, characterized in that: The execution module is specifically used to determine the operation step adjacent to the current operation step as the next operation step if the current operation step is successfully executed on the corresponding state machine node; if the current operation step fails to be executed on the corresponding state machine node, determine the current operation step itself as the next operation step; or, determine the operation step determined according to the execution strategy of the current operation step as the next operation step.
9. An electronic device, characterized in that: include: one or more processors; a memory for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the state machine-based operation and maintenance method according to any one of claims 1 to 4.
10. A storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the state machine-based operation and maintenance method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
State machine based fault positioning method and apparatus
CN105159809A
Storage device testing method and testing device
CN1851819A