A server firmware updating method and device integrating static resource services and a storage medium

By integrating static resource services, using lightweight HTTP services and thread pool technology, and dynamically monitoring resource utilization, efficient and reliable server firmware updates were achieved. This solved the problems of cumbersome and uncontrollable concurrency in traditional update methods, ensuring firmware integrity and network stability.

CN120723277BActive Publication Date: 2025-11-04POWERLEADER COMPUTER SYST CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511158937.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-19
Publication Date
2025-11-04
Estimated Expiration
2045-08-19

AI Technical Summary

Technical Problem

Traditional server firmware update methods are cumbersome and suffer from uncontrollable concurrency and inability to verify firmware integrity, leading to network anomalies and functional overload.

Method used

By integrating static resource services, a lightweight HTTP service is used to support multi-threaded concurrent downloads, dynamically monitor system resources and network utilization, use a thread pool to execute update tasks concurrently, perform MD5 verification and URL generation on firmware files, and dynamically adjust the number of concurrent processes to optimize the update process.

Benefits of technology

It simplifies the firmware update process, avoids the traditional FTP server dependency and URL concatenation steps, enables simple and reliable firmware updates, ensures firmware integrity through dual verification, and optimizes network load management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120723277B_ABST
    Figure CN120723277B_ABST
Patent Text Reader

Abstract

The application relates to a server firmware updating method and device integrating static resource services and a storage medium, and the method comprises the following steps: an upper computer acquires at least one piece of server information to be updated; a lightweight HTTP service for providing a firmware file downloading service is started, multi-thread concurrent downloading is supported, and URL coding and file transmission tasks are automatically processed; a user selects a firmware file, calculates an MD5 check value of the firmware file, copies the firmware file to a preset static file server directory, and generates an accessible address URL of the firmware file; system resources and network utilization are dynamically monitored, and server updating tasks are concurrently executed through a thread pool; and updating information is fed back through the upper computer. The traditional concurrent firmware updating process is optimized, the firmware can be simply updated, and traditional processes such as establishing an ftp server, uploading firmware to a remote place and splicing a firmware downloading address URL are not needed.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of server operation and maintenance, and in particular to a server firmware updating method and device integrating static resource services and a storage medium. BACKGROUND

[0002] The conventional firmware updating method is complicated, and has risks such as uncontrollable concurrency and inability to verify firmware. The prior art has obvious disadvantages in that it cannot verify whether the firmware updating address exists or whether the remote firmware package is complete. Through the way of updating firmware remotely, it is impossible to determine whether the firmware is correctly pulled. Although the control end sends a request to the server, the server automatically pulls the firmware from the address, but since the conventional firmware address and the control end are not in the same service, it is difficult to determine whether the server correctly sends a request to the updating address. Moreover, the concurrency of the prior art is uncontrollable and unmanageable. If 1000 tasks are automatically pulled by the server, the data volume of the request is too large, which may cause the service function of the static resource end to be overloaded or network abnormal packet loss. Moreover, the conventional method needs to find the updated firmware, upload it to the server, determine whether the uploading is completed, and confirm the address of the updating firmware, and the link needs to be copied after the downloading is confirmed, which is very complicated and prone to errors. SUMMARY

[0003] The present application provides a server firmware updating method and device integrating static resource services and a storage medium, which aims to at least solve one of the technical problems existing in the prior art.

[0004] The technical solution of the present application is a server firmware updating method integrating static resource services, which is applied to a server firmware updating device integrating static resource services. The server firmware updating device integrating static resource services includes a host computer and a server. The host computer and the server are electrically connected through a network. The number of servers is at least one. The server firmware updating method integrating static resource services includes the following steps:

[0005] S100, the host computer acquires information of at least one server to be updated, and the server information at least includes the IP address, username and password of the server;

[0006] S200, a lightweight HTTP service for providing a firmware file downloading service is started, multi-threaded concurrent downloading is supported, and URL encoding and file transmission tasks are automatically processed;

[0007] S300, the user selects a firmware file (such as.bin or.img), calculates the MD5 checksum of the firmware file, and copies the firmware file to a preset static file server directory to generate an accessible address URL of the firmware file;

[0008] S400, dynamically monitor system resources and network utilization, and execute server update tasks concurrently through a thread pool;

[0009] S500, update information is fed back through the host computer.

[0010] Further, step S100 includes the following steps:

[0011] S110, use the filedialog.askopenfilename function to pop up a file selection dialog box to allow the user to select an Excel file, if the user cancels the selection, return empty information None, record the log and exit the filedialog.askopenfilename function;

[0012] S120, use pandas.read_excel to read the Excel file content, check if the server information is complete, if the server information is not complete, return an error information ValueError;

[0013] S130, store the parsed server information in dictionary format, record the log and display the number of loaded servers and server information.

[0014] Further, step S200 includes the following steps:

