Mirror image generation method and device, equipment, storage medium and program product

By copying and running configuration script files in a virtual machine in turn and debugging with interrupt identifiers, the problem of inefficient image generation is solved, and an efficient mirror production process is achieved.

CN120371328AActive Publication Date: 2025-07-25CHINA TELECOM CLOUD TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202510866380.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-26
Publication Date
2025-07-25
Estimated Expiration
2045-06-26

AI Technical Summary

Technical Problem

In traditional mirror generation methods, the configuration and debugging of customized contents require manual operation, resulting in inefficient image generation, especially in complex situations, requiring repeated debugging.

Method used

Copy the configuration script file in the virtual machine and run the script file in sequence through sequential identification and interrupt identification, allowing the previous script file to be debugged after the interrupt script file to generate a target image.

Benefits of technology

Improve the efficiency of mirror generation, avoid repeated debugging, shorten the mirror production cycle, and improve flexibility and resource utilization efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120371328A_ABST
    Figure CN120371328A_ABST
Patent Text Reader

Abstract

The invention relates to a mirror image generation method and device, equipment, a storage medium and a program product. The method comprises the following steps: copying each configuration script file into a virtual machine; according to the sequence identifier of each configuration script file and the interrupt identifier of the interrupt script file in each configuration script file, running each configuration script file in sequence to realize the configuration of the basic mirror image; and after all the configuration script files are operated, generating a target mirror image according to the configured basic mirror image. According to the scheme, the interrupt script file is introduced, and execution of the interrupt script can be realized in the process of running each configuration script file, so that the configuration script file after running the interrupt script file is interrupted, and the configuration script file before the interrupt script file is debugged; debugging does not need to be carried out after the target mirror image is manufactured, the problem of repeated debugging is avoided, and therefore the mirror image manufacturing efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of cloud computing technology, and particularly to a method, device, equipment, storage medium and program product for generating an image. Background Art

[0002] An image is a file or data set that contains an operating system, software, configuration information, etc. It can be used to quickly create and deploy a computer system or application environment. For example, a bare-metal image is a system image for a bare-metal server, which contains an operating system and some basic software and configuration information that may be pre-installed. Among them, a bare-metal server refers to providing users with the ability to directly access and use physical servers in a cloud computing environment without sharing hardware resources among multiple users through virtualization technology.

[0003] In traditional technologies, an image is usually made through an image generation tool and an image file in a preset format is exported. The process of making an image is usually divided into two stages. In the first stage, an optical disc image file ISO system file is installed on a virtual machine and a basic image is exported. In the second stage, customized content (such as partitioning, drivers, etc.) is configured in the virtual machine installed with the basic image and a customized image is exported. The second stage generally realizes the automatic configuration of the image by pre-configuring customized content such as scripts, drivers, software packages, etc.

[0004] In traditional technologies, in the second stage, content such as script and driver installation needs to be manually debugged. Each time customized content is configured, the image needs to be remade and exported again, and debugging is required again after the image is made, and it cannot be interrupted. For relatively complex customized content, debugging needs to be repeated several times, resulting in low efficiency of image generation. Summary of the Invention

[0005] Based on this, it is necessary to provide a method, device, equipment, storage medium and program product for generating an image to solve the above technical problems and improve the efficiency of image generation.

[0006] In a first aspect, this application provides a method for generating an image, including:

[0007] Copying each configuration script file into a virtual machine; wherein, the virtual machine is created based on a basic image; the basic image provides a basic operating system environment for the virtual machine;

[0008] According to the sequence identifier of each configuration script file and the interruption identifier of the interruption script file in each configuration script file, running each configuration script file in sequence to configure the basic image; wherein, the interruption identifier is used to indicate interrupting the configuration script files after the interruption script file to debug the configuration script files before the interruption script file;

[0009] After all configuration script files have finished running, a target image is generated based on the configured base image.

[0010] In one embodiment, running each configuration script file in sequence according to the sequence identifier of each configuration script file and the interruption identifier of the interruption script file in each configuration script file includes:

[0011] Running each configuration script file in sequence according to the sequence identifier of each configuration script file;

[0012] During the process of running each configuration script file in sequence, if an interruption identifier is recognized, the configuration script file after the interruption script file is interrupted from running, and the configuration script files before the interruption script file are debugged;

[0013] After the configuration script files before the interruption script file are debugged, if a continue running instruction is obtained, the configuration script file after the interruption script file is continued to be run.

[0014] In one embodiment, the base image includes a public key for connecting to the virtual machine; running each configuration script file in sequence according to the sequence identifier of each configuration script file and the interruption identifier of the interruption script file in each configuration script file includes:

[0015] Through a first session connection, controlling the virtual machine to run each configuration script file in sequence according to the sequence identifier of each configuration script file; wherein, the first session connection is a session connection established between the virtual machine and the virtual machine using a private key matching the public key;

[0016] During the process of the virtual machine running each configuration script file in sequence, if an interruption identifier is recognized, the configuration script file after the interruption script file is interrupted from running;

[0017] Through a second session connection, debugging the configuration script files before the interruption script file; wherein, the second session connection is a session connection established between the virtual machine and the virtual machine using a private key matching the public key;

[0018] After the configuration script files before the interruption script file are debugged, if a continue running instruction triggered based on the first session connection is obtained, the configuration script file after the interruption script file is continued to be run.

[0019] In one embodiment, generating the target image based on the configured base image includes:

[0020] Obtaining a log file; wherein, the log file includes data records for configuring the base image;

[0021] Based on the log file, verify the configured base image;

[0022] If the verification passes, delete the public key in the configured base image to obtain the target image.

[0023] In one embodiment, the interruption identifier is established in the following manner:

[0024] Determine the sequence identifier and file identifier of the configuration script file that needs to be debugged;

[0025] Combine the sequence identifier, file identifier, and interruption function identifier of the configuration script file that needs to be debugged to obtain the interruption identifier.

[0026] In one embodiment, each configuration script file includes a common script file and a customized script file; the interruption script file belongs to the common script file;

[0027] The copying of each configuration script file to the virtual machine includes:

[0028] Copy the customized script file to the image production directory, and copy the common script file to the image production directory through the soft link corresponding to the common script file; wherein, the soft link corresponding to the common script file includes the storage path of the common script file and the path of the image production directory;

[0029] Through virtualization software, copy the common script file and the customized script file from the image production directory to the virtual machine.

[0030] In a second aspect, the present application also provides an image generation device, including:

[0031] An acquisition module, configured to copy each configuration script file to a virtual machine; wherein, the virtual machine is created based on a base image; the base image provides a basic operating system environment for the virtual machine;

[0032] An operation module, configured to sequentially run each configuration script file according to the sequence identifier of each configuration script file and the interruption identifier of the interruption script file in each configuration script file to implement the configuration of the base image; wherein, the interruption identifier is used to indicate interrupting the operation of the configuration script file after the interruption script file to facilitate debugging the configuration script file before the interruption script file;

[0033] A generation module, configured to generate a target image according to the configured base image after all configuration script files have been run.

[0034] In a third aspect, the present application further provides a computer device, including a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0035] Copy each configuration script file to a virtual machine; wherein, the virtual machine is created based on a base image; the base image provides a basic operating system environment for the virtual machine;

[0036] Run each configuration script file in sequence according to the sequence identifier of each configuration script file and the interruption identifier of the interruption script file in each configuration script file to implement the configuration of the base image; wherein, the interruption identifier is used to indicate interrupting the execution of the configuration script files after the interruption script file for debugging the configuration script files before the interruption script file;

[0037] After all the configuration script files have been run, generate a target image according to the configured base image.

[0038] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:

[0039] Copy each configuration script file to a virtual machine; wherein, the virtual machine is created based on a base image; the base image provides a basic operating system environment for the virtual machine;

[0040] Run each configuration script file in sequence according to the sequence identifier of each configuration script file and the interruption identifier of the interruption script file in each configuration script file to implement the configuration of the base image; wherein, the interruption identifier is used to indicate interrupting the execution of the configuration script files after the interruption script file for debugging the configuration script files before the interruption script file;

[0041] After all the configuration script files have been run, generate a target image according to the configured base image.

[0042] In a fifth aspect, the present application further provides a computer program product, including a computer program. When the computer program is executed by a processor, the following steps are implemented:

[0043] Copy each configuration script file to a virtual machine; wherein, the virtual machine is created based on a base image; the base image provides a basic operating system environment for the virtual machine;

[0044] Run each configuration script file in sequence according to the sequence identifier of each configuration script file and the interruption identifier of the interruption script file in each configuration script file to implement the configuration of the base image; wherein, the interruption identifier is used to indicate the interruption of running the configuration script files after the interruption script file, so as to debug the configuration script files before the interruption script file;

[0045] After all the configuration script files have been run, generate a target image based on the configured base image.

[0046] In the above image generation method, device, equipment, storage medium and program product, copy each configuration script file to a virtual machine; run each configuration script file in sequence according to the sequence identifier of each configuration script file and the interruption identifier of the interruption script file in each configuration script file to implement the configuration of the base image; after all the configuration script files have been run, generate a target image based on the configured base image. In the above solution, an interruption script file is introduced, which can interrupt the execution of the script during the running of each configuration script file to interrupt the running of the configuration script files after the interruption script file, so as to debug the configuration script files before the interruption script file; there is no need to debug after the target image is produced, avoiding the problem of repeated debugging several times, thus improving the efficiency of image production. Description of the Drawings

[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following will briefly introduce the drawings required for the description of the embodiments of the present application or related technologies. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other related drawings can also be obtained based on these drawings.

[0048] Figure 1 It is a schematic flowchart of the image generation method in an embodiment;

[0049] Figure 2 It is a schematic flowchart of running each configuration script file in sequence in an embodiment;

[0050] Figure 3 It is a schematic flowchart of running each configuration script file in sequence in another embodiment;

[0051] Figure 4 It is a schematic flowchart of generating a target image in an embodiment;

[0052] Figure 5 It is a schematic flowchart of generating an interruption identifier in an embodiment;

[0053] Figure 6Schematic diagram of the process of copying each configuration script file to a virtual machine in one embodiment;

[0054] Figure 7 Schematic diagram of the mirror generation method in another embodiment;

[0055] Figure 8 Structural block diagram of the mirror generation device in one embodiment;

[0056] Figure 9 Internal structure diagram of a computer device in one embodiment. Detailed implementation manners

[0057] In order to make the objectives, technical solutions and advantages of the present application clearer and more understandable, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0058] The mirror generation method provided by the embodiments of the present application can be applied to the application scenario of making system mirrors. This method can be executed by a server or by a terminal with a certain computing power.

[0059] Among them, the server can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. The terminal can be, but is not limited to, various personal computers, laptop computers, smart phones, tablet computers, Internet of Things devices, and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, projection devices, etc. The portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The head-mounted devices can be virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, etc.

[0060] In an exemplary embodiment, as Figure 1 shown, a mirror generation method is provided. Taking the application of this method to a server as an example, the method includes the following steps:

[0061] S101, copy each configuration script file to the virtual machine.

