Mirror image file processing method and device, electronic equipment and storage medium

By obtaining and combining configuration information and general configuration information for different operating systems, the mirror file is automatically configured, which solves the problems of low efficiency and error-prone configuration of mirror file parameters in the prior art, and achieves efficient and accurate mirror file configuration.

CN119829074APending Publication Date: 2025-04-15CHINA TELECOM CLOUD TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411744404.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-30
Publication Date
2025-04-15

AI Technical Summary

Technical Problem

In the prior art, the parameter configuration of mirror files is inefficient and is prone to missed or errors in parameter configuration.

Method used

By obtaining the pre-generated first file and the second file, the configuration information and general configuration information for different operating systems are stored respectively, the configuration information of the target operating system is automatically obtained, and combined with the general configuration information to be configured into the mirror file to be configured.

Benefits of technology

Automatic configuration of mirror files is realized, configuration efficiency is improved, and the possibility of missed or errors in parameter configurations is reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119829074A_ABST
    Figure CN119829074A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a mirror image file processing method and device, electronic equipment and a storage medium, and the method comprises the steps: obtaining a pre-generated first file which stores first configuration information set for at least one operating system, obtaining a pre-generated second file which stores first configuration information set for at least one operating system, the second file stores universal second configuration information suitable for at least one operating system. The method comprises the steps of obtaining a target operating system of a to-be-configured mirror image file, then obtaining target first configuration information corresponding to the target operating system from a first file, obtaining second configuration information from a second file, and configuring the target first configuration information and the second configuration information to the to-be-configured mirror image file to obtain a configured mirror image file, the automatic configuration of the mirror image file is realized, and the generation efficiency of the mirror image file is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer network technology, and in particular relates to a method, apparatus, electronic device and storage medium for processing image files. Background Technology

[0002] A cloud server is a service based on cloud computing technology that allows applications to be deployed on a cloud server based on a pre-made image file.

[0003] In related technologies, image file parameters are configured manually. However, the configuration parameters for image files differ across operating systems. Methods based on these technologies require manual configuration of image files for each operating system, leading to low efficiency and a high risk of omissions or errors in parameter configuration. Summary of the Invention

[0004] This invention provides a method, apparatus, electronic device, and storage medium for processing image files, in order to solve the technical problems of low efficiency in configuring image file parameters and the tendency for parameter configuration to be omitted or incorrect in related technologies.

[0005] In a first aspect, the present invention provides a method for processing image files, the method comprising:

[0006] Obtain a pre-generated first file; the first file stores first configuration information, which is configuration information set separately for each operating system in at least one operating system;

[0007] Obtain a pre-generated second file, which stores second configuration information; the second configuration information is general configuration information applicable to at least one operating system.

[0008] Obtain the target operating system of the image file to be configured, and obtain the target first configuration information corresponding to the target operating system from the first file;

[0009] The second configuration information is obtained from the second file, and the target first configuration information and the second configuration information are configured to the image file to be configured, so as to obtain the configured image file.

[0010] Optionally, from the first file, obtain the target first configuration information corresponding to the target operating system, including:

[0011] The target first configuration information corresponding to the target operating system is obtained from the first file through the information call command of the Shell script;

[0012] The target first configuration information and the second configuration information are configured to the image file to be configured to obtain the configured image file, including:

[0013] The target first configuration information and the second configuration information are configured to the image file to be configured through the information configuration instructions in the Shell script, and the configured image file is obtained.

[0014] Optionally, the method further includes:

[0015] Obtain first configuration information adapted to each of at least one operating system;

[0016] Based on the first configuration information, generate the first file in YAML format.

[0017] Optionally, the method further includes:

[0018] Obtain second configuration information applicable to at least one operating system;

[0019] Based on the second configuration information, a second file in Shell script format is generated.

[0020] Optionally, after obtaining the configured image file, the method further includes:

[0021] Install the configured image file and obtain the actual status information of the configured image file;

[0022] Based on the actual status information, determine the validity of the configured image file.

[0023] Optionally, determining the validity of the configured image file based on the actual status information includes:

[0024] Retrieve preset status information for the configured image file;

[0025] If the actual status information is the same as the preset status information, then the configured image file is determined to be valid.

[0026] Optionally, the actual status information includes the actual configuration information of the image file, and the preset status information is the target first configuration information; after obtaining the preset status information for the configured image file, it further includes:

[0027] If the actual status information and the preset status information are different, the configured image file is determined to be invalid.

[0028] Re-obtain the target first configuration information configuration corresponding to the target operating system from the first file;

