A virtual machine password resetting method, device and medium

By setting a first identifier and a second identifier inside the virtual machine, and modifying the first identifier to make the Cloud-Init process run during virtual machine reconstruction, the problem of virtual machine password reset failure was resolved, thus improving the reliability and security of the virtual machine.

CN115543539BActive Publication Date: 2026-04-21JINAN INSPUR DATA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
JINAN INSPUR DATA TECH CO LTD
Filing Date
2022-10-14
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

After the virtual machine operating system crashes, the Cloud-Init process cannot be executed, causing virtual machine initialization settings to fail and the password to be unable to be reset, affecting the reliability and security of the virtual machine.

Method used

By setting a first identifier and a second identifier inside the virtual machine, the first identifier is modified so that the Cloud-Init process can run during virtual machine reconstruction, and the virtual machine password is reset.

Benefits of technology

This feature enables successful password reset after virtual machine rebuild, improving the reliability and security of virtual machines and preventing initialization failures.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115543539B_ABST
    Figure CN115543539B_ABST
Patent Text Reader

Abstract

The application relates to the field of servers and discloses a virtual machine password resetting method and device and a medium, which comprises the following steps: when a reconstruction instruction is detected, a reconstruction image file corresponding to the reconstruction instruction is acquired, so as to reconstruct a virtual machine according to the reconstruction image file; it is judged whether the reconstruction image file is a virtual machine snapshot, if the reconstruction image file is the virtual machine snapshot, a first identifier of the virtual machine corresponding to the virtual machine snapshot is modified to obtain a reconstruction snapshot, wherein the virtual machine has the first identifier and a second identifier, the first identifier is a universally unique identifier, and the second identifier is a unique identifier in a virtual machine platform; a reconstruction virtual machine is created according to the reconstruction snapshot, and a virtual machine initialization process is called to reset the password of the reconstruction virtual machine. According to the application, the first identifier and the second identifier are arranged in the virtual machine, and the first identifier is modified when a reconstruction virtual machine is created by using an initial virtual machine image snapshot, so that the initialization process can run in the reconstruction virtual machine to reset the password.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of servers, and in particular to a method, apparatus, and medium for resetting virtual machine passwords. Background Technology

[0002] With the development of cloud computing technology, more and more users are choosing to upload their data and services to cloud computing platforms. Currently, OpenStack is commonly used to manage virtual machines and provide cloud computing services to users. Cloud-Init is a setup process provided by the OpenStack platform. It executes virtual machine initialization setup tasks during the first startup after a virtual machine is created. After the initialization setup tasks are completed, a run record is generated in a fixed directory. This run record corresponds to the virtual machine's Universally Unique Identifier (UUID), indicating that the Cloud-Init process has successfully run on the virtual machine corresponding to that UUID.

[0003] When a virtual machine operating system crashes and cannot be repaired, the initial image is typically used to restore and rebuild the virtual machine. To restore as much of the virtual machine's attribute information as possible, the initial image used is often a snapshot of the original virtual machine. The UUID of the virtual machine remains the same before and after reconstruction. The rebuilt virtual machine system retains the running records of Cloud-Init within the virtual machine corresponding to that UUID, making it impossible to execute the Cloud-Init process again. This causes the virtual machine initialization setup to fail, preventing the user from resetting the virtual machine password. If the user forgets the virtual machine password, the virtual machine cannot be started, affecting the user's normal work.

[0004] Therefore, providing a virtual machine password reset method to prevent virtual machine initialization settings from failing and password reset due to the Cloud-Init process failing to execute after virtual machine reconstruction, thereby improving the reliability and security of virtual machines, is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0005] The purpose of this application is to provide a virtual machine password reset method, apparatus, and medium to prevent virtual machine initialization settings from failing and virtual machine passwords from being reset due to the Cloud-Init process failing to execute after rebuilding a virtual machine using a virtual machine image snapshot, thereby improving the reliability and security of the virtual machine.

[0006] To address the aforementioned technical issues, this application provides a virtual machine password reset method, applicable to virtual machines on the OpenStack platform, comprising:

[0007] When a reconstruction command is detected, the reconstruction image file corresponding to the reconstruction command is obtained;

