Class: MiqHostDatastoreSystem
- Inherits:
-
Object
- Object
- MiqHostDatastoreSystem
- Includes:
- VMwareWebService::Logging
- Defined in:
- lib/VMwareWebService/MiqHostDatastoreSystem.rb
Instance Attribute Summary collapse
-
#invObj ⇒ Object
readonly
Returns the value of attribute invObj.
Instance Method Summary collapse
-
#addNasDatastoreByName(dsName, accessMode = "readWrite") ⇒ Object
Utility method to add an existing NAS datastore to the host in question.
- #capabilities ⇒ Object
- #createNasDatastore(remoteHost, remotePath, localPath, accessMode = "readWrite", type = "nfs", userName = nil, password = nil) ⇒ Object
- #datastore ⇒ Object
-
#initialize(dssMor, invObj) ⇒ MiqHostDatastoreSystem
constructor
A new instance of MiqHostDatastoreSystem.
Methods included from VMwareWebService::Logging
Constructor Details
#initialize(dssMor, invObj) ⇒ MiqHostDatastoreSystem
Returns a new instance of MiqHostDatastoreSystem.
8 9 10 11 |
# File 'lib/VMwareWebService/MiqHostDatastoreSystem.rb', line 8 def initialize(dssMor, invObj) @invObj = invObj @dssMor = dssMor end |
Instance Attribute Details
#invObj ⇒ Object (readonly)
Returns the value of attribute invObj.
6 7 8 |
# File 'lib/VMwareWebService/MiqHostDatastoreSystem.rb', line 6 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.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# 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 ⇒ Object
13 14 15 |
# 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) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# 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 ⇒ Object
17 18 19 |
# File 'lib/VMwareWebService/MiqHostDatastoreSystem.rb', line 17 def datastore @invObj.getMoProp(@dssMor, 'datastore')['datastore'] end |