[0029] Using the target first configuration information, the configured file is reconfigured to obtain a reconfigured image file.

[0030] In a second aspect, the present invention provides an image file processing apparatus, the apparatus comprising:

[0031] The first acquisition module is used to acquire a pre-generated first file; the first file stores first configuration information; the first configuration information is configuration information set for at least one operating system.

[0032] The second acquisition module is used to acquire a pre-generated second file, which stores second configuration information; the second configuration information is general configuration information applicable to at least one operating system.

[0033] The third acquisition module is used to acquire the target operating system of the image file to be configured, and to acquire the target first configuration information corresponding to the target operating system from the first file;

[0034] The configuration module is used to obtain second configuration information from the second file, and configure the target first configuration information and the second configuration information to the image file to be configured, so as to obtain the configured image file.

[0035] Thirdly, the present invention provides an electronic device, comprising:

[0036] A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, implements the method as described in the first aspect.

[0037] Fourthly, the present invention provides a readable storage medium that, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to perform the method described in the first aspect.

[0038] In this embodiment of the invention, a pre-generated first file is obtained, storing first configuration information. A pre-generated second file is also obtained, storing second configuration information. The target operating system of the image file to be configured is obtained. Based on the target operating system, target first configuration information corresponding to the target operating system is obtained from the first file, and second configuration information is obtained from the second file. Then, the target first configuration information and the second configuration information are configured onto the image file to be configured, resulting in a configured image file. Based on the first and second files, automatic configuration of the image file can be achieved. First configuration information set for each operating system and general second configuration information applicable to at least one operating system are stored in the first and second files respectively. If the configuration information for a particular operating system needs to be modified, only the first file needs to be modified. This improves the efficiency of setting configuration information applicable to the operating system of the image file, thereby further improving the configuration efficiency of the image file. Attached Figure Description

[0039] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0040] Figure 1 This is a flowchart of the steps of an image file processing method provided in an embodiment of the present invention;

[0041] Figure 2 This is a flowchart of another image file processing method provided in an embodiment of the present invention;

[0042] Figure 3 This is a flowchart of a mirror validity detection method provided by an embodiment of the present invention;

[0043] Figure 4 This is a flowchart of the steps of an image file processing method provided by an embodiment of the present invention;

[0044] Figure 5 This is a structural diagram of an image file processing device provided in an embodiment of the present invention;

[0045] Figure 6 This is a structural diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0046] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0047] Figure 1 This is a flowchart of the steps of an image file processing method provided in an embodiment of the present invention, as follows: Figure 1 As shown, the method may include:

[0048] Step 101: Obtain the pre-generated first file.

[0049] For example, the first file stores first configuration information. This first configuration information is configured for at least one operating system.

[0050] For example, the first file can be a YAML file.

[0051] For example, the method of this embodiment can be applied to the field of cloud computing technology, such as cloud servers. A cloud server is a computing resource rental service provided by a cloud service provider based on cloud computing technology. The computing resources provided by a cloud server can be rented, expanded, or reduced at any time without the need to purchase or maintain physical servers or other hardware.

[0052] In the application of cloud computing technology, image files on cloud servers enable the rapid deployment of required applications. Therefore, image files on cloud servers are crucial. It should be noted that an image file is a packaged file that includes elements such as the operating system, pre-installed software, configuration information, and runtime data.

[0053] Image files can contain elements such as operating systems, pre-installed software, and configuration information. When users need to deploy applications on cloud servers, they only need to create a new cloud server based on the image file created for the application, without needing to reinstall and configure the operating system. Using image files saves time in deploying and configuring new hosts and reduces security issues associated with new hosts. In other words, image files can be used to quickly create new cloud servers without reinstalling and configuring the operating system and software. Therefore, the installation and deployment of image files is crucial in the cloud computing field. However, the process of creating an image file requires parameter configuration.

[0054] Cloud computing services can provide users with different operating systems. These operating systems can include the CentOS series, such as CentOS 6, CentOS 7, and CentOS 8. They can also include Ubuntu, such as Ubuntu 16 and Ubuntu 18; and CTYLE OS, such as CTYLE OS 2 and CTYLE OS 3. Furthermore, they can include Kylin, such as Kylin v10 SP1 and Kylin v10 SP2. Other operating systems include Linux distributions such as Hygon, UnionTech OS (UOS), and Debian, as well as operating systems like Windows and macOS.