[0008] Determine whether the reconstructed image file is a virtual machine snapshot;

[0009] If it is a virtual machine snapshot, modify the first identifier of the initial virtual machine corresponding to the virtual machine snapshot to obtain a reconstructed snapshot, wherein the initial virtual machine has a first identifier and a second identifier, the first identifier is a universally unique identifier of the initial virtual machine, and the second identifier is a unique identifier of the initial virtual machine in the OpenStack platform;

[0010] A rebuilt virtual machine is created based on the rebuilt snapshot, and the virtual machine initialization process is invoked to reset the password of the rebuilt virtual machine.

[0011] Preferably, after the step of modifying the first identifier of the initial virtual machine corresponding to the virtual machine snapshot to obtain the reconstructed snapshot, the method further includes:

[0012] Update the first identifier in the relational database, wherein the relational database is a database that stores the correspondence between the first identifier and the second identifier.

[0013] Preferably, the step of invoking the virtual machine initialization process to reset the password of the rebuilt virtual machine includes:

[0014] Execute the Cloud-Init process to retrieve the password reset command entered by the user;

[0015] The password of the rebuilt virtual machine is updated according to the password reset instruction.

[0016] Preferably, before the step of modifying the first identifier of the initial virtual machine corresponding to the virtual machine snapshot to obtain the reconstructed snapshot, the method further includes:

[0017] Determine whether the second identifier is included in the nova database of the OpenStack platform;

[0018] If the second identifier exists, then the step of modifying the first identifier of the initial virtual machine corresponding to the virtual machine snapshot to obtain the reconstructed snapshot is performed.

[0019] Preferably, after the step of determining whether the Nova database of the OpenStack platform includes the second identifier, the method further includes:

[0020] If the second identifier does not exist, then add the second identifier to the nova database, with the initial value of the second identifier being the universally unique identifier;

[0021] An interface function is created based on the second identifier, enabling the OpenStack platform to call the corresponding virtual machine through the second identifier.

[0022] Preferably, before the step of obtaining the reconstruction image file corresponding to the reconstruction instruction, the method further includes:

[0023] Determine whether the current time meets the preset conditions;

[0024] If the preset conditions are met, create the virtual machine image snapshot for the initial virtual machine.

[0025] Preferably, after the step of updating the password of the rebuilt virtual machine according to the password reset instruction, the method further includes:

[0026] Determine whether a password reset success signal from the Cloud-Init process has been received within the threshold time.

[0027] If the password reset success signal is not received, a warning message will be sent to the administrator.

[0028] To address the aforementioned technical issues, this application also provides a virtual machine password reset device, applied to virtual machines under the OpenStack platform, comprising:

[0029] The acquisition module is used to acquire the reconstructed image file corresponding to the reconstruction instruction when a reconstruction instruction is detected;

[0030] The determination module is used to determine whether the reconstructed image file is a virtual machine snapshot;

[0031] The modification module is used to modify the first identifier of the initial virtual machine corresponding to the virtual machine snapshot to obtain a reconstructed snapshot if it is the virtual machine snapshot. The initial virtual machine has the first identifier and the second identifier. The first identifier is a universally unique identifier of the initial virtual machine, and the second identifier is a unique identifier of the initial virtual machine in the OpenStack platform.

[0032] A creation module is used to create a rebuilt virtual machine based on the rebuilt snapshot and to call the virtual machine initialization process to reset the password of the rebuilt virtual machine.

[0033] To address the aforementioned technical problems, this application also provides a virtual machine password reset device, including a memory for storing computer programs;

[0034] A processor, configured to implement the virtual machine password reset method when executing the computer program.

[0035] To address the aforementioned technical problems, this application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the virtual machine password reset method.

