Configuration file acquisition method, device, equipment and storage medium

By creating interface status detection threads and configuration file loading threads when the switch is started, loop detection and restarting the network interface in turn according to the interface score, the problem of slow network device configuration speed is solved, and the efficiency and success rate of configuration file acquisition is improved.

CN116471246BActive Publication Date: 2025-08-15INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310429934.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-20
Publication Date
2025-08-15
Estimated Expiration
2043-04-20

AI Technical Summary

Technical Problem

During the deployment of network equipment, the restart operation of multiple network interfaces takes a long time, affecting the configuration speed, and the probability of interfaces with smaller serial numbers obtaining configuration files is low.

Method used

Create an interface status detection thread and a configuration file loading thread when the switch is started. The network interface status is detected by the detection thread loop. After entering the state of the waiting restart, the network interface is restarted in sequence from large to small according to the interface score, and request the configuration file through the restarted interface.

Benefits of technology

It improves the efficiency of network device configuration and the speed of configuration file acquisition, and increases the probability of obtaining configuration files, especially prioritizing the restart of high-scoring interfaces to improve the acquisition success rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116471246B_ABST
    Figure CN116471246B_ABST
Patent Text Reader

Abstract

The embodiments of the present application relate to the field of network technology, and specifically to a configuration file acquisition method, apparatus, device, and storage medium, which are intended to improve the speed of network device configuration. The method comprises: when a switch is started, creating an interface status detection thread and a configuration file loading thread; loopingly detecting the interface status of all network interfaces on the switch through the interface status detection thread; when a connected network interface is detected on the switch, the switch enters a pending restart state; when the time the switch enters the pending restart state exceeds a preset pending restart time threshold, the connected network interfaces are sequentially restarted in descending order of their scores based on the interface score of each network interface; requesting a configuration file from a host configuration server through the restarted network interface; and loading the configuration file when the configuration file loading thread detects that the switch has obtained the configuration file.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of network technology, and more specifically, to a configuration file acquisition method, apparatus, device, and storage medium. Background Art

[0002] When deploying network devices, after the network devices are installed, the devices need to run the ZTP (Zero Touch Provisioning) function to enable the network devices to automatically load the deployment files and complete configuration and deployment. In related technologies, when a device runs the ZTP function and detects that a network interface is connected, it restarts the network service of the network interface. After the restart is complete, it checks whether the configuration file is obtained. If the configuration file is detected, it loads the configuration file and completes the configuration of the network device.

[0003] In related technologies, when there are multiple network interfaces on a device, the operation of restarting the network services of multiple network interfaces takes a long time, which delays the speed of network device configuration. In addition, network interfaces are generally restarted in the order of their serial numbers. Network interfaces with smaller serial numbers generally have lower speeds and are not easy to obtain configuration files, which also affects the speed of network device configuration. Summary of the Invention

[0004] The embodiments of the present application provide a configuration file acquisition method, apparatus, device, and storage medium, aiming to increase the speed of network device configuration.

[0005] A first aspect of an embodiment of the present application provides a method for obtaining a configuration file, the method comprising:

[0006] When the switch starts, it creates an interface status detection thread and a configuration file loading thread;

[0007] Performing cyclic detection on the interface status of all network interfaces on the switch through the interface status detection thread;

[0008] When detecting that the network interface on the switch is in a connected state, the switch enters a waiting-to-restart state;

[0009] When the time that the switch enters the pending restart state exceeds a preset pending restart time threshold, restarting the network of all connected network interfaces in descending order of the score according to the interface score of each network interface;

[0010] Requesting a configuration file from a host configuration server via the restarted network interface;

[0011] When the configuration file loading thread detects that the switch obtains the configuration file, it loads the configuration file.

[0012] Optionally, before performing a network restart on each of the network interfaces in a connected state in sequence according to the interface score of each of the network interfaces, the method further includes:

[0013] An interface score of each network interface is determined according to the interface rate, interface sequence number, and interface connection status of each network interface.

[0014] Optionally, determining the interface score of each network interface according to the interface rate, interface sequence number, and interface connection status of each network interface includes:

[0015] Determining the interface rate of each of the network interfaces, scoring each of the network interfaces in ascending order of interface rate, and determining a first interface score of the network interface;