[0055] The parameter configurations during image creation differ depending on the operating system. These differences include the storage path of service configuration files, software versions, and so on. For example, the initial configuration information may include the storage path of configuration files and the software version. Furthermore, the initial configuration information may also include the configuration mode of the Internet Protocol (IP) address, which can be either dynamic or static.

[0056] Step 102: Obtain the pre-generated second file, which stores the configuration information of the second mirror.

[0057] The second configuration information is general configuration information applicable to at least one operating system. In other words, the second configuration information is applicable to different operating systems. For example, the second file is a shell script.

[0058] Step 103: Obtain the target operating system of the image file to be configured, and obtain the target first configuration information corresponding to the target operating system from the first file.

[0059] The target operating system is the operating system that the user needs to install from the image file. The target operating system can be set according to the user's needs. For example, the target operating system can be CentOS, Ubuntu 1, Debian, etc.

[0060] Specifically, the first file stores at least one operating system and corresponding first configuration information for each operating system. For example, a shell script can retrieve the operating system (the same as the target operating system) from the first file, use the corresponding first configuration information for that operating system, and then determine the target first configuration information for that operating system.

[0061] Step 104: Obtain the second configuration information from the second file, and configure the target first configuration information and the second configuration information to the image file to be configured, so as to obtain the configured image file.

[0062] The second configuration information is configuration information that is compatible with at least one operating system. For example, the second configuration information can be read directly from the second file using a shell script.

[0063] After obtaining the target's first and second configuration information through a Shell script, the Shell script then configures the target's first and second configuration information onto the image file to be configured, resulting in a configured image file.

[0064] For example, the first file is a YAML file, and the second file is a Shell script file. The Shell script file also includes instructions for retrieving target first configuration information and instructions for retrieving second configuration information. Based on the instructions in the Shell script for retrieving the target first configuration information, the target first configuration information is read from the YAML file; based on the instructions in the Shell script for retrieving the second configuration information, the second configuration information is retrieved from the Shell script. Then, using the instructions in the Shell script for configuring the configuration information to the image file to be configured, the target first and second configuration information are configured to the image file to be configured, resulting in a configured image file.

[0065] The creation of an image file involves not only installing the software required by the user and tools to improve system security, but also configuring various system software and service parameters. This includes configuring the GRandUnified Bootloader (GRUB), the primary network interface card (NIC), and elastic NICs. GRUB is the operating system bootloader; an elastic NIC is an elastic network interface bound to a cloud server within a Virtual Private Cloud (VPC), and can be freely migrated between multiple cloud servers; and NIC multi-queues are multiple independent network interface queues supported by the instance specification.

[0066] In related technologies, the configuration of elastic network interfaces (NICs) in image files requires manual intervention; that is, NIC information needs to be manually configured. However, different operating systems have different NIC parameter configurations. Therefore, for different operating systems, image files for different operating systems need to be configured manually. Furthermore, methods based on these technologies also require the creation of routing tables and the configuration of routing rules. Specifically, when configuring elastic NICs, various NIC information parameters are first manually configured. For example, for Linux operating systems, NIC information parameters may include parameters specifying the protocol used by the network interface at startup (BOOTPROTO), parameters specifying the network interface name (DEVICE), and parameters controlling whether non-root users are allowed to control the network device (USERCTL), etc. These parameters need to be configured manually. After manually configuring the parameters, two routing tables are created, and default routes are configured for both tables. Finally, routing policy rules are configured. This complex configuration method requiring manual parameter configuration increases the time cost of the image file creation process.

[0067] In this embodiment, a pre-generated first file containing first configuration information is obtained, and a pre-generated second file containing second configuration information is also obtained. The target operating system of the image file to be configured is then acquired. Based on the target operating system, target first configuration information corresponding to the target operating system is obtained from the first file, and second configuration information is obtained from the second file. The target first and second configuration information are then configured onto the image file to be configured, resulting in a configured image file. Based on the first and second files, automatic configuration of the image file can be achieved. First configuration information set for each operating system and general second configuration information applicable to at least one operating system are stored in the first and second files respectively. Therefore, if the configuration information for a specific operating system needs to be modified, only the first file needs to be modified. This improves the efficiency of setting configuration information applicable to the operating system of the image file, thereby improving the configuration efficiency of the image file.

[0068] Reference Figure 2 The image file processing method provided in this embodiment may include the following steps:

[0069] Step 201: Obtain first configuration information adapted to each operating system in at least one operating system.

[0070] For example, the operating system may include CentOS, Ubuntu, etc. The initial configuration information of the operating system may include the configuration information of GRUB, the primary network interface card (NIC), and the elastic NIC.