[0036] This application provides a virtual machine password reset method applied to virtual machines under the OpenStack platform. The method includes: when a rebuild command is detected, obtaining a rebuild image file corresponding to the rebuild command to rebuild the virtual machine based on the rebuild image file; determining whether the rebuild image file is a virtual machine snapshot; if it is, modifying the first identifier of the virtual machine corresponding to the virtual machine snapshot to obtain a rebuild snapshot. The virtual machine has a first identifier and a second identifier. The first identifier is a universally unique identifier for the initial virtual machine, allowing the Cloud-Init program to run in the newly created virtual machine after the first identifier changes; the second identifier is a unique identifier for the initial virtual machine within the OpenStack platform, allowing users to call the virtual machine in the OpenStack platform using the second identifier. The rebuilt virtual machine is created based on the rebuild snapshot, and the virtual machine initialization process is invoked to reset the password of the rebuilt virtual machine. Therefore, the virtual machine password reset method provided in this application, by setting a first identifier and a second identifier inside the virtual machine and modifying the first identifier when creating the rebuilt virtual machine using the initial virtual machine image snapshot, enables the Cloud-Init process to run in the rebuilt virtual machine to reset the password.

[0037] In addition, this application also provides a virtual machine password reset device and medium, which correspond to the above method and have the same effect. Attached Figure Description

[0038] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0039] Figure 1 A flowchart illustrating a virtual machine password reset method provided in this application embodiment;

[0040] Figure 2 A timing diagram for creating a virtual machine based on a snapshot, provided as an embodiment of this application;

[0041] Figure 3 This is a structural diagram of a virtual machine password reset device provided in an embodiment of this application;

[0042] Figure 4This is a structural diagram of a virtual machine password reset device provided in another embodiment of this application. Detailed Implementation

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

[0044] The core of this application is to provide a virtual machine password reset method, device, and medium to prevent virtual machine initialization settings from failing and virtual machine passwords from being reset due to the Cloud-Init process failing to execute after rebuilding a virtual machine using the original virtual machine image snapshot, thereby improving the reliability and security of the virtual machine.

[0045] During server operation, users may forget their virtual machine passwords. To prevent this, the password can be reset by rebuilding the virtual machine. To preserve user data as much as possible, a snapshot of the image created by the user can be used to rebuild the virtual machine. However, resetting the virtual machine password requires starting a virtual machine initialization process, which cannot be executed in a virtual machine that has already run this process, causing the password reset to fail. To solve this problem, this application provides a virtual machine password reset method. This method involves setting a first identifier and a second identifier within the virtual machine, and modifying the first identifier when rebuilding the virtual machine using an initial virtual machine image snapshot. This allows the virtual machine initialization process to run in the rebuilt virtual machine to reset the password. The first identifier is a universally unique identifier for the initial virtual machine, enabling the Cloud-Init program to run in the newly created virtual machine after the first identifier changes. The second identifier is a unique identifier for the initial virtual machine within the OpenStack platform, allowing users to access the virtual machine within the OpenStack platform using the second identifier.

[0046] The technical solution provided in this application is applied to servers running the OpenStack platform. It should be noted that this solution is illustrated using the server architecture of the Intel platform, but the method is not limited to servers on the Intel platform, nor is it limited to server systems. It still has general application value on server systems or other computer systems.

[0047] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0048] Figure 1A flowchart of a virtual machine password reset method provided in this application embodiment is shown below. Figure 1 As shown, the method includes:

[0049] S10: When a reconstruction command is detected, obtain the reconstruction image file corresponding to the reconstruction command.

[0050] S11: Determine whether the reconstructed image file is a virtual machine snapshot.

[0051] In practice, when a user-sent rebuild command is detected, the virtual machine rebuild process is initiated, and the rebuild image file used to rebuild the virtual machine is obtained. It can be understood that the rebuild image file can be a blank image file corresponding to the initial virtual machine, or a snapshot of the virtual machine saved during its use.

[0052] It is important to note that since the virtual machine initialization process used for password reset is the Cloud-Init process, it generates an unmodifiable runtime log in a specified directory within the virtual machine after completing its initial tasks. When this runtime log exists, the Cloud-Init task cannot be executed again upon restarting the virtual machine. In this embodiment, when a blank image file is used to perform the virtual machine reconstruction task, the runtime log of the Cloud-Init task does not exist in the virtual machine system, allowing the password reset process to proceed. However, when a virtual machine snapshot is used to perform the reconstruction task, the corresponding runtime log exists in the virtual machine system, requiring the password reset scheme provided in this application to reset the password. Therefore, it is necessary to determine the reconstruction image file used to rebuild the virtual machine to determine the subsequent procedures.

