Method and device for docking virtual machine with storage device, electronic device and storage medium

By automatically creating a virtual machine on the server side and generating a Fibre Channel link based on the identifier matching mechanism, the problem of accuracy and low efficiency when the virtual machine is connected to storage devices is solved, and an efficient and stable environment is achieved.

CN120578342APending Publication Date: 2025-09-02INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510666268.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-22
Publication Date
2025-09-02

AI Technical Summary

Technical Problem

In the test cluster environment, in the prior art, virtual machines docking storage devices have problems with low docking accuracy and efficiency. Especially in the environment of multiple servers or multiple different images, manual operations are time-consuming and error-prone, resulting in confusion in host docking and cannot guarantee accuracy.

Method used

Based on the server-side resource size and number of Fibre Channel ports, a virtual machine is automatically created, and a Fibre Channel link is generated through the identifier matching mechanism to dock the storage device. After completion, the docking result is verified to ensure that the Fibre Channel host is created and the target volume is mapped after the identifier matching is successful.

Benefits of technology

It improves the efficiency and accuracy of virtual machines docking storage devices, reduces human errors, improves the convenience and stability of environmental construction, and saves labor costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120578342A_ABST
    Figure CN120578342A_ABST
Patent Text Reader

Abstract

The invention discloses a method and device for docking a virtual machine with a storage device, electronic equipment and a storage medium, and relates to the technical field of computers.The virtual machine is automatically created based on the resource size of a server side and the number of optical fiber channel ports, and an optical fiber channel link is generated based on an identifier matching mechanism to be docked with the storage device. And after the docking is completed, the docking result verification is performed, so that the docking efficiency and accuracy can be improved, the manpower can be saved, environmental errors or abnormities caused by human conditions can be prevented, and the convenience and stability of environment construction can be improved under the scene of docking multiple different versions of virtual machines.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method, apparatus, electronic device, and storage medium for docking a virtual machine with a storage device. Background Art

[0002] Currently, in a clustered test environment, if a storage device needs to connect to multiple servers or multiple virtual machine environments with different images on a single server for compatibility testing, it is necessary to manually allocate the virtual machine's CPU (Central Processing Unit), memory, and hard disk resources to each image on the server side through ESXi (a management tool specifically designed for running virtual machines, deployed on physical machines, and on which virtual machines can be installed). Furthermore, when connecting to the storage device, each server also needs to add a different FC (a high-speed transmission protocol designed specifically for storage area networks) card device port to ensure that the WWPN (port unique identifier) ​​does not conflict. Repeatedly assigning the same FC card device port to a virtual machine will result in addition failure. Manual creation of multiple virtual machines is not only time-consuming and error-prone, but also prone to parameter configuration errors when there are many FC links connected to the storage and many FC hosts created, which can easily lead to host connection confusion and other problems. This increases manpower and time costs while failing to guarantee connection accuracy. Summary of the Invention

[0003] The present application provides a method, apparatus, electronic device, and storage medium for docking a virtual machine with a storage device, in order to at least solve the problems of low docking accuracy and efficiency in related technologies.

[0004] This application provides a method for connecting a virtual machine to a storage device, including:

[0005] Based on the resource size and the number of Fibre Channel ports on the server side, create at least one virtual machine and assign a target Fibre Channel port to the virtual machine;

[0006] Obtaining a first identifier corresponding to the target Fibre Channel port and a second identifier of the Fibre Channel port of the storage device;

[0007] In response to a successful match between the first identifier and the second identifier, docking the virtual machine and the storage device and creating a Fibre Channel host, marking the Fibre Channel host based on a target identifier, the target identifier being the same as the first identifier or the second identifier;

[0008] In response to the Fibre Channel host being in a normal working state, creating a target volume on the storage device and mapping the target volume to the Fibre Channel host containing the target identifier;

[0009] Determine the connection result between the virtual machine and the storage device based on the mapping result of the target volume.

[0010] The present application also provides a device for connecting a virtual machine to a storage device, comprising:

[0011] A first creation module is configured to create at least one virtual machine based on the resource size and the number of fiber channel ports on the server side, and allocate a target fiber channel port to the virtual machine;

[0012] an acquisition module, configured to acquire a first identifier corresponding to a target Fibre Channel port and a second identifier of a Fibre Channel port of a storage device;

[0013] a second creation module, configured to, in response to a successful match between the first identifier and the second identifier, dock the virtual machine and the storage device, create a Fibre Channel host, and tag the Fibre Channel host based on a target identifier, the target identifier being the same as the first identifier or the second identifier;

[0014] a third creation module, configured to create a target volume on the storage device in response to the Fibre Channel host being in a normal working state, and map the target volume to the Fibre Channel host containing the target identifier;

[0015] The docking module is used to determine the docking result between the virtual machine and the storage device according to the mapping result of the target volume.

[0016] The present application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the following steps of a method for docking a virtual machine with a storage device when executing the computer program:

[0017] Based on the resource size and the number of Fibre Channel ports on the server side, create at least one virtual machine and assign a target Fibre Channel port to the virtual machine;

[0018] Obtaining a first identifier corresponding to the target Fibre Channel port and a second identifier of the Fibre Channel port of the storage device;