[0071] For example, the first configuration information corresponding to the operating system can be obtained based on the operating system's configuration requirements.

[0072] Step 202: Generate a first file in YAML format based on the first configuration information.

[0073] For example, the first configuration information is written to a YAML format file, resulting in a first YAML format file. This first file stores the first configuration information, which is configuration information set specifically for at least one operating system.

[0074] Step 203: Obtain the target operating system of the image file to be configured, and obtain the target first configuration information corresponding to the target operating system from the first file through the information call command of the Shell script.

[0075] The configuration information is invoked through the shell script to obtain the first configuration information corresponding to the target operating system from the first file in YAML format.

[0076] Step 204: Obtain second configuration information applicable to at least one operating system.

[0077] For example, based on the requirements of the application to be deployed via the image file and / or the configuration requirements of the operating system, second configuration information applicable to at least one operating system is obtained.

[0078] Step 205: Generate a second file in Shell script format based on the second configuration information.

[0079] For example, generic second configuration information applicable to at least one operating system is compiled into a second file in shell script format. The resulting second file stores the second mirror configuration information. This second configuration information is generic configuration information applicable to settings of at least one operating system.

[0080] Step 206: Obtain the second configuration information from the second file.

[0081] For example, the second configuration information is retrieved from a second file using a command in a shell script to retrieve the second configuration information.

[0082] Step 207: Using the information configuration instructions in the Shell script, configure the target first configuration information and second configuration information to the image file to be configured, and obtain the configured image file.

[0083] By using the information configuration commands in the Shell script, the target first configuration information and second configuration information are taken as input parameters and configured into the corresponding parameters in the image file to be configured, thus obtaining the configured image file.

[0084] Step 208: Install the configured image file and obtain the actual status information of the configured image file.

[0085] For example, the actual status information may include the configuration information actually configured for the image file, whether the service corresponding to the image file is enabled, whether the software to be installed is installed, and other information related to the image file.

[0086] Step 209: Determine the validity of the configured image file based on the actual status information.

[0087] For example, the validity of the image file is determined by comparing the actual status information with the preset expected status information. Further, if the actual status information and the expected status information are the same, the image file is determined to be valid; if the actual status information and the expected status information are different, the image file is determined to be invalid.

[0088] For example, by using an image file detection tool in conjunction with steps 208 and 209 of this embodiment, the validity of the image is automatically detected. After the image creation requirement is met, the method of this embodiment ensures the legality of the created image file and guarantees that the image file meets the stability and validity requirements of the cloud server. The image validity detection tool, which can execute the method of this embodiment, can detect whether all relevant configurations of the image file are correct.

[0089] The configuration information checks include whether software such as Cloudinit, QEMU Guest Agent, Network File System (NFS), and security software are installed; whether services such as NetworkManager and Secure Shell Daemon (SSHD) are automatically started; whether parameters such as the primary network interface card (NIC), elastic NIC, and NIC multi-queue are configured correctly; and whether the firewall (firewalld) and Security-Enhanced Linux (SElinux) are disabled. NFS is a protocol for sharing file systems over a network, allowing different computer systems to share files and directories, enabling remote computers to access remote files as if they were local files. Cloudinit is a tool specifically developed for initializing virtual machines in cloud environments, used to read relevant data from various data sources and customize the virtual machine's configuration during startup. The QEMU Guest Agent (QGA) is a daemon running inside the virtual machine, used to manage applications and execute commands issued by the host machine. NetworkManager is a backend service, a tool for controlling the graphical interface of network interfaces on the operating system. SSHD is a service that uses the SSH protocol to remotely control computers or transfer files between them.

[0090] Furthermore, after obtaining the actual status information of the image file, if the actual status information is inconsistent with the preset status information, it indicates that the actual status information is incorrect. This incorrect actual status information can be stored in a log file for subsequent problem analysis. The incorrect actual status information can also be displayed to operations and maintenance personnel through the console for timely error handling. Specifically, error information detected by an image validity detection tool can be saved in a log file, and incorrect or missing configuration information can be output to the console.

[0091] For example, based on the first configuration information corresponding to different operating systems and the general configuration information applicable to multiple operating systems, the resilient network interface card (NIC) and NIC multi-queue are automatically configured. The method for automatically configuring image files based on the first and second files in this embodiment is compatible with different operating systems. A validity detection tool that implements the method of this embodiment can be used to detect the validity of the configured image file; this validity detection tool is also compatible with different operating systems.