[0053] S12: If it is a virtual machine snapshot, modify the first identifier of the initial virtual machine corresponding to the virtual machine snapshot to obtain the reconstructed snapshot. The initial virtual machine has a first identifier and a second identifier. The first identifier is the universally unique identifier of the initial virtual machine, and the second identifier is the unique identifier of the initial virtual machine in the OpenStack platform.

[0054] S13: Create a rebuild virtual machine based on the rebuild snapshot, and call the virtual machine initialization process to reset the password of the rebuild virtual machine.

[0055] In the OpenStack system, to ensure that each virtual machine can function properly, it is necessary to create a different unique identifier for each virtual machine. The Cloud-Init runtime log is a log file generated based on this unique identifier. To address this issue, this embodiment sets an additional identifier (UID) in the virtual machine. The first identifier is the initial virtual machine's universally unique identifier (UUID), so that the Cloud-Init program can run in a newly created virtual machine after the first identifier changes. The second identifier is the initial virtual machine's unique identifier (UID) within the OpenStack platform, allowing users to access the virtual machine in the OpenStack platform using the second identifier.

[0056] In practice, the first identifier is used to ensure that underlying applications and processes in the virtual machine system can execute according to the first identifier, thereby ensuring that the virtual machine can function normally. The second identifier is a unique identifier for the virtual machine within the OpenStack platform, used by users or administrators to operate on the virtual machine processes through the OpenStack platform.

[0057] In practice, the second identifier UID is used to uniquely identify a virtual machine. When the virtual machine is not rebuilt, the value of this field is the same as the original first identifier UUID. At this time, the two fields can identify a virtual machine at the same time. When the virtual machine performs a rebuild operation, the original first identifier UUID value is modified to a new UUID value, while the second identifier UID remains unchanged. In this way, the virtual machine has a new UUID value after rebuilding. When the virtual machine recognizes the new UUID value, it will normally execute the password reset task. The password reset can be successfully executed, thus realizing the function of resetting the virtual machine password during the rebuild process.

[0058] Figure 2 A timing diagram for creating a virtual machine based on a snapshot, as provided in this application embodiment, is shown below. Figure 2 As shown, the process of creating a virtual machine includes:

[0059] S20: Obtain the reconstruction command sent by the user, and determine the target virtual machine corresponding to the command based on the first identifier UUID in the user's reconstruction command, and obtain the relevant information of the target virtual machine;

[0060] S21: Obtain the target image required to rebuild the virtual machine according to the rebuild command. The target image includes a blank image and a virtual machine snapshot.

[0061] S22: Update the Instance table of the OpenStack platform;

[0062] S23: Add a UID field and related interface functions to the instance table;

[0063] S24: Send an RPC request to the Nova_scheduler process to select the compute node to mount and rebuild the virtual machine;

[0064] S25: Synchronize the updated Instance table to the Nova_compute process;

[0065] S26: Obtain the image file corresponding to the first identifier UUID, and send the image file to glance;

[0066] S27: Update the task list (task_state) of the Nova_compute process;

[0067] S28: Destroy the instance table in the libvirt process;

[0068] S29: Update the memory table (vm_state) and task table (task_state) in the OpenStack platform database.

[0069] This embodiment provides a virtual machine password reset method applied to virtual machines under the OpenStack platform. The method includes: when a rebuild command is detected, obtaining a rebuild image file corresponding to the rebuild command to rebuild the virtual machine based on the rebuild image file; determining whether the rebuild image file is a virtual machine snapshot; if it is, modifying the first identifier of the virtual machine corresponding to the virtual machine snapshot to obtain a rebuild snapshot. The virtual machine has a first identifier and a second identifier. The first identifier is a universally unique identifier for the initial virtual machine, allowing the Cloud-Init program to run in the newly created virtual machine after the first identifier changes; the second identifier is a unique identifier for the initial virtual machine within the OpenStack platform, allowing users to call the virtual machine in the OpenStack platform using the second identifier. A rebuilt virtual machine is created based on the rebuild snapshot, and the virtual machine initialization process is invoked to reset the password of the rebuilt virtual machine. Therefore, the virtual machine password reset method provided in this application, by setting a first identifier and a second identifier inside the virtual machine and modifying the first identifier when creating a rebuilt virtual machine using an initial virtual machine image snapshot, enables the Cloud-Init process to run in the rebuilt virtual machine to reset the password.