[0016] According to the interface serial number of the network interface, in order of the interface serial number from low to high, scoring each of the network interfaces in order from low to high, to determine a second interface score of the network interface;

[0017] Scoring the network interface connected to the cable or module according to the interface connection status of the network interface to determine a third interface score of the network interface;

[0018] The first interface score, the second interface score, and the third interface score are added together to obtain the interface score.

[0019] Optionally, the performing a network restart on each of the network interfaces in a connected state according to the interface score of each of the network interfaces includes:

[0020] Determine an interface score for each network interface in a connectivity state;

[0021] Add each network interface in a connected state to a restart queue in descending order of interface scores;

[0022] The network interfaces in the restart queue are restarted in sequence.

[0023] Optionally, requesting a configuration file from a host configuration server through the restarted network interface includes:

[0024] Sending a configuration file request to the host configuration server through the restarted network interface;

[0025] Receiving configuration file information sent by the host configuration server;

[0026] Download the configuration file according to the configuration file information.

[0027] Optionally, when the configuration file loading thread detects that the switch has acquired the configuration file, loading the configuration file, the method further includes:

[0028] Sending an end signal to the interface status detection thread through the configuration file loading thread;

[0029] After receiving the end signal, the interface status detection thread stops detecting the interface status of the network interface.

[0030] Optionally, the method further includes:

[0031] When the configuration file loading thread fails to detect that the switch has acquired the configuration file, the steps performed by the interface status detection thread are repeated.

[0032] A second aspect of an embodiment of the present application provides a configuration file acquisition device, the device comprising:

[0033] The thread creation module is used to create an interface status detection thread and a configuration file loading thread when the switch starts;

[0034] An interface status detection module, configured to perform cyclic detection on the interface status of all network interfaces on the switch through the interface status detection thread;

[0035] a waiting-to-restart state module, configured to, when detecting that the network interface on the switch is in a connected state, cause the switch to enter a waiting-to-restart state;

[0036] A network interface restart module is configured to, when the time the switch has been in a pending restart state exceeds a preset pending restart time threshold, restart all connected network interfaces in descending order of their scores based on their interface scores;

[0037] A configuration file request module is used to request a configuration file from a host configuration server through the restarted network interface;

[0038] The configuration file loading module is configured to load the configuration file when the configuration file loading thread detects that the switch has acquired the configuration file.

[0039] Optionally, the device further comprises:

[0040] The network interface score determination module is used to determine the interface score of each network interface according to the interface rate, interface sequence number and interface connection status of each network interface.

[0041] Optionally, the network interface score determination module includes:

[0042] a first interface score determination submodule, configured to determine an interface rate of each of the network interfaces, and score each of the network interfaces in ascending order of interface rates to determine a first interface score of the network interface;

[0043] A second interface score determination submodule is configured to score each of the network interfaces in ascending order according to the interface sequence numbers of the network interfaces, to determine a second interface score of the network interface;

[0044] a third interface score determination submodule, configured to score the network interface connected to the cable or module according to the interface connection status of the network interface, and determine a third interface score of the network interface;

[0045] The interface score obtaining submodule is configured to add the first interface score, the second interface score, and the third interface score to obtain the interface score.

[0046] Optionally, the network interface restart module includes:

[0047] An interface score determination submodule, configured to determine an interface score of the network interface in each connectivity state;

[0048] Add each network interface in a connected state to a restart queue in descending order of interface scores;

[0049] The network interface restart submodule is used to restart the network interfaces in the restart queue in sequence.

[0050] Optionally, the configuration file request module includes:

[0051] a configuration file request sending submodule, configured to send a configuration file request to the host configuration server through the restarted network interface;

[0052] A configuration file information acquisition submodule, configured to receive configuration file information sent by the host configuration server;

[0053] The configuration file downloading submodule is used to download the configuration file according to the configuration file information.

[0054] Optionally, the configuration file loading module further includes:

[0055] An end signal sending submodule, configured to send an end signal to the interface status detection thread through the configuration file loading thread;

[0056] The interface status detection stopping submodule is used for the interface status detection thread to stop detecting the interface status of the network interface after receiving the end signal.

[0057] Optionally, the device further comprises:

[0058] The repetition detection module is configured to repeat the steps executed by the interface status detection thread when the configuration file loading thread fails to detect that the switch has obtained the configuration file.