[0019] In response to a successful match between the first identifier and the second identifier, docking the virtual machine and the storage device and creating a Fibre Channel host, marking the Fibre Channel host based on a target identifier, the target identifier being the same as the first identifier or the second identifier;

[0020] In response to the Fibre Channel host being in a normal working state, creating a target volume on the storage device and mapping the target volume to the Fibre Channel host containing the target identifier;

[0021] Determine the connection result between the virtual machine and the storage device based on the mapping result of the target volume.

[0022] The present application also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the following steps of a method for docking a virtual machine with a storage device are implemented:

[0023] Based on the resource size and the number of Fibre Channel ports on the server side, create at least one virtual machine and assign a target Fibre Channel port to the virtual machine;

[0024] Obtaining a first identifier corresponding to the target Fibre Channel port and a second identifier of the Fibre Channel port of the storage device;

[0025] In response to a successful match between the first identifier and the second identifier, docking the virtual machine and the storage device and creating a Fibre Channel host, marking the Fibre Channel host based on a target identifier, the target identifier being the same as the first identifier or the second identifier;

[0026] In response to the Fibre Channel host being in a normal working state, creating a target volume on the storage device and mapping the target volume to the Fibre Channel host containing the target identifier;

[0027] Determine the connection result between the virtual machine and the storage device based on the mapping result of the target volume.

[0028] The present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the following steps of the method for docking a virtual machine with a storage device:

[0029] Based on the resource size and the number of Fibre Channel ports on the server side, create at least one virtual machine and assign a target Fibre Channel port to the virtual machine;

[0030] Obtaining a first identifier corresponding to the target Fibre Channel port and a second identifier of the Fibre Channel port of the storage device;

[0031] In response to a successful match between the first identifier and the second identifier, docking the virtual machine and the storage device and creating a Fibre Channel host, marking the Fibre Channel host based on a target identifier, the target identifier being the same as the first identifier or the second identifier;

[0032] In response to the Fibre Channel host being in a normal working state, creating a target volume on the storage device and mapping the target volume to the Fibre Channel host containing the target identifier;

[0033] Determine the connection result between the virtual machine and the storage device based on the mapping result of the target volume.

[0034] This application automatically creates a virtual machine based on the resource size and number of Fibre Channel ports on the server side and generates a Fibre Channel link based on an identifier matching mechanism to connect to the storage device. After the connection is completed, the connection result is verified, thereby improving the connection efficiency and accuracy in the scenario of connecting multiple virtual machines of different versions, saving manpower, preventing environmental errors or anomalies caused by human factors, and improving the convenience and stability of environment construction. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0036] Figure 1 An application environment diagram of a method for connecting a virtual machine to a storage device is provided for an embodiment of the present application;

[0037] Figure 2 A schematic diagram of the overall process of a method for connecting a virtual machine to a storage device is provided for an embodiment of the present application;

[0038] Figure 3 A schematic diagram of the physical topology structure of a method for connecting a virtual machine to a storage device is provided for an embodiment of the present application;

[0039] Figure 4 Another overall flow chart of a method for connecting a virtual machine to a storage device is provided for an embodiment of the present application;

[0040] Figure 5 A structural block diagram of an apparatus for connecting a virtual machine to a storage device is provided for an embodiment of the present application;

[0041] Figure 6 FIG. 1 is a diagram showing the internal structure of an electronic device in one embodiment. DETAILED DESCRIPTION

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

[0043] It should be noted that, in the description of this application, the terms "comprises," "includes," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. The terms "first," "second," etc., in this application are used to distinguish similar objects, and are not used to describe a particular order or sequence.

[0044] It should be noted that the terms "S1", "S2", etc. are used only for the purpose of describing the steps and do not specifically refer to the order or sequence, nor are they used to limit this application. They are merely for the convenience of describing the method of this application and should not be understood as indicating the order of the steps. In addition, the technical solutions between the various embodiments can be combined with each other, but this must be based on the fact that ordinary technicians in this field can implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.

[0045] At present, various storage devices need to be connected to various operating system versions for storage testing in order to ensure the compatibility of the device environment. Virtual machines simulate the hardware operating environment of physical computers through software, allowing multiple operating systems to run simultaneously on the same physical machine. Virtual machines abstract physical resources (such as CPU, memory, storage, network, etc.) into logical resources through virtualization technology, providing each virtual machine with an independent computing environment. Therefore, virtual machines are isolated from each other and can run different operating systems and applications. The main advantages of virtual machines are high resource utilization, strong flexibility and easy management. They are particularly suitable for scenarios such as server virtualization, construction of development and testing environments, and application isolation. However, their performance is slightly reduced compared to operating systems running directly on hardware. According to background technology, when creating multiple virtual machines based on manual operations, it is not only time-consuming and parameter configuration is prone to errors, but also when there are many FC links for storage connection and FC hosts created, a series of problems such as host connection confusion are prone to occur. While increasing manpower and time costs, the accuracy of connection cannot be guaranteed.