[0015] S210, create a directory static_firmware under the current working directory for storing firmware files;

[0016] S220, use the hug framework to create a simple HTTP server, add CORS middleware to allow cross-domain access;

[0017] S230, define a static file request processing function serve_static, return the file content according to the requested file name, if the file does not exist, return 404 error information, if an exception occurs, return 500 error information;

[0018] S240, avoid blocking the main thread, start the HTTP server in the background thread, and use hug.API(__name__).http.server to start the server;

[0019] S250, copy the firmware file to the static file directory, generate the accessible address URL of the firmware file.

[0020] Further, step S300 includes the following steps:

[0021] S310, use the filedialog.askopenfilename function to pop up a file selection dialog box, allow the user to select a firmware file, if the user cancels the selection, return empty information None, record the log and exit the filedialog.askopenfilename function;

[0022] S320, use hashlib.md5 to calculate the MD5 check value of the firmware file, to ensure the integrity of the firmware file;

[0023] S330, call self.file_server.add_firmware to copy the firmware file to the static file server directory, generate the accessible URL of the firmware file, and store it in self.firmware_url.

[0024] Further, step S400 includes the following steps:

[0025] S410, dynamically calculate and adjust the concurrency according to the minimum value of the preset concurrency, CPU core limit, memory limit and network bandwidth limit;

[0026] S420, execute server update tasks concurrently through thread pool concurrent.futures.ThreadPoolExecutor;

[0027] S430, for a single server to be updated, execute the update task;

[0028] S440, update the progress bar and log information in real time through the callback function.

[0029] Further, step S420 includes the following steps:

[0030] S421, create a control_thread thread, the target function is self.dynamic_concurrency_control, set as a daemon thread (daemon=True), to ensure that when the main thread ends, the thread will also automatically end, call control_thread.start to start the thread;

[0031] S422, Create a thread pool with concurrent.futures.ThreadPoolExecutor, maximum worker threads self.max_concurrent, submit each server's update task to the thread pool through executor.submit, use concurrent.futures.as_completed to monitor task completion, process results in order, call self.progress_callback to update progress bar and log information after each task is completed;

[0032] S423, In the self.dynamic_concurrency_control method, the thread periodically monitors the utilization of the current network, and dynamically adjusts the concurrency according to the network load. If the network utilization is too high, reduce the concurrency; if the network utilization is low, increase the concurrency;

[0033] S424, Call the self.generate_report method to generate an update report, save the update results to an Excel file, and return the report path and success rate information.

[0034] Further, step S430 includes the following steps:

[0035] S431, According to the address specified by self.firmware_url, use requests.get to download the image of the firmware file;

[0036] S432, Calculate the MD5 hash value of the file block by block during the download process, and compare it with the expected MD5 value passed in to ensure that the firmware has not been tampered with or damaged;

[0037] S433, Use requests.post to send an update request to the server, and use ImageURI to specify the accessible address URL of the firmware file;

[0038] S434, Use HTTPBasicAuth to provide username and password for authentication;

[0039] S435, Set the request timeout time, if an exception occurs, catch the exception and record the failure reason.

[0040] Further, step S500 includes the following steps:

[0041] S510, In the host computer, use tk.Label to display the statistical information of the update results through the ResultWindow class, including the number of successes and the success rate;

[0042] S520, create a table using ttk.Treeview to display the IP address and update status of each server, set column width and title, add scroll bar to support the display of a large amount of data, fill the data into the table, and display the status of the failed server in red;

[0043] S530, allow the user to export the update result as an Excel file, save the result to the specified path using pandas.DataFrame.to_excel, and pop up a prompt box to inform the user.

[0044] Further, the application also proposes a server firmware updating device integrating static resource service, which is used to execute the server firmware updating method integrating static resource service.

[0045] The upper computer;

[0046] The server, the upper computer and the server are electrically connected through the network, and the number of the server is at least one.

[0047] Further, the application also proposes a computer readable storage medium, which stores program instructions, and the program instructions are executed by the processor to implement the server firmware updating method integrating static resource service.

[0048] The application has the following advantages:

[0049] The server firmware updating method, device and storage medium integrating static resource service optimize the traditional concurrent firmware updating process, have a simple firmware updating method, and do not need the traditional process of establishing ftp server, uploading firmware to remote, and splicing firmware download address URL. BRIEF DESCRIPTION OF DRAWINGS

[0050] Figure 1 The flowchart of the server firmware updating method integrating static resource service.

[0051] Figure 2 The schematic diagram of the upper computer acquiring server information and firmware files in the server firmware updating method integrating static resource service.

[0052] Figure 3 The schematic diagram of loading static file server in the server firmware updating method integrating static resource service. DETAILED DESCRIPTION

[0053] The concept, specific structure and generated technical effects of the present application will be described clearly and completely in combination with embodiments and drawings to fully understand the purpose, scheme and effects of the present application. It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict.