[0059] A third aspect of an embodiment of the present application provides a readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps in the method described in the first aspect of the present application are implemented.

[0060] A fourth aspect of an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method described in the first aspect of the present application are implemented.

[0061] Using the configuration file acquisition method provided in the present application, when the switch starts, an interface status detection thread and a configuration file loading thread are created; the interface status of all network interfaces on the switch is cyclically detected by the interface status detection thread; when a network interface in a connected state is detected on the switch, the switch enters a pending restart state; when the time the switch enters the pending restart state exceeds a preset pending restart time threshold, all network interfaces in a connected state are restarted in sequence according to the interface score of each network interface; a configuration file is requested from a host configuration server through the restarted network interface; and when the configuration file loading thread detects that the switch has obtained the configuration file, the configuration file is loaded. In the method provided in the present application, when the switch is started, two threads are created. The network interface status is detected by the interface status detection thread, and the configuration file is loaded by the configuration file loading thread. This can speed up the switch to obtain the configuration file and speed up the switch to load the configuration file, thereby improving the efficiency of network device configuration. When it is detected that there is a network interface in a connected state on the switch, it enters the waiting-for-restart state. When the running time of the switch exceeds the preset waiting-for-restart time threshold, the network interfaces are restarted in sequence according to the interface score of each network interface. During the waiting-for-restart event, multiple network interfaces can be allowed to obtain the configuration file as much as possible to increase the probability of obtaining the configuration file, and the network interfaces are restarted in sequence according to the network score of each interface. The network interface with a larger network interface score is more likely to obtain the configuration file, and the probability of obtaining the configuration file is further improved by restarting the network interfaces in the order of the interface score size. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0063] Figure 1 This is a flowchart of a configuration file acquisition method proposed in one embodiment of the present application;

[0064] Figure 2 This is a schematic diagram of switch connection proposed in one embodiment of the present application;

[0065] Figure 3 Schematic diagram of a configuration file acquisition device proposed in an embodiment of the present application. DETAILED DESCRIPTION

[0066] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0067] refer to Figure 1 , Figure 1 This is a flowchart of a configuration file acquisition method proposed in one embodiment of the present application.

[0068] like Figure 1 As shown, the method includes the following steps:

[0069] S11: When the switch starts, it creates an interface status detection thread and a configuration file loading thread.

[0070] In this embodiment, reference Figure 2 , Figure 2 This is a schematic diagram of a switch connection proposed in an embodiment of the present application. Figure 2 As shown in the figure, the switch is connected to the configuration server and the client, forwarding the signal sent by the server to the client. When the switch starts, it needs to perform initial configuration and enter the ZTP (Zero Touch Provisioning) process to realize automatic configuration of the switch. When the switch is configured, it needs to obtain the configuration file from the configuration server.

[0071] In this embodiment, the switch is a network device used for signal forwarding. The switch has multiple network interfaces, which are connected to the server and the client via cables and forward signals sent by the server to the client. The interface status detection thread is a program that runs independently in the operating system of the switch. The program is used to cyclically detect the connection status of all network interfaces on the switch. The configuration file loading thread is used to detect in real time whether a configuration file is obtained on the switch. When it is detected that a configuration file is obtained on the switch, the configuration file is loaded and the status detection thread is notified to stop status detection.

[0072] In this embodiment, a thread to be run at startup is pre-set in the switch. When the switch is started, two threads are automatically created, one thread is an interface status detection thread, and the other thread is a configuration file loading thread.

[0073] For example, the switch is any switch running a switch operating system, and is not limited here.

[0074] S12: Performing cyclic detection on the interface status of all network interfaces on the switch through the interface status detection thread.

[0075] In this embodiment, the interface status includes a connected state (up) and a disconnected state (down). A network interface in a connected state is an interface that has established a communication connection with a server or client, and a network interface in a disconnected state has not established a communication connection with a server or client.

[0076] In this embodiment, the switch starts an interface status detection thread, and performs cyclic detection on the interface status of all network interfaces on the switch through the interface status detection thread.

[0077] S13: When it is detected that the network interface on the switch is in a connected state, the switch enters a waiting-to-restart state.

[0078] In this embodiment, the waiting-for-restart state is a waiting stage before the switch restarts the network service of the network interface. In the waiting-for-restart stage, the remaining network interfaces on the switch can still establish communication connections with external devices.