[0046] To solve the above technical problems, the present application provides a method, apparatus, electronic device and storage medium for docking a virtual machine with a storage device. The method automatically creates a virtual machine based on the resource size and the number of Fibre Channel ports on the server side and generates a Fibre Channel link to dock the storage device based on an identifier matching mechanism. The docking result is verified after the docking is completed, thereby improving the docking efficiency and accuracy in the scenario of docking multiple different versions of virtual machines, saving manpower, preventing environmental errors or anomalies caused by human factors, and improving the convenience and stability of environment construction.

[0047] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.

[0048] The method for connecting a virtual machine to a storage device provided in this application can be applied to Figure 1 In the application environment shown, the terminal 102 communicates with a data processing platform provided on the server 104 via a network. The terminal 102 may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, and portable wearable devices. The server 104 may be implemented as an independent server or a server cluster consisting of multiple servers.

[0049] like Figure 2 As shown, the embodiment of the present application provides a method for connecting a virtual machine to a storage device, and the method is applied to Figure 1 The following steps are used as an example to illustrate the terminal in the figure:

[0050] S1: Based on the resource size and number of Fibre Channel ports on the server, create at least one virtual machine and allocate a target Fibre Channel port to the virtual machine.

[0051] It should be noted that the resource size on the server side usually refers to the resources that the server side can allocate for creating virtual machines. The Fibre Channel port refers to the FC (Fibre Channel, a high-speed transmission protocol designed specifically for storage area networks, mainly used for data transmission between storage devices) port. Virtual machines are generally created on ESXi (a management tool designed specifically for running virtual machines, deployed on physical machines, on which virtual machines can be installed). A virtual machine refers to a software simulation of the hardware operating environment of a physical computer, allowing multiple operating systems to run simultaneously on the same physical machine.

[0052] S2: Obtain a first identifier corresponding to the target Fibre Channel port and a second identifier of the Fibre Channel port of the storage device.

[0053] It should be noted that the identifier refers to a unique identifier of the port, wwpn (world wide port number). Both the server side and the storage device side are provided with multiple FC ports, and each FC port is provided with a unique identifier, wwpn.

[0054] S3: In response to the first identifier and the second identifier successfully matching, docking the virtual machine and the storage device, creating a Fibre Channel host, and marking the Fibre Channel host based on a target identifier, where the target identifier is the same as the first identifier or the second identifier.

[0055] It should be noted that the criterion for successful matching refers to the first identifier and the second identifier being the same; docking a virtual machine and a storage device refers to generating an FC communication link through the FC port corresponding to the first identifier and the FC port corresponding to the second identifier; the target identifier is the same as the first identifier and the second identifier, that is, using wwpn, a Fibre Channel host with the same name is created; a Fibre Channel host refers to an FC host, which refers to a host device that uses Fibre Channel (FC) technology, and the FC host connects to the storage device through Fibre Channel (FC) technology.

[0056] S4: In response to the Fibre Channel host being in a normal working state, creating a target volume on the storage device and mapping the target volume to the Fibre Channel host including the target identifier.

[0057] It should be noted that the Fibre Channel host being in normal working status means that the Fibre Channel host and the storage device can be connected normally, and the target volume refers to a normal volume, that is, a basic storage unit in the storage system. The normal volume is mapped to the Fibre Channel host containing the target identifier through the corresponding script.

[0058] S5: Determine the connection result between the virtual machine and the storage device based on the mapping result of the target volume.

[0059] It should be noted that the docking results include successful docking and failed docking. After the volume mapping is successful, the volume mapped to the Fibre Channel host is scanned on the virtual machine side to determine whether the virtual machine and the storage device are successfully docked.

[0060] In the above implementation, a virtual machine is automatically created based on the resource size and the number of Fibre Channel ports on the server side, and a Fibre Channel link is generated based on an identifier matching mechanism to connect to the storage device. After the connection is completed, the connection result is verified. This can improve the connection efficiency and accuracy in the scenario of connecting to multiple versions of virtual machines, save manpower, prevent environmental errors or anomalies caused by human factors, and improve the convenience and stability of environment construction.

[0061] In some embodiments, Figure 4 As shown, before creating at least one virtual machine based on the resource size and the number of Fibre Channel ports on the server side, the following steps are also included:

[0062] Get the standardized topology;

[0063] Based on a standardized topology and target network environment, interconnect the server, storage devices, and Fibre Channel switches. The target network environment means that the three ends are in the same network environment.

[0064] In response to successful interconnection, a management address is set for the node in the storage device and the node status is detected. The address refers to the IP address.

[0065] In response to the node being in the Candidate Active state, configure the node management address, storage cluster address, and server-side virtual machine management tool address in the automation platform or target configuration file. In the Elasticsearch (ES) cluster, the Candidate Active state refers to the state in which a node may become a master node during the election process.

[0066] In response to the configuration being completed, the method further includes:

[0067] Based on the node management address, the storage cluster address, and the server-side virtual machine management tool address, respectively, obtain the node hardware configuration information and the server-side hardware configuration information; based on the node hardware configuration information and the server-side hardware configuration information, determine whether the active Fibre Channel port of the storage device and the active Fibre Channel port of the server are in the same communication area, where the same communication area refers to the same zone;