[0070] In a preferred embodiment, before modifying the first identifier of the initial virtual machine corresponding to the virtual machine snapshot to obtain the reconstructed snapshot, the method further includes:

[0071] Determine whether the Nova database on the OpenStack platform contains a second identifier;

[0072] If a second identifier exists, then the step of modifying the first identifier of the initial virtual machine corresponding to the virtual machine snapshot to obtain the step of rebuilding the snapshot is performed.

[0073] If a second identifier does not exist, it will be added to the nova database, with its initial value being a universally unique identifier. An interface function will be created based on this second identifier so that the OpenStack platform can call the corresponding virtual machine using it.

[0074] In a preferred embodiment, after modifying the first identifier of the initial virtual machine corresponding to the virtual machine snapshot to obtain the reconstructed snapshot, the method further includes:

[0075] Update the first identifier in the relational database, where the relational database is a database that stores the correspondence between the first identifier and the second identifier.

[0076] In practice, the OpenStack platform uses UID to call virtual machines with corresponding UUIDs to execute tasks. Therefore, the mapping between UIDs and UUIDs needs to be stored in a relational database to ensure that the virtual machines can work properly.

[0077] Furthermore, the process of adding a second identifier, UID, to the virtual machine includes:

[0078] (1) Extend the OpenStack nova database by adding a UID field to the instances table of the OpenStack nova database to uniquely identify a virtual machine. Its initial value is the value of the first identifier UUID of the current virtual machine.

[0079] (2) Extend the virtual machine nova service data operation interface to adapt to the extended instances table, and add new interfaces to the instances table to ensure that OpenStack platform users or administrators can read and write table records through the second identifier UID field.

[0080] (3) Extend the object item of the nova project, add a new attribute second identifier UID to the Instance object class, and add the corresponding interface get_by_UID. This interface can ensure that the virtual machine instance can be obtained through the UID of the user or administrator of the OpenStack platform.

[0081] (4) Modify the OpenStack nova_api service to rebuild the virtual machine interface. In the original processing flow, add the following processing logic: regenerate the virtual machine UUID and write the new UUID to the database for storage.

[0082] (5) Modify the remaining part of the rebuild process, changing the logic of using UUID to identify the virtual machine to use the new field UID.

[0083] (6) Modify the interfaces for querying, modifying, deleting, pausing, suspending, and resetting virtual machines to allow users to perform the above operations on virtual machines using the virtual machine UID.

[0084] (7) Modify the virtual machine creation interface. When creating a virtual machine, use the first identifier UUID of the virtual machine as the value of the second identifier UID and save it to the database. By default, the values ​​of the first identifier UUID and the second identifier UID are the same. When the virtual machine is rebuilt, the value of the first identifier UUID will be modified to make the values ​​of the first identifier UUID and the second identifier UID different.

[0085] Based on the above embodiments, resetting and rebuilding the virtual machine password by calling the virtual machine initialization process includes: executing the Cloud-Init process to obtain the password reset instruction entered by the user; and updating the password of the rebuilt virtual machine according to the password reset instruction.

[0086] Cloud-init is a tool specifically developed for initializing virtual machines in cloud environments. It reads relevant data from various data sources and configures the virtual machine accordingly. Common data sources include cloud platform metadata services and ConfigDrive. Common configurations include setting the virtual machine's hostname, hosts file, username and password, updating the apt-get local cache, and adjusting the file system size.

[0087] It's important to note that to ensure normal user operation, it's also necessary to verify whether the password was successfully reset. After updating and rebuilding the virtual machine's password according to the password reset command, the process also includes: determining whether a password reset success signal from the Cloud-Init process was received within a threshold time; if no password reset success signal is received, an alert is sent to administrators.

[0088] It should be noted that, in order to prevent data loss during the use of virtual machines, in addition to the above embodiments, it is also necessary to create snapshots for each virtual machine in each backup cycle to back up data and files.