[0079] In this embodiment, when the interface status detection thread performs a round of detection on all interfaces on the switch, when it is detected that there is an interface in the connected state on the switch, the switch enters the waiting-for-restart state. The switch entering the waiting-for-restart state will not immediately restart the network service of the network interface when a connected interface is detected. The switch will first enter the waiting-for-restart state. During the process of entering the waiting-for-restart state, the remaining interfaces of the switch can continue to establish communication connections with the other interfaces.

[0080] In the traditional configuration file acquisition process, when the network interface of the switch establishes a communication connection with the external device, the network service of the switch will be restarted immediately, and then the configuration file will be obtained through the network interface. However, the network interface may not establish a connection with the configuration file server, but may also establish a connection with other servers or clients. Therefore, directly restarting the network server is time-consuming and may not obtain the configuration file. Therefore, waiting for more interfaces to establish connections with external devices can increase the probability of obtaining the configuration file, prevent the switch from restarting the network service ineffectively multiple times, and effectively improve the speed of obtaining the configuration file.

[0081] S14: When the time for the switch to enter the pending restart state exceeds a preset pending restart time threshold, restart the network of all connected network interfaces in descending order of the score according to the interface score of each network interface.

[0082] In this embodiment, the pending restart time threshold is a preset maximum time for the switch to enter the pending restart state. The interface score is a comprehensive score of the network interface based on the interface rate, interface number, and interface connection status of each network interface. The network interface with a larger interface score has a greater probability of obtaining the configuration file.

[0083] In this embodiment, when the switch enters the pending restart state and the time in the pending restart state exceeds the preset pending restart time threshold, the network is restarted in sequence for all connected network interfaces in descending order of scores based on the score of each network interface.

[0084] For example, the preset restart time threshold is 10s. There are 5 network interfaces on the switch. When the interface status detection thread detects that interfaces 1 and 3 on the switch are connected, it waits for 10 seconds. Within these 10 seconds, interface 5 also establishes a communication connection with the external device. After 10 seconds, interfaces 1, 3, and 5 are restarted in descending order of their scores.

[0085] S15: Requesting a configuration file from the host configuration server through the restarted network interface.

[0086] In this embodiment, the configuration server is also called a DHCP (Dynamic Host Configuration Protocol) server, which is used to send the configuration file required for networking to the switch. The configuration file is a file that initializes the configuration of the switch. After the switch loads the configuration file, the universal configuration of the switch is completed, and then it can normally receive and send network signals.

[0087] In this embodiment, the switch requests a configuration file from the host configuration server through the network interface after restart. The switch attempts to send a request to the configuration server on each network interface after restart to request the configuration file. When the network interface establishes a communication connection with the configuration server, the switch receives relevant information sent by the configuration server, including the device's IP address, the device's default gateway, the device's intermediate service address, the intermediate file name, etc. The switch downloads the configuration file based on this relevant information.

[0088] S16: When the configuration file loading thread detects that the switch has obtained the configuration file, it loads the configuration file.

[0089] In this embodiment, the configuration file loading thread obtains the configuration file when detecting the switch after each network interface is restarted. When the configuration file loading thread detects that the switch has obtained the configuration file, it directly loads the configuration file. After the configuration file is loaded, the configuration of the switch is completed.

[0090] In this embodiment, two independent threads are used to detect the status of the switch interface and load the configuration file, which improves the speed of obtaining the configuration file. When a network interface in a connected state is detected, it enters the restart waiting state and waits for a window period. When the switch operation time exceeds the preset restart waiting time threshold, each network interface is restarted in sequence according to the interface score of each network interface. The interface with a higher network score is more likely to obtain the configuration file, so it is restarted first, which increases the possibility of obtaining the configuration file and thus improves the speed of obtaining the configuration file.

[0091] In another embodiment of the present application, before performing a network restart on each of the network interfaces in a connected state in sequence according to the interface score of each of the network interfaces, the method further includes:

[0092] S21: Determine an interface score for each network interface according to the interface rate, interface sequence number, and interface connection status of each network interface.

[0093] In this embodiment, the interface rate is the maximum transmission speed of the network interface, the interface number is the number of the network interface on the switch, and the interface connection status refers to whether the interface is connected to a cable or module. The interface score represents the probability of the interface obtaining the configuration file.

