獲取虛擬磁碟資訊

2021-08-21 00:21:15 字數 1329 閱讀 5116

對虛擬機器進行備份時,需要獲取指定虛擬機器的磁碟相關資訊,包含磁碟容量、磁碟路徑、磁碟 key 等資訊,這些資訊可以在快照建立完成之後通過快照來獲取,下面給出根據虛擬機器獲取虛擬磁碟資訊**:

/**

*@title: getdiskinfo

*@description: 獲取磁碟資訊

*@param vmmor

*@param vmname

*@return

*@throws runtimefaultfaultmsg

*@throws invalidpropertyfaultmsg

*@version 1.0

*@throws exception

*/@override

public diskinfo getdiskinfo(managedobjectreference vmmor, string vmname, string snapshotname)

throws runtimefaultfaultmsg, invalidpropertyfaultmsg, exception ;

// 獲取屬性對應的實體,並設定到diskinfo

diskinfo info = new diskinfo();

info.setname(vmname);

virtualmachinesnapshotinfo snap = (virtualmachinesnapshotinfo) retrieveentityprops(vmmor, propsarr).get("snapshot");

info.setsnapshot(snap);

if (stringutils.isnotblank(snapshotname)) )

.get("config.hardware.device");

for (virtualdevice vd : devs.getvirtualdevice())

}} else )

.get("config.hardware.device");

for (virtualdevice vd : devs.getvirtualdevice())

}} return info;

}

diskinfo實體物件如下:

import com.vmware.vim25.virtualmachinesnapshotinfo;

/** *@classname: diskinfo

*@description: 磁碟資訊

*/public

class

diskinfo

**僅供學習參考。

QT獲取磁碟資訊

qt在5.4以及以後版本提供了乙個qstorageinfo來獲取磁碟資訊 官方文件 provides information about currently mounted storage and drives.allows retrieving information about the volu...

Powershell獲取磁碟資訊

使用powershell完成系統管理實在是太方便了,磁碟資訊獲取只需幾行 即可。1 diskcount get wmiobject class win32 diskdrive caption count2 獲取磁碟分割槽大小3 diskinfo get wmiobject class win32 l...

linux 獲取檔案系統資訊(磁碟資訊)

源 例如以下 include include include include 檔案系統資訊結構體 struct filesystem info 獲取檔案系統資訊 int get filesystem info const char filesystem name,struct filesystem ...