[0089] In a preferred embodiment, before obtaining the reconstruction image file corresponding to the reconstruction instruction, the method further includes: determining whether the current time meets a preset condition; if the preset condition is met, creating a virtual machine image snapshot for the initial virtual machine. The backup period can be a fixed period set by the user, or a variable period determined based on data changes or business pressure (e.g., when data changes exceed a threshold, or when business pressure exceeds a threshold, a virtual machine snapshot needs to be created to back up the data to prevent data loss due to virtual machine failure).

[0090] The virtual machine password reset method has been described in detail in the above embodiments. This application also provides embodiments corresponding to the virtual machine password reset device. It should be noted that this application describes the embodiments of the device part from two perspectives: one is based on the functional module, and the other is based on the hardware.

[0091] Figure 3 This application provides a structural diagram of a virtual machine password reset device, applied to a virtual machine on an OpenStack platform, comprising:

[0092] The acquisition module 10 is used to acquire the reconstructed image file corresponding to the reconstruction instruction when a reconstruction instruction is detected.

[0093] Module 11 is used to determine whether the reconstructed image file is a virtual machine snapshot;

[0094] Modify module 12, which is used to modify the first identifier of the initial virtual machine corresponding to the virtual machine snapshot to obtain a reconstructed snapshot if it is a virtual machine snapshot. The initial virtual machine has a first identifier and a second identifier. The first identifier is a universally unique identifier of the initial virtual machine, and the second identifier is a unique identifier of the initial virtual machine in the OpenStack platform.

[0095] Create module 13 to create a rebuild virtual machine based on the rebuild snapshot and call the virtual machine initialization process to reset the password of the rebuild virtual machine.

[0096] In addition, the virtual machine password reset device provided in this embodiment also includes: an identifier update module, an identifier judgment module, a database update module, a snapshot creation module, and an early warning module;

[0097] The identifier update module is used to update the first identifier in the relational database, where the relational database is a database that stores the correspondence between the first identifier and the second identifier.

[0098] The identifier determination module is used to determine whether the Nova database of the OpenStack platform includes a second identifier; if a second identifier exists, the module executes the step of modifying the first identifier of the initial virtual machine corresponding to the virtual machine snapshot to obtain the step of rebuilding the snapshot.

[0099] The database update module is used to add a second identifier to the nova database if the second identifier does not exist. The initial value of the second identifier is a universally unique identifier. It also creates interface functions based on the second identifier so that the OpenStack platform can call the corresponding virtual machine through the second identifier.

[0100] The snapshot creation module is used to determine whether the current time meets the preset conditions; if the preset conditions are met, a virtual machine image snapshot is created for the initial virtual machine.

[0101] The early warning module is used to determine whether a password reset success signal from the Cloud-Init process has been received within a threshold time. If no password reset success signal is received, an early warning message is sent to the administrator.

[0102] Since the embodiments of the apparatus and the embodiments of the method correspond to each other, please refer to the description of the embodiments of the method for the embodiments of the apparatus, which will not be repeated here.

[0103] This embodiment provides a virtual machine password reset device applied to virtual machines under the OpenStack platform. The device includes: when a rebuild command is detected, obtaining a rebuild image file corresponding to the rebuild command to rebuild the virtual machine based on the rebuild image file; determining whether the rebuild image file is a virtual machine snapshot; if it is, modifying the first identifier of the virtual machine corresponding to the virtual machine snapshot to obtain a rebuild snapshot. The virtual machine has a first identifier and a second identifier. The first identifier is a universally unique identifier for the initial virtual machine, allowing the Cloud-Init program to run in the newly created virtual machine after the first identifier changes; the second identifier is a unique identifier for the initial virtual machine in the OpenStack platform, allowing users to call the virtual machine in the OpenStack platform using the second identifier. The rebuilt virtual machine is created based on the rebuild snapshot, and the virtual machine initialization process is invoked to reset the password of the rebuilt virtual machine. Therefore, the virtual machine password reset device provided in this application, by setting a first identifier and a second identifier inside the virtual machine and modifying the first identifier when creating the rebuilt virtual machine using the initial virtual machine image snapshot, enables the Cloud-Init process to run in the rebuilt virtual machine to reset the password.