[0068] In response to the active fiber channel port of the storage device and the active fiber channel port of the server being in the same communication zone, an image required for creating a virtual machine, ie, a virtual machine image, is obtained.

[0069] Specifically, before executing the virtual machine automatic deployment script, you need to first interconnect the storage devices, server and switch devices according to the standard topology structure so that all devices are in a network environment, such as Figure 3As shown, the switch device refers to the FC switch, especially the zone division of the switch port must ensure that all configured node interconnection IPs are interoperable, the IP used for front-end host services and the host IP are interoperable, FC wwpn is interoperable, and management IPs are set for all nodes for remote SSH (a security protocol used as the main means of remotely connecting to Linux servers) access and login, and the status of all nodes is in the candidate active state, and no other errors occur in the nodes. Furthermore, all node management IP information (nodes such as Node1, Node2), storage cluster IP, and esxi on the server to be configured for storage are required. The IP is configured in a configuration file that can be read by the automation platform or script. After automatically obtaining this information, it can be used for node login and business configuration detection. Furthermore, each node can be remotely logged in to obtain the current hardware configuration of each node through the query command supported by the cluster system, and the standardization of the current hardware configuration can be checked. Among them, the standard configuration requirements are divided into hard specifications and soft specifications. Hard specifications are specifications that must be met, and soft specifications do not affect subsequent functional tests and can be selectively ignored. Log in to the esxi node of the server and obtain the hardware configuration of the server side, mainly the FC card status, through the query command supported by the system. Log in to the FC switch and check the configuration information viewed by the above login node to confirm that the active FC port of the storage and the active FC port of the server are in the same zone, thereby ensuring that there are no abnormalities in the connection between the virtual machine created on esxi and the storage device.

[0070] In the above implementation, by detecting the virtual machine image uploaded to esxi and automatically configuring the resources required for virtual machine creation based on the number of builds and the virtual machine parameter setting values, and adding the FC card port required for the virtual machine to connect to the storage device, the reliability of the connection is guaranteed.

[0071] In some specific embodiments, creating at least one virtual machine based on the resource size and the number of Fibre Channel ports on the server side includes:

[0072] Upload the image required to create the virtual machine. The image required to create the virtual machine is usually an operating system installation disk image in ISO format. These image files contain the complete data content of the operating system. Users can use these files to install the operating system in the virtual machine without using physical media;

[0073] In response to the upload being completed, determining the number of images, and reading the resource size and the number of Fibre Channel ports on the server side;

[0074] Compare the number of mirrors to the number of Fibre Channel ports;

[0075] In response to the number of mirrors being greater than the number of Fibre Channel ports, issuing a prompt message to the user indicating that the number of Fibre Channel ports is insufficient;

[0076] In response to the number of images being less than or equal to the number of Fibre Channel ports, set the target value of the virtual machine parameters. The target value of the virtual machine parameters can be set according to actual requirements, and the preferred value is the minimum value of the virtual machine parameters, such as 1 core of CPU, 2G of memory, and 20G of hard disk capacity.

[0077] Based on the number of images and the target value of the virtual machine parameters, determine the size of the resources required to create a virtual machine.

[0078] Compare the size of the resources required to create a virtual machine with the size of the resources on the server side.

[0079] In response to the size of the resources required to create a virtual machine being greater than the size of the resources on the server side, send a prompt message of insufficient resources to the user.

[0080] In response to the size of the resources required to create a virtual machine being less than or equal to the size of the resources on the server side, create at least one virtual machine based on the virtual machine creation script.

[0081] Specifically, the server uploads the ISO image package required to build a virtual machine, and records the number of uploaded images each time an image is successfully uploaded. The total number of finally uploaded images is defined as A. According to the logged-in esxi host information, read the size of the resources of the server and the number of FC ports. Assume that the total number of CPU cores is B, the total memory is C, the total hard disk capacity is D, and the number of FC ports is E. Since each virtual machine needs to be assigned a FC port, it will be compared with the port number E after confirming the number A and give feedback. When A>E, it will prompt that the number of FC ports is insufficient according to the comparison result. When A<E and A=E, it will normally run the virtual machine creation script automatically. When creating a virtual machine, the script will set a minimum value of virtual machine parameters in advance, generally 1 core of CPU, 2G of memory, and 20G of hard disk capacity. According to this parameter and the number A of virtual machines to be created obtained in the above steps, calculate the total resources of the server required to create virtual machines automatically this time, which is 1xA of CPU cores, 2xA of memory, and 20xA of hard disk capacity. If the current resources of the server are insufficient, it will also return a prompt. If the resources are sufficient, it will continue to create virtual machines.

[0082] In the above embodiment, by uploading the environment image to be created to esxi, and then according to the number of uploaded images or the number of virtual machines to be created, calculate the CPU, memory, and hard disk resources allocated to the virtual machines according to the total resources of the server side to create virtual machines, avoiding waste of resources and improving the docking efficiency.

[0083] In some specific embodiments, obtain the resource requirements for virtual machine creation within multiple time periods, as well as the idle resources of the server.

[0084] The time period is divided into multiple time periods according to the time step. Both the time period and the time step can be set according to actual needs, such as a time period of one day and a time step of 30 minutes.

