Sha256: 55883582bf666e46803da5d818e5731366df38a7b3fa200ec1155869c8659bcc

Contents?: true

Size: 1.16 KB

Versions: 60

Compression:

Stored size: 1.16 KB

Contents

require 'util/miq-xml'
require 'util/runcmd'
require 'metadata/VmConfig/VmConfig'

class GetNativeCfg
  LSHW = "lshw"

  def self.new
    lshwXml = MiqUtil.runcmd("#{LSHW} -xml")
    nodeHash = Hash.new { |h, k| h[k] = [] }
    doc = MiqXml.load(lshwXml)
    doc.find_match("//node").each { |n| nodeHash[n.attributes["id"].split(':', 2)[0]] << n }

    hardware = ""

    nodeHash["disk"].each do |d|
      diskid = d.find_first('businfo').get_text.to_s
      next unless diskid
      sn = d.find_first('size')
      # If there's no size node, assume it's a removable drive.
      next unless sn
      busType, busAddr = diskid.split('@', 2)
      if busType == "scsi"
        f1, f2 = busAddr.split(':', 2)
        f2 = f2.split('.')[1]
        busAddr = "#{f1}:#{f2}"
      else
        busAddr['.'] = ':'
      end
      diskid = busType + busAddr
      filename = d.find_first('logicalname').get_text.to_s
      hardware += "#{diskid}.present = \"TRUE\"\n"
      hardware += "#{diskid}.filename = \"#{filename}\"\n"
    end

    VmConfig.new(hardware)
  end
end

if __FILE__ == $0

  cfg = GetNativeCfg.new
  cfg.getDiskFileHash.each { |dtag, df| puts "#{dtag}\t=> #{df}" }

end

Version data entries

60 entries across 60 versions & 1 rubygems

Version Path
manageiq-smartstate-0.3.4 lib/metadata/VmConfig/GetNativeCfg.rb
manageiq-smartstate-0.4.0 lib/metadata/VmConfig/GetNativeCfg.rb
manageiq-smartstate-0.2.18.2 lib/metadata/VmConfig/GetNativeCfg.rb
manageiq-smartstate-0.3.3 lib/metadata/VmConfig/GetNativeCfg.rb
manageiq-smartstate-0.3.2 lib/metadata/VmConfig/GetNativeCfg.rb
manageiq-smartstate-0.3.1 lib/metadata/VmConfig/GetNativeCfg.rb
manageiq-smartstate-0.3.0 lib/metadata/VmConfig/GetNativeCfg.rb
manageiq-smartstate-0.2.24 lib/metadata/VmConfig/GetNativeCfg.rb
manageiq-smartstate-0.2.18.1 lib/metadata/VmConfig/GetNativeCfg.rb
manageiq-smartstate-0.2.23 lib/metadata/VmConfig/GetNativeCfg.rb
manageiq-smartstate-0.2.22 lib/metadata/VmConfig/GetNativeCfg.rb
manageiq-smartstate-0.2.21 lib/metadata/VmConfig/GetNativeCfg.rb
manageiq-smartstate-0.2.20 lib/metadata/VmConfig/GetNativeCfg.rb
manageiq-smartstate-0.2.19 lib/metadata/VmConfig/GetNativeCfg.rb
manageiq-smartstate-0.2.18 lib/metadata/VmConfig/GetNativeCfg.rb
manageiq-smartstate-0.2.17 lib/metadata/VmConfig/GetNativeCfg.rb
manageiq-smartstate-0.2.16 lib/metadata/VmConfig/GetNativeCfg.rb
manageiq-smartstate-0.2.15 lib/metadata/VmConfig/GetNativeCfg.rb
manageiq-smartstate-0.2.14 lib/metadata/VmConfig/GetNativeCfg.rb
manageiq-smartstate-0.2.13 lib/metadata/VmConfig/GetNativeCfg.rb