[0104] Figure 4 A structural diagram of a virtual machine password reset device provided in another embodiment of this application is shown below. Figure 4As shown, the virtual machine password reset device includes: a memory 20 for storing computer programs;

[0105] The processor 21 is used to implement the steps of the virtual machine password reset method as described in the above embodiment when executing a computer program.

[0106] The server provided in this embodiment may include, but is not limited to, smartphones, tablets, laptops, or desktop computers.

[0107] The processor 21 may include one or more processing cores, such as a quad-core processor or an octa-core processor. The processor 21 may be implemented using at least one of the following hardware forms: Digital Signal Processor (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 21 may also include a main processor and a coprocessor. The main processor, also known as the Central Processing Unit (CPU), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 21 may integrate a Graphics Processing Unit (GPU), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, the processor 21 may also include an Artificial Intelligence (AI) processor, which is used to handle computational operations related to machine learning.

[0108] The memory 20 may include one or more computer-readable storage media, which may be non-transitory. The memory 20 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In this embodiment, the memory 20 is used to store at least the following computer program 201, which, after being loaded and executed by the processor 21, is capable of implementing the relevant steps of the virtual machine password reset method disclosed in any of the foregoing embodiments. In addition, the resources stored in the memory 20 may also include an operating system 202 and data 203, and the storage method may be temporary or permanent storage. The operating system 202 may include Windows, Unix, Linux, etc. The data 203 may include, but is not limited to, virtual machine image files, a first identifier, a second identifier, etc.

[0109] In some embodiments, the virtual machine password reset may also include a display screen 22, an input / output interface 23, a communication interface 24, a power supply 25, and a communication bus 26.

[0110] Those skilled in the art will understand that Figure 4 The structure shown does not constitute a limitation on the virtual machine password reset device and may include more or fewer components than illustrated.

[0111] The virtual machine password reset device provided in this application includes a memory and a processor. When the processor executes a program stored in the memory, it can implement the following method:

[0112] When a rebuild command is detected, the rebuild image file corresponding to the rebuild command is obtained;

[0113] Determine whether the reconstructed image file is a virtual machine snapshot;

[0114] If it is a virtual machine snapshot, modify the first identifier of the initial virtual machine corresponding to the virtual machine snapshot to obtain the reconstructed snapshot. The initial virtual machine has a first identifier and a second identifier. The first identifier is a universally unique identifier of the initial virtual machine, and the second identifier is a unique identifier of the initial virtual machine in the OpenStack platform.

[0115] Create a rebuilt virtual machine based on the rebuilt snapshot, and call the virtual machine initialization process to reset the password of the rebuilt virtual machine.

[0116] This embodiment provides a virtual machine password reset device applied to virtual machines under the OpenStack platform. The device includes: when a rebuild command is detected, obtaining a rebuild image file corresponding to the rebuild command to rebuild the virtual machine based on the rebuild image file; determining whether the rebuild image file is a virtual machine snapshot; if it is, modifying the first identifier of the virtual machine corresponding to the virtual machine snapshot to obtain a rebuild snapshot. The virtual machine has a first identifier and a second identifier. The first identifier is a universally unique identifier for the initial virtual machine, allowing the Cloud-Init program to run in the newly created virtual machine after the first identifier changes; the second identifier is a unique identifier for the initial virtual machine in the OpenStack platform, allowing users to call the virtual machine in the OpenStack platform using the second identifier. The rebuilt virtual machine is created based on the rebuild snapshot, and the virtual machine initialization process is invoked to reset the password of the rebuilt virtual machine. Therefore, the virtual machine password reset device provided in this application, by setting a first identifier and a second identifier inside the virtual machine and modifying the first identifier when creating the rebuilt virtual machine using the initial virtual machine image snapshot, enables the Cloud-Init process to run in the rebuilt virtual machine to reset the password.

[0117] Finally, this application also provides an embodiment corresponding to a computer-readable storage medium. The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps described in the above method embodiments.

[0118] It is understood that if the methods in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and executes all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0119] The virtual machine password reset method, apparatus, and medium provided in this application have been described in detail above. The various embodiments in the specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section. It should be noted that those skilled in the art can make several improvements and modifications to this application without departing from the principles of this application, and these improvements and modifications also fall within the protection scope of the claims of this application.