[0085] In response to the resource demand of the target time period being less than the idle resource amount of the server, marking the target time period;

[0086] In response to the target time period appearing more than a preset threshold number of times in multiple time periods, the target time period is marked twice. The preset threshold can be set according to actual needs, and is generally a value greater than half the number of time periods. For example, if the number of time periods is 20, the preset threshold is generally greater than 10.

[0087] In response to the current moment in the next time period belonging to the target time period, the automatic virtual machine creation script is directly run normally to create the virtual machine.

[0088] In the above embodiment, by predicting the time period when the resource demand is less than or equal to the idle resource amount of the server, the virtual machine creation script is directly run during the time period in the future time period, thereby improving the docking efficiency.

[0089] In some embodiments, assigning a target Fibre Channel port to a virtual machine includes:

[0090] In response to the virtual machine being created, allocating an unused address in the same network segment to the virtual machine, setting a name of the virtual machine based on an image name of the virtual machine, and simultaneously allocating a target Fibre Channel port to the virtual machine based on an active Fibre Channel port on the server, and determining a first identifier corresponding to the target Fibre Channel port;

[0091] In some embodiments, creating a Fibre Channel host, and marking the Fibre Channel host based on a target identifier includes:

[0092] In response to the first identifier and the second identifier successfully matching, determining the first identifier corresponding to the virtual machine according to the name of the virtual machine;

[0093] A target identifier is determined based on a first identifier corresponding to the virtual machine, and the Fibre Channel host is marked based on the target identifier, the first identifier and the second identifier being the same.

[0094] Specifically, after the virtual machine is installed, the unused IP address in the same network segment will be tested and assigned to the virtual machine. Then, log in to the virtual machine node, query the environment status and configuration, and rename and record the name of the virtual machine on esxi based on the queried virtual machine image name. Then, compare the wwpn of the FC port queried on the virtual machine with the FC active port detected by logging into the storage device configuration node. After querying the FC port with the same wwpn number, use this wwpn to create an FC host with the same name based on the recorded virtual machine name on esxi, and confirm that the host status is online.

[0095] In the above implementation, by detecting the FC card and port status on the server to ensure that the port is active and has an FC cable connection, the port is then allocated to each virtual machine in turn, and the allocated port is detected to prevent duplicate allocation, and wwpn confirmation is performed to ensure that the created FC host has no duplication or abnormalities, thereby improving the docking accuracy.

[0096] In some specific implementations, determining the result of the connection between the virtual machine and the storage device according to the mapping result of the target volume includes:

[0097] In response to the target volume being mapped, scanning the target volume based on the virtual machine;

[0098] If the target volume is not found within the preset time, the connection between the virtual machine and the storage device is determined to have failed. The preset time can be set according to actual needs, such as 3 minutes.

[0099] If the target volume is found within the preset time and the target volume's identification drive letter is the same as the identification drive letter recorded by the storage device, it is determined that the virtual machine and the storage device are successfully connected.

[0100] Specifically, after the FC host is created, the storage side verifies whether the host creation can be used normally. If it can be used normally, a normal volume is created in the storage device and the identification drive letter of the volume is recorded. Then, based on the script, the volume is mapped to the host created according to the virtual machine. After the volume mapping is completed, the storage volume is scanned on the virtual machine side and the timer starts. If the volume is not scanned within 3 minutes, it means that there is an abnormality in the connection between the created FC host and the virtual machine. The problem is reported and the active status of the FC ports of the server and the storage device is re-checked to see if the FC link fails. If the volume can be scanned on the virtual machine side within 3 minutes, the volume information is queried to see if the volume identification recorded by the storage device is the same. If the identification is consistent, it means that the host can connect the FC service with the virtual machine, indicating that the virtual machine is successfully connected to the storage device.

[0101] In the above implementation, after the construction is completed, the host is created on the storage device to realize the automated process of creating a whole set of virtual machines and docking with storage devices, fundamentally solving a series of problems such as time-consuming and labor-intensive creation of too many virtual machines, configuration errors, and host docking confusion, reducing errors caused by manual creation, ensuring the reliability of docking, and improving the convenience and stability of environment construction.

[0102] The above-mentioned method for docking a virtual machine with a storage device includes: creating at least one virtual machine based on the resource size and the number of Fibre Channel ports on the server side, and allocating a target Fibre Channel port to the virtual machine; obtaining a first identifier corresponding to the target Fibre Channel port and a second identifier of the Fibre Channel port of the storage device; in response to a successful match between the first identifier and the second identifier, docking the virtual machine with the storage device and creating a Fibre Channel host, marking the Fibre Channel host based on the target identifier, the target identifier being the same as the first identifier or the second identifier; in response to the Fibre Channel host being in a normal working state, creating a target volume on the storage device and mapping the target volume to the Fibre Channel host containing the target identifier; determining the docking result between the virtual machine and the storage device based on the mapping result of the target volume; the present application automatically creates a virtual machine based on the resource size and the number of Fibre Channel ports on the server side and generates a Fibre Channel link for docking with the storage device based on an identifier matching mechanism, and verifies the docking result after the docking is completed, thereby improving docking efficiency and accuracy in scenarios where multiple versions of virtual machines are docked, saving manpower, preventing environmental errors or anomalies caused by human factors, and improving the convenience and stability of environment setup.