[0062] Exemplarily, in the process of generating the mirror file, it needs to go through two stages. Among them, in the first stage, an ISO system file can be installed on the virtual machine and a base mirror can be exported. The ISO system file is a kind of optical disc image file that contains the operating system installation program and related files.

[0063] In the first stage, the system ISO system file can be downloaded first, and the checksum can be verified. The checksum is a string calculated based on the file content through a preset algorithm. The preset algorithm can be Message-Digest Algorithm 5 (MD5), Secure Hash Algorithm 1 (SHA-1), Secure Hash Algorithm 256-bit (SHA-256), etc. Different file contents will generate different checksums. Even if the file content has only minor changes, the checksum will be completely different. Therefore, it is possible to determine whether an error has occurred or the file has been tampered with during the download process by comparing whether the checksum of the downloaded file is the same as the checksum provided by the official.

[0064] Secondly, the system can be installed in a Quick Emulator (QEMU) virtual machine based on unattended installation kickstart, preseeding, etc. After shutting down the virtual machine, the virtual machine image can be saved as a base image. Among them, the base image can be in the Raw Image Format (raw) or qcow2 format. Among them, qcow2 is a disk image format that supports dynamic allocation, Copy-On-Write, and snapshots.

[0065] In the second stage, first, the base image can be downloaded to a new virtual machine, that is, a new virtual machine can be created based on the base image, which means that the virtual machine is created based on the base image; the base image provides a basic operating system environment for the virtual machine.

[0066] Furthermore, each configuration script file can be copied to the virtual machine. Each configuration script file is used to perform system configuration, service and process configuration, security reinforcement, file and directory operation settings, containerization configuration, and automated test integration on the base image, etc., so that after the base image is configured based on each configuration script file, an image file in a preset format can be exported to obtain the target image file.

[0067] Based on this, in the second stage, each configuration script file needs to be copied to the virtual machine. Each configuration script file is usually saved in the image production directory. Each configuration script file needs to be copied to the virtual machine to implement the configuration of the base image using each configuration script file.

[0068] S102, Run each configuration script file in sequence according to the sequence identifier of each configuration script file and the interruption identifier of the interruption script file in each configuration script file to implement the configuration of the base image.

[0069] Exemplarily, each configuration script file can be named according to a unified naming format, and the naming format needs to carry a sequential identifier so as to run each configuration script file in sequence. Moreover, if the configuration script file is an interruption script file, the naming format of the interruption script file needs to have an interruption identifier, and the interruption identifier is used to indicate interrupting the execution of the configuration script files after the interruption script file, so as to debug the configuration script files before the interruption script file.

[0070] Exemplarily, each configuration script file can be named according to the naming format of "[0-9]+[0-9]+script name". For example, the name of a certain configuration script file is "12-config-dns.sh", where "12" is used to indicate the execution order of the configuration script file. If an interruption operation needs to be performed after the configuration script file named "12-config-dns.sh", an interruption script file can be placed after this configuration script file, and the name of this interruption script file can be "12-config-dns-hold.sh", which is used to indicate performing an interruption operation after the configuration script file named "12-config-dns.sh"; "hold" is marked in "12-config-dns-hold.sh", and thus the name of the interruption script file can be used as the interruption identifier.

[0071] Exemplarily, each configuration script file can be run in sequence according to the sequential identifier of each configuration script file and the interruption identifier of the interruption script file in each configuration script file. For example, each configuration script file can be run in sequence according to the sequential identifier of each configuration script file; during the process of running each configuration script file, if the interruption identifier of the interruption script file in the configuration script file is recognized, it is necessary to interrupt the execution of the configuration script files after the interruption script file so as to debug the configuration script files before the interruption script file. After all the configuration script files have been run, the configuration of the base image is completed.

[0072] S103, after all the configuration script files have been run, generate a target image according to the configured base image.

[0073] Exemplarily, after all the configuration script files have been run, that is, the configuration operation of the base image has been completed according to each configuration script file, a target image can be generated according to the configured base image. For example, the configured base image can be converted into a preset image format to obtain the target image. Among them, the preset image format includes but is not limited to qcow2, raw, squashfs (compressed read-only file system), etc.

[0074] In the above mirror image generation method, each configuration script file is copied to a virtual machine; according to the sequence identifier of each configuration script file and the interruption identifier of the interruption script file in each configuration script file, each configuration script file is run in sequence to implement the configuration of the base mirror image; after all the configuration script files have been run, a target mirror image is generated based on the configured base mirror image. In the above solution, an interruption script file is introduced, which can interrupt the execution of the interruption script during the process of running each configuration script file, so as to interrupt the configuration script file after the interruption script file, in order to debug the configuration script file before the interruption script file; there is no need to perform debugging only after the target mirror image is produced, avoiding the problem of repeated debugging several times, thereby improving the mirror image production efficiency.

[0075] In some optional implementation manners, during the process of running each configuration script file, interruption can be performed according to the interruption script file to debug the configuration script file; and when a continue running instruction is recognized, the subsequent configuration script files are continued to be run.

[0076] Based on this, see Figure 2 , Figure 2 A flow chart for sequentially running each configuration script file is provided, which specifically includes the following steps:

[0077] S201, According to the sequence identifier of each configuration script file, each configuration script file is run in sequence.

[0078] Exemplarily, each configuration script file can be named in the naming format of "[0-9]+[0-9]+script name", where "[0-9]+[0-9]" is the sequence identifier of each configuration script file, used to indicate the running order of each configuration script file. Thus, each configuration script file can be run in sequence according to the sequence identifier of each configuration script file.

[0079] S202, During the process of sequentially running each configuration script file, if an interruption identifier is recognized, the configuration script file after the interruption script file is interrupted from running, and the configuration script file before the interruption script file is debugged.

