Class: MiqHostDatastoreSystem

Inherits:
Object
  • Object
show all
Includes:
DRb::DRbUndumped, MiqBrokerVimConnectionCheck
Defined in:
lib/VMwareWebService/MiqVimBrokerMods.rb,
lib/VMwareWebService/MiqHostDatastoreSystem.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MiqBrokerVimConnectionCheck

#connectionRemoved?

Constructor Details

#initialize(dssMor, invObj) ⇒ MiqHostDatastoreSystem

Returns a new instance of MiqHostDatastoreSystem.



4
5
6
7
# File 'lib/VMwareWebService/MiqHostDatastoreSystem.rb', line 4

def initialize(dssMor, invObj)
  @invObj = invObj
  @dssMor = dssMor
end

Instance Attribute Details

#invObjObject (readonly)

Returns the value of attribute invObj.



2
3
4
# File 'lib/VMwareWebService/MiqHostDatastoreSystem.rb', line 2

def invObj
  @invObj
end

Instance Method Details

#addNasDatastoreByName(dsName, accessMode = "readWrite") ⇒ Object

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



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/VMwareWebService/MiqHostDatastoreSystem.rb', line 33

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

  $vim_log.info "MiqHostDatastoreSystem.addNasDatastoreByName: remoteHost = #{remoteHost}, remotePath = #{remotePath}, localPath = #{localPath}"
  createNasDatastore(remoteHost, remotePath, localPath, accessMode, type)
end

#capabilitiesObject



9
10
11
# File 'lib/VMwareWebService/MiqHostDatastoreSystem.rb', line 9

def capabilities
  @capabilities ||= @invObj.getMoProp(@dssMor, 'capabilities')['capabilities']
end

#createNasDatastore(remoteHost, remotePath, localPath, accessMode = "readWrite", type = "nfs", userName = nil, password = nil) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/VMwareWebService/MiqHostDatastoreSystem.rb', line 17

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

#datastoreObject



13
14
15
# File 'lib/VMwareWebService/MiqHostDatastoreSystem.rb', line 13

def datastore
  @invObj.getMoProp(@dssMor, 'datastore')['datastore']
end