Switch configuration management method and device, electronic equipment and storage medium
By automatically converting YAML configuration data into JSON and XML configuration instructions, the problem of complex and inefficient traditional switch configuration management is solved, achieving efficient and easy-to-use switch configuration management.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-27
- Publication Date
- 2026-04-07
AI Technical Summary
Traditional switch configuration and management methods are complex and inefficient, especially in intelligent computing centers and supercomputing centers where parameters need to be adjusted frequently. Manual operation is time-consuming, labor-intensive, and uncontrollable in terms of security. Although NETCONF technology improves management efficiency, it requires a high level of expertise and is complex to write and maintain.
Configuration data in YAML format is automatically converted into JSON format and then into XML format configuration instructions, thereby achieving automated switch configuration management, reducing the professional requirements of users and improving configuration management efficiency.
By automatically converting YAML to JSON and then to XML, the switch configuration management process is simplified, reducing user learning costs and configuration error rates, and improving the efficiency and readability of configuration management.
Smart Images

Figure CN121814564A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of network, in particular to a switch configuration management method and device, electronic equipment and storage medium. BACKGROUND
[0002] The network switch is a core device for connecting network devices, responsible for data forwarding and communication. In a local area network, the switch realizes communication between multiple devices through learning and forwarding data frames, ensuring efficient transmission of data between network nodes.
[0003] Traditional network switches almost do not need to be configured and adjusted after networking is built. However, with the construction of modern intelligent computing centers and supercomputing centers, the requirement for network latency is further improved, and more and more RDMA (Remote Direct Memory Access) technologies are applied to production, such as RoCE (Remote Direct Memory Access over Converged Ethernet) and IB (InfiniBand). These switches need to be frequently optimized after deployment, such as adjustment of DCB (Data Center Bridging), PFC (Priority Flow Control), ECN (Explicit Congestion Notification) and other indicators. Therefore, how to provide a high-performance and highly available configuration management system for users (such as network operation and maintenance personnel) has become a topic worthy of study.
[0004] The traditional switch configuration management method is usually to log in to the switch by the user, and input commands manually, but this is very time-consuming and laborious, and the security is uncontrollable. In view of the pain point of manual input command configuration, the NETCONF (Network Configuration Protocol) technology is proposed, which is a network configuration management protocol based on XML (Extensible Markup Language), and the user can realize configuration management of the remote switch by writing configuration data in XML format. However, XML has high professional requirements and poor readability, and is complex to write and maintain, which leads to a complex and inefficient switch configuration management process. SUMMARY
[0005] The embodiment of the application aims to provide a switch configuration management method, device, electronic equipment and storage medium, which can solve the problems of complex switch configuration management process and low efficiency.
[0006] In a first aspect, the embodiment of the application provides a switch configuration management method, which comprises: receiving target configuration data in YAML format configured for a target switch; converting the target configuration data in YAML format into target configuration data in JSON format, and generating task data according to the target configuration data in JSON format; converting the target configuration data in JSON format into target configuration data in XML format according to the task data, and sending a configuration instruction containing the target configuration data in XML format to the target switch, so that the target switch executes the configuration instruction.
[0007] Optionally, the target configuration data comprises device identification of the target switch, target resource types of the target switch and sequential numbers of each target resource type; and generating the task data according to the target configuration data in JSON format comprises: allocating a task group identification to the device identification of the target switch, allocating a task identification under the task group identification to each target resource type of the target switch, taking the sequential numbers of the target resource types as task sequences corresponding to the target resource types, and taking the task group identification, the task identification, the task sequences and the target configuration data in JSON format as the task data.
[0008] Optionally, converting the target configuration data in JSON format into target configuration data in XML format according to the task data, and sending a configuration instruction containing the target configuration data in XML format to the target switch comprises: in the order of the task sequences, converting first target configuration data in JSON format corresponding to the task sequences in the target configuration data in JSON format into first target configuration data in XML format corresponding to the task sequences, and sending a configuration instruction containing the first target configuration data in XML format to the target switch.
[0009] Optionally, converting the first target configuration data in JSON format corresponding to the task sequences in the target configuration data in JSON format into first target configuration data in XML format corresponding to the task sequences comprises: According to a mapping rule of a target resource type corresponding to the task sequence, the first target configuration data in the JSON format corresponding to the task sequence in the target configuration data in the JSON format is converted into first target configuration data in the XML format corresponding to the task sequence. The mapping rule of the target resource type corresponding to the task sequence refers to a mapping rule between the JSON format and the XML format under the target resource type corresponding to the task sequence.
[0010] Optionally, the conversion of the target configuration data in the YAML format into target configuration data in the JSON format and the generation of task data according to the target configuration data in the JSON format comprise: The target configuration data in the YAML format is converted into target configuration data in the JSON format by a parsing thread, task data is generated according to the target configuration data in the JSON format, the task data is stored in a database, and a task group identifier in the task data is transmitted to an execution thread. The conversion of the target configuration data in the JSON format into target configuration data in the XML format, the sending of a configuration instruction containing the target configuration data in the XML format to the target switch, according to the task data, comprise: The task data is read from the database by the execution thread according to the task group identifier, the target configuration data in the JSON format is converted into target configuration data in the XML format according to the task data, and a configuration instruction containing the target configuration data in the XML format is sent to the target switch.
[0011] Optionally, the conversion of the target configuration data in the YAML format into target configuration data in the JSON format and the generation of task data according to the target configuration data in the JSON format comprise: The target configuration data in the YAML format is converted into target configuration data in the JSON format by a parsing thread, task data is generated according to the target configuration data in the JSON format, the task data is stored in a database, and a task group identifier in the task data is transmitted to a client. The method further comprises: receiving, by a query thread, a query request containing the task group identifier sent by the client, reading task execution status corresponding to the task data from the database according to the task group identifier, and returning the task execution status to the client.
[0012] Optionally, the method further comprises: Upon receiving a replication configuration request, the system obtains the current configuration data in JSON format corresponding to the switch to be replicated as indicated by the replication configuration request, converts the current configuration data in JSON format into current configuration data in YAML format, and returns the current configuration data in YAML format to the client, so that the client can replicate the current configuration data in YAML format to the target configuration data in YAML format.
[0013] Secondly, embodiments of this application provide a switch configuration management apparatus, the apparatus comprising: The receiving module is used to receive target configuration data in YAML format configured for the target switch; The generation module is used to convert the target configuration data in YAML format into target configuration data in JSON format, and generate task data based on the target configuration data in JSON format. The conversion module is used to convert the target configuration data in JSON format into target configuration data in XML format according to the task data, and send a configuration instruction containing the target configuration data in XML format to the target switch so that the target switch executes the configuration instruction.
[0014] Optionally, the target configuration data includes the device identifier of the target switch, the target resource type of the target switch, and the sequence number of each target resource type; the generation module is specifically used for: Assign a task group identifier to the device identifier of the target switch, assign a task identifier under the task group identifier to each target resource type of the target switch, use the sequential number of the target resource type as the task sequence corresponding to the target resource type, and use the task group identifier, the task identifier, the task sequence, and the target configuration data in JSON format as the task data.
[0015] Optionally, the conversion module includes: The format conversion unit is used to convert the first target configuration data in JSON format corresponding to the task sequence in the target configuration data in JSON format into the first target configuration data in XML format corresponding to the task sequence, according to the order of the task sequence. The instruction sending unit is used to send a configuration instruction containing the first target configuration data in XML format to the target switch.
[0016] Optionally, the format conversion unit is specifically used for: According to the mapping rules of the target resource type corresponding to the task sequence, the first target configuration data in JSON format corresponding to the task sequence in the target configuration data in JSON format is converted into the first target configuration data in XML format corresponding to the task sequence. The mapping rule for the target resource type corresponding to the task sequence refers to the mapping rule between JSON format and XML format under the target resource type corresponding to the task sequence.
[0017] Optionally, the generation module is specifically used for: The parsing thread converts the YAML-formatted target configuration data into JSON-formatted target configuration data, generates task data based on the JSON-formatted target configuration data, stores the task data in the database, and transmits the task group identifier in the task data to the execution thread. The conversion module is specifically used for: The execution thread reads the task data from the database according to the task group identifier, converts the JSON-formatted target configuration data into XML-formatted target configuration data based on the task data, and sends a configuration instruction containing the XML-formatted target configuration data to the target switch.
[0018] Optionally, the generation module is specifically used for: The target configuration data in YAML format is converted into target configuration data in JSON format by a parsing thread, task data is generated based on the target configuration data in JSON format, the task data is stored in the database, and the task group identifier in the task data is transmitted to the client. The conversion module is further configured to receive a query request containing the task group identifier sent by the client through a query thread, read the task execution status corresponding to the task data from the database according to the task group identifier, and return the task execution status to the client.
[0019] Optionally, the device further includes: The replication module is used to receive a replication configuration request, obtain the current configuration data in JSON format corresponding to the switch to be replicated indicated by the replication configuration request, convert the current configuration data in JSON format into current configuration data in YAML format, and return the current configuration data in YAML format to the client so that the client can copy the current configuration data in YAML format to the target configuration data in YAML format.
[0020] Thirdly, embodiments of this application provide an electronic device, which includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor. When the program or instructions are executed by the processor, they implement the switch configuration management method as described in any of the preceding claims.
[0021] Fourthly, embodiments of this application provide a readable storage medium storing a program or instructions that, when executed by a processor, implement the switch configuration management method as described in any of the preceding claims.
[0022] Fifthly, embodiments of this application provide a chip, the chip including a processor and a communication interface, the communication interface being coupled to the processor, the processor being used to run programs or instructions to implement the switch configuration management method as described in any of the preceding claims.
[0023] In this embodiment, target switch is configured with target configuration data in YAML (YAML Ain't Markup Language) format. The YAML target configuration data is automatically converted to JSON (JavaScript Object Notation) format. Task data is generated based on the JSON target configuration data. The task data is then automatically converted to XML target configuration data. A configuration instruction containing the XML target configuration data is sent to the target switch so that the target switch can automatically execute the configuration instruction.
[0024] Therefore, in this embodiment of the application, the YAML format of the target configuration data has significantly improved readability compared to the XML format, and is easier to write and maintain. It also requires less expertise from users, thus decoupling the user and switch adaptation operations, reducing the user's learning cost and configuration error rate. Furthermore, by automatically generating task data and automatically converting the target configuration data format and issuing configuration instructions based on the task data, it can greatly reduce the workload of relevant personnel, reduce the complexity of switch configuration management, and improve the efficiency of switch configuration management.
[0025] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description
[0026] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the drawings described below are only some drawings of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0027] Figure 1 This is a flowchart of a switch configuration management method according to an embodiment of this application; Figure 2 This is an architecture diagram of a switch configuration management system according to an embodiment of this application; Figure 3 This is a structural block diagram of a switch configuration management device according to an embodiment of this application; Figure 4 This is a structural block diagram of an electronic device according to an embodiment of this application; Figure 5 This is a structural block diagram of a readable storage medium according to an embodiment of this application. Detailed Implementation
[0028] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0029] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0030] The switch configuration management method of this application embodiment can be used for switch configuration management in scenarios such as intelligent computing centers (which are infrastructures in the smart era, dedicated to serving artificial intelligence data computing centers, supporting the intelligent transformation of industries such as smart cities, intelligent manufacturing, smart homes and smart healthcare by providing computing power services, data services and intelligent services) or supercomputing centers (which refer to institutions and facilities that deploy and operate supercomputers).
[0031] The switch configuration management method of this application embodiment can be applied to a switch configuration management system. The switch configuration management system may include a client, a server, a database, and switches.
[0032] Reference Figure 1 The diagram shows a flowchart of a switch configuration management method according to an embodiment of this application. Figure 1 The switch configuration management method shown can be executed by the server in the switch configuration management system.
[0033] like Figure 1 As shown, the switch configuration management method may include the following steps: Step 101: Receive target configuration data in YAML format for the target switch.
[0034] In this embodiment of the application, the client can provide a visual switch management page in the switch configuration management system. Users (such as network maintenance personnel) can use this visual switch management page to configure target configuration data in YAML format for the target switch that needs to be managed. After configuration, clicking submit on the visual switch management page allows the client to send the YAML format target configuration data configured for the target switch to the server. The server can receive the YAML format target configuration data configured for the target switch sent by the client.
[0035] For example, the target configuration data may include, but is not limited to: the device identifier of the target switch, the target resource type of the target switch (the resource type to be configured), the sequence number of each target resource type, the configuration parameters of each target resource type, etc. The target resource type may include, but is not limited to: ECN, DcbPfc (Data Center Bridging Priority Flow Control), Queue, etc. The sequence number of the target resource type refers to the configuration order of the target resource type. The configuration parameters of the target resource type refer to the specific configuration parameters of the target resource type, such as threshold parameters, timer parameters, etc.
[0036] Step 102: Convert the target configuration data in YAML format to target configuration data in JSON format, and generate task data based on the target configuration data in JSON format.
[0037] In this embodiment of the application, after receiving the target configuration data in YAML format configured by the target switch, the server can convert the target configuration data in YAML format into target configuration data in JSON format.
[0038] Converting target configuration data in YAML format to target configuration data in JSON format refers to converting the human-readable YAML structure, with indentation and line breaks, into a string format JSON object that is more efficient for machine processing. The conversion from YAML to JSON is for adapting to backend data processing (such as database storage, API transmission, etc.). After conversion, the JSON structure corresponds one-to-one with the YAML, only the format is adjusted to JSON key-value pairs.
[0039] For example, any applicable library capable of converting YAML to JSON (such as the PyYAML library, Jackson library, etc.) can be called to convert the target configuration data in YAML format to target configuration data in JSON format. The specific conversion process can be handled according to actual experience, and will not be discussed in detail in this embodiment.
[0040] In this embodiment of the application, after the server converts the target configuration data in YAML format into target configuration data in JSON format, it can generate task data based on the target configuration data in JSON format, so that the server can perform task scheduling based on the task data.
[0041] In one optional implementation, the process of generating task data based on the target configuration data in JSON format may include: assigning a task group identifier to the device identifier of the target switch; assigning a task identifier under the task group identifier to each target resource type of the target switch; using the sequential number of the target resource type as the task sequence corresponding to the target resource type; and using the task group identifier, the task identifier, the task sequence, and the target configuration data in JSON format as the task data. In this way, the target configuration data in JSON format can be combined with task metadata (the task group identifier, the task identifier, and the task sequence) to form complete, ordered, traceable, and schedulable task data, enabling the server to smoothly schedule tasks based on this task data.
[0042] In this embodiment of the application, each target switch corresponds to a task group, so a task group identifier is assigned to the device identifier of the target switch; each target resource type of the target switch corresponds to a task under the task group, so a task identifier under the task group identifier is assigned to each target resource type of the target switch; each target resource type has its own execution order, so the sequence number of the target resource type is used as the task sequence (i.e., the execution sequence number of the task) corresponding to the target resource type.
[0043] Step 103: Based on the task data, convert the target configuration data in JSON format into target configuration data in XML format, and send a configuration instruction containing the target configuration data in XML format to the target switch so that the target switch executes the configuration instruction.
[0044] In this embodiment, after the server generates task data based on the target configuration data in JSON format, it can convert the JSON-formatted target configuration data into XML-formatted target configuration data based on the task data, and then send a configuration command containing the XML-formatted target configuration data to the target switch. The conversion from JSON to XML format is to adapt to the NETCONF protocol supported by the switch.
[0045] For example, the process of converting the target configuration data in JSON format to target configuration data in XML format may include: converting the target configuration data in JSON format to target configuration data in XML format according to the mapping rules between JSON and XML formats. The mapping rules can be pre-configured according to actual needs.
[0046] In one optional implementation, the process of converting the JSON-formatted target configuration data into XML-formatted target configuration data based on the task data, and sending a configuration instruction containing the XML-formatted target configuration data to the target switch, may include: converting the first JSON-formatted target configuration data corresponding to the task sequence in the JSON-formatted target configuration data into the first XML-formatted target configuration data corresponding to the task sequence, according to the chronological order of the task sequence, and sending a configuration instruction containing the first XML-formatted target configuration data to the target switch. This method enables the sequential configuration of target resource types, satisfying not only the data transmission requirements of individual resource types but also the sequential dependencies between target resource types.
[0047] In this embodiment, tasks corresponding to each task sequence are processed one by one according to the chronological order of the task sequence. For each task sequence, the target configuration data in JSON format corresponding to the task sequence is obtained from the target configuration data in JSON format, and is used as the first target configuration data in JSON format corresponding to the task sequence. The first target configuration data in JSON format corresponding to the task sequence is the target configuration data in JSON format corresponding to the target resource type of the task sequence. Then, the first target configuration data in JSON format corresponding to the task sequence is converted into first target configuration data in XML format corresponding to the task sequence. Next, a configuration instruction containing the first target configuration data in XML format is generated and sent to the target switch.
[0048] In one optional implementation, the process of converting the first target configuration data in JSON format corresponding to the task sequence in the target configuration data into the first target configuration data in XML format corresponding to the task sequence may include: converting the first target configuration data in JSON format corresponding to the task sequence into the first target configuration data in XML format corresponding to the task sequence according to the mapping rules of the target resource type corresponding to the task sequence. Here, the mapping rules of the target resource type corresponding to the task sequence refer to the mapping rules between JSON format and XML format under the target resource type corresponding to the task sequence.
[0049] In this embodiment, mapping rules for each resource type can be pre-configured. The mapping rule for any resource type refers to the mapping rule between JSON and XML formats under that resource type. The specific content of the mapping rules can be set according to actual needs, and will not be discussed in detail here.
[0050] For example, mapping rules need to be combined with resource types and exchange instruction rules. For instance, rules can be defined to specify how key-value pairs in JSON are represented as XML elements and text content; how arrays / lists in JSON are represented as repeating elements in XML; how nested objects in JSON are represented as nested elements in XML, and so on.
[0051] For example, the mapping rules described above can be mapping templates. Mapping templates are configured for each resource type. Each mapping template defines how to translate general, structured data (JSON) into specific, switch-executable instructions (XML). The mapping template contains positions to be filled corresponding to the target configuration data in JSON format. During the conversion, the first target configuration data in JSON format corresponding to the task sequence is filled into its respective positions to obtain the first target configuration data in XML format corresponding to the task sequence. Of course, the mapping template can also include XML skeleton information, namespaces, static content, default values, etc., but this embodiment does not impose any limitations on this.
[0052] For example, in the process of converting the first target configuration data in JSON format corresponding to the task sequence into the first target configuration data in XML format corresponding to the task sequence, a mapping rule for the target resource type corresponding to the task sequence can be obtained according to the target resource type corresponding to the task sequence. Then, according to the mapping rule, the configuration parameters in JSON format corresponding to the target resource type in the first target configuration data in JSON format corresponding to the task sequence can be converted into configuration parameters in XML format corresponding to the target resource type corresponding to the task sequence. Based on the device identifier of the target switch, a configuration instruction containing the configuration parameters in XML format corresponding to the target resource type of the task sequence can be sent to the target switch.
[0053] In one alternative implementation, multi-threaded execution can be configured to further improve processing efficiency.
[0054] For example, a parsing thread and an execution thread can be set.
[0055] Accordingly, the process of converting the target configuration data in YAML format to target configuration data in JSON format and generating task data based on the target configuration data in JSON format includes: converting the target configuration data in YAML format to target configuration data in JSON format through a parsing thread, generating task data based on the target configuration data in JSON format, storing the task data in a database, and transmitting the task group identifier in the task data to the execution thread.
[0056] Accordingly, the process of converting the target configuration data in JSON format to target configuration data in XML format based on the task data, and sending a configuration instruction containing the target configuration data in XML format to the target switch includes: reading the task data from the database by the execution thread based on the task group identifier, converting the target configuration data in JSON format to target configuration data in XML format based on the task data, and sending a configuration instruction containing the target configuration data in XML format to the target switch.
[0057] In this embodiment, after receiving a configuration instruction, the target switch can execute the configuration instruction and configure itself according to the target configuration data in XML format contained in the configuration instruction. The target switch can also return execution results to the server. For example, after successfully executing the configuration instruction, the target switch can return a successful execution result to the server; if the configuration instruction fails to execute, it can return a failed execution result to the server.
[0058] In this embodiment of the application, the server can maintain the task execution status and switch return results corresponding to each task identifier in the database. The switch return results are the execution results returned by the switch. The task execution status is determined by the server according to the execution status of each task. The task execution status may include executing, created, executed successfully, executed failed, etc.
[0059] For example, a parsing thread and a query thread can be set.
[0060] Accordingly, the target configuration data in YAML format is converted into target configuration data in JSON format, and task data is generated based on the target configuration data in JSON format. This includes: converting the target configuration data in YAML format into target configuration data in JSON format through a parsing thread, generating task data based on the target configuration data in JSON format, storing the task data in a database, and transmitting the task group identifier in the task data to the client.
[0061] The method further includes: receiving a query request containing the task group identifier sent by the client through a query thread, reading the task execution status corresponding to the task data from the database according to the task group identifier, and returning the task execution status to the client.
[0062] After receiving the task execution status, the client can perform corresponding operations on the switch management page. For example, if the task execution status corresponding to a certain task identifier is successful, the client can display the configuration parameters of the resource type corresponding to the successful task identifier on the page; if the task execution status corresponding to a certain task identifier is failed, the client can display the failure result on the page for network maintenance personnel to handle.
[0063] In one optional implementation, the client-side visual switch management page can provide a "Copy Configuration" button. When configuring target configuration data in YAML format for a target switch, the user can select the switch to be copied and click the "Copy Configuration" button, triggering a copy configuration request. The client then sends this request to the server. Upon receiving the copy configuration request, the server retrieves the current configuration data in JSON format corresponding to the switch to be copied, converts this JSON data to YAML format, and returns it to the client. The JSON data for the switch to be copied can be retrieved from a database. After receiving the JSON data, the client can copy it to the target configuration data in YAML format. This method fulfills the configuration data copying requirement, further simplifying the configuration process.
[0064] In this embodiment, the YAML format of the target configuration data has significantly improved readability compared to the XML format, making it easier to write and maintain and requiring less expertise from users. Therefore, it can decouple the user and switch adaptation operations, reduce the user's learning cost and configuration error rate, and by automatically generating task data and automatically converting the target configuration data format and issuing configuration instructions based on the task data, it can greatly reduce the workload of relevant personnel, reduce the complexity of switch configuration management, and improve the efficiency of switch configuration management.
[0065] This application embodiment designs a switch configuration management system. By encapsulating the native switch configuration and transforming it into a visually accessible page, it allows network operations and maintenance personnel to intuitively distribute and manage switch configurations. This solves the problems of invisible switch configurations and difficulty for network operations and maintenance personnel to distribute configurations to switches in traditional networks. The configurations (usually XML) directly distributed to the switch via NETCONF are transformed into RESTful APIs (Representational State Transfer Application Programming Interfaces) for invocation. Then, a task management system is designed to transform the NETCONF configuration distribution into HTTP (Hypertext Transfer Protocol) requests. Finally, a visual switch management page is provided through the client (i.e., the front end) for network operations and maintenance personnel to use.
[0066] Reference Figure 2 The diagram illustrates the architecture of a switch configuration management system according to an embodiment of this application.
[0067] like Figure 2 As shown, the switch configuration management system may include a switch management page, a task management system, a configuration converter, a database, and switches. The switch management page belongs to the client, while the task management system and the configuration converter belong to the server.
[0068] The switch management page is responsible for interacting with the user in the form of a webpage. When the switch management page loads, it calls the switch query interface of the task management system to obtain a list of switches, and then performs a full resource query operation on each switch to obtain a resource list view.
[0069] Figure 2 Taking two switches, each with two full resources, as an example, the process first retrieves the switch lists switch1 (switch 1) and switch2 (switch 2). Then, it retrieves the resource types managed by the server: ECN (Explicit Congestion Notification) and DcbPfc (Data Center Bridging Priority Flow Control). A query operation is performed for each resource type on each switch to obtain the current configuration data for that switch. If there is no current configuration data on a switch, it will be displayed as empty.
[0070] for example, Figure 2 The current configuration data for switch1 is as follows: ECN (Explicit Congestion Notification): DropProfiles: DropProfileName (drop profile name): dropl Lowlimit_atl (lowest threshold): 7000 DcbPfc (Data Center Bridging Priority Flow Control): DeadlockDetectTimer: 100 RecoveryBehavior: SlotId (Slot Identifier): 1 BehaviorType: discard Figure 2 The current configuration data for switch2 is as follows: ECN (Explicit Congestion Notification): DropProfiles: Discard Profiles DropProfileName (drop profile name): dropl Lowlimit_atl (lowest threshold): 7000 DcbPfc (Data Center Bridging Priority Flow Control): DeadlockDetectTimer: 100 RecoveryBehavior: SlotId (Slot Identifier): 1 BehaviorType: discard For each resource type, buttons for querying, editing, submitting, and deleting are provided, along with a button to obtain a configuration template. For switches, functions such as copying configuration, pasting configuration, overall editing, overall submission, and refreshing are available. Users can obtain a YAML configuration template by clicking the "Obtain Configuration Template" button and configure the target configuration data in YAML format using the template. Overall editing allows simultaneous editing of all resource types under the switch, and these resource types can be sequentially numbered to determine the order in which they are issued. Because YAML format offers greater readability and modifiability than XML format, it is more conducive to development. Developers only need to build the display framework; as the number of resource types increases, their development workload does not increase.
[0071] A task management system must contain at least three threads.
[0072] The parsing thread is responsible for receiving and parsing configuration requests from clients, which contain target configuration data in YAML format for the target switch, and generating task data that is stored in the database. The database may include task group IDs (task group identifiers, such as Tg-1, Tg-2, Tg-3, etc.), task IDs (task identifiers, such as T-1, T-2, T-3, etc.), task sequences, device IDs (device identifiers), resource types, parameters (i.e., configuration parameters for the resource type), task execution status, and switch return results. The parsing thread sends the task group IDs to the execution thread and returns them to the client.
[0073] The query thread is responsible for receiving query requests containing task group IDs from clients (e.g., periodically sent), retrieving the task execution status under that task group ID from the database, and returning the status to the client. If the task execution status is successful, the client will persist the issued configuration data on the switch management page; if the task execution status is failed, the client will display the failure result to network maintenance personnel.
[0074] The execution thread is responsible for listening for and receiving task group IDs from the parsing thread. Upon receiving a task group ID, it retrieves the tasks under that task group ID from the database, and then calls the configuration converter one by one according to the task sequence field. The configuration converter converts the JSON format to XML format and sends the configuration instructions to the exchange. The parsing thread and the execution thread can communicate with each other via a message queue.
[0075] The configuration converter is responsible for converting between JSON and XML formats.
[0076] The switch executes the received configuration commands and performs corresponding operations such as adding, deleting, and querying configuration data.
[0077] Traditional switch configuration management requires the front-end to set a text box for each field of each resource type, and the back-end to receive, parse, and encapsulate this parameter into XML before sending it to the switch. This results in switch configurations being characterized by a large number of parameters, complexity, and difficulty in maintenance. In this embodiment, NETCONF is converted to YAML format, shifting network operations personnel from manually typing command lines to visual operation via a web page. This decouples the operations of network operations personnel from switch adaptation, significantly reducing the workload of both front-end and back-end personnel, improving the management capabilities of switch configurations, and facilitating the rapid copying of configuration data from one switch to another for task distribution. If a new resource type is added, the workload mainly focuses on adding mapping rules between the corresponding JSON and XML formats in the configuration converter, greatly reducing development workload.
[0078] It should be noted that the switch configuration management method provided in this application embodiment can be executed by a switch configuration management device, or a control module within the switch configuration management device for executing the loading switch configuration management method. This application embodiment uses the execution of the loading switch configuration management method by a switch configuration management device as an example to illustrate the switch configuration management method provided in this application embodiment.
[0079] Reference Figure 3 The diagram shows a structural block diagram of a switch configuration management device according to an embodiment of this application.
[0080] like Figure 3 As shown, the switch configuration management device may include the following modules: The receiving module 301 is used to receive target configuration data in YAML format configured for the target switch; The generation module 302 is used to convert the target configuration data in YAML format into target configuration data in JSON format, and generate task data based on the target configuration data in JSON format; The conversion module 303 is used to convert the target configuration data in JSON format into target configuration data in XML format according to the task data, and send a configuration instruction containing the target configuration data in XML format to the target switch so that the target switch executes the configuration instruction.
[0081] Optionally, the target configuration data includes the device identifier of the target switch, the target resource type of the target switch, and the sequence number of each target resource type; the generation module 302 is specifically used for: Assign a task group identifier to the device identifier of the target switch, assign a task identifier under the task group identifier to each target resource type of the target switch, use the sequential number of the target resource type as the task sequence corresponding to the target resource type, and use the task group identifier, the task identifier, the task sequence, and the target configuration data in JSON format as the task data.
[0082] Optionally, the conversion module 303 includes: The format conversion unit is used to convert the first target configuration data in JSON format corresponding to the task sequence in the target configuration data in JSON format into the first target configuration data in XML format corresponding to the task sequence, according to the order of the task sequence. The instruction sending unit is used to send a configuration instruction containing the first target configuration data in XML format to the target switch.
[0083] Optionally, the format conversion unit is specifically used for: According to the mapping rules of the target resource type corresponding to the task sequence, the first target configuration data in JSON format corresponding to the task sequence in the target configuration data in JSON format is converted into the first target configuration data in XML format corresponding to the task sequence. The mapping rule for the target resource type corresponding to the task sequence refers to the mapping rule between JSON format and XML format under the target resource type corresponding to the task sequence.
[0084] Optionally, the generation module 302 is specifically used for: The parsing thread converts the YAML-formatted target configuration data into JSON-formatted target configuration data, generates task data based on the JSON-formatted target configuration data, stores the task data in the database, and transmits the task group identifier in the task data to the execution thread. The conversion module 303 is specifically used for: The execution thread reads the task data from the database according to the task group identifier, converts the JSON-formatted target configuration data into XML-formatted target configuration data based on the task data, and sends a configuration instruction containing the XML-formatted target configuration data to the target switch.
[0085] Optionally, the generation module 302 is specifically used for: The target configuration data in YAML format is converted into target configuration data in JSON format by a parsing thread, task data is generated based on the target configuration data in JSON format, the task data is stored in the database, and the task group identifier in the task data is transmitted to the client. The conversion module 303 is further configured to receive a query request containing the task group identifier sent by the client through a query thread, read the task execution status corresponding to the task data from the database according to the task group identifier, and return the task execution status to the client.
[0086] Optionally, the device further includes: The replication module is used to receive a replication configuration request, obtain the current configuration data in JSON format corresponding to the switch to be replicated indicated by the replication configuration request, convert the current configuration data in JSON format into current configuration data in YAML format, and return the current configuration data in YAML format to the client so that the client can copy the current configuration data in YAML format to the target configuration data in YAML format.
[0087] In this embodiment, the YAML format of the target configuration data has significantly improved readability compared to the XML format, making it easier to write and maintain and requiring less expertise from users. Therefore, it can decouple the user and switch adaptation operations, reduce the user's learning cost and configuration error rate, and by automatically generating task data and automatically converting the target configuration data format and issuing configuration instructions based on the task data, it can greatly reduce the workload of relevant personnel, reduce the complexity of switch configuration management, and improve the efficiency of switch configuration management.
[0088] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0089] The switch configuration management device in this application embodiment can be a device, or it can be a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. For example, mobile electronic devices can be mobile phones, tablets, laptops, PDAs, in-vehicle electronic devices, wearable devices, ultra-mobile personal computers (UMPCs), netbooks, or personal digital assistants (PDAs), etc., while non-mobile electronic devices can be servers, network attached storage (NAS), personal computers (PCs), televisions (TVs), ATMs, or self-service machines, etc. This application embodiment does not specifically limit the scope.
[0090] The switch configuration management device in this application embodiment can be a device with an operating system. This operating system can be Android, iOS, or other possible operating systems; this application embodiment does not specifically limit it.
[0091] The switch configuration management device provided in this application embodiment can implement the various processes implemented by the switch configuration management device in any of the above-mentioned method embodiments. To avoid repetition, these processes will not be described again here.
[0092] Optionally, embodiments of this application also provide an electronic device.
[0093] Reference Figure 4 The diagram shows a structural block diagram of an electronic device according to an embodiment of this application.
[0094] like Figure 4As shown, the electronic device 11 includes a processor 111, a memory 112, and a program or instruction 1121 stored in the memory and executable on the processor. When the program or instruction 1121 is executed by the processor 111, it implements the various processes of any of the above-described switch configuration management method embodiments and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0095] It should be noted that the electronic devices in the embodiments of this application include the mobile electronic devices and non-mobile electronic devices described above.
[0096] Optionally, embodiments of this application also provide a readable storage medium.
[0097] Reference Figure 5 The diagram shows a structural block diagram of a readable storage medium according to an embodiment of this application.
[0098] like Figure 5 As shown, the readable storage medium 21 stores a program or instruction 211. When the program or instruction 211 is executed by the processor, it implements the various processes of any of the above-mentioned switch configuration management method embodiments and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0099] The processor may be the processor in the electronic device described in the above embodiments.
[0100] Optionally, this application embodiment also provides a chip, the chip including a processor and a communication interface, the communication interface and the processor being coupled, the processor being used to run programs or instructions to implement the various processes of the above-described switch configuration management method embodiments, and achieving the same technical effect, so it will not be described again here to avoid repetition.
[0101] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.
[0102] The processors mentioned above may include, but are not limited to: Central Processing Unit (CPU), Network Processor (NP), Digital Signal Processor (DSP), Application Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0103] The aforementioned readable storage media include computer-readable storage media, which may include, but are not limited to: read-only memory (ROM), random access memory (RAM), compact disc read-only memory (CD-ROM), electronically erasable programmable read-only memory (EEPROM), hard disk, floppy disk, flash memory, etc.
[0104] The various embodiments in this specification are related to each other and are described in a progressive manner. Each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other.
[0105] It should be noted that all actions involving the acquisition of signals, information, or data in this application are carried out in compliance with the relevant data protection laws and regulations of the locality and with authorization from the owner of the relevant device.
[0106] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
[0107] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.
[0108] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection between devices or units, and may be electrical, mechanical, or other forms. The functional units in the various embodiments of this application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0109] Although preferred embodiments of the present application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present invention.
[0110] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
Claims
1. A switch configuration management method, characterized in that, The method includes: Receive target configuration data in YAML format for the target switch; Convert the target configuration data in YAML format to target configuration data in JSON format, and generate task data based on the target configuration data in JSON format. Based on the task data, the target configuration data in JSON format is converted into target configuration data in XML format, and a configuration instruction containing the target configuration data in XML format is sent to the target switch so that the target switch executes the configuration instruction.
2. The method according to claim 1, characterized in that, The target configuration data includes the device identifier of the target switch, the target resource type of the target switch, and the sequence number of each target resource type; task data is generated based on the target configuration data in JSON format, including: Assign a task group identifier to the device identifier of the target switch, assign a task identifier under the task group identifier to each target resource type of the target switch, use the sequential number of the target resource type as the task sequence corresponding to the target resource type, and use the task group identifier, the task identifier, the task sequence, and the target configuration data in JSON format as the task data.
3. The method according to claim 2, characterized in that, The step of converting the target configuration data in JSON format to target configuration data in XML format based on the task data, and sending a configuration instruction containing the target configuration data in XML format to the target switch includes: According to the order of the task sequence, the first target configuration data in JSON format corresponding to the task sequence in the target configuration data in JSON format is converted into the first target configuration data in XML format corresponding to the task sequence, and a configuration instruction containing the first target configuration data in XML format is sent to the target switch.
4. The method according to claim 3, characterized in that, The step of converting the first target configuration data in JSON format corresponding to the task sequence in the target configuration data in JSON format into the first target configuration data in XML format corresponding to the task sequence includes: According to the mapping rules of the target resource type corresponding to the task sequence, the first target configuration data in JSON format corresponding to the task sequence in the target configuration data in JSON format is converted into the first target configuration data in XML format corresponding to the task sequence. The mapping rule for the target resource type corresponding to the task sequence refers to the mapping rule between JSON format and XML format under the target resource type corresponding to the task sequence.
5. The method according to claim 1, characterized in that, The step of converting the target configuration data in YAML format to target configuration data in JSON format, and generating task data based on the target configuration data in JSON format, includes: The parsing thread converts the YAML-formatted target configuration data into JSON-formatted target configuration data, generates task data based on the JSON-formatted target configuration data, stores the task data in the database, and transmits the task group identifier in the task data to the execution thread. The step of converting the target configuration data in JSON format to target configuration data in XML format based on the task data, and sending a configuration instruction containing the target configuration data in XML format to the target switch includes: The execution thread reads the task data from the database according to the task group identifier, converts the JSON-formatted target configuration data into XML-formatted target configuration data based on the task data, and sends a configuration instruction containing the XML-formatted target configuration data to the target switch.
6. The method according to claim 1, characterized in that, The step of converting the target configuration data in YAML format to target configuration data in JSON format, and generating task data based on the target configuration data in JSON format, includes: The target configuration data in YAML format is converted into target configuration data in JSON format by a parsing thread, task data is generated based on the target configuration data in JSON format, the task data is stored in the database, and the task group identifier in the task data is transmitted to the client. The method further includes: receiving a query request containing the task group identifier sent by the client through a query thread, reading the task execution status corresponding to the task data from the database according to the task group identifier, and returning the task execution status to the client.
7. The method according to claim 1, characterized in that, The method further includes: Upon receiving a replication configuration request, the system obtains the current configuration data in JSON format corresponding to the switch to be replicated as indicated by the replication configuration request, converts the current configuration data in JSON format into current configuration data in YAML format, and returns the current configuration data in YAML format to the client, so that the client can replicate the current configuration data in YAML format to the target configuration data in YAML format.
8. A switch configuration management device, characterized in that, The device includes: The receiving module is used to receive target configuration data in YAML format configured for the target switch; The generation module is used to convert the target configuration data in YAML format into target configuration data in JSON format, and generate task data based on the target configuration data in JSON format. The conversion module is used to convert the target configuration data in JSON format into target configuration data in XML format according to the task data, and send a configuration instruction containing the target configuration data in XML format to the target switch so that the target switch executes the configuration instruction.
9. An electronic device, characterized in that, The electronic device includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor. When the program or instructions are executed by the processor, they implement the switch configuration management method as described in any one of claims 1 to 7.
10. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed by a processor, implement the switch configuration management method as described in any one of claims 1 to 7.