Class: MiqVimFolder
- Inherits:
-
Object
- Object
- MiqVimFolder
- Includes:
- VMwareWebService::Logging
- Defined in:
- lib/VMwareWebService/MiqVimFolder.rb
Instance Attribute Summary collapse
-
#invObj ⇒ Object
readonly
Returns the value of attribute invObj.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #addStandaloneHost(hostName, userName, password, *args) ⇒ Object
- #createFolder(fname) ⇒ Object
-
#createVM(configSpec, pool, host = nil) ⇒ Object
Creates empty VM, that can be installed later from ISO or whatever.
- #fh ⇒ Object
- #fMor ⇒ Object
-
#initialize(invObj, fh) ⇒ MiqVimFolder
constructor
A new instance of MiqVimFolder.
-
#moveIntoFolder(vCenterObject) ⇒ Object
Places vCenterObject into current folder, removing it from other folders.
- #registerVM(path, name, pool = nil, host = nil, asTemplate = false) ⇒ Object
-
#release ⇒ Object
Called when client is finished using this MiqVimVm object.
- #reload ⇒ Object
- #subFolderMors ⇒ Object
- #waitForTask(tmor) ⇒ Object
Methods included from VMwareWebService::Logging
Constructor Details
#initialize(invObj, fh) ⇒ MiqVimFolder
Returns a new instance of MiqVimFolder.
8 9 10 11 12 13 14 15 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 8 def initialize(invObj, fh) @invObj = invObj @sic = invObj.sic @fh = fh @name = @fh["name"] @fMor = @fh["MOR"] end |
Instance Attribute Details
#invObj ⇒ Object (readonly)
Returns the value of attribute invObj.
6 7 8 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 6 def invObj @invObj end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 6 def name @name end |
Instance Method Details
#addStandaloneHost(hostName, userName, password, *args) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 50 def addStandaloneHost(hostName, userName, password, *args) ah = {:force => false, :wait => true, :asConnected => true} if args.length == 1 && args.first.kind_of?(Hash) ah.merge!(args.first) elsif args.length > 1 ah.merge!(Hash[*args]) end cspec = VimHash.new('HostConnectSpec') do |cs| cs.force = ah[:force].to_s cs.hostName = hostName cs.userName = userName cs.password = password cs.managementIp = ah[:managementIp] unless ah[:managementIp].nil? cs.port = ah[:port] unless ah[:port].nil? cs.sslThumbprint = ah[:sslThumbprint] unless ah[:sslThumbprint].nil? cs.vimAccountName = ah[:vimAccountName] unless ah[:vimAccountName].nil? cs.vimAccountPassword = ah[:vimAccountPassword] unless ah[:vimAccountPassword].nil? cs.vmFolder = ah[:vmFolder] unless ah[:vmFolder].nil? end logger.info "MiqVimCluster(#{@invObj.server}, #{@invObj.username}).addStandaloneHost: calling addStandaloneHost_Task" taskMor = @invObj.addStandaloneHost_Task(@fMor, cspec, ah[:asConnected].to_s, ah[:license]) logger.info "MiqVimCluster(#{@invObj.server}, #{@invObj.username}).addStandaloneHost: returned from addStandaloneHost_Task" return taskMor unless ah[:wait] waitForTask(taskMor) end |
#createFolder(fname) ⇒ Object
110 111 112 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 110 def createFolder(fname) @invObj.createFolder(@fMor, fname) end |
#createVM(configSpec, pool, host = nil) ⇒ Object
Creates empty VM, that can be installed later from ISO or whatever
configSpec - describes VM details, it should be filled in calling code since there are too many possible options pool - VMware resource pool new VM will belong to host - VMware host this VM should start on, it can be nil if pool is on DRS cluster or single-host cluster
Returns MOR of new VM
98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 98 def createVM(configSpec, pool, host = nil) hMor = pMor = nil hMor = (host.kind_of?(Hash) ? host['MOR'] : host) if host pMor = (pool.kind_of?(Hash) ? pool['MOR'] : pool) if pool logger.info "MiqVimFolder(#{@invObj.server}, #{@invObj.username}).createVM calling createVM_Task" taskMor = @invObj.createVM_Task(@fMor, configSpec, pMor, hMor) logger.info "MiqVimFolder(#{@invObj.server}, #{@invObj.username}).createVM returned from createVM_Task" logger.debug "MiqVimFolder::createVM: taskMor = #{taskMor}" waitForTask(taskMor) end |
#fh ⇒ Object
34 35 36 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 34 def fh (@fh) end |
#fMor ⇒ Object
30 31 32 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 30 def fMor (@fMor) end |
#moveIntoFolder(vCenterObject) ⇒ Object
Places vCenterObject into current folder, removing it from other folders
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 80 def moveIntoFolder(vCenterObject) oMor = nil oMor = (vCenterObject.kind_of?(Hash) ? vCenterObject['MOR'] : vCenterObject) if vCenterObject logger.info "MiqVimFolder(#{@invObj.server}, #{@invObj.username}).moveIntoFolder: calling moveIntoFolder_Task" taskMor = @invObj.moveIntoFolder_Task(@fMor, oMor) logger.info "MiqVimFolder(#{@invObj.server}, #{@invObj.username}).moveIntoFolder: returned from moveIntoFolder_Task" logger.debug "MiqVimFolder::moveIntoFolder: taskMor = #{taskMor}" waitForTask(taskMor) end |
#registerVM(path, name, pool = nil, host = nil, asTemplate = false) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 38 def registerVM(path, name, pool = nil, host = nil, asTemplate = false) hmor = pmor = nil hmor = (host.kind_of?(Hash) ? host['MOR'] : host) if host pmor = (pool.kind_of?(Hash) ? pool['MOR'] : pool) if pool logger.info "MiqVimFolder(#{@invObj.server}, #{@invObj.username}).registerVM: calling registerVM_Task" taskMor = @invObj.registerVM_Task(@fMor, path, name, asTemplate.to_s, pmor, hmor) logger.info "MiqVimFolder(#{@invObj.server}, #{@invObj.username}).registerVM: returned from registerVM_Task" logger.debug "MiqVimFolder::registerVM: taskMor = #{taskMor}" waitForTask(taskMor) end |
#release ⇒ Object
Called when client is finished using this MiqVimVm object. The server will delete its reference to the object, so the server-side object csn be GC’d
22 23 24 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 22 def release # @invObj.releaseObj(self) end |
#reload ⇒ Object
26 27 28 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 26 def reload @fh = @invObj.getMoProp(@fMor) end |
#subFolderMors ⇒ Object
114 115 116 117 118 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 114 def subFolderMors fh['childEntity'].each_with_object([]) do |ce, ra| ra << ce if ce.vimType == 'Folder' end end |
#waitForTask(tmor) ⇒ Object
120 121 122 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 120 def waitForTask(tmor) @invObj.waitForTask(tmor, self.class.to_s) end |