[0094] In this embodiment, whether the network interface can obtain the configuration file has three important factors: interface speed, interface serial number and interface connection status. Among them, the most important factor is interface speed, followed by interface connection status, and finally interface serial number.

[0095] In this embodiment, when the switch is started, the switch scores each network interface based on its interface rate, interface sequence number, and interface connection status to determine the interface score of each network interface. Step S21 specifically includes:

[0096] S22-1: Determine the interface rate of each of the network interfaces, and score each of the network interfaces in order from low to high according to the interface rates, to determine a first interface score of the network interface.

[0097] In this embodiment, the first interface score is a score of the network interface based on the network rate of the network interface.

[0098] In this embodiment, the interface rate of the network interface is pre-set. The interface rate of each network interface can be obtained by checking the relevant information of the pre-stored network interface. Different scores are given to network interfaces with different rates based on the rate of each interface on the switch. The interface rate of the network interface is very important to whether the network interface can obtain the configuration file and is an important influencing factor. Therefore, the score will increase significantly with each level increase in the network interface rate.

[0099] For example, the network interface with the lowest speed is scored as 1 point, and the score increases by 100 points each time the speed of the network interface increases by one level.

[0100] S22-2: According to the interface serial numbers of the network interfaces, scores are assigned to each network interface in ascending order according to the interface serial numbers, to determine a second interface score of the network interface.

[0101] In this embodiment, the second interface score is a score for the network interface according to the interface sequence number of the network interface.

[0102] In this embodiment, when connecting the switch, the network interface with the larger serial number is generally connected to the server, and the network interface with the smaller serial number is connected to the client. Therefore, the network interface with the larger serial number is more likely to be the network interface connected to the configuration server. The interface serial number starts from the smallest network interface, and the score of each network interface increases in sequence. The serial number has a smaller impact on whether the network interface can obtain the configuration file. Therefore, as the serial number increases, the score of each network interface increases. Based on the serial number of the network interface, according to the order of the interface serial number from low to high, each network interface is scored in order from low to high to determine the second interface score of the network interface.

[0103] For example, the interface number starts from the smallest network interface, and the score of each network interface increases by 1.

[0104] S23 - 3 : Score the network interface connected to the cable or module according to the interface connection status of the network interface to determine a third interface score of the network interface.

[0105] In this embodiment, the third interface score is a score assigned to the interface according to the interface connection status of the network interface.

[0106] In this embodiment, the switch operating system displays the cables or modules connected to the network interfaces. However, some network interfaces that already have cables or modules connected may not be displayed in the switch operating system. When scoring the network interfaces, network interfaces that display connected cables or modules are scored. Network interfaces that have connected cables or modules are more likely to obtain configuration files. The influence on whether an interface can obtain configuration files is greater than the interface number but less than the interface rate. Based on the network interface connection status, the network interfaces that have connected cables or modules are scored to determine a third interface score for the network interface.

[0107] For example, for a network interface connected to a cable or module, 50 points are added to the existing score.

[0108] S23-4: Add the first interface score, the second interface score, and the third interface score to obtain the interface score.

[0109] In this embodiment, after the first interface score, the second interface score, and the third interface score are determined, the scores of the three are added together to obtain the interface score of the network interface.

[0110] For example, the speed level of an interface is level 2, the first interface score is 100, the interface sequence number is 3, the second interface score is 3, the interface is connected to a cable, and the third interface score is 50. The final interface score of the network interface is 153.

[0111] In this embodiment, the network interface is scored based on the interface rate, interface serial number and interface connection status of the network interface. When restarting the network service of the network interface, the network interface with the highest score and the greatest possibility of obtaining the configuration file is restarted first based on the interface score, thereby increasing the speed of obtaining the configuration file.

[0112] In another embodiment of the present application, the performing a network restart on each of the network interfaces in a connected state according to the interface score of each of the network interfaces includes:

[0113] S31: Determine the interface score of each network interface in the connectivity state.

[0114] In this embodiment, after the switch determines all network interfaces in a connected state through the interface status detection thread, it determines the interface score of each network interface in a connected state and obtains the interface score of the network interface by checking the interface information of each network interface.