[0103] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method.

[0104] It should be understood that although Figure 2-Figure 4 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. In addition, Figure 2-Figure 4 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0105] The embodiment of the present application also provides a device for connecting a virtual machine to a storage device, such as Figure 5 As shown, it includes a first creation module, an acquisition module, a second creation module, a third creation module and a docking module, wherein:

[0106] A first creation module is configured to create at least one virtual machine based on the resource size and the number of fiber channel ports on the server side, and allocate a target fiber channel port to the virtual machine;

[0107] an acquisition module, configured to acquire a first identifier corresponding to a target Fibre Channel port and a second identifier of a Fibre Channel port of a storage device;

[0108] a second creation module, configured to, in response to a successful match between the first identifier and the second identifier, dock the virtual machine and the storage device, create a Fibre Channel host, and tag the Fibre Channel host based on a target identifier, the target identifier being the same as the first identifier or the second identifier;

[0109] a third creation module, configured to create a target volume on the storage device in response to the Fibre Channel host being in a normal working state, and map the target volume to the Fibre Channel host containing the target identifier;

[0110] The docking module is used to determine the docking result between the virtual machine and the storage device according to the mapping result of the target volume.

[0111] As a preferred implementation, in an embodiment of the present invention, the device further includes a detection module, which is specifically configured to:

[0112] Get the standardized topology;

[0113] Interconnect servers, storage devices, and Fibre Channel switches based on standardized topology and target network environment;

[0114] In response to the successful interconnection, setting a management address for the node in the storage device and detecting the status of the node;

[0115] In response to the node being in a candidate active state, a node management address, a storage cluster address, and a server-side virtual machine management tool address are configured into an automation platform or a target configuration file.

[0116] As a preferred implementation, in an embodiment of the present invention, the detection module is further configured to:

[0117] Based on the node management address, storage cluster address, and server-side virtual machine management tool address, obtain the node hardware configuration information and server-side hardware configuration information respectively;

[0118] Determining, based on the hardware configuration information of the node and the hardware configuration information of the server, whether the active Fibre Channel port of the storage device and the active Fibre Channel port of the server are in the same communication zone;

[0119] In response to the active fiber channel port of the storage device and the active fiber channel port of the server being in the same communication zone, an image required for creating a virtual machine is obtained.

[0120] As a preferred implementation, in an embodiment of the present invention, the first creation module is specifically configured to:

[0121] Upload the image required to create the virtual machine;

[0122] In response to the upload being completed, determining the number of images, and reading the resource size and the number of Fibre Channel ports on the server side;

[0123] Compare the number of mirrors to the number of Fibre Channel ports;

[0124] In response to the number of mirrors being greater than the number of Fibre Channel ports, issuing a prompt message to the user indicating that the number of Fibre Channel ports is insufficient;

[0125] In response to the number of mirrors being less than or equal to the number of Fibre Channel ports, setting a target value for a virtual machine parameter;

[0126] Determine the resource size required to create the virtual machine based on the number of images and the target values ​​of the virtual machine parameters;

[0127] Compare the resource size required to create the virtual machine with the resource size on the server side;

[0128] In response to the resource size required for creating the virtual machine being greater than the resource size on the server side, a prompt message indicating insufficient resources is sent to the user;

[0129] In response to the resource size required for creating the virtual machine being smaller than or equal to the resource size of the server, at least one virtual machine is created based on the virtual machine creation script.

[0130] As a preferred implementation, in an embodiment of the present invention, the first creation module is further configured to:

[0131] In response to the virtual machine being created, an unused address in the same network segment is allocated to the virtual machine, and a name of the virtual machine is set based on the image name of the virtual machine. At the same time, a target Fibre Channel port is allocated to the virtual machine based on the active Fibre Channel port on the server side, and a first identifier corresponding to the target Fibre Channel port is determined.

[0132] As a preferred implementation, in an embodiment of the present invention, the second creation module is specifically configured to:

[0133] In response to the first identifier and the second identifier successfully matching, determining the first identifier corresponding to the virtual machine according to the name of the virtual machine;

[0134] A target identifier is determined based on a first identifier corresponding to the virtual machine, and the Fibre Channel host is marked based on the target identifier, the first identifier and the second identifier being the same.

[0135] As a preferred implementation, in an embodiment of the present invention, the docking module is specifically used to:

[0136] In response to the target volume being mapped, scanning the target volume based on the virtual machine;

[0137] If the target volume is not found within the preset time, it is determined that the connection between the virtual machine and the storage device has failed;

[0138] If the target volume is found within the preset time and the target volume's identification drive letter is the same as the identification drive letter recorded by the storage device, it is determined that the virtual machine and the storage device are successfully connected.