[0080] During the process of sequentially running each configuration script file, if an interruption identifier is recognized, the configuration script file after the interruption script file can be interrupted from running, and the configuration script file before the interruption script file is debugged. Among them, the naming of the interruption script file will include the "hold" field. When a file naming containing the "hold" field is recognized, it is considered that the interruption identifier is recognized. At this time, the configuration script file after the interruption script file can be interrupted from running, and the configuration script file before the interruption script file is debugged.

[0081] Exemplarily, by adding a startup parameter HOLD variable, an interruption script file for debugging intervention can be added, which supports pausing the mirror configuration process during the automated mirror production process, facilitating troubleshooting, testing the driver and software package installation process, updating software packages and scripts, etc.

[0082] Exemplarily, after interrupting the configuration script file after the interruption script file runs, the server can automatically debug the configuration script file before the interruption script file; or send a debugging prompt message to the debugger to prompt the debugger to debug the configuration script file before the interruption script file.

[0083] S203, after the configuration script file before the interruption script file is debugged, if a continue running instruction is obtained, continue to run the configuration script file after the interruption script file.

[0084] After the configuration script file before the interruption script file is debugged, a continue running instruction can be automatically generated, or a continue running instruction can be sent to the server. If a continue running instruction is obtained, the configuration script file after the interruption script file can be continued to run.

[0085] Among them, the continue running instruction can be custom-set, and can be set to a specified field or instruction information. For example, the continue running instruction can be set to "continue".

[0086] In the embodiments of the present application, by setting an interruption script file, it is possible to interrupt the running of the configuration script file after the interruption script file is recognized, and debug the configuration script file before the interruption script file. In this way, it is not necessary to debug the configuration script file after the target mirror is produced, avoiding the problem of repeated debugging several times, thereby improving the mirror production efficiency.

[0087] In some optional implementation manners, the server can run each configuration script file and debug the configuration script file through different session connections respectively. That is, running each configuration script file and debugging each configuration script file can be carried out through different session connections to achieve isolation of running the script file and debugging each configuration script file, so as to improve the generation efficiency of the target mirror.

[0088] Exemplarily, during the process of generating a base mirror, a session connection public key can be injected into the virtual machine that has downloaded the base mirror, so that each configuration script file can be run and each configuration script file can be debugged based on different session connections.

[0089] Based on this, see Figure 3 , Figure 3 Another schematic diagram of the process of sequentially running each configuration script file is provided, which specifically includes the following steps:

[0090] S301. Control the virtual machine to sequentially run each configuration script file according to the sequence identifier of each configuration script file through the first session connection.

[0091] Exemplarily, the Internet Protocol (IP) of the virtual machine that has downloaded the base image can be determined first, and then a first session connection can be established based on the virtual machine IP and the private key that matches the public key. That is, the first session connection is a session connection established with the virtual machine using the private key that matches the public key. The first session connection can be understood as a process for running each configuration script file. Among them, the first session connection can be a Secure Shell Protocol (SSH) connection.

[0092] Based on this, through the first session connection, according to the sequence identifier of each configuration script file, the virtual machine can be controlled to sequentially run each configuration script file. Each configuration script file can also be named in the naming format of "[0-9]+[0-9]+script name", where "[0-9]+[0-9]" is the sequence identifier of each configuration script file, used to indicate the running order of each configuration script file. Thus, each configuration script file can be sequentially run according to the sequence identifier of each configuration script file to implement the configuration of the base image using each configuration script file.

[0093] S302. During the process of the virtual machine sequentially running each configuration script file, if an interruption identifier is recognized, interrupt the running of the configuration script files after the interrupted script file.

[0094] Furthermore, during the process of the virtual machine sequentially running each configuration script file, if an interruption identifier is recognized, the running of the configuration script files after the interrupted script file can be interrupted. Among them, the name of the interrupted script file will include the "hold" field. In the case of recognizing a file name containing the "hold" field, it is considered that an interruption identifier is recognized, and at this time, the running of the configuration script files after the interrupted script file can be interrupted.

[0095] S303. Debug the configuration script files before the interrupted script file through the second session connection.

[0096] Exemplarily, a second session connection can also be established based on the virtual machine IP and the private key that matches the public key. That is, the second session connection is a session connection established with the virtual machine using the private key that matches the public key. The second session connection can also be an SSH connection.

[0097] Based on this, the configuration script file before the interruption script file can be automatically debugged through the second session connection; or a debugging prompt message can be sent to the debugger to prompt the debugger to debug the configuration script file before the interruption script file through the second session connection. In this way, the isolation between running the configuration script file and debugging the configuration script file is achieved, so as to improve the generation efficiency of the target image.

[0098] S304, after the configuration script file before the interruption script file is debugged, if a continue running instruction triggered based on the first session connection is obtained, then continue to run the configuration script file after the interruption script file.

[0099] Exemplarily, after the configuration script file before the interruption script file is debugged, a continue running instruction can be automatically generated based on the first session connection, or a continue running instruction can be sent to the server based on the first session connection. If the continue running instruction is obtained, then the configuration script file after the interruption script file can be continued to run. In this way, it is possible to continue to use the first session connection to run the subsequent configuration script files.

[0100] In the embodiments of the present application, by setting different session connections, the isolation between running each configuration script file and debugging each configuration script file is achieved, and the generation efficiency of the target image is improved.

[0101] Exemplarily, on the basis of Figure 3 the shown embodiment, the configured base image can be verified before generating the target image to improve the reliability of the target image.

[0102] Based on this, referring to Figure 4 , Figure 4 a schematic flow diagram for generating a target image is provided, which specifically includes the following steps:

[0103] S401, obtain a log file.