[0115] For example, the switch has three connected network interfaces, namely network interface 1, network interface 3, and network interface 5. The interface score of network interface 1 is 51, the interface score of network interface 3 is 153, and the interface score of network interface 5 is 155.

[0116] S32: Add each of the network interfaces in a connected state to a restart queue in descending order of interface scores.

[0117] In this embodiment, the restart queue is a queue created by the interface status detection thread, and the network interfaces in the queue will restart the network services in sequence.

[0118] In this embodiment, after the interface score of each network interface in a connected state is determined, the interfaces are sequentially added to the restart queue in descending order of the interface score.

[0119] S33: Restart the network interfaces in the restart queue in sequence.

[0120] In this embodiment, after the network interface is added to the restart queue, the network interfaces in the restart queue will be restarted in turn, and the network services in the network interfaces will be restarted. The one with the highest score will be at the front of the queue and restarted the earliest, and the one with the lowest score will be at the back of the queue and restarted the latest.

[0121] For example, among the three network interfaces in step S31 , network interface 3 is at the front of the queue and is restarted first, network interface 5 is in the middle of the queue and is restarted second, and network interface 1 is at the third position in the queue and is restarted last.

[0122] In this embodiment, the network interfaces are restarted according to the scores, and the network interface that is most likely to obtain the configuration file is restarted first, thereby increasing the probability of obtaining the configuration file and thereby improving the speed of obtaining the configuration file.

[0123] In another embodiment of the present application, requesting a configuration file from a host configuration server through the restarted network interface includes:

[0124] S41: Sending a configuration file request to the host configuration server through the restarted network interface.

[0125] In this embodiment, the configuration file request is a request message sent by the switch to the host configuration server through the network interface, and is used to request a configuration file for configuring the switch.

[0126] In this embodiment, after the network interface is restarted, the switch attempts to send a configuration file request to the host configuration server through the restarted network interface. When a communication connection is established between the network interface and the host configuration server, the configuration file request will be sent to the host configuration server. When the switch interface is not connected to the host configuration server, the configuration file request will not be sent to the host configuration server because the switch interface may be connected to another server or a client.

[0127] S42: Receive configuration file information sent by the host configuration server.

[0128] In this embodiment, the configuration file information is the corresponding response message sent by the host configuration server to the switch after receiving the configuration file request sent by the switch, which includes the IP address assigned to the switch, the default gateway, the address of the intermediate file server, the intermediate file name, etc.

[0129] In this embodiment, the host configuration server receives a configuration file request sent by the switch through a network interface, and sends configuration file information to the corresponding network interface.

[0130] S43: Download the configuration file according to the configuration file information.

[0131] In this embodiment, the switch determines the name of the configuration file and the network address of the configuration file according to the configuration file information, and downloads the configuration file from the network address.

[0132] In another embodiment of the present application, when the configuration file loading thread detects that the switch has obtained the configuration file, the method further includes:

[0133] S51: Sending an end signal to the interface status detection thread through the configuration file loading thread.

[0134] In this embodiment, the end signal is used to notify the interface status detection thread to end its operation.

[0135] In this embodiment, after the configuration file loading thread detects that the switch has obtained the configuration file, it sends a termination signal to the interface status detection thread, instructing the interface status detection thread to terminate the interface status detection of each interface on the switch.

[0136] S52: After receiving the end signal, the interface status detection thread stops detecting the interface status of the network interface.

[0137] In this embodiment, after receiving the end signal sent by the configuration file loading thread, the interface status detection thread stops detecting the interface status of the network interface on the switch.

[0138] In this embodiment, after detecting that the switch has obtained the configuration file, the configuration file loading thread immediately notifies the interface status detection thread to stop working, which saves computing resources of the switch and is more conducive to accelerating the configuration of the switch.

[0139] In another embodiment of the present application, the method further includes:

[0140] S61: When the configuration file loading thread fails to detect that the switch has obtained the configuration file, the steps performed by the interface status detection thread are repeated.

[0141] In this embodiment, the configuration file loading thread checks the switch for the configuration file. If the configuration file loading thread fails to detect the configuration file, the interface status detection thread detects a connected network interface on the switch and proceeds to a restart state. After a waiting window, the connected network interface is restarted. The steps performed by the interface status detection thread are repeated until the configuration file loading thread detects that the switch has obtained the configuration file, at which point the interface status detection thread ceases execution.