[0120] It should also be noted that, in this specification, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

Claims

1. A virtual machine password reset method, characterized by, Virtual machines used on the OpenStack platform include: When a reconstruction command is detected, the reconstruction image file corresponding to the reconstruction command is obtained; Determine whether the reconstructed image file is a virtual machine snapshot; If it is a virtual machine snapshot, modify the first identifier of the initial virtual machine corresponding to the virtual machine snapshot to obtain a reconstructed snapshot. The initial virtual machine has a first identifier and a second identifier. The first identifier is a universally unique identifier of the initial virtual machine, and the second identifier is a unique identifier of the initial virtual machine in the OpenStack platform. The OpenStack platform can call the corresponding virtual machine through the second identifier. A rebuilt virtual machine is created based on the rebuilt snapshot, and the virtual machine initialization process is invoked to reset the password of the rebuilt virtual machine; After the step of modifying the first identifier of the initial virtual machine corresponding to the virtual machine snapshot to obtain the reconstructed snapshot, the method further includes: Update the first identifier in the relational database, wherein the relational database is a database that stores the correspondence between the first identifier and the second identifier.

2. The virtual machine password reset method of claim 1, wherein, The step of invoking the virtual machine initialization process to reset the password of the rebuilt virtual machine includes: Execute the Cloud-Init process to retrieve the password reset command entered by the user; The password of the rebuilt virtual machine is updated according to the password reset instruction.

3. The virtual machine password reset method of claim 1, wherein, Before the step of modifying the first identifier of the initial virtual machine corresponding to the virtual machine snapshot to obtain the reconstructed snapshot, the method further includes: Determine whether the second identifier is included in the nova database of the OpenStack platform; If the second identifier exists, then the step of modifying the first identifier of the initial virtual machine corresponding to the virtual machine snapshot to obtain the reconstructed snapshot is performed.

4. The virtual machine password reset method of claim 3, wherein, After the step of determining whether the Nova database of the OpenStack platform includes the second identifier, the method further includes: If the second identifier does not exist, then add the second identifier to the nova database, with the initial value of the second identifier being the universally unique identifier; An interface function is created based on the second identifier, enabling the OpenStack platform to call the corresponding virtual machine through the second identifier.

5. The virtual machine password reset method of claim 1, wherein, Before the step of obtaining the reconstruction image file corresponding to the reconstruction instruction, the method further includes: Determine whether the current time meets the preset conditions; If the preset conditions are met, create the virtual machine image snapshot for the initial virtual machine.

6. The virtual machine password reset method of claim 2, wherein, After the step of updating the password of the rebuilt virtual machine according to the password reset instruction, the method further includes: Determine whether a password reset success signal from the Cloud-Init process has been received within the threshold time. If the password reset success signal is not received, a warning message will be sent to the administrator.

7. A virtual machine password reset device, characterized in that, Virtual machines used on the OpenStack platform include: The acquisition module is used to acquire the reconstructed image file corresponding to the reconstruction instruction when a reconstruction instruction is detected; The determination module is used to determine whether the reconstructed image file is a virtual machine snapshot; The modification module is used to modify the first identifier of the initial virtual machine corresponding to the virtual machine snapshot to obtain a reconstructed snapshot if it is the virtual machine snapshot. The initial virtual machine has the first identifier and the second identifier. The first identifier is a universally unique identifier of the initial virtual machine, and the second identifier is a unique identifier of the initial virtual machine in the OpenStack platform. The OpenStack platform can call the corresponding virtual machine through the second identifier. A creation module is used to create a reconstructed virtual machine based on the reconstructed snapshot and to call the virtual machine initialization process to reset the password of the reconstructed virtual machine; Also includes: An identifier update module is used to update a first identifier in a relational database, wherein the relational database is a database that stores the correspondence between the first identifier and the second identifier.

8. A virtual machine password reset apparatus, comprising: Includes memory used to store computer programs; A processor, configured to implement the steps of the virtual machine password reset method as described in any one of claims 1 to 6 when executing the computer program.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the virtual machine password reset method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Password updating method and device for virtual machine

    CN111639329A

  • Virtual machine initialization method, computer equipment and storage medium

    CN114138407A