[0104] Exemplarily, the log file may include data records for configuring the base image. For example, a large amount of log information is usually generated during the process of configuring the base image, and these log information record various operations and events during the image production process, such as software package installation, modification of configuration script files, setting of system parameters, etc. By viewing the log file, it is possible to understand whether there are errors during the image production process, which steps take a long time, etc., which helps to optimize the image production process and solve potential problems.

[0105] Generally, the log file is stored in a specified file, and the log content can be directly obtained by viewing this file.

[0106] S402, verify the configured base image based on the log file.

[0107] Based on this, the configured base image can be verified based on the log file. Exemplarily, a hash algorithm (such as MD5, SHA-256, etc.) can be used to calculate the hash value of the configured base image and compare it with a pre-provided or known correct hash value. If the two hash values are the same, it indicates that the configured base image has not changed during transmission or storage, that is, the verification is considered to pass; if they are different, it means that the configured base image may be corrupted and needs to be remade or downloaded, that is, the verification is considered to fail.

[0108] S403, in the case where the verification passes, delete the public key in the configured base image to obtain the target image.

[0109] Exemplarily, in the case where the verification passes, the public key in the configured base image can be deleted, and then the configured base image can be converted to a preset image format to obtain the target image. Among them, the preset image format includes but is not limited to qcow2, raw, squashfs, etc.

[0110] In the embodiments of the present application, by verifying the configured base image and generating the target image in the case where the verification passes, the reliability of the target image can be improved in this way.

[0111] In some alternative implementation manners, the interruption identifier can be set according to the file name of the configuration script file that needs to be debugged, so that the interruption script file can run after the configuration script file that needs to be debugged, so as to interrupt the execution of the configuration script file after the interruption script file and debug the configuration script file before the interruption script file.

[0112] Based on this, participate Figure 5 , Figure 5 A flow diagram for generating an interruption identifier is provided, which specifically includes the following steps:

[0113] S501, determine the sequence identifier and file identifier of the configuration script file that needs to be debugged.

[0114] Exemplarily, the sequence identifier and file identifier of the configuration script file that needs to be debugged can be determined first. Among them, the configuration script file can be named in the naming format of "[0-9]+[0-9]+script name", where "[0-9]+[0-9]" can be understood as the sequence identifier; "[script name]" can be understood as the file identifier.

[0115] Under normal circumstances, the configuration script files that need to be debugged can be set in advance. For example, if the configuration script files "12-config-dns.sh" and "17-install-nvidia-fabricmanager.sh" need to be debugged, an interruption script file can be executed after the configuration script file "12-config-dns.sh", and an interruption script file can be executed after the configuration script file "17-install-nvidia-fabricmanager.sh". Among them, the sequence identifier and file identifier of the configuration script file "12-config-dns.sh" are "12" and "config-dns.sh" respectively; the sequence identifier and file identifier of the configuration script file "17-install-nvidia-fabricmanager.sh" are "17" and "install-nvidia-fabricmanager.sh" respectively.

[0116] S502, combine the sequence identifier, file identifier, and interruption function identifier of the configuration script file that needs to be debugged to obtain an interruption identifier.

[0117] Exemplarily, the sequence identifier, file identifier, and interruption function identifier of the configuration script file that needs to be debugged can be combined to obtain an interruption identifier. Among them, the interruption function identifier is "hold".

[0118] For example, the interruption identifier of the interruption script file executed after the configuration script file "12-config-dns.sh" is "12-config-dns-hold.sh"; the interruption identifier of the interruption script file executed after the configuration script file "17-install-nvidia-fabricmanager.sh" is "17-install-nvidia-fabricmanager-hold.sh".

[0119] In the embodiments of the present application, by combining the sequence identifier and file identifier of the debugged configuration script file, and the interruption function identifier, the interruption identifier of the interruption script file is generated, which can interrupt the execution of the configuration script file after the interruption script file and debug the configuration script file before the interruption script file.

[0120] In some alternative implementation manners, to improve the efficiency of mirror maintenance and update, each configuration script file can be divided into a common script file and a customized script file, where the interruption script file belongs to the common script file. The common script file can be understood as a script file that can be used for creating each mirror file, and the customized script file, that is, the private script file, can be understood as a script file that needs to be flexibly set according to the requirements for the mirror when creating the mirror file.

[0121] Exemplarily, the common script file can be understood as a script with relatively strong generality, which can be shared and reused in multiple systems, environments or projects, and is usually used to implement general configuration, management and maintenance tasks. For example, the common script file can include common component scripts, network configuration scripts, security configuration scripts, default configuration scripts for Network Time Protocol (NTP) and Domain Name System (DNS), and log cleaning scripts, etc.

[0122] The customized script file can be understood as a script customized for a specific customer, project or environment, and usually includes drivers, software or personalized requirements provided by the customer. For example, the customized script file includes private reinforcement scripts, private driver and software installation scripts.