[0142] In the above embodiment of the present application, when the switch is started, each network interface of the switch is first scored. The score reflects the possibility of the network interface obtaining the configuration file. The higher the score, the more likely the network interface is to obtain the configuration file. Two threads are created. One thread is the interface status detection thread, which cyclically detects the interface status of each network interface on the switch. When a network interface in a connected state is detected, the switch enters a waiting-for-restart state. When the time the switch enters the waiting-for-restart state exceeds a preset waiting-for-restart time threshold, the network interfaces in the connected state are restarted in sequence according to the score. This allows as many network interfaces as possible to be connected, increases the probability of obtaining the configuration file, and thus accelerates the acquisition of the configuration file, saving the time of the entire switch configuration. The other thread is the configuration file loading thread, which is dedicated to detecting and loading the configuration file on the switch, making the configuration file loading speed faster and improving the configuration speed of the switch. When the scale of the ZTP task is large and there are many levels, the execution speed of the entire ZTP process can be greatly improved, completing the rapid and automated deployment of the switch.

[0143] Based on the same inventive concept, an embodiment of the present application provides a configuration file acquisition device. Figure 3 , Figure 3 Schematic diagram of a configuration file 300 acquisition device proposed in an embodiment of the present application. Figure 3 As shown, the device includes:

[0144] The thread creation module 301 is used to create an interface status detection thread and a configuration file loading thread when the switch starts;

[0145] An interface status detection module 302 is configured to perform cyclic detection on the interface status of all network interfaces on the switch through the interface status detection thread;

[0146] The waiting-for-restart state module 303 is configured to, when detecting that the network interface on the switch is in a connected state, cause the switch to enter a waiting-for-restart state;

[0147] The network interface restart module 304 is configured to, when the time the switch has been in the pending restart state exceeds a preset pending restart time threshold, restart all connected network interfaces in descending order of their scores based on their interface scores;

[0148] The configuration file request module 305 is used to request a configuration file from the host configuration server through the restarted network interface;

[0149] The configuration file loading module 306 is configured to load the configuration file when the configuration file loading thread detects that the switch has obtained the configuration file.

[0150] Optionally, the device further comprises:

[0151] The network interface score determination module is used to determine the interface score of each network interface according to the interface rate, interface sequence number and interface connection status of each network interface.

[0152] Optionally, the network interface score determination module includes:

[0153] a first interface score determination submodule, configured to determine an interface rate of each of the network interfaces, and score each of the network interfaces in ascending order of interface rates to determine a first interface score of the network interface;

[0154] A second interface score determination submodule is configured to score each of the network interfaces in ascending order according to the interface sequence numbers of the network interfaces, to determine a second interface score of the network interface;

[0155] a third interface score determination submodule, configured to score the network interface connected to the cable or module according to the interface connection status of the network interface, and determine a third interface score of the network interface;

[0156] The interface score obtaining submodule is configured to add the first interface score, the second interface score, and the third interface score to obtain the interface score.

[0157] Optionally, the network interface restart module includes:

[0158] An interface score determination submodule, configured to determine an interface score of the network interface in each connectivity state;

[0159] Add each network interface in a connected state to a restart queue in descending order of interface scores;

[0160] The network interface restart submodule is used to restart the network interfaces in the restart queue in sequence.

[0161] Optionally, the configuration file request module includes:

[0162] a configuration file request sending submodule, configured to send a configuration file request to the host configuration server through the restarted network interface;

[0163] A configuration file information acquisition submodule, configured to receive configuration file information sent by the host configuration server;

[0164] The configuration file downloading submodule is used to download the configuration file according to the configuration file information.

[0165] Optionally, the configuration file loading module further includes:

[0166] An end signal sending submodule, configured to send an end signal to the interface status detection thread through the configuration file loading thread;

[0167] The interface status detection stopping submodule is used for the interface status detection thread to stop detecting the interface status of the network interface after receiving the end signal.

[0168] Optionally, the device further comprises:

[0169] The repetition detection module is configured to repeat the steps executed by the interface status detection thread when the configuration file loading thread fails to detect that the switch has obtained the configuration file.