[0092] Furthermore, in cloud computing service applications, to ensure a safe and stable cloud server resource for user experience, verifying the legality of image creation is a necessary process. However, manual verification methods in related technologies not only suffer from high time consumption and missed configuration item checks, but may also lead to configuration errors due to modifications made to existing configurations during the verification process. For example, based on the method of this embodiment, image file configuration can be implemented using shell scripts, and an image file validity verification tool developed in Python can be used to automatically verify the validity of the image file. Based on this, automated configuration of elastic network interfaces and network interface multi-queues can be achieved during image creation, and automatic verification of image file validity can be implemented after image file creation is complete. By automatically configuring and verifying image files, the time costs for image file configuration and validity verification can be effectively saved, and errors caused by manual operation can be avoided.

[0093] For example, configuring an image file can include configuring the operating system, specifically including configuring network interface card (NIC) multi-queues and elastic NICs. Furthermore, based on the method of this embodiment, when configuring NIC multi-queues, an automated configuration script can automatically complete the NIC multi-queue configuration according to the NIC device's configuration information. Furthermore, the first file in this embodiment includes configuration information for at least one operating system, and the second file includes general configuration information adapted to at least one operating system. Based on the method of this embodiment, it can be compatible with the configuration requirements of image files for different operating systems. For example, the method of this embodiment can be compatible with different Linux distributions, achieving unified automated configuration. Through the automated script of this embodiment, automatic elastic NIC configuration can be achieved, avoiding the problems of time-consuming and error-prone manual configuration, while also being compatible with different Linux distributions.

[0094] For example, step 209, which determines the validity of the configured image file based on the actual status information, may include the following sub-steps:

[0095] Sub-step 2091: Obtain the preset status information for the image file.

[0096] For example, the preset status information can be set according to the services, application environment, and other information that the image file to be configured is to implement.

[0097] Sub-step 2092: If the actual status information is the same as the preset status information, then the image file is determined to be valid.

[0098] Actual status information includes the actual configuration information of the image file, while preset status information includes the target's primary configuration information.

[0099] The image file is valid, meaning that the actual configuration information of the image file is the same as the target's primary configuration information, and the installation status of the image file is the same as the default installation status.

[0100] For example, checking the validity of an image file includes whether a virtual machine is installed. The installation status of the virtual machine can be determined based on the `installed` field, which indicates whether the virtual machine is installed. For example, a value of `installed` equal to `True` indicates that the virtual machine is installed. The default status information is that a value of `installed` equals `True`, meaning the default status information is that the virtual machine is installed. In this embodiment, if the detection result for the actual status information of whether the virtual machine is installed is `True`, and the default status information `installed` is `True`, then the actual status information and the default status information are the same, and the image file is determined to be valid. For example, the default status information includes whether the virtual machine is installed; if the value of `installed` is `True`, it means that the actual status information for this item is the same as the default status information. If each actual status information is the same as its corresponding default status information, then the image file is determined to be valid.

[0101] Sub-step 2093: If the actual configuration information is different from the preset configuration information, then the image file is determined to be invalid.

[0102] For example, if the actual configuration information is that the IP address is configured dynamically, while the default configuration information is that the IP address is configured statically, then the actual configuration information and the default configuration information are different, and the image file is determined to be invalid.

[0103] For example, if any actual configuration information differs from its corresponding preset configuration information, the image file is determined to be invalid.

[0104] Sub-step 2094: Re-obtain the target first configuration information configuration corresponding to the target operating system from the first file.

[0105] If the actual configuration information is different from the preset configuration information, it means that an error occurred when configuring the parameters of the image file to be configured. The incorrect configuration information of the image file can be corrected by reconfiguring the target first configuration information corresponding to the target operating system from the first file.

[0106] Sub-step 2095: Use the target first configuration information to reconfigure the configuration file to obtain a reconfigured image file.

[0107] For example, the preset status information also includes second configuration information. If the preset status information corresponding to the actual status information is the target first configuration information, then the target first configuration information is used to reconfigure the configuration file to be configured; if the preset information corresponding to the actual status information is the second configuration information, then the second configuration information is used to reconfigure the configuration file to be configured.

[0108] In related technologies, image files are configured manually, and their validity is checked manually. However, this method is time-consuming and prone to errors during image creation and verification. It is not only time-consuming but also susceptible to errors during creation and verification, leading to system errors in the cloud server system and increasing maintenance costs. This embodiment uses shell scripts to automate the configuration of elastic network interfaces and network interface multi-queues in the image file, reducing the amount of parameter configuration processing. Furthermore, an image validity detection tool developed in Python can be used to check the validity of the image file, automatically checking all configurations after image creation to ensure the legality and validity of the image file. For example, incorrect configuration information can be saved to a log file or output to the console, providing this information to the verification personnel.