[0054] It should be noted that, unless otherwise specified, when a certain feature is referred to as being "fixed" or "connected" to another feature, it can be directly fixed or connected to the other feature, or indirectly fixed or connected to the other feature. In addition, the up, down, left, right, top, bottom and the like used in the present application are only relative to the relative position of the components of the present application in the drawings.

[0055] In addition, unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art. The terms used in the specification herein are only for the purpose of describing specific embodiments and are not intended to limit the present application. The term "and / or" used herein includes any combination of one or more related listed items.

[0056] It should be understood that although the terms first, second, third, etc. can be used in the present disclosure to describe various elements, these elements should not be limited to these terms. These terms are only used to distinguish elements of the same type from each other. For example, without departing from the scope of the present disclosure, a first element can also be referred to as a second element, and similarly, a second element can also be referred to as a first element.

[0057] Referring to Figures 1 to 3 In some embodiments, the technical scheme of the present application is a server firmware updating method integrating static resource services, applied to a server firmware updating device integrating static resource services, which comprises a host computer and a server. The host computer and the server are electrically connected through a network. The number of servers is at least one. Referring to Figure 1 The server firmware updating method integrating static resource services comprises the following steps:

[0058] S100, the host computer acquires information of at least one server to be updated, which at least includes the IP address, username and password of the server;

[0059] S200, start a lightweight HTTP service for providing a firmware file download service, support multi-thread concurrent download, and automatically process URL encoding and file transfer tasks;

[0060] S300, the user selects a firmware file (such as.bin or.img), calculates the MD5 check value of the firmware file, and copies the firmware file to a preset static file server directory to generate an accessible address URL of the firmware file;

[0061] S400, dynamically monitor system resources and network utilization, and execute server update tasks through thread pool concurrency;

[0062] S500, update information is fed back through the host computer.

[0063] The beneficial effects of the present application are:

[0064] The server firmware update method, device and storage medium integrating static resource services optimize the traditional concurrent firmware update process, have a simple firmware update method, and do not need the traditional processes of establishing an ftp server, uploading firmware to a remote, and splicing firmware download address URL.

[0065] The present application has an integrated firmware distribution process, which does not need to rely on the traditional manual FTP upload, file path recording, URL splicing and other complex processes, but simply selects a local firmware file to automatically generate a URL path and perform distribution update.

[0066] The present application also controls concurrent threads, rather than blindly concurrent, and can detect local load and pressure at any time, which is more secure.

[0067] The present application has a double verification mechanism for firmware, which not only checks the uploaded firmware locally, but also checks the firmware of the generated firmware URL address, greatly ensuring the integrity of the firmware.

[0068] The present application establishes a core algorithm control based on CPU load, which is an innovative intelligent adjustment function.

[0069] Further, referring to Figure 1 And Figure 2 , step S100 includes the following steps:

[0070] S110, a filedialog.askopenfilename function is used to pop up a file selection dialog box, allowing the user to select an Excel file, if the user cancels the selection, returns empty information None, records the log and exits the filedialog.askopenfilename function;

[0071] S120. Use pandas.read_excel to read the contents of the Excel file, check if the server information is complete, and return the error message ValueError if the server information is incomplete.

[0072] S130. Store the parsed server information in dictionary format, record logs, and display the number of loaded servers and server information.

[0073] Specifically, the user selects an Excel file containing server information via a file selection dialog box. The Excel file must include at least the necessary columns such as IP address (ip), username (user), and password (password). The program parses the file content and stores the server information as a dictionary (dict) format. The user selects a firmware file (e.g., .bin or .img), and the program calculates the MD5 checksum of the firmware file and copies it to the static file server directory. An accessible URL for the firmware file is then generated. Partial code is shown below:

[0074] def select_server_list(self):

[0075] """Select and parse the server list Excel file"""

[0076] path = filedialog.askopenfilename(filetypes=[("Excel file", "*.xlsx *.csv")])

[0077] if not path:

[0078] self.log("No server list file selected")

[0079] return

[0080] self.server_list_path.set(path)

[0081] try:

[0082] # Parse Excel files

[0083] df = pd.read_excel(path)

[0084] required_columns = ['ip', 'user', 'password']

[0085] if not all(col in df.columns for col in required_columns):

[0086] Raise a ValueError("Excel file is missing required columns: ip, user, password")

[0087] self.servers = df.to_dict('records')

[0088] self.log(f"Successfully loaded the server list, a total of {len(df)} servers")

[0089] self.log("Server example: " + str(self.servers[0]))

[0090] except Exception as e:

[0091] self.log(f"Failed to load server list: {e}")

[0092] Furthermore, refer to Figure 1 and Figure 3 Step S200 includes the following steps:

[0093] S210. Create a directory static_firmware in the current working directory to store firmware files;

[0094] S220. Use the hug framework to create a simple HTTP server, add CORS middleware, and allow cross-domain access;