[0123] Among them, the private reinforcement script can include customized security policies (for example, adjusting kernel parameters and file permissions according to the customer's industry (such as finance, medical)) and private protocol support (for example, integrating encryption protocols or authentication methods specified by the customer).

[0124] The private driver and software installation scripts include hardware driver installation (for example, automated deployment of NVIDIA Graphics Processing Unit (NVIDIA GPU) drivers, InfiniBand Architecture (InfiniBand) network card drivers), specific software deployment (for example, installing private software provided by the customer (such as customized databases, middleware)), and dependency management (for example, automatically installing runtime libraries and frameworks required by the software).

[0125] Based on this, referring to Figure 6 , Figure 6 a schematic flow diagram for copying each configuration script file to a virtual machine is provided, which specifically includes the following steps:

[0126] S601, copy the customized script file to the mirror making directory, and copy the common script file to the mirror making directory through the soft link corresponding to the common script file.

[0127] Exemplarily, the customized script file can be directly stored in the image creation directory. If it is stored in other paths, the customized script file needs to be copied to the image creation directory. The public script file is usually stored in the public script directory, and the public script file can be copied to the image creation directory through the corresponding soft link of the public script file.

[0128] Among them, the soft link corresponding to the public script file includes the storage path of the public script file and the path of the image creation directory. A soft link, also known as a symbolic link, is a special file that contains a reference to another file or directory. Similar to a shortcut, a file or directory in another location can be accessed through a soft link. A soft link does not occupy actual file storage space, but only records the path information of the target file or directory. When accessing a soft link, the system will find the corresponding target file or directory according to the path information in the link and perform operations. In the Linux system, the ln - s command can be used to create a soft link.

[0129] S602, through virtualization software, copy the public script file and the customized script file from the image creation directory to the virtual machine.

[0130] Exemplarily, through virtualization software, the public script file and the customized script file can be copied from the image creation directory to the virtual machine. Among them, the virtualization software can adopt the Secure Copy protocol (scp). Scp is a command - line tool for securely copying files over a network. The server can automatically call the scp command to copy the public script file and the customized script file from the image creation directory to the virtual machine.

[0131] In the embodiments of the present application, by dividing each configuration script file into a public script file and a customized script file, the efficiency of image maintenance and update is improved; and through virtualization software, the public script file and the customized script file can be copied from the image creation directory to the virtual machine, which is convenient for generating the target image.

[0132] Exemplarily, see Figure 7 , Figure 7 A flowchart of another image generation method is provided, and the image generation method is introduced in two stages, which specifically includes the following steps:

[0133] The first stage:

[0134] S701, download the ISO system file and check the checksum.

[0135] S702, install the ISO system file in the virtual machine and inject the public key for connecting to the virtual machine.

[0136] S703. Shut down the virtual machine and save the image to obtain the base image.

[0137] The second stage:

[0138] S704. Download the base image to a new virtual machine and obtain the identifier of the virtual machine.

[0139] Among them, the identifier of the virtual machine can be the virtual machine IP.

[0140] S705. Copy the customized script file to the image production directory and soft link the public script file to the image production directory.

[0141] S706. Connect to the virtual machine based on the first session connection and copy each configuration script file to the virtual machine.

[0142] Among them, each configuration script file includes the public script file, the customized script file, the driver software package, etc.

[0143] S707. Based on the first session connection, run each configuration script file in sequence according to the sequence identifier of each configuration script file.

[0144] S708. Determine whether all configuration script files have been run. If so, execute S713. If not, execute S709.

[0145] S709. Determine whether it is an interrupt script file. If so, execute S710. If not, execute S707.

[0146] S710. Interrupt the execution of the configuration script files after the interrupt script file.

[0147] S711. Debug the configuration script files before the interrupt script file based on the second session connection.

[0148] S712. After the configuration script files before the interrupt script file are debugged and a continue running instruction triggered by the first session connection is obtained, continue to execute S707.

[0149] S713. Verify the configured base image based on the log file.

[0150] S714. In the case of passing the verification, delete the public key in the configured base image and convert the configured base image to a preset format to obtain the target image.

[0151] In the embodiments of the present application, on the one hand, the configuration script file in the second stage is finely divided into multiple scripts according to the configuration content and functions, and some common configurations are extracted as a common script file, which is linked to the image production directory through a soft link for subsequent image maintenance and update. On the other hand, the script naming is formatted as "[0-9]+[0-9]+ script name", and the scripts are automatically executed according to the order of the script file names, so as to control the execution order of the scripts. In addition, a startup parameter HOLD variable is added to the common script hold.sh for adding debugging intervention, which supports pausing the image configuration process during the automated image production process, facilitating troubleshooting, testing the driver and software package installation process, updating software packages and scripts, etc.; after the test is completed, the previous image configuration process can be continued to complete the debugging and production process of the image at one time. This method improves the efficiency and flexibility of image production, shortens the image production cycle, reduces resource consumption, can respond to customer needs faster, provides high-quality customized services, and thus improves customer satisfaction.

[0152] Taking the production of a bare-metal image as an example, the steps of the image generation method are introduced in detail below. Assume that the image customization requirement is the Community Enterprise Operating System 7.6 version (CentOS-7.6 system), and it is necessary to install the NVIDIA Graphics Driver (nvidia-driver) (version 535), install the Compute Unified Device Architecture 12.2 version (cuda-12.2), install the adapted NVIDIA Unified Fabric Manager (nvidia-fabricmanager) software package, and modify the SSH port to 10000.

[0153] Specifically, it includes the following steps:

[0154] S01, manually configure the soft link of the required common script file and write the private script file of this image.

[0155] In addition to the common configuration scripts for bare metal, soft link configurations can be added according to requirements:

[0156] install-nvidia-driver-535.sh -> under the production directory. Among them, 15-install-nvidia-driver-535.sh is used to install nvidia-driver.

[0157] install-cuda-12-2.sh -> Under the production directory. Among them, 16-install-cuda-12-2.sh is used to install cuda-12.2.

[0158] It is necessary to write private scripts:

[0159] 17-install-nvidia-fabricmanager.sh is used to install nvidia-fabricmanager.

[0160] 29-config-ssh.sh is used to modify the SSH port to 10000.

[0161] S02, start the mirror automatic production process, set the HOLD variable of the startup parameter to 17-install-nvidia-fabricmanager.sh. This parameter will soft link the public script hold.sh -> 17-install-nvidia-fabricmanager-hold.sh under the mirror production directory at the beginning of the automatic production process. The hold.sh script contains the hold_on() function.

[0162] S03, download the system ISO system file and check the checksum. Install the system in the qemu virtual machine based on automatic installation methods such as kickstart and preseed. After shutting down the virtual machine, save the virtual machine image as the base image. (Inject an SSH public key into the virtual machine during automatic installation configuration for connecting to the virtual machine in the second stage).

[0163] S04, copy the base image of the first stage, automatically start the virtual machine, and obtain the virtual machine IP.

[0164] S05, connect to the virtual machine using the corresponding SSH private key, and copy a series of scripts (private scripts and public scripts) and driver software packages under the mirror production directory into the virtual machine.

[0165] S06, execute the script to modify the mirror through SSH. When executing the hold_on() function in the 17-install-nvidia-fabricmanager-hold.sh script, the script execution of the current SSH connection (later recorded as SSH-1 connection) will be paused.

[0166] S07, Manually verify whether the installed nvidia-fabricmanager is installed successfully through the new SSH connection to the virtual machine (denoted as SSH-2 connection), and debug the software functions. If the installed version is not compatible with the current nvidia-driver version, you can copy the compatible nvidia-fabricmanager software package to the virtual machine via scp, and then manually install, debug, and verify it.

[0167] S08, After the verification is completed, close the SSH-2 connection. Enter the specified string "continue" in the SSH-1 connection to resume the automated image production process.

[0168] S09, After all the scripts have been run, extract the log of the produced image, verify the image; delete the temporary files such as the public key of the image SSH in the image.

[0169] S10, Shut down the virtual machine, save the image, and convert the image to an image format (raw, qcow2, squashfs, etc.) to obtain the target image CentOS-7.6@cuda-12.2.qcow2.

[0170] It should be understood that although the steps in the flowcharts involved in the above-described embodiments are shown in sequence according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless specifically stated in this article, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-described embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be executed alternately or in turn with at least a part of other steps or steps or stages in other steps.

[0171] Based on the same inventive concept, the embodiments of the present application also provide an image generation device for implementing the above-mentioned image generation method. The implementation solutions provided by this device to solve problems are similar to the implementation solutions described in the above method. Therefore, the specific limitations in one or more embodiments of the following image generation devices can refer to the limitations on the image generation method in the above text, and will not be repeated here.

[0172] In an exemplary embodiment, as Figure 8 shown, an image generation device is provided, including:

[0173] An acquisition module 10 is used to copy each configuration script file into a virtual machine; wherein, the virtual machine is created based on a base image; the base image provides a basic operating system environment for the virtual machine;

[0174] An operation module 20 is used to sequentially run each configuration script file according to the sequence identifier of each configuration script file and the interruption identifier of the interruption script file in each configuration script file, so as to implement the configuration of the base image; wherein, the interruption identifier is used to indicate the interruption of running the configuration script files after the interruption script file, so as to debug the configuration script files before the interruption script file;

[0175] A generation module 30 is used to generate a target image according to the configured base image after all the configuration script files have been run.

[0176] The above image generation device copies each configuration script file into a virtual machine; sequentially runs each configuration script file according to the sequence identifier of each configuration script file and the interruption identifier of the interruption script file in each configuration script file, so as to implement the configuration of the base image; and generates a target image according to the configured base image after all the configuration script files have been run. In the above solution, an interruption script file is introduced, which can interrupt the execution of the script during the running of each configuration script file, so as to interrupt the running of the configuration script files after the interruption script file, so as to debug the configuration script files before the interruption script file; there is no need to perform debugging only after the target image is made, avoiding the problem of repeated debugging several times, thereby improving the image making efficiency.

[0177] In one embodiment, the operation module 20 is specifically used for:

[0178] Sequentially run each configuration script file according to the sequence identifier of each configuration script file; during the sequential running of each configuration script file, if the interruption identifier is recognized, interrupt the running of the configuration script files after the interruption script file, and debug the configuration script files before the interruption script file; after the configuration script files before the interruption script file are debugged, if a continue running instruction is obtained, continue to run the configuration script files after the interruption script file.

[0179] In one embodiment, the base image includes a public key for connecting to the virtual machine; the operation module 20 is specifically used for:

[0180] Through the first session connection, according to the sequence identifier of each configuration script file, control the virtual machine to run each configuration script file in sequence; wherein, the first session connection is a session connection established with the private key matching the public key and the virtual machine; during the process of the virtual machine running each configuration script file in sequence, if an interruption identifier is recognized, interrupt the running of the configuration script files after the interrupted script file; through the second session connection, debug the configuration script files before the interrupted script file; wherein, the second session connection is a session connection established with the private key matching the public key and the virtual machine; after the configuration script files before the interrupted script file are debugged, if a continue running instruction triggered based on the first session connection is obtained, continue to run the configuration script files after the interrupted script file.

[0181] In one embodiment, the generating module 30 is specifically configured to:

[0182] Obtain a log file; wherein, the log file includes data records for configuring the base image; based on the log file, verify the configured base image; in the case of passing the verification, delete the public key in the configured base image to obtain a target image.

[0183] In one embodiment, the apparatus further includes an establishing module, configured to:

[0184] Determine the sequence identifier and file identifier of the configuration script file that needs to be debugged; combine the sequence identifier, file identifier, and interruption function identifier of the configuration script file that needs to be debugged to obtain an interruption identifier.

[0185] In one embodiment, each configuration script file includes a common script file and a customized script file; the interrupted script file belongs to the common script file; the obtaining module 10 is specifically configured to:

[0186] Copy the customized script file to the image making directory, and copy the common script file to the image making directory through the soft link corresponding to the common script file; wherein, the soft link corresponding to the common script file includes the storage path of the common script file and the path of the image making directory; through virtualization software, copy the common script file and the customized script file from the image making directory to the virtual machine.

[0187] Each module in the above image generation apparatus can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in the processor of the computer device in hardware form or be independent of it, or can be stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to the above modules.

[0188] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structural diagram may be as shown in Figure 9 shown. The computer device includes a processor, a memory, an input / output (I / O) interface, and a communication interface. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store script files and mirror file data. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with external terminals through a network connection. When the computer program is executed by the processor, it implements a mirror generation method.

[0189] Those skilled in the art can understand that Figure 9 the structure shown in is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0190] In an exemplary embodiment, a computer device is provided, including a memory and a processor. A computer program is stored in the memory, and when the processor executes the computer program, it implements the steps of the mirror generation method described in any of the above embodiments.