[0109] In one embodiment, refer to Figure 3 The detection items for image files include cloudintit, qemu guestagnet, elastic network interface, GRUB, Network interface, and may also include network interface multi-queue, primary network interface, etc.

[0110] The compatible operating systems include Ctyunos, Ubuntu, Kylin, Centos, and Uos.

[0111] Furthermore, the actual status information of the installed image file can be obtained through modules such as os and Subprocess in the Python standard library, and the validity of the image file can be determined based on the actual status information.

[0112] The following reference Figure 4 The image file validity detection method of this application embodiment will be further illustrated by an example. Referring to the figures, the image file validity detection method may include the following steps:

[0113] Step S1: Install the image inspection tool in a virtual machine, and use the Python standard library OS and subprocess modules to obtain the actual status information of the image file and store the actual status information in a YAML format file.

[0114] For example, before step S1, the method further includes: obtaining the configuration information of the image file to be configured from the YAML file and the shell script file using a shell script; configuring the configuration information to the image file to be configured using the shell script; and thus obtaining the configured image file. Therefore, the configuration of the image file is completed through an automatic configuration method.

[0115] After obtaining the configured image file, install the configured image file, and then use the method in this embodiment to perform a validity check on the installed image file.

[0116] For example, the status information of an image file in a virtual machine can be detected using the `OS` and `subprocess` modules in the Python standard library. This detected status information can include metadata such as whether the software configuration file is being read, whether the software starts automatically on boot, whether services are running, and whether the software is installed. After obtaining this metadata, it can be stored in a YAML file.

[0117] Step S2: Obtain a YAML file to determine whether the actual status information matches expectations.

[0118] By obtaining the YAML format file, we determine whether the detection items in the image file meet expectations. Furthermore, based on the key fields corresponding to the actual status information, we retrieve the actual status information from the YAML format file.

[0119] For example, for image file detection items including checking cloudinit, the installed field can be used to obtain the virtual machine's installation status information. Specifically, the value of installed is checked to see if it equals True. If the value of installed equals True, it is determined that the virtual machine is installed, indicating that the actual status information meets expectations; otherwise, it is determined that the virtual machine is not installed, and the actual status information does not meet expectations. As another example, the enabled field can be obtained, where the enabled field indicates whether cloudinit starts automatically on boot. If the value of enabled equals True, it is determined that cloudinit has started automatically on boot, and the actual status information meets expectations; otherwise, it is determined that cloudinit has not started automatically on boot, and the actual status information does not meet expectations.

[0120] Step S3: Write any unexpected information to the log file.

[0121] After analyzing and detecting the actual status information, the analysis results are written to a log file. Alternatively, the analysis information can also be output to the console.

[0122] Step S4: Automatically repair the configuration information of the image file through the log file.

[0123] The obtained log files can be used to automatically repair the configuration information of the image file, thereby ensuring that the image is created correctly and guaranteeing its validity.

[0124] For example, the actual status information detected includes network items. When detecting network items, different Linux distributions have different requirements for the image network; therefore, configuration needs to be tailored to the operating system type. For example, the detection tool provides a network detection interface to ensure compatibility with different operating systems. Systems compatible with the image detection tool include CentOS, Ubuntu, Kylin, and Debian. Furthermore, since different operating system versions of the image file may have different Python versions installed (Python 2 or Python 3), in this embodiment, the image detection tool can also solve the Python interpreter compatibility problem to ensure it can run in various Python environments. After the image is created, the image detection tool can perform image validity checks. Based on the analysis results, the image file can be reconfigured according to the configuration information in the configuration file to automatically modify the configuration information of invalid image files, thereby ensuring the integrity and correctness of the image creation.

[0125] This embodiment automates the configuration and validity testing of image files. Specifically, a Python-based image file validity testing tool is used to perform validity checks, overcoming the time-consuming and prone-to-miss issues of manual image validity testing in related technologies. Furthermore, after validity testing, a detection analysis report is generated based on the results. This report allows for the automated correction of errors during the image creation process, avoiding the hassle of manual repair. This embodiment also automates the configuration of image files, resolving the high time overhead associated with manually configuring elastic network interfaces and multi-queue network interfaces in related technologies, simplifying the image creation process and reducing its cost.

