class MiqHostDatastoreSystem

Attributes

invObj[R]

Public Class Methods

new(dssMor, invObj) click to toggle source
# File lib/VMwareWebService/MiqHostDatastoreSystem.rb, line 8
def initialize(dssMor, invObj)
  @invObj = invObj
  @dssMor = dssMor
end

Public Instance Methods

addNasDatastoreByName(dsName, accessMode = "readWrite") click to toggle source

Utility method to add an existing NAS datastore to the host in question.

# File lib/VMwareWebService/MiqHostDatastoreSystem.rb, line 37
def addNasDatastoreByName(dsName, accessMode = "readWrite")
  if (dsh = @invObj.dataStoresByFilter_local("summary.name" => dsName).first).nil?
    raise "MiqHostDatastoreSystem.addNasDatastoreByName: datastore #{sdName} not found"
  end

  unless dsh.summary.type.casecmp('nfs') == 0 || dsh.summary.type.casecmp('nas') == 0
    raise "MiqHostDatastoreSystem.addNasDatastoreByName: datastore #{dsName} is not NAS"
  end

  remoteHost  = dsh.info.nas.remoteHost
  remotePath  = dsh.info.nas.remotePath
  localPath = dsh.info.nas.name
  type    = dsh.info.nas.type

  logger.info "MiqHostDatastoreSystem.addNasDatastoreByName: remoteHost = #{remoteHost}, remotePath = #{remotePath}, localPath = #{localPath}"
  createNasDatastore(remoteHost, remotePath, localPath, accessMode, type)
end
capabilities() click to toggle source
# File lib/VMwareWebService/MiqHostDatastoreSystem.rb, line 13
def capabilities
  @capabilities ||= @invObj.getMoProp(@dssMor, 'capabilities')['capabilities']
end
createNasDatastore(remoteHost, remotePath, localPath, accessMode = "readWrite", type = "nfs", userName = nil, password = nil) click to toggle source
# File lib/VMwareWebService/MiqHostDatastoreSystem.rb, line 21
def createNasDatastore(remoteHost, remotePath, localPath, accessMode = "readWrite", type = "nfs", userName = nil, password = nil)
  spec = VimHash.new('HostNasVolumeSpec') do |s|
    s.remoteHost  = remoteHost
    s.remotePath  = remotePath
    s.localPath   = localPath
    s.accessMode  = accessMode
    s.type      = type
    s.userName    = userName
    s.password    = password
  end
  @invObj.createNasDatastore(@dssMor, spec)
end
datastore() click to toggle source
# File lib/VMwareWebService/MiqHostDatastoreSystem.rb, line 17
def datastore
  @invObj.getMoProp(@dssMor, 'datastore')['datastore']
end