[0191] In an embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by the processor, it implements the steps of the mirror generation method described in any of the above embodiments.

[0192] In an embodiment, a computer program product is provided, including a computer program. When the computer program is executed by the processor, it implements the steps of the mirror generation method described in any of the above embodiments.

[0193] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data need to comply with relevant regulations.

[0194] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, database, or other medium used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in this application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the embodiments provided in this application can be general-purpose processors, central processors, graphics processors, digital signal processors, programmable logic devices, data processing logics based on quantum computing, artificial intelligence (AI) processors, etc., without limitation.

[0195] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope recorded in this application.

[0196] The above-described embodiments merely represent several implementation manners of the present application. The description thereof is relatively specific and detailed, but it should not be construed as a limitation on the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all fall within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the appended claims.

Claims

1. A method for generating a mirror image, characterized in that, The method includes: Copy each configuration script file into the virtual machine; wherein, the virtual machine is created based on a base image; the base image provides a basic operating system environment for the virtual machine; Run each configuration script file in sequence according to the sequence identifier of each configuration script file and the interruption identifier of the interruption script file in each configuration script file to implement the configuration of the base image; wherein, the interruption identifier is used to indicate interrupting the configuration script files after the interruption script file to facilitate debugging the configuration script files before the interruption script file; After all configuration script files have been run, generate a target image according to the configured base image.