[0126] Figure 5 This is a structural diagram of an image file processing device provided in an embodiment of the present invention. The device 30 may include:

[0127] The first acquisition module 301 is used to acquire a pre-generated first file; the first file stores first configuration information, which is configuration information set separately for each operating system in at least one operating system.

[0128] The second acquisition module 302 is used to acquire a pre-generated second file, which stores second configuration information; the second configuration information is general configuration information applicable to at least one operating system.

[0129] The third acquisition module 303 is used to acquire the target operating system of the image file to be configured, and to acquire the target first configuration information corresponding to the target operating system from the first file;

[0130] Configuration module 304 is used to obtain second configuration information from the second file, and configure the target first configuration information and second configuration information to the image file to be configured, so as to obtain the configured image file.

[0131] Optionally, the third acquisition module 303 may include:

[0132] The first acquisition submodule is used to retrieve the target first configuration information corresponding to the target operating system from the first file through information invocation instructions from the Shell script;

[0133] Configuration module 304 may include:

[0134] The first configuration submodule is used to configure the target first configuration information and second configuration information to the image file to be configured through the information configuration instructions in the Shell script, so as to obtain the configured image file.

[0135] Optionally, device 30 may include:

[0136] The fourth acquisition module is used to acquire first configuration information adapted to each operating system in at least one operating system.

[0137] The first generation module is used to generate a first file in YAML format based on the first configuration information;

[0138] The fifth acquisition module is used to acquire second configuration information applicable to at least one operating system;

[0139] The second generation module is used to generate a second file in Shell script format based on the second configuration information.

[0140] Optionally, device 30 also includes:

[0141] The sixth acquisition module is used to install the configured image file after obtaining the configured image file, and to obtain the actual status information of the configured image file.

[0142] The first determination module is used to determine the validity of the configured image file based on the actual status information.

[0143] Optionally, the first determining module may include:

[0144] The second acquisition submodule is used to acquire preset status information for the configured image file;

[0145] The first determination submodule is used to determine that the configured image file is valid if the actual status information is the same as the preset status information.

[0146] Optionally, the actual status information includes the actual configuration information of the image file, and the preset status information includes the target's first configuration information; the first determination module may include:

[0147] The second determination submodule is used to determine that the configured image file is invalid if the actual status information is different from the preset status information.

[0148] The third acquisition submodule is used to re-acquire the target first configuration information configuration corresponding to the target operating system from the first file;

[0149] The fourth submodule is used to reconfigure the already configured file using the target's first configuration information, and obtain a reconfigured image file.

[0150] In summary, the process involves obtaining a pre-generated first file containing first configuration information, obtaining a pre-generated second file containing second configuration information, obtaining the target operating system of the image file to be configured, retrieving the target first configuration information corresponding to the target operating system from the first file, retrieving the second configuration information from the second file, and configuring the target first and second configuration information onto the image file to be configured, resulting in a configured image file. Based on the first and second files, automatic configuration of the image file can be achieved. The first configuration information, specifically set for each operating system, and the general second configuration information applicable to at least one operating system are stored in the first and second files respectively. Therefore, if the configuration information for a specific operating system needs to be modified, only the first file needs to be modified. This improves the efficiency of setting configuration information applicable to the operating system of the image file, thereby improving the overall configuration efficiency of the image file.

[0151] The present invention also provides an electronic device, see [link to relevant documentation]. Figure 6 It includes: a processor 901, a memory 902, and a computer program 9021 stored in the memory and executable on the processor. When the processor executes the program, it implements the image file processing method of the aforementioned embodiments.

[0152] The present invention also provides a readable storage medium that, when the instructions in the storage medium are executed by the processor of an electronic device, enables the electronic device to perform the image file processing method of the foregoing embodiments.

[0153] As the apparatus embodiment is basically similar to the method embodiment, it is described in a relatively simple manner. For relevant details, please refer to the description of the method embodiment.

[0154] It should be noted that all information and data obtained in the embodiments of the present invention were obtained with the authorization of the information / data holder.

[0155] The algorithms and displays provided herein are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used in conjunction with the teachings herein. The required structure for constructing such systems is apparent from the above description. Furthermore, this invention is not directed to any particular programming language. It should be understood that the contents of the invention described herein can be implemented using various programming languages, and the above description of specific languages ​​is for the purpose of disclosing the best mode of implementation of the invention.

[0156] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.

