Sha256: 92a3b6aa69fe391981bb8ff027bd49285adfb79b9a0424f5e5e35c5c45f3a763

Contents?: true

Size: 1.82 KB

Versions: 27

Compression:

Stored size: 1.82 KB

Contents

require 'manageiq-gems-pending'
require 'ostruct'
require 'MiqVm/MiqVm'
require 'VmwareWebService/MiqVim'

require 'logger'
$vim_log = $log = Logger.new(STDERR)

SERVER        = raise "please define SERVER"
USERNAME      = raise "please define USERNAME"
PASSWORD      = raise "please define PASSWORD"
vim = MiqVim.new(SERVER, USERNAME, PASSWORD)

vimVm = nil
vm    = nil

alignment = 64 * 1024 # Check for alignment on a 64kB boundary

begin

  vim.virtualMachinesByMor.values.each do |vmo|
    begin
      vimVm = vim.getVimVmByMor(vmo['MOR'])

      vmx = vimVm.dsPath
      puts "VM: #{vimVm.name}, VMX = #{vmx}"

      if vimVm.poweredOn?
        puts "\tSkipping running VM"
        puts
        next
      end

      ost = OpenStruct.new
      ost.miqVim = vim

      #
      # Given an MiqVm object, we check to see if its partitions are aligned on a given boundary.
      # This boundary is usually based on the logical block size of the underlying storage array;
      # in this example, 64kB.
      #
      vm = MiqVm.new(vmx, ost)

      #
      # We check all of physical volumes of the VM. This Includes visible and hidden volumes, but excludes logical volumes.
      # The alignment of hidden volumes affects the performance of the logical volumes that are based on them.
      #
      vm.volumeManager.allPhysicalVolumes.each do |pv|
        vmdk = pv.dInfo.filename || pv.dInfo.vixDiskInfo[:fileName]
        aligned = pv.startByteAddr % alignment == 0 ? "Yes" : "No"
        puts "\t#{vmdk}, Partition: #{pv.partNum}, Partition type: #{pv.partType}, LBA: #{pv.lbaStart}, offset: #{pv.startByteAddr}, aligned: #{aligned}"
      end

      puts
    ensure
      vimVm.release if vimVm
      vm.unmount    if vm
      vimVm = vm = nil
    end
  end

rescue => err
  puts err.to_s
  puts err.backtrace.join("\n")
ensure
  vim.disconnect  if vim
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
manageiq-smartstate-0.2.18.2 lib/MiqVm/test/partitionAlignmentCheck.rb
manageiq-smartstate-0.3.1 lib/MiqVm/test/partitionAlignmentCheck.rb
manageiq-smartstate-0.3.0 lib/MiqVm/test/partitionAlignmentCheck.rb
manageiq-smartstate-0.2.24 lib/MiqVm/test/partitionAlignmentCheck.rb
manageiq-smartstate-0.2.18.1 lib/MiqVm/test/partitionAlignmentCheck.rb
manageiq-smartstate-0.2.23 lib/MiqVm/test/partitionAlignmentCheck.rb
manageiq-smartstate-0.2.22 lib/MiqVm/test/partitionAlignmentCheck.rb
manageiq-smartstate-0.2.21 lib/MiqVm/test/partitionAlignmentCheck.rb
manageiq-smartstate-0.2.20 lib/MiqVm/test/partitionAlignmentCheck.rb
manageiq-smartstate-0.2.19 lib/MiqVm/test/partitionAlignmentCheck.rb
manageiq-smartstate-0.2.18 lib/MiqVm/test/partitionAlignmentCheck.rb
manageiq-smartstate-0.2.17 lib/MiqVm/test/partitionAlignmentCheck.rb
manageiq-smartstate-0.2.16 lib/MiqVm/test/partitionAlignmentCheck.rb
manageiq-smartstate-0.2.15 lib/MiqVm/test/partitionAlignmentCheck.rb
manageiq-smartstate-0.2.14 lib/MiqVm/test/partitionAlignmentCheck.rb
manageiq-smartstate-0.2.13 lib/MiqVm/test/partitionAlignmentCheck.rb
manageiq-smartstate-0.2.12 lib/MiqVm/test/partitionAlignmentCheck.rb
manageiq-smartstate-0.2.11 lib/MiqVm/test/partitionAlignmentCheck.rb
manageiq-smartstate-0.2.10 lib/MiqVm/test/partitionAlignmentCheck.rb
manageiq-smartstate-0.2.9 lib/MiqVm/test/partitionAlignmentCheck.rb