[0170] Based on the same inventive concept, another embodiment of the present application provides a readable storage medium having a computer program stored thereon. When the program is executed by a processor, the steps in the configuration file acquisition method described in any of the above embodiments of the present application are implemented.

[0171] Based on the same inventive concept, another embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When executed by the processor, the steps of the configuration file acquisition method described in any of the above embodiments of the present application are implemented.

[0172] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0173] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0174] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, devices, or computer program products. Therefore, the embodiments of the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0175] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0176] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0177] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0178] Although preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic inventive concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.

[0179] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.

[0180] The configuration file acquisition method, apparatus, device, and storage medium provided in this application are described in detail above. Specific examples are used herein to illustrate the principles and implementation methods of this application. The description of the above embodiments is only intended to help understand the method and core ideas of this application. At the same time, for those skilled in the art, according to the ideas of this application, there may be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as limiting this application.

Claims

1. A configuration file acquisition method, characterized in that: The method comprises: When the switch starts, it creates an interface status detection thread and a configuration file loading thread; Performing cyclic detection on the interface status of all network interfaces on the switch through the interface status detection thread; When detecting that the network interface on the switch is in a connected state, the switch enters a waiting-to-restart state; When the time that the switch enters the pending restart state exceeds a preset pending restart time threshold, restarting the network of all connected network interfaces in descending order of the score according to the interface score of each network interface; Requesting a configuration file from a host configuration server via the restarted network interface; When the configuration file loading thread detects that the switch obtains the configuration file, it loads the configuration file.

2. The method according to claim 1, characterized in that Before performing a network restart on each of the network interfaces in a connected state in sequence according to the interface score of each of the network interfaces, the method further includes: An interface score of each network interface is determined according to the interface rate, interface sequence number, and interface connection status of each network interface.

3. The method according to claim 2, characterized in that Determining an interface score of each network interface according to the interface rate, interface sequence number, and interface connection status of each network interface includes: Determining the interface rate of each of the network interfaces, scoring each of the network interfaces in ascending order of interface rate, and determining a first interface score of the network interface; According to the interface serial number of the network interface, in order of the interface serial number from low to high, scoring each of the network interfaces in order from low to high, to determine a second interface score of the network interface; Scoring the network interface connected to the cable or module according to the interface connection status of the network interface to determine a third interface score of the network interface; The first interface score, the second interface score, and the third interface score are added together to obtain the interface score.

4. The method according to claim 1, wherein The step of restarting the network for each of the network interfaces in a connected state according to the interface score of each of the network interfaces includes: Determine an interface score for each network interface in a connectivity state; Add each network interface in a connected state to a restart queue in descending order of interface scores; The network interfaces in the restart queue are restarted in sequence.

5. The method according to claim 1, wherein The requesting a configuration file from a host configuration server through the restarted network interface includes: Sending a configuration file request to the host configuration server through the restarted network interface; Receiving configuration file information sent by the host configuration server; Download the configuration file according to the configuration file information.

6. The method according to claim 1, characterized in that When the configuration file loading thread detects that the switch has acquired the configuration file, loading the configuration file, the method further includes: Sending an end signal to the interface status detection thread through the configuration file loading thread; After receiving the end signal, the interface status detection thread stops detecting the interface status of the network interface.

7. The method according to claim 1, characterized in that The method further comprises: When the configuration file loading thread fails to detect that the switch has acquired the configuration file, the steps performed by the interface status detection thread are repeated.

8. A configuration file acquisition device, characterized in that: The device comprises: The thread creation module is used to create an interface status detection thread and a configuration file loading thread when the switch starts; An interface status detection module, configured to perform cyclic detection on the interface status of all network interfaces on the switch through the interface status detection thread; a waiting-to-restart state module, configured to, when detecting that the network interface on the switch is in a connected state, cause the switch to enter a waiting-to-restart state; A network interface restart module is configured to, when the time the switch has been in a pending restart state exceeds a preset pending restart time threshold, restart all connected network interfaces in descending order of their scores based on their interface scores; A configuration file request module is used to request a configuration file from a host configuration server through the restarted network interface; The configuration file loading module is configured to load the configuration file when the configuration file loading thread detects that the switch has acquired the configuration file.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Automatic deployment method and device for access switcher

    CN105071948A

  • Switch equipment networking method, switch equipment supporting profinet protocol and storage medium

    CN111541566A