[0157] Similarly, it should be understood that, in order to simplify the invention and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof. However, this disclosure should not be construed as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim. Rather, as reflected in the following claims, inventive aspects lie in fewer than all features of a single foregoing disclosed embodiment. Therefore, the claims following the detailed description are hereby expressly incorporated into this detailed description, wherein each claim itself is a separate embodiment of the invention.

[0158] Those skilled in the art will understand that modules in the device of the embodiments can be adaptively changed and placed in one or more devices different from that embodiment. Modules, units, or components in the embodiments can be combined into a single module, unit, or component, and further, they can be divided into multiple sub-modules, sub-units, or sub-components. Except where at least some of such features and / or processes or units are mutually exclusive, any combination can be used to combine all features disclosed in this specification (including the accompanying claims, abstract, and drawings) and all processes or units of any method or device so disclosed. Unless expressly stated otherwise, each feature disclosed in this specification (including the accompanying claims, abstract, and drawings) may be replaced by an alternative feature that serves the same, equivalent, or similar purpose.

[0159] The various component embodiments of the present invention can be implemented in hardware, or as software modules running on one or more processors, or a combination thereof. Those skilled in the art will understand that microprocessors or digital signal processors (DSPs) can be used in practice to implement some or all of the functions of some or all of the components in the sorting device according to the present invention. The present invention can also be implemented as a device or apparatus program for performing part or all of the methods described herein. Such a program implementing the present invention can be stored on a computer-readable medium, or can be in the form of one or more signals. Such signals can be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.

[0160] It should be noted that the above embodiments are illustrative of the invention and not restrictive, and that those skilled in the art can devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names.

[0161] The user information (including but not limited to user device information, user personal information, etc.) and related data involved in this invention are all information authorized by the user or by the parties.

[0162] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0163] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

[0164] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A method for processing an image file, characterized in that: The method comprises: Obtain a pre-generated first file; the first file stores first configuration information, where the first configuration information is configuration information set for each operating system of at least one operating system; Acquire a pre-generated second file, wherein the second file stores second configuration information; the second configuration information is general configuration information applicable to at least one operating system; Obtaining a target operating system of the image file to be configured, and obtaining target first configuration information corresponding to the target operating system from the first file; The second configuration information is obtained from the second file, and the target first configuration information and the second configuration information are configured to the image file to be configured, so as to obtain a configured image file.

2. The method according to claim 1, characterized in that Obtaining target first configuration information corresponding to the target operating system from the first file includes: Acquire target first configuration information corresponding to the target operating system from the first file through an information calling instruction of a Shell script; The first target configuration information and the second configuration information are configured to the image file to be configured to obtain a configured image file, including: The target first configuration information and the second configuration information are configured to the image file to be configured through the information configuration instructions in the Shell script, so as to obtain a configured image file.

3. The method according to claim 1, characterized in that The method further comprises: Acquire first configuration information respectively adapted to each operating system of at least one operating system; Generate a first file in YAML format according to the first configuration information.

4. The method according to claim 1, characterized in that: The method further comprises: Acquire second configuration information applicable to at least one operating system; A second file in a Shell script format is generated according to the second configuration information.

5. The method according to claim 1, characterized in that After obtaining the configured image file, the method further includes: Install the configured image file and obtain the actual status information of the configured image file; The validity of the configured image file is determined according to the actual status information.

6. The method according to claim 5, characterized in that The determining, according to the actual status information, the validity of the configured image file includes: Obtain preset status information for the configured image file; If the actual status information is the same as the preset status information, it is determined that the configured image file is valid.

7. The method according to claim 6, characterized in that The actual state information includes the actual configuration information of the image file, and the preset state information includes the target first configuration information; After obtaining the preset status information of the configured image file, the following is also included: If the actual status information is different from the preset status information, it is determined that the configured image file is invalid; Re-acquiring a target first configuration information configuration corresponding to a target operating system from the first file; The configured file is reconfigured using the target first configuration information to obtain a reconfigured image file.

8. An image file processing device, characterized in that: The device comprises: A first acquisition module is used to acquire a pre-generated first file; the first file stores first configuration information; the first configuration information is configuration information set for at least one operating system; A second acquisition module, used to acquire a pre-generated second file, wherein the second file stores second configuration information; the second configuration information is general configuration information applicable to at least one operating system; A third acquisition module is used to acquire a target operating system of the image file to be configured, and acquire target first configuration information corresponding to the target operating system from the first file; The configuration module is used to obtain the second configuration information from the second file, and configure the target first configuration information and the second configuration information to the image file to be configured to obtain a configured image file.

9. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 7 when executing the program.

10. A readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute any one of the methods described in claims 1-7.