2. The method according to claim 1, wherein The running of each configuration script file in sequence according to the sequence identifier of each configuration script file and the interruption identifier of the interruption script file in each configuration script file includes: Run each configuration script file in sequence according to the sequence identifier of each configuration script file; During the process of running each configuration script file in sequence, if the interruption identifier is recognized, interrupt the running of the configuration script files after the interruption script file and debug the configuration script files before the interruption script file; After the configuration script files before the interruption script file have been debugged, if a continue running instruction is obtained, continue running the configuration script files after the interruption script file.

3. The method according to claim 1, wherein The base image includes a public key for connecting to the virtual machine; The running of each configuration script file in sequence according to the sequence identifier of each configuration script file and the interruption identifier of the interruption script file in each configuration script file includes: Through a first session connection, control the virtual machine to run each configuration script file in sequence according to the sequence identifier of each configuration script file; wherein, the first session connection is a session connection established between the virtual machine and the virtual machine using a private key matching the public key; During the process of the virtual machine running each configuration script file in sequence, if the interruption identifier is recognized, interrupt the running of the configuration script files after the interruption script file; Through a second session connection, debug the configuration script files before the interruption script file; wherein, the second session connection is a session connection established between the virtual machine and the virtual machine using a private key matching the public key; After the configuration script files before the interruption script file have been debugged, if a continue running instruction triggered based on the first session connection is obtained, continue running the configuration script files after the interruption script file.

4. The method according to claim 3, wherein The generating of the target image according to the configured base image includes: Obtain a log file; wherein, the log file includes data records for configuring the base image; Based on the log file, verify the configured base image; If the verification passes, delete the public key in the configured base image to obtain the target image.

5. The method according to claim 1, characterized in that The interruption identifier is established in the following manner: Determine the sequence identifier and file identifier of the configuration script file that needs to be debugged; Combine the sequence identifier, file identifier, and interruption function identifier of the configuration script file that needs to be debugged to obtain the interruption identifier.

6. The method according to claim 1, characterized in that, Each configuration script file includes a common script file and a customized script file; The interruption script file belongs to the common script file; Copying each configuration script file into the virtual machine includes: Copying the customized script file to the image production directory, and copying the common script file to the image production directory through the soft link corresponding to the common script file; wherein, the soft link corresponding to the common script file includes the storage path of the common script file and the path of the image production directory; Through virtualization software, copying the common script file and the customized script file from the image production directory to the virtual machine.

7. A mirror image generation device, characterized in that, The device includes: An acquisition module, configured to copy each configuration script file into the virtual machine; wherein, the virtual machine is created based on a base image; the base image provides a basic operating system environment for the virtual machine; An operation module, configured to sequentially operate each configuration script file according to the sequence identifier of each configuration script file and the interruption identifier of the interruption script file in each configuration script file, so as to implement the configuration of the base image; wherein, the interruption identifier is used to indicate interrupting the operation of the configuration script file after the interruption script file, so as to debug the configuration script file before the interruption script file; A generation module, configured to generate a target image according to the configured base image after all configuration script files are operated.

8. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

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

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Page debugging method and device, electronic equipment and storage medium

    CN112988599A

  • Code deployment method and device, storage medium and electronic equipment

    CN114895916A

  • Mirror image file generation method and device of operating system and computer equipment

    CN115344275A

  • Debugging file generation method and device, computing equipment and storage medium

    CN115640215A

  • Virtual machine creation method and device, equipment and storage medium

    CN117742890A