[0139] For descriptions of features in the embodiments corresponding to the apparatus for interfacing a virtual machine with a storage device, please refer to the descriptions of the embodiments corresponding to the method for interfacing a virtual machine with a storage device, and will not be repeated here. Each module in the apparatus for interfacing a virtual machine with a storage device may be implemented in whole or in part through software, hardware, or a combination thereof. Each of the modules may be embedded in or independent of a processor in an electronic device in hardware form, or may be stored in a memory in the electronic device in software form, so that the processor can call and execute operations corresponding to each of the modules.

[0140] In one embodiment, an electronic device is provided. The electronic device may be a terminal, and its internal structure diagram may be as follows: Figure 6 As shown. The electronic device includes a processor, a memory, a network interface, a display screen and an input device connected via a system bus. The processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the electronic device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a method for docking a virtual machine with a storage device is implemented. The display screen of the electronic device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the electronic device can be a touch layer covering the display screen, or a button, trackball or touchpad provided on the housing of the electronic device, or an external keyboard, touchpad or mouse, etc.

[0141] Those skilled in the art will understand that Figure 6The structure shown in the figure 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 electronic device to which the solution of the present application is applied. The specific electronic device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0142] An embodiment of the present application provides an electronic device, including a memory and a processor. The memory stores a computer program, and the processor is configured to run the computer program to perform steps in an embodiment of a method for docking a virtual machine with a storage device, including:

[0143] S1: Based on the resource size and number of Fibre Channel ports on the server side, create at least one virtual machine and allocate a target Fibre Channel port to the virtual machine;

[0144] S2: Obtain a first identifier corresponding to the target Fibre Channel port and a second identifier of the Fibre Channel port of the storage device;

[0145] S3: In response to a successful match between the first identifier and the second identifier, docking the virtual machine and the storage device, creating a Fibre Channel host, and marking the Fibre Channel host based on a target identifier, where the target identifier is the same as the first identifier or the second identifier;

[0146] S4: In response to the Fibre Channel host being in a normal working state, creating a target volume on the storage device and mapping the target volume to the Fibre Channel host including the target identifier;

[0147] S5: Determine the connection result between the virtual machine and the storage device based on the mapping result of the target volume.

[0148] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program is configured to execute the steps of an embodiment of a method for docking a virtual machine with a storage device when run, including:

[0149] S1: Based on the resource size and number of Fibre Channel ports on the server side, create at least one virtual machine and allocate a target Fibre Channel port to the virtual machine;

[0150] S2: Obtain a first identifier corresponding to the target Fibre Channel port and a second identifier of the Fibre Channel port of the storage device;

[0151] S3: In response to a successful match between the first identifier and the second identifier, docking the virtual machine and the storage device, creating a Fibre Channel host, and marking the Fibre Channel host based on a target identifier, where the target identifier is the same as the first identifier or the second identifier;

[0152] S4: In response to the Fibre Channel host being in a normal working state, creating a target volume on the storage device and mapping the target volume to the Fibre Channel host including the target identifier;

[0153] S5: Determine the connection result between the virtual machine and the storage device based on the mapping result of the target volume.

[0154] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.

[0155] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in the embodiment of the method for docking a virtual machine with a storage device include:

[0156] S1: Based on the resource size and number of Fibre Channel ports on the server side, create at least one virtual machine and allocate a target Fibre Channel port to the virtual machine;

[0157] S2: Obtain a first identifier corresponding to the target Fibre Channel port and a second identifier of the Fibre Channel port of the storage device;

[0158] S3: In response to a successful match between the first identifier and the second identifier, docking the virtual machine and the storage device, creating a Fibre Channel host, and marking the Fibre Channel host based on a target identifier, where the target identifier is the same as the first identifier or the second identifier;

[0159] S4: In response to the Fibre Channel host being in a normal working state, creating a target volume on the storage device and mapping the target volume to the Fibre Channel host including the target identifier;

[0160] S5: Determine the connection result between the virtual machine and the storage device based on the mapping result of the target volume.

[0161] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the steps of an embodiment of a method for docking a virtual machine with a storage device are implemented, including:

[0162] S1: Based on the resource size and number of Fibre Channel ports on the server side, create at least one virtual machine and allocate a target Fibre Channel port to the virtual machine;

[0163] S2: Obtain a first identifier corresponding to the target Fibre Channel port and a second identifier of the Fibre Channel port of the storage device;

[0164] S3: In response to a successful match between the first identifier and the second identifier, docking the virtual machine and the storage device, creating a Fibre Channel host, and marking the Fibre Channel host based on a target identifier, where the target identifier is the same as the first identifier or the second identifier;

[0165] S4: In response to the Fibre Channel host being in a normal working state, creating a target volume on the storage device and mapping the target volume to the Fibre Channel host including the target identifier;

[0166] S5: Determine the connection result between the virtual machine and the storage device based on the mapping result of the target volume.

[0167] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0168] The above is a detailed introduction to the method, apparatus, electronic device and storage medium for docking a virtual machine with a storage device provided by the present application. This article uses specific examples to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.

Claims

1. A method for connecting a virtual machine to a storage device, characterized in that: The method comprises: Creating at least one virtual machine based on the resource size and the number of Fibre Channel ports on the server side, and allocating a target Fibre Channel port to the virtual machine; Obtaining a first identifier corresponding to the target Fibre Channel port and a second identifier of the Fibre Channel port of the storage device; In response to a successful match between the first identifier and the second identifier, docking the virtual machine and the storage device, creating a Fibre Channel host, and marking the Fibre Channel host based on a target identifier, the target identifier being the same as the first identifier or the second identifier; In response to the Fibre Channel host being in a normal working state, creating a target volume on the storage device and mapping the target volume to the Fibre Channel host including a target identifier; The result of docking between the virtual machine and the storage device is determined according to the mapping result of the target volume.

2. The method for connecting a virtual machine to a storage device according to claim 1, wherein: Before creating at least one virtual machine based on the resource size and the number of fiber channel ports on the server side, the method further includes: Get the standardized topology; Based on the standardized topology and the target network environment, interconnecting the server, the storage device, and the Fibre Channel switch; In response to the successful interconnection, setting a management address for the node in the storage device and detecting the status of the node; In response to the state of the node being a candidate active state, a node management address, a storage cluster address, and an address of a virtual machine management tool on the server side are configured into an automation platform or a target configuration file.

3. The method for connecting a virtual machine to a storage device according to claim 2, wherein: In response to the configuration being completed, the method further includes: Based on the node management address, the storage cluster address and the virtual machine management tool address of the server, respectively obtaining the hardware configuration information of the node and the hardware configuration information of the server; Determining, based on the hardware configuration information of the node and the hardware configuration information of the server, whether the active Fibre Channel port of the storage device and the active Fibre Channel port of the server are in the same communication zone; In response to the active fiber channel port of the storage device and the active fiber channel port of the server being in the same communication zone, an image required for creating a virtual machine is obtained.

4. The method for connecting a virtual machine to a storage device according to claim 1, wherein: Based on the server's resource size and the number of Fibre Channel ports, create at least one virtual machine including: Upload the image required to create the virtual machine; In response to the upload being completed, determining the number of images, and reading the resource size and the number of fiber channel ports on the server side; comparing the number of mirrors to the number of Fibre Channel ports; In response to the number of the mirrors being greater than the number of the Fibre Channel ports, issuing a prompt message to the user indicating that the number of Fibre Channel ports is insufficient; In response to the number of mirrors being less than or equal to the number of Fibre Channel ports, setting a target value of a virtual machine parameter; Determining the size of resources required to create the virtual machine based on the number of the images and the target values ​​of the virtual machine parameters; Comparing the resource size required for creating the virtual machine with the resource size of the server side; In response to the resource size required for creating the virtual machine being greater than the resource size of the server, issuing a prompt message indicating insufficient resources to the user; In response to the resource size required for creating the virtual machine being less than or equal to the resource size of the server, at least one virtual machine is created based on the virtual machine creation script.

5. The method for connecting a virtual machine to a storage device according to claim 1, wherein: Allocating a target Fibre Channel port to the virtual machine includes: In response to the virtual machine being created, an unused address in the same network segment is allocated to the virtual machine, and a name of the virtual machine is set based on the image name of the virtual machine. At the same time, a target Fibre Channel port is allocated to the virtual machine based on the active Fibre Channel port on the server side, and a first identifier corresponding to the target Fibre Channel port is determined.

6. The method for connecting a virtual machine to a storage device according to claim 5, wherein: Creating a Fibre Channel host, and tagging the Fibre Channel host based on a target identifier includes: In response to a successful match between the first identifier and the second identifier, determining a first identifier corresponding to the virtual machine according to the name of the virtual machine; The target identifier is determined based on a first identifier corresponding to the virtual machine, and the Fibre Channel host is marked based on the target identifier, wherein the first identifier and the second identifier are the same.

7. The method for connecting a virtual machine to a storage device according to claim 1, wherein: Determining, according to the mapping result of the target volume, a result of interconnection between the virtual machine and the storage device includes: In response to the target volume being mapped, scanning the target volume based on the virtual machine; If the target volume is not scanned within the preset time, it is determined that the connection between the virtual machine and the storage device has failed; If the target volume is scanned within a preset time and the identification drive letter of the target volume is the same as the identification drive letter recorded by the storage device, it is determined that the virtual machine and the storage device are successfully connected.

8. A device for connecting a virtual machine to a storage device, characterized in that: The device comprises: A first creation module is configured to create at least one virtual machine based on the resource size and the number of Fibre Channel ports on the server side, and allocate a target Fibre Channel port to the virtual machine; an acquisition module, configured to acquire a first identifier corresponding to the target Fibre Channel port and a second identifier of the Fibre Channel port of the storage device; a second creation module configured to, in response to a successful match between the first identifier and the second identifier, dock the virtual machine and the storage device, create a Fibre Channel host, and tag the Fibre Channel host based on a target identifier, the target identifier being the same as the first identifier or the second identifier; a third creation module, configured to create a target volume on the storage device in response to the Fibre Channel host being in a normal working state, and map the target volume to the Fibre Channel host including a target identifier; The docking module is used to determine the docking result between the virtual machine and the storage device according to the mapping result of the target volume.

9. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the method for docking a virtual machine with a storage device according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the steps of the method for docking a virtual machine with a storage device according to any one of claims 1 to 7 are implemented.