[0095] S230. Define a static file request handling function `serve_static` that returns the file content based on the requested file name. If the file does not exist, return a 404 error message; if an exception occurs, return a 500 error message.

[0096] S240. To avoid blocking the main thread, start the HTTP server in a background thread using hug.API(__name__).http.server.

[0097] S250: Copy the firmware file to the static file directory and generate the accessible URL of the firmware file.

[0098] Specifically, a lightweight HTTP server is started to provide a download service for firmware files. Multi-threaded concurrent download is supported, and URL encoding and file transfer are automatically handled. Part of the code is as follows:

[0099] class StaticFileServer:

[0100] def __init__(self, port=601):

[0101] # Create static file directory

[0102] self.directory=os.path.join(os.getcwd(), static_firmware')

[0103] os.makedirs(self.directory, exist_ok=True)

[0104] self.port = port

[0105] # Configure Hug API

[0106] self.api = hug.API(__name__)

[0107] self.api.http.add_middleware(CORSMiddleware(api=self.api))

[0108] @staticmethod

[0109] @hug.get(' / {filename}')

[0110] def serve_static(filename: str, response):

[0111] """Handle static file requests"""

[0112] try:

[0113] instance = StaticFileServer._instance

[0114] decoded_filename = urllib.parse.unquote(filename)

[0115] file_path = os.path.join(instance.directory, decoded_filename)

[0116] if not os.path.exists(file_path):

[0117] response.status = hug.HTTP_NOT_FOUND

[0118] return {"error": "File not found"}

[0119] # Stream large files

[0120] response.stream = open(file_path, 'rb')

[0121] response.content_type = 'application / octet-stream'

[0122] response.content_disposition = f'attachment; filename="{decoded_filename}"'

[0123] except Exception as e:

[0124] response.status = hug.HTTP_INTERNAL_SERVER_ERROR

[0125] return {"error": str(e)}

[0126] def start(self):

[0127] """Start the server in a background thread"""

[0128] StaticFileServer._instance = self

[0129] self.server_thread = threading.Thread(

[0130] target = lambda: hug.API(__name__).http.serve(port=self.port),

[0131] daemon=True )

[0133] self.server_thread.start()

[0134] def add_firmware(self, firmware_path):

[0135] """Add firmware to static directory"""

[0136] filename = os.path.basename(firmware_path)

[0137] dest_path = os.path.join(self.directory, filename)

[0138] if not os.path.exists(dest_path):

[0139] shutil.copy(firmware_path, dest_path)

[0140] encoded_filename = urllib.parse.quote(filename)

[0141] return f"http: / / localhost:{self.port} / {encoded_filename}"

[0142] Further, referring to Figure 1 and Figure 2 , step S300 includes the following steps:

[0143] S310, use the filedialog.askopenfilename function to pop up a file selection dialog box, allowing the user to select a firmware file, if the user cancels the selection, return empty information None, record the log and exit the filedialog.askopenfilename function;

[0144] S320, use hashlib.md5 to calculate the MD5 checksum of the firmware file to ensure the integrity of the firmware file;

[0145] S330, Call self.file_server.add_firmware to copy the firmware file to the static file server directory, generate an accessible URL for the firmware file, and store it in self.firmware_url. Partial code as follows:

[0146] def select_firmware(self):

[0147] """Select a firmware file and prepare for distribution"""

[0148] path = filedialog.askopenfilename(filetypes=[("Firmware file", "*.bin*.img")])

[0149] if not path:

[0150] self.log("No firmware file selected")

[0151] return

[0152] try:

[0153] # Verify the firmware file (first firmware verification)

[0154] with open(path, 'rb') as f:

[0155] firmware_data = f.read()

[0156] md5 = hashlib.md5(firmware_data).hexdigest()

[0157] self.log(f"Firmware MD5 checksum: {md5}")

[0158] # Start the static file server (if not already started)

[0159] if not self.file_server_started:

[0160] self.file_server.start()

[0161] self.file_server_started = True

[0162] self.log("Static file server started")

[0163] # Add firmware to static directory

[0164] self.firmware_url = self.file_server.add_firmware(path)

[0165] self.firmware_path.set(path)

[0166] self.log(f"Firmware is ready, access URL: {self.firmware_url}")

[0167] except Exception as e:

[0168] self.log(f"Firmware processing failed: {e}")

[0169] Further, referring to Figure 1 , step S400 includes the following steps:

[0170] S410, dynamically calculate and adjust the concurrency according to the minimum value of the preset concurrency, CPU core limit, memory limit and network bandwidth limit;

[0171] Specifically, the reference code of step S410 is as follows:

[0172] def calculate_optimal_concurrency(self, user_set):

[0173] """Calculate optimal concurrency based on system resources"""

[0174] cpu_cores = psutil.cpu_count()

[0175] mem_available = psutil.virtual_memory().available / (1024**3) #GB

[0176] net_speed = 1000 # Assuming 1Gbps network

[0177] # Calculate resource limits

[0178] max_by_cpu = cpu_cores * 2

[0179] max_by_mem = int(mem_available / 0.5) # Assuming each task requires 0.5GB

[0180] max_by_network = net_speed / 5 # Assuming each task requires 5Mbps

[0181] return min(user_set, max_by_cpu, max_by_mem, max_by_network)

[0182] S420: Execute server update tasks concurrently using the thread pool `concurrent.futures.ThreadPoolExecutor`.

[0183] S430: Execute an update task for a single server to be updated;

[0184] S440: Update the progress bar and log information in real time through a callback function.

[0185] The following is a sample code:

[0186] def calculate_optimal_concurrency(self, user_set):

[0187] "Calculate the optimal concurrency based on system resources"

[0188] cpu_cores = psutil.cpu_count()

[0189] mem_available = psutil.virtual_memory().available / (1024**3) #GB

[0190] net_speed = 1000 # Assuming a 1Gbps network

[0191] # Computing resource limitations

[0192] max_by_cpu = cpu_cores * 2

[0193] max_by_mem = int(mem_available / 0.5) # Assuming each task requires 0.5GB

[0194] max_by_network = net_speed / 5 # Assuming each task requires 5Mbps

[0195] return min(user_set, max_by_cpu, max_by_mem, max_by_network)

[0196] The instance code for dynamically adjusting the concurrency in step S410 is as follows:

[0197] def dynamic_concurrency_control(self):

[0198] """Dynamic concurrency adjustment"""

[0199] while self.running:

[0200] # Monitor network utilization

[0201] net_io = psutil.net_io_counters()

[0202] current_usage = (net_io.bytes_sent + net_io.bytes_recv) / (1024**2) # MB

[0203] # Adjustment strategy

[0204] if current_usage > 800: # Over 800Mbps

[0205] self.max_concurrent = max(5, self.max_concurrent - 5)

[0206] elif current_usage < 500:

[0207] self.max_concurrent = min(50, self.max_concurrent + 2)

[0208] time.sleep(5)

[0209] For example: Use psutil.net_io_counters() to get the current network sending and receiving byte count, calculate the network utilization. If the network utilization exceeds 800Mbps, reduce the concurrency (at least keep 5 concurrency), if the network utilization is lower than 500Mbps, increase the concurrency (at most 50 concurrency). Adjust the network utilization and adjust the concurrency every 5 seconds.

[0210] In one specific embodiment, the optimal concurrency is dynamically calculated: based on system resources (CPU, memory, network bandwidth) to dynamically calculate the optimal concurrency. Use thread pool to execute update tasks concurrently: through

[0211] concurrent.futures.ThreadPoolExecutor concurrent execution of server update tasks.

[0212] Real-time monitoring of network conditions to adjust concurrency: dynamically monitor network utilization and dynamically adjust concurrency based on network load. Provide progress callback to update UI: update progress bar and log information in real time through callback function.

[0213] CPU cores: get the number of system CPU cores through psutil.cpu_count(), assuming that each core can handle two tasks.

[0214] Available memory: get the available memory of the system through psutil.virtual_memory().available, assuming that each task requires 0.5GB of memory.

[0215] Network bandwidth: assume network bandwidth is 1Gbps, each task requires 5Mbps bandwidth.

[0216] Final concurrency: get the minimum value of user-set concurrency, CPU core limit, memory limit and network bandwidth limit.

[0217] Further, referring to Figure 1 , step S420 includes the following steps:

[0218] S421, create a control_thread thread, the target function is self.dynamic_concurrency_control, set as a daemon thread (daemon=True), ensure that the thread will also automatically end when the main thread ends, call control_thread.start to start the thread;

[0219] S422, Create a thread pool with concurrent.futures.ThreadPoolExecutor, max worker threads is self.max_concurrent, submit each server's update task to the thread pool through executor.submit, listen to the task completion status using concurrent.futures.as_completed, process the results in the order of completion, call self.progress_callback to update the progress bar and log information after each task is completed;

[0220] S423, In the self.dynamic_concurrency_control method, the thread periodically monitors the utilization of the current network, and dynamically adjusts the concurrency according to the network load, if the network utilization is too high, reduce the concurrency, if the network utilization is low, increase the concurrency;

[0221] S424, Call the self.generate_report method to generate an update report, save the update results to an Excel file, and return the report path and success rate information.

[0222] Further, with reference to Figure 1 , step S430 includes the following steps:

[0223] S431, According to the address specified by self.firmware_url, use requests.get to download the image of the firmware file;

[0224] S432, Calculate the MD5 hash value of the file block by block during the download process, and compare it with the expected MD5 value passed in to ensure that the firmware has not been tampered with or damaged;

[0225] S433, Use requests.post to send an update request to the server, use ImageURI to specify the accessible address URL of the firmware file;

[0226] S434, Use HTTPBasicAuth to provide username and password for authentication;

[0227] S435, Set the request timeout time, if an exception occurs, catch the exception and record the failure reason.

[0228] In one specific embodiment, the following is an example code for updating a single server:

[0229] import hashlib

[0230] import requests

[0231] from requests.auth import HTTPBasicAuth

[0232] def calculate_md5(url, expected_md5, chunk_size=4096):

[0233] Download the file and calculate its MD5 value.

[0234] try:

[0235] response = requests.get(url, stream=True, timeout=30, verify=False)

[0236] response.raise_for_status()

[0237] md5_hash = hashlib.md5()

[0238] for chunk in response.iter_content(chunk_size=chunk_size):

[0239] if chunk:

[0240] md5_hash.update(chunk)

[0241] calculated_md5 = md5_hash.hexdigest()

[0242] if calculated_md5 != expected_md5:

[0243] raise ValueError(f"MD5 check failed: expected value {expected_md5}, actual value {calculated_md5}")

[0244] return True

[0245] except Exception as e:

[0246] raise RuntimeError(f"Firmware download or MD5 check failed: {str(e)}")

[0247] def update_server(self, server, expected_md5):

[0248] """ Update a single server and perform MD5 checksum of the firmware before updating

[0249] :param server: Server information dictionary containing ip, user, password

[0250] :param expected_md5: Expected MD5 value of the firmware

[0251] :return: Result dictionary """

[0252] result = {'ip': server['ip'],'status': 'pending'}

[0253] try:

[0254] # 1. Download firmware and verify MD5

[0255] print(f"[{server['ip']}] Performing firmware MD5 checksum...")

[0256] is_valid = calculate_md5(self.firmware_url, expected_md5)

[0257] if not is_valid:

[0258] raise RuntimeError("Firmware checksum failed, stopping update process")

[0259] # 2. Trigger update using Redfish API

[0260] print(f"[{server['ip']}] Starting firmware update...")

[0261] response = requests.post(

[0262] f"https: / / xxxxxxxx",

[0263] json={"ImageURI": self.firmware_url},

[0264] auth=HTTPBasicAuth(server['user'], server['password']),

[0265] timeout=60,

[0266] verify=False )

[0268] response.raise_for_status()

[0269] result['status'] ='success'

[0270] except Exception as e:

[0271] result['status'] = f"failed: {str(e)}"

[0272] return result

[0273] In a specific embodiment, initiating batch updates includes: dynamically calculating the optimal concurrency based on system resources (CPU, memory, network bandwidth); concurrently executing server update tasks using a thread pool (concurrent.futures.ThreadPoolExecutor); dynamically monitoring network utilization and adjusting the concurrency based on network load; updating the progress bar and log information in real time via callback functions, providing progress callback updates to the UI; creating a concurrency control thread (control_thread) with the target function self.dynamic_concurrency_control; setting it as a daemon thread (daemon=True) to ensure it automatically terminates when the main thread ends; calling control_thread.start() to start the thread; creating a thread pool using concurrent.futures.ThreadPoolExecutor with a maximum number of worker threads (self.max_concurrent), and executing concurrently within the thread pool; submitting each server update task to the thread pool using executor.submit; monitoring task completion using concurrent.futures.as_completed and processing results in the order of completion; and updating the progress bar and log information by calling self.progress_callback after each task is completed. In the `self.dynamic_concurrency_control` method, the thread periodically monitors the current network utilization and dynamically adjusts the concurrency based on the network load. If network utilization is too high (e.g., exceeding 800Mbps), the concurrency is reduced; if network utilization is low (e.g., below 500Mbps), the concurrency is increased. Finally, the `self.generate_report` method is called to generate an update report, save the update results to an Excel file, and return information such as the report path and success rate.

[0274] The following is a sample code:

[0275] def start(self):

[0276] "Start Batch Update"

[0277] self.running = True # Mark update process has started

[0278] # Start the dynamic concurrency control thread

[0279] control_thread= threading.Thread(target=self.dynamic_concurrency_control, daemon=True)

[0280] control_thread.start() # Start the thread

[0281] # Use a thread pool to execute update tasks concurrently

[0282] with concurrent.futures.ThreadPoolExecutor(max_workers=self.max_concurrent) as executor:

[0283] futures = {

[0284] executor.submit(self.update_server, server): server

[0285] for server in self.servers

[0286] }

[0287] for i, future in enumerate(concurrent.futures.as_completed(futures)):

[0288] result = future.result()

[0289] self.results.append(result)

[0290] # Update Progress

[0291] if self.progress_callback:

[0292] self.progress_callback(i+1, len(self.servers))

[0293] self.running = False # Mark the end of the update process

[0294] control_thread.join() # Wait for the dynamic concurrent control thread to finish.

[0295] self.generate_report() # Generate update report

[0296] Furthermore, refer to Figure 1 Figure 1 Step S500 includes the following steps:

[0297] S510. In the host computer, use the ResultWindow class and tk.Label to display the statistical information of the update results, including the number of successes and the success rate.

[0298] S520: Use ttk.Treeview to create a table that displays the IP address and update status of each server, set the column width and header, add scrollbars to support the display of large amounts of data, populate the table with data, and display the status of failed servers in red;

[0299] S530 allows users to export update results to an Excel file, using pandas.DataFrame.to_excel to save the results to a specified path and displaying a prompt to inform the user.

[0300] Specifically, display update result statistics: Show update result statistics in the UI, including the number of successes and the success rate. In the ResultWindow class, use tk.Label to display update result statistics, including the number of successes and the success rate.

[0301] Provide a detailed results table: Display a detailed update results table in the UI, including the IP address and update status of each server. Use ttk.Treeview to create a table showing the IP address and update status of each server. Set column widths and headers, and add scrollbars to support the display of large amounts of data. Populate the table with data, and display the status of failed servers in red.

[0302] Generate Excel report file: Save the update results as an Excel file for easy viewing and analysis later. Support result filtering and export: Allow users to filter and export the update results. Provide a button to allow users to export the update results to an Excel file. Use pandas.DataFrame.to_excel to save the results to the specified path and display a prompt box to inform the user that the report has been saved.

[0303] The following is a sample code:

[0304] class ResultWindow(tk.Toplevel):

[0305] def __init__(self, parent, results):

[0306] super().__init__(parent)

[0307] self.title("Update Results Report")

[0308] # Statistics

[0309] success = sum(1 for r in results if r['status'] =='success')

[0310] total = len(results)

[0311] tk.Label(self, text=f"Update Complete! Success: {success} / {total}({success / total:.1%})",

[0312] font=('Arial', 12, 'bold')).pack(pady=10)

[0313] # Results Table

[0314] columns = ("IP Address", "Status")

[0315] self.tree = ttk.Treeview(self, columns=columns, show="headings", height=15)

[0316] # Set column width and headings

[0317] self.tree.column("IP Address", width=150, anchor='center')

[0318] self.tree.column("Status", width=300, anchor='center')

[0319] for col in columns:

[0320] self.tree.heading(col, text=col)

[0321] # Add scrollbar

[0322] scrollbar = ttk.Scrollbar(self, orient="vertical", command=self.tree.yview)

[0323] self.tree.configure(yscrollcommand=scrollbar.set)

[0324] scrollbar.pack(side="right", fill="y")

[0325] self.tree.pack(fill="both", expand=True)

[0326] # Fill data

[0327] for result in results:

[0328] status = result['status']

[0329] if 'failed' in status:

[0330] self.tree.insert("", "end", values=(result['ip'],status), tags=('failed',))

[0331] else:

[0332] self.tree.insert("", "end", values=(result['ip'],status))

[0333] # Set the color of failed rows

[0334] self.tree.tag_configure('failed', foreground='red')

[0335] # Export button

[0336] tk.Button(self, text="Export Report", command=lambda: self.export_report(results)).pack(pady=10)

[0337] def export_report(self, results):

[0338] Export detailed report

[0339] path = filedialog.asksaveasfilename(

[0340] defaultextension=".xlsx",

[0341] filetypes=[("Excel file", "*.xlsx")] )

[0343] if path:

[0344] df = pd.DataFrame(results)

[0345] df.to_excel(path, index=False)

[0346] tk.messagebox.showinfo("Export successful", f"Report saved to:\n{path}")

[0347] Furthermore, the present invention also proposes a server firmware update apparatus for integrating static resource services, used to execute the server firmware update method for integrating static resource services, the server firmware update apparatus for integrating static resource services comprising:

[0348] Host computer;

[0349] The host computer is electrically connected to the server via a network, and the number of servers is at least one.

[0350] In summary, these are merely preferred embodiments of the present invention. The present invention is not limited to the above-described embodiments. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this disclosure, as long as they achieve the technical effects of the present invention by the same means, should be included within the scope of protection of this disclosure.

Claims

1. A method for updating server firmware integrating static resource services, applied to a server firmware update device integrating static resource services, the server firmware update device integrating static resource services comprising a host computer and a server, the host computer and the server being electrically connected via a network, and the number of servers being at least one, characterized in that, The server firmware update method for integrating static resource services includes the following steps: S100: The host computer obtains at least one server information to be updated, the server information including at least the server's IP address, username, and password; S200: Starts a lightweight HTTP service for providing firmware file download services, supports multi-threaded concurrent downloads, and automatically handles URL encoding and file transfer tasks; S300: The user selects a firmware file, calculates the MD5 checksum of the firmware file, copies the firmware file to the preset static file server directory, generates an accessible URL for the firmware file, and stores it in self.firmware_url. S400: Dynamically monitor system resources and network utilization, and concurrently execute server update tasks through a thread pool; Step S400 includes the following steps: S410: Dynamically calculate and adjust the number of concurrent connections based on the minimum value among the preset concurrency limit, CPU core limit, memory limit, and network bandwidth limit; S420: Execute server update tasks concurrently using the thread pool `concurrent.futures.ThreadPoolExecutor`. S430: Execute an update task for a single server to be updated; Step S430 includes the following steps: S431. Download the firmware file image using requests.get based on the address specified by self.firmware_url; S432. During the download process, calculate the MD5 hash value of the file block by block and compare it with the expected MD5 value to ensure that the firmware has not been tampered with or damaged. S433. Use requests.post to send an update request to the server, and use ImageURI to specify the accessible URL of the firmware file; S434. Use HTTPBasicAuth to provide a username and password for authentication; S435. Set the request timeout period. If an exception occurs, capture the exception and record the reason for the failure. S440: Update the progress bar and log information in real time via callback functions; S500 updates information via feedback from the host computer.

2. The server firmware update method for integrating static resource services according to claim 1, characterized in that, Step S100 includes the following steps: S110. Use the filedialog.askopenfilename function to pop up a file selection dialog box, allowing the user to select an Excel file. If the user cancels the selection, return an empty message None, log the information, and exit the filedialog.askopenfilename function. S120. Use pandas.read_excel to read the contents of the Excel file, check if the server information is complete, and return the error message ValueError if the server information is incomplete. S130. Store the parsed server information in dictionary format, record logs, and display the number of loaded servers and server information.

3. The server firmware update method for integrating static resource services according to claim 1, characterized in that, Step S200 includes the following steps: S210. Create a directory static_firmware in the current working directory to store firmware files; S220. Use the hug framework to create a simple HTTP server, add CORS middleware, and allow cross-domain access; S230. Define a static file request handling function `serve_static` that returns the file content based on the requested file name. If the file does not exist, return a 404 error message; if an exception occurs, return a 500 error message. S240. To avoid blocking the main thread, start the HTTP server in a background thread using hug.API.http.server. S250: Copy the firmware file to the static file directory and generate the accessible URL of the firmware file.

4. The server firmware update method for integrating static resource services according to claim 1, characterized in that, Step S300 includes the following steps: S310. Use the filedialog.askopenfilename function to pop up a file selection dialog box, allowing the user to select a firmware file. If the user cancels the selection, return an empty message None, log the information, and exit the filedialog.askopenfilename function. S320 uses hashlib.md5 to calculate the MD5 checksum of the firmware file to ensure the integrity of the firmware file; S330 calls self.file_server.add_firmware to copy the firmware file to the static file server directory, generates an accessible URL for the firmware file, and stores it in self.firmware_url.

5. The server firmware update method for integrating static resource services according to claim 1, characterized in that, Step S420 includes the following steps: S421. Create a control_thread with the target function self.dynamic_concurrency_control, set it as a daemon thread to ensure that the thread will automatically terminate when the main thread terminates, and call control_thread.start to start the thread. S422. Create a thread pool using concurrent.futures.ThreadPoolExecutor, with a maximum number of worker threads of self.max_concurrent. Submit each server's update task to the thread pool using executor.submit. Use concurrent.futures.as_completed to monitor task completion status and process results in the order of completion. After each task is completed, call self.progress_callback to update the progress bar and log information. S423. In the self.dynamic_concurrency_control method, the thread periodically monitors the current network utilization and dynamically adjusts the number of concurrent connections based on the network load. If the network utilization is too high, the number of concurrent connections is reduced; if the network utilization is low, the number of concurrent connections is increased. S424. Call the self.generate_report method to generate an update report, save the update results to an Excel file, and return the report path and success rate information.

6. The server firmware update method for integrating static resource services according to claim 1, characterized in that, Step S500 includes the following steps: S510. In the host computer, use the ResultWindow class and tk.Label to display the statistical information of the update results, including the number of successes and the success rate. S520: Use ttk.Treeview to create a table that displays the IP address and update status of each server, set the column width and header, add scrollbars to support the display of large amounts of data, populate the table with data, and display the status of failed servers in red; S530 allows users to export update results to an Excel file, using pandas.DataFrame.to_excel to save the results to a specified path and displaying a prompt to inform the user.

7. A server firmware update apparatus for integrating static resource services, used to execute the server firmware update method for integrating static resource services as described in any one of claims 1 to 6, characterized in that, The server firmware update device for integrating static resource services includes: Host computer; The host computer is electrically connected to the server via a network, and the number of servers is at least one.

8. A computer-readable storage medium, characterized in that, It stores program instructions that, when executed by a processor, implement the server firmware update method for integrated static resource services as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Firmware upgrade method and device

    CN109214168A

  • Launch multiple devices firmware update operation from another application with device list context

    US20180359144A1