#NEWLINE# def get_vmdk_info( session , vm_ref , uuid = None ) : #NEWLINE# #INDENT# 'Returns information for the primary VMDK attached to the given VM.' #NEWLINE# hardware_devices = session . _call_method ( vutil , 'get_object_property' , vm_ref , 'config.hardware.device' ) #NEWLINE# if ( hardware_devices . __class__ . __name__ == 'ArrayOfVirtualDevice' ) : #NEWLINE# #INDENT# hardware_devices = hardware_devices . VirtualDevice #NEWLINE# #UNINDENT# vmdk_file_path = None #NEWLINE# vmdk_controller_key = None #NEWLINE# disk_type = None #NEWLINE# capacity_in_bytes = 0 #NEWLINE# root_disk = None #NEWLINE# root_device = None #NEWLINE# if uuid : #NEWLINE# #INDENT# root_disk = ( '%s.vmdk' % uuid ) #NEWLINE# #UNINDENT# vmdk_device = None #NEWLINE# adapter_type_dict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for device in hardware_devices : #NEWLINE# #INDENT# if ( device . __class__ . __name__ == 'VirtualDisk' ) : #NEWLINE# #INDENT# if ( adapter_type . backing . __class__ . __name__ == 'VirtualDiskFlatVer2BackingInfo' ) : #NEWLINE# #INDENT# path = ds_obj . DatastorePath . parse ( device . backing . fileName ) #NEWLINE# if ( root_disk and ( path . basename == root_disk ) ) : #NEWLINE# #INDENT# root_device = device #NEWLINE# #UNINDENT# vmdk_device = device #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( device . __class__ . __name__ == 'VirtualLsiLogicController' ) : #NEWLINE# #INDENT# adapter_type_dict [ device . key ] = constants . DEFAULT_ADAPTER_TYPE #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( device . __class__ . __name__ == 'VirtualBusLogicController' ) : #NEWLINE# #INDENT# adapter_type_dict [ device . key ] = constants . ADAPTER_TYPE_BUSLOGIC #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( device . __class__ . __name__ == 'VirtualIDEController' ) : #NEWLINE# #INDENT# adapter_type_dict [ device . key ] = constants . ADAPTER_TYPE_IDE #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( device . __class__ . __name__ == 'VirtualLsiLogicSASController' ) : #NEWLINE# #INDENT# adapter_type_dict [ device . key ] = constants . ADAPTER_TYPE_LSILOGICSAS #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( device . __class__ . __name__ == 'ParaVirtualSCSIController' ) : #NEWLINE# #INDENT# adapter_type_dict [ device . key ] = constants . ADAPTER_TYPE_PARAVIRTUAL #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if root_disk : #NEWLINE# #INDENT# vmdk_device = root_device #NEWLINE# #UNINDENT# if vmdk_device : #NEWLINE# #INDENT# vmdk_file_path = vmdk_device . backing . fileName #NEWLINE# capacity_in_bytes = _get_device_capacity ( vmdk_device ) #NEWLINE# vmdk_controller_key = vmdk_device . controllerKey #NEWLINE# disk_type = _get_device_disk_type ( vmdk_device ) #NEWLINE# #UNINDENT# adapter_type = adapter_type_dict . get ( vmdk_controller_key ) #NEWLINE# return VmdkInfo ( vmdk_file_path , adapter_type , disk_type , capacity_in_bytes , vmdk_device )