CN111355716A - Method, system, equipment and medium for determining unique identifier of virtual machine - Google Patents
Method, system, equipment and medium for determining unique identifier of virtual machine Download PDFInfo
- Publication number
- CN111355716A CN111355716A CN202010109610.0A CN202010109610A CN111355716A CN 111355716 A CN111355716 A CN 111355716A CN 202010109610 A CN202010109610 A CN 202010109610A CN 111355716 A CN111355716 A CN 111355716A
- Authority
- CN
- China
- Prior art keywords
- network card
- physical network
- network
- information
- cards
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 29
- 238000004590 computer program Methods 0.000 claims description 14
- 230000004044 response Effects 0.000 claims description 12
- 238000004364 calculation method Methods 0.000 claims description 5
- 230000008859 change Effects 0.000 abstract description 5
- 238000010586 diagram Methods 0.000 description 7
- 230000006870 function Effects 0.000 description 6
- 230000003287 optical effect Effects 0.000 description 4
- 238000005516 engineering process Methods 0.000 description 3
- 230000001360 synchronised effect Effects 0.000 description 3
- 238000004422 calculation algorithm Methods 0.000 description 2
- 238000013461 design Methods 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 239000000835 fiber Substances 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 238000012217 deletion Methods 0.000 description 1
- 230000037430 deletion Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000001914 filtration Methods 0.000 description 1
- 230000014509 gene expression Effects 0.000 description 1
- 230000008569 process Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L63/00—Network architectures or network communication protocols for network security
- H04L63/08—Network architectures or network communication protocols for network security for authentication of entities
- H04L63/0876—Network architectures or network communication protocols for network security for authentication of entities based on the identity of the terminal or configuration, e.g. MAC address, hardware or software configuration or device fingerprint
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L61/00—Network arrangements, protocols or services for addressing or naming
- H04L61/30—Managing network names, e.g. use of aliases or nicknames
- H04L61/3015—Name registration, generation or assignment
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L61/00—Network arrangements, protocols or services for addressing or naming
- H04L61/45—Network directories; Name-to-address mapping
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
- G06F2009/45595—Network integration; Enabling network access in virtual machine instances
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L2101/00—Indexing scheme associated with group H04L61/00
- H04L2101/60—Types of network addresses
- H04L2101/604—Address structures or formats
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L2101/00—Indexing scheme associated with group H04L61/00
- H04L2101/60—Types of network addresses
- H04L2101/618—Details of network addresses
- H04L2101/622—Layer-2 addresses, e.g. medium access control [MAC] addresses
Abstract
The invention discloses a method for determining a unique identifier of a virtual machine, which comprises the following steps: obtaining the operating system type of the virtual machine; responding to the fact that the operating system type is a Windows operating system, acquiring GUIDs of all network cards and numerical values corresponding to the corresponding network card types according to a registry, and acquiring MAC addresses corresponding to the GUIDs of all the network cards according to WMI; carrying out bit and operation on the numerical value corresponding to the network card type to determine the GUID corresponding to the physical network card in the GUIDs of all the network cards; determining the MAC address corresponding to the physical network card according to the GUID of the physical network card; and splicing the determined MAC addresses, and then calculating a hash value to obtain the unique identifier. The invention also discloses a system, a computer device and a readable storage medium. The scheme provided by the invention can quickly identify the virtual host in the cloud environment, determine the uniqueness of the virtual host, and solve the problem that the virtual host cannot be identified due to frequent change of virtual hardware in the cloud environment.
Description
Technical Field
The invention relates to the field of virtual machines, in particular to a method, a system, equipment and a storage medium for determining a unique identifier of a virtual machine.
Background
With the rapid development of computer technology, more and more enterprises migrate business environments from physical computing environments to cloud environments. In a set of physical servers, there are typically hundreds of heterogeneous virtual hosts. Some business logic needs to determine the uniqueness of a host. However, hardware information such as a CPU, a memory, and a hard disk changes every time the virtual host is restarted, and the uniqueness of the host is not well determined.
Although uniqueness can be determined through a MAC address in the prior art, for example, uniqueness is determined by using UUID + MAC address, or uniqueness is determined by using certificate + hardware information, or uniqueness is determined by using MAC address matching with management platform ID, hardware information such as CPU, memory, hard disk, etc. may change after a virtual host is restarted, and at the same time, a virtual network card, a bridge, a container, etc. may bring about changes in network environment. The acquisition of the MAC address is affected by the virtual network cards and bridges which are frequently changed in the virtual host, and meanwhile, various containers are frequently present in the virtual host in the cloud environment, and the addition and deletion of the containers affect the calculation of the MAC address.
Disclosure of Invention
In view of the above, in order to overcome at least one aspect of the above problem, an embodiment of the present invention provides a method for determining a unique identifier of a virtual machine, including the following steps:
obtaining the operating system type of the virtual machine;
responding to the fact that the operating system type is a Windows operating system, acquiring GUIDs of all network cards and numerical values corresponding to the corresponding network card types according to a registry, and acquiring MAC addresses corresponding to the GUIDs of all the network cards according to WMI;
carrying out bit and operation on the numerical value corresponding to the network card type to determine the GUID corresponding to the physical network card in the GUIDs of all the network cards;
determining the MAC address corresponding to the physical network card according to the GUID of the physical network card;
and splicing the determined MAC addresses, and then calculating a hash value to obtain the unique identifier.
In some embodiments, performing bit and operation on the numerical value corresponding to the network card type to determine the GUID corresponding to the physical network card in the GUIDs of all the network cards, further includes:
carrying out bit AND operation on the numerical value corresponding to the network card type and a first preset numerical value and a second preset numerical value respectively;
and determining the GUID corresponding to the physical network card by using the numerical value corresponding to the network card type of which the bit and the operation result are true.
In some embodiments, further comprising:
responding to the operating type of the Linux operating system, and acquiring a non-physical network card list and network information of all network cards;
excluding the non-physical network card information in the network information of all the network cards according to the name of each network card in the non-physical network card list to obtain the information of the physical network card;
and after the MAC addresses in the information of the physical network cards are spliced, calculating a hash value to obtain the unique identifier.
In some embodiments, the obtaining the list of non-physical network cards and the network information of all network cards further includes:
and acquiring the non-physical network card list at a preset position under the Linux operating system, and acquiring the network information of all the network cards by executing a preset command.
Based on the same inventive concept, according to another aspect of the present invention, an embodiment of the present invention further provides a system for determining a unique identifier of a virtual machine, including:
an obtaining module configured to obtain an operating system type of the virtual machine;
the first response module is configured to respond that the operating system type is a Windows operating system, acquire GUIDs of all network cards and numerical values corresponding to the corresponding network card types according to a registry, and acquire MAC addresses corresponding to the GUIDs of all the network cards according to WMI;
a first determining module, configured to perform bit and operation on the numerical value corresponding to the network card type to determine the GUID corresponding to the physical network card in the GUIDs of all network cards;
the second determining module is configured to determine the MAC address corresponding to the physical network card according to the GUID of the physical network card;
and the calculation module is configured to splice the determined MAC addresses and then calculate a hash value to obtain the unique identifier.
In some embodiments, the first determination module is further configured to:
carrying out bit AND operation on the numerical value corresponding to the network card type and a first preset numerical value and a second preset numerical value respectively;
and determining the GUID corresponding to the physical network card by using the numerical value corresponding to the network card type of which the bit and the operation result are true.
In some embodiments, the system further comprises a second response module configured to:
responding to the operating type of the Linux operating system, and acquiring a non-physical network card list and network information of all network cards;
excluding the non-physical network card information in the network information of all the network cards according to the name of each network card in the non-physical network card list to obtain the information of the physical network card;
and after the MAC addresses in the information of the physical network cards are spliced, calculating a hash value to obtain the unique identifier.
In some embodiments, the second response module is further configured to:
and acquiring the non-physical network card list at a preset position under the Linux operating system, and acquiring the network information of all the network cards by executing a preset command.
Based on the same inventive concept, according to another aspect of the present invention, an embodiment of the present invention further provides a computer apparatus, including:
at least one processor; and
a memory storing a computer program operable on the processor, wherein the processor executes the program to perform any of the steps of the method for determining a virtual machine unique identifier as described above.
Based on the same inventive concept, according to another aspect of the present invention, an embodiment of the present invention further provides a computer-readable storage medium storing a computer program which, when executed by a processor, performs the steps of any of the methods for determining a unique identifier of a virtual machine as described above.
The invention has one of the following beneficial technical effects: the scheme provided by the invention can quickly identify the virtual host in the cloud environment, determine the uniqueness of the virtual host, and solve the problem that the virtual host cannot be identified due to frequent change of virtual hardware in the cloud environment.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other embodiments can be obtained by using the drawings without creative efforts.
Fig. 1 is a schematic flowchart of a method for determining a unique identifier of a virtual machine according to an embodiment of the present invention;
FIG. 2 is a diagram of a registry provided by an embodiment of the present invention;
fig. 3 is a schematic diagram of a non-physical network card list according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of all network card information provided by the embodiment of the present invention
Fig. 5 is a schematic structural diagram of a system for determining a unique identifier of a virtual machine according to an embodiment of the present invention;
FIG. 6 is a schematic structural diagram of a computer device provided in an embodiment of the present invention;
fig. 7 is a schematic structural diagram of a computer-readable storage medium according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the following embodiments of the present invention are described in further detail with reference to the accompanying drawings.
It should be noted that all expressions using "first" and "second" in the embodiments of the present invention are used for distinguishing two entities with the same name but different names or different parameters, and it should be noted that "first" and "second" are merely for convenience of description and should not be construed as limitations of the embodiments of the present invention, and they are not described in any more detail in the following embodiments.
According to an aspect of the present invention, an embodiment of the present invention provides a method for determining a unique identifier of a virtual machine, which may include the steps of: s1, acquiring the operating system type of the virtual machine; s2, responding to the fact that the operating system type is a Windows operating system, acquiring GUIDs of all network cards and numerical values corresponding to the corresponding network card types according to a registry, and acquiring MAC addresses corresponding to the GUIDs of all the network cards according to WMI; s3, carrying out bit and operation on the numerical value corresponding to the network card type to determine the GUID corresponding to the physical network card in the GUIDs of all the network cards; s4, determining the MAC address corresponding to the physical network card according to the GUID of the physical network card; s5, splicing the determined MAC addresses, and calculating a hash value to obtain the unique identifier.
The scheme provided by the invention can quickly identify the virtual host in the cloud environment, determine the uniqueness of the virtual host, and solve the problem that the virtual host cannot be identified due to frequent change of virtual hardware in the cloud environment.
In some embodiments, in the step S1, in obtaining the operating system type of the virtual machine, specifically, the method for obtaining the MAC address corresponding to different operating systems is different, so that it is necessary to first determine the operating system type of the virtual machine.
In some embodiments, in step S2, in response to that the operating system type is a Windows operating system, the GUIDs of all the network cards and the corresponding numerical values of the network card types are obtained according to the registry, and in the GUIDs of all the network cards and the corresponding MAC addresses are obtained according to the WMI, specifically, all the network card information may be obtained by deriving the registry, and it should be noted that only the network card types and GUIDs corresponding to all the network cards can be obtained through the registry. And then, acquiring network card supplementary information by using WMI, namely acquiring the GUID and the MAC address of the network card by using WMI.
For example, in some embodiments, fig. 2 shows a schematic diagram of a derived registry, which can execute the instruction reg query and then obtain Characteristics (network card type), netcfgstanceid (network card GUID) by "HKLM \ SYSTEM \ CurrentControlSet \ Control \ Class \ \ 4d36e972-e325-11ce-bfc1-08002be 10318 }". In some embodiments, when WMI is used to obtain the network card supplementary information, WMI obtaining tool class wmiutil selective objectfrom provided by Java third party package oshi, util, platform, windows may be used to obtain the network card supplementary information, where the main parameters may be wmilass: Win32_ network adapters properties: GUID, MACAddress.
In some embodiments, in step S3, performing bit and operation on the numerical value corresponding to the network card type to determine the GUID corresponding to the physical network card in the GUIDs of all network cards, further includes:
carrying out bit AND operation on the numerical value corresponding to the network card type and a first preset numerical value and a second preset numerical value respectively;
and determining the GUID corresponding to the physical network card by using the numerical value corresponding to the network card type of which the bit and the operation result are true.
Specifically, as shown in fig. 2, the 16-system numerical values corresponding to the network card types of all the network cards acquired through the registry are then respectively subjected to bit and operation with 0x4 (a first preset numerical value) and 0x80 (a second preset numerical value), and only when the operation result is True (that is, 1), the network card is a physical network card.
It should be noted that the information of the network cards acquired through the registry or the WMI is information of all the network cards, so that the physical network card needs to be determined through the type of the network card first, then the network card type in the registry is the GUID corresponding to the physical network card, and finally the corresponding MAC address is determined through the GUID in the network card supplementary information acquired through the WMI.
In some embodiments, in step S5, the determined MAC addresses are spliced and then a hash value is calculated to obtain the unique identifier, specifically, since there may be more than one physical network card of the virtual machine obtained through the above steps, the MAC addresses of the physical network cards may be spliced and then the hash value is calculated to obtain the unique identifier, so as to determine the uniqueness of the virtual machine.
In some embodiments, the method may further comprise:
responding to the operating type of the Linux operating system, and acquiring a non-physical network card list and network information of all network cards;
excluding the non-physical network card information in the network information of all the network cards according to the name of each network card in the non-physical network card list to obtain the information of the physical network card;
and after the MAC addresses in the information of the physical network cards are spliced, calculating a hash value to obtain the unique identifier.
In some embodiments, the obtaining the list of non-physical network cards and the network information of all network cards further includes:
and acquiring the non-physical network card list at a preset position under the Linux operating system, and acquiring the network information of all the network cards by executing a preset command.
Specifically, the non-physical network card list may be obtained under a Linux system/sys/devices/virtual/net folder, for example, as shown in fig. 3, names lo, virbr0, and virbr0-nic of 3 non-physical network cards may be determined through the non-physical network card list. Then, the network environment information, that is, the information of all the network cards, is obtained by executing the command ip link, for example, as shown in fig. 4, the names lo, ens32, virbr0, virbr0-nic of all the network cards can be obtained by the obtained information of all the network cards. And finally, filtering out the name of the physical network card through the name of the non-physical network card in the non-physical network card list, that is, determining that the network card with the name ens32 is the physical network card through the non-physical network card list shown in fig. 3 and all the network card information shown in fig. 4, and finally finding out the corresponding MAC address in the obtained information of all the network cards through the name of the physical network card.
It should be noted that, because there may be more than one physical network card of the virtual machine obtained through the above steps, the MAC addresses of several physical network cards may be spliced, and then the hash value is calculated, so as to obtain the unique identifier and determine the uniqueness of the virtual machine.
The scheme provided by the scheme can screen out interference information such as a virtual network card and a network bridge by utilizing a WMI (wireless multimedia interface) provided by Java and combining system data to obtain physical network card information. Meanwhile, aiming at the virtual host with more heterogeneous scenes in the cloud environment, methods for acquiring the physical network card in the Windows system and the Linux system are provided. The scheme provided by the invention can quickly identify the virtual host in the cloud environment, determine the uniqueness of the virtual host, and solve the problem that the virtual host cannot be identified due to frequent change of virtual hardware in the cloud environment.
Based on the same inventive concept, according to another aspect of the present invention, an embodiment of the present invention further provides a system 400 for determining a unique identifier of a virtual machine, as shown in fig. 5, including:
an obtaining module 401, where the obtaining module 401 is configured to obtain an operating system type of the virtual machine;
a first response module 402, where the first response module 402 is configured to, in response to that the operating system type is a Windows operating system, obtain GUIDs of all network cards and corresponding numerical values of the network card types according to a registry, and obtain MAC addresses corresponding to the GUIDs of all network cards according to WMI;
a first determining module 403, where the first determining module 403 is configured to perform bit and operation on a numerical value corresponding to the network card type to determine a GUID corresponding to a physical network card in GUIDs of all network cards;
a second determining module 404, where the second determining module 404 is configured to determine, according to the GUID of the physical network card, the MAC address corresponding to the physical network card;
a calculation module 405, where the calculation module 405 is configured to splice the determined MAC addresses and then calculate a hash value to obtain the unique identifier.
In some embodiments, the first determination module 403 is further configured to:
carrying out bit AND operation on the numerical value corresponding to the network card type and a first preset numerical value and a second preset numerical value respectively;
and determining the GUID corresponding to the physical network card by using the numerical value corresponding to the network card type of which the bit and the operation result are true.
In some embodiments, the system 400 further comprises a second response module configured to:
responding to the operating type of the Linux operating system, and acquiring a non-physical network card list and network information of all network cards;
excluding the non-physical network card information in the network information of all the network cards according to the name of each network card in the non-physical network card list to obtain the information of the physical network card;
and after the MAC addresses in the information of the physical network cards are spliced, calculating a hash value to obtain the unique identifier.
In some embodiments, the second response module is further configured to:
and acquiring the non-physical network card list at a preset position under the Linux operating system, and acquiring the network information of all the network cards by executing a preset command.
Based on the same inventive concept, according to another aspect of the present invention, as shown in fig. 6, an embodiment of the present invention further provides a computer apparatus 501, including:
at least one processor 520; and
a memory 510, the memory 510 storing a computer program 511 executable on the processor, the processor 520 executing the program to perform the steps of any of the above methods of determining a unique identification of a virtual machine.
Based on the same inventive concept, according to another aspect of the present invention, as shown in fig. 7, an embodiment of the present invention further provides a computer-readable storage medium 601, where the computer-readable storage medium 601 stores computer program instructions 610, and the computer program instructions 610, when executed by a processor, perform the steps of any of the above methods for determining a unique identifier of a virtual machine.
Finally, it should be noted that, as will be understood by those skilled in the art, all or part of the processes of the methods of the above embodiments may be implemented by a computer program to instruct related hardware to implement the methods. The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), a Random Access Memory (RAM), or the like. The embodiments of the computer program may achieve the same or similar effects as any of the above-described method embodiments.
In addition, the apparatuses, devices, and the like disclosed in the embodiments of the present invention may be various electronic terminal devices, such as a mobile phone, a Personal Digital Assistant (PDA), a tablet computer (PAD), a smart television, and the like, or may be a large terminal device, such as a server, and the like, and therefore the scope of protection disclosed in the embodiments of the present invention should not be limited to a specific type of apparatus, device. The client disclosed by the embodiment of the invention can be applied to any one of the electronic terminal devices in the form of electronic hardware, computer software or a combination of the electronic hardware and the computer software.
Furthermore, the method disclosed according to an embodiment of the present invention may also be implemented as a computer program executed by a CPU, and the computer program may be stored in a computer-readable storage medium. The computer program, when executed by the CPU, performs the above-described functions defined in the method disclosed in the embodiments of the present invention.
Further, the above method steps and system elements may also be implemented using a controller and a computer readable storage medium for storing a computer program for causing the controller to implement the functions of the above steps or elements.
Further, it should be appreciated that the computer-readable storage media (e.g., memory) herein can be either volatile memory or nonvolatile memory, or can include both volatile and nonvolatile memory. By way of example, and not limitation, nonvolatile memory can include Read Only Memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM), which can act as external cache memory. By way of example and not limitation, RAM is available in a variety of forms such as synchronous RAM (DRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DRRAM). The storage devices of the disclosed aspects are intended to comprise, without being limited to, these and other suitable types of memory.
Those of skill would further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the disclosure herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as software or hardware depends upon the particular application and design constraints imposed on the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the disclosed embodiments of the present invention.
The various illustrative logical blocks, modules, and circuits described in connection with the disclosure herein may be implemented or performed with the following components designed to perform the functions herein: a general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination of these components. A general purpose processor may be a microprocessor, but in the alternative, the processor may be any conventional processor, controller, microcontroller, or state machine. A processor may also be implemented as a combination of computing devices, e.g., a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a DSP, and/or any other such configuration.
The steps of a method or algorithm described in connection with the disclosure herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor such the processor can read information from, and write information to, the storage medium. In the alternative, the storage medium may be integral to the processor. The processor and the storage medium may reside in an ASIC. The ASIC may reside in a user terminal. In the alternative, the processor and the storage medium may reside as discrete components in a user terminal.
In one or more exemplary designs, the functions may be implemented in hardware, software, firmware, or any combination thereof. If implemented in software, the functions may be stored on or transmitted over as one or more instructions or code on a computer-readable medium. Computer-readable media includes both computer storage media and communication media including any medium that facilitates transfer of a computer program from one place to another. A storage media may be any available media that can be accessed by a general purpose or special purpose computer. By way of example, and not limitation, such computer-readable media can comprise RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a general-purpose or special-purpose computer, or a general-purpose or special-purpose processor. Also, any connection is properly termed a computer-readable medium. For example, if the software is transmitted from a website, server, or other remote source using a coaxial cable, fiber optic cable, twisted pair, Digital Subscriber Line (DSL), or wireless technologies such as infrared, radio, and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of medium. Disk and disc, as used herein, includes Compact Disc (CD), laser disc, optical disc, Digital Versatile Disc (DVD), floppy disk, blu-ray disc where disks usually reproduce data magnetically, while discs reproduce data optically with lasers. Combinations of the above should also be included within the scope of computer-readable media.
The foregoing is an exemplary embodiment of the present disclosure, but it should be noted that various changes and modifications could be made herein without departing from the scope of the present disclosure as defined by the appended claims. The functions, steps and/or actions of the method claims in accordance with the disclosed embodiments described herein need not be performed in any particular order. Furthermore, although elements of the disclosed embodiments of the invention may be described or claimed in the singular, the plural is contemplated unless limitation to the singular is explicitly stated.
It should be understood that, as used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly supports the exception. It should also be understood that "and/or" as used herein is meant to include any and all possible combinations of one or more of the associated listed items.
The numbers of the embodiments disclosed in the embodiments of the present invention are merely for description, and do not represent the merits of the embodiments.
It will be understood by those skilled in the art that all or part of the steps of implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
Those of ordinary skill in the art will understand that: the discussion of any embodiment above is meant to be exemplary only, and is not intended to intimate that the scope of the disclosure, including the claims, of embodiments of the invention is limited to these examples; within the idea of an embodiment of the invention, also technical features in the above embodiment or in different embodiments may be combined and there are many other variations of the different aspects of the embodiments of the invention as described above, which are not provided in detail for the sake of brevity. Therefore, any omissions, modifications, substitutions, improvements, and the like that may be made without departing from the spirit and principles of the embodiments of the present invention are intended to be included within the scope of the embodiments of the present invention.
Claims (10)
1. A method for determining a unique identifier of a virtual machine, comprising the steps of:
obtaining the operating system type of the virtual machine;
responding to the fact that the operating system type is a Windows operating system, acquiring GUIDs of all network cards and numerical values corresponding to the corresponding network card types according to a registry, and acquiring MAC addresses corresponding to the GUIDs of all the network cards according to WMI;
carrying out bit and operation on the numerical value corresponding to the network card type to determine the GUID corresponding to the physical network card in the GUIDs of all the network cards;
determining the MAC address corresponding to the physical network card according to the GUID of the physical network card;
and splicing the determined MAC addresses, and then calculating a hash value to obtain the unique identifier.
2. The method of claim 1, wherein performing a bit and operation on the numerical value corresponding to the network card type to determine the GUID corresponding to the physical network card among the GUIDs of all network cards, further comprises:
carrying out bit AND operation on the numerical value corresponding to the network card type and a first preset numerical value and a second preset numerical value respectively;
and determining the GUID corresponding to the physical network card by using the numerical value corresponding to the network card type of which the bit and the operation result are true.
3. The method of claim 1, further comprising:
responding to the operating type of the Linux operating system, and acquiring a non-physical network card list and network information of all network cards;
excluding the non-physical network card information in the network information of all the network cards according to the name of each network card in the non-physical network card list to obtain the information of the physical network card;
and after the MAC addresses in the information of the physical network cards are spliced, calculating a hash value to obtain the unique identifier.
4. The method of claim 3, wherein obtaining the list of non-physical network cards and the network information of all network cards further comprises:
and acquiring the non-physical network card list at a preset position under the Linux operating system, and acquiring the network information of all the network cards by executing a preset command.
5. A system for determining a unique identification of a virtual machine, comprising:
an obtaining module configured to obtain an operating system type of the virtual machine;
the first response module is configured to respond that the operating system type is a Windows operating system, acquire GUIDs of all network cards and numerical values corresponding to the corresponding network card types according to a registry, and acquire MAC addresses corresponding to the GUIDs of all the network cards according to WMI;
a first determining module, configured to perform bit and operation on the numerical value corresponding to the network card type to determine the GUID corresponding to the physical network card in the GUIDs of all network cards;
the second determining module is configured to determine the MAC address corresponding to the physical network card according to the GUID of the physical network card;
and the calculation module is configured to splice the determined MAC addresses and then calculate a hash value to obtain the unique identifier.
6. The system of claim 5, wherein the first determination module is further configured to:
carrying out bit AND operation on the numerical value corresponding to the network card type and a first preset numerical value and a second preset numerical value respectively;
and determining the GUID corresponding to the physical network card by using the numerical value corresponding to the network card type of which the bit and the operation result are true.
7. The system of claim 5, further comprising a second response module configured to:
responding to the operating type of the Linux operating system, and acquiring a non-physical network card list and network information of all network cards;
excluding the non-physical network card information in the network information of all the network cards according to the name of each network card in the non-physical network card list to obtain the information of the physical network card;
and after the MAC addresses in the information of the physical network cards are spliced, calculating a hash value to obtain the unique identifier.
8. The system of claim 7, wherein the second response module is further configured to:
and acquiring the non-physical network card list at a preset position under the Linux operating system, and acquiring the network information of all the network cards by executing a preset command.
9. A computer device, comprising:
at least one processor; and
memory storing a computer program operable on the processor, characterized in that the processor executes the program to perform the steps of the method according to any of claims 1-4.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, is adapted to carry out the steps of the method according to any one of claims 1-4.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010109610.0A CN111355716B (en) | 2020-02-22 | 2020-02-22 | Method, system, equipment and medium for determining unique identifier of virtual machine |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010109610.0A CN111355716B (en) | 2020-02-22 | 2020-02-22 | Method, system, equipment and medium for determining unique identifier of virtual machine |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111355716A true CN111355716A (en) | 2020-06-30 |
CN111355716B CN111355716B (en) | 2022-05-13 |
Family
ID=71195779
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010109610.0A Active CN111355716B (en) | 2020-02-22 | 2020-02-22 | Method, system, equipment and medium for determining unique identifier of virtual machine |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111355716B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114915592A (en) * | 2022-04-08 | 2022-08-16 | 苏州浪潮智能科技有限公司 | Method, system, storage medium and device for port binding of aggregation group |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20120084458A1 (en) * | 2010-09-30 | 2012-04-05 | International Business Machines Corporation | Communication between a host operating system and a guest operating system |
CN103731514A (en) * | 2013-12-29 | 2014-04-16 | 国云科技股份有限公司 | Virtual network management method |
CN108965494A (en) * | 2018-07-05 | 2018-12-07 | 郑州云海信息技术有限公司 | Data transmission method and device in data system |
CN110519147A (en) * | 2018-05-22 | 2019-11-29 | 中兴通讯股份有限公司 | Data frame transmission method, device, equipment and computer readable storage medium |
-
2020
- 2020-02-22 CN CN202010109610.0A patent/CN111355716B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20120084458A1 (en) * | 2010-09-30 | 2012-04-05 | International Business Machines Corporation | Communication between a host operating system and a guest operating system |
CN103731514A (en) * | 2013-12-29 | 2014-04-16 | 国云科技股份有限公司 | Virtual network management method |
CN110519147A (en) * | 2018-05-22 | 2019-11-29 | 中兴通讯股份有限公司 | Data frame transmission method, device, equipment and computer readable storage medium |
CN108965494A (en) * | 2018-07-05 | 2018-12-07 | 郑州云海信息技术有限公司 | Data transmission method and device in data system |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114915592A (en) * | 2022-04-08 | 2022-08-16 | 苏州浪潮智能科技有限公司 | Method, system, storage medium and device for port binding of aggregation group |
CN114915592B (en) * | 2022-04-08 | 2023-08-15 | 苏州浪潮智能科技有限公司 | Method, system, storage medium and device for port binding of aggregation group |
Also Published As
Publication number | Publication date |
---|---|
CN111355716B (en) | 2022-05-13 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110427342B (en) | Method, equipment and readable medium for creating mirror library | |
US20190199687A1 (en) | Dynamically opening ports for trusted application processes hosted in containers | |
CN107516038B (en) | Method and device for determining device fingerprint | |
KR101857511B1 (en) | Method and apparatus for determining virtual machine migration | |
US11036535B2 (en) | Data storage method and apparatus | |
CN108268609B (en) | File path establishing and accessing method and device | |
CN111177043A (en) | Method, system, device and medium for accelerating reading of field replaceable unit information | |
CN107870802B (en) | Virtual machine migration method and device | |
CN107580032B (en) | Data processing method, device and equipment | |
CN111064804B (en) | Network access method and device | |
CN104268229A (en) | Resource obtaining method and device based on multi-process browser | |
CN111221581A (en) | Network card starting method, equipment and storage medium | |
CN111355716B (en) | Method, system, equipment and medium for determining unique identifier of virtual machine | |
CN110008758B (en) | ID obtaining method and device, electronic equipment and storage medium | |
CN114745133A (en) | Method and device for identifying uniqueness of equipment | |
CN111367560A (en) | Method, system, equipment and medium for expanding server function | |
CN113157487A (en) | Data recovery method and apparatus thereof | |
JP2019511060A (en) | Method and apparatus for page display | |
CN111309264B (en) | Method, system, device and medium for making directory quota compatible with snapshot | |
CN110417579B (en) | Method, equipment and readable medium for managing gigabit network by using gigabit network card | |
CN106878252B (en) | Method for establishing password-free login relationship, method for clearing account and device thereof | |
KR20150139546A (en) | Removable storage device identity and configuration information | |
CN111813507A (en) | Method, system, equipment and medium for high availability of virtual machine based on sanlock | |
US11979307B2 (en) | Network switching method and apparatus, electronic device, and storage medium | |
US20110264883A1 (en) | Device for selecting and configuring a default storage section and the corresponding method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |