Class: MiqVimFolder
- Inherits:
-
Object
- Object
- MiqVimFolder
- Includes:
- DRb::DRbUndumped, MiqBrokerObjRegistry, MiqBrokerVimConnectionCheck
- Defined in:
- lib/VMwareWebService/MiqVimFolder.rb,
lib/VMwareWebService/MiqVimBrokerMods.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
(also: #release_orig)
Called when client is finished using this MiqVimVm object.
- #reload ⇒ Object
- #subFolderMors ⇒ Object
- #waitForTask(tmor) ⇒ Object
Methods included from MiqBrokerVimConnectionCheck
Methods included from MiqBrokerObjRegistry
#holdBrokerObj, #registerBrokerObj, #unregisterBrokerObj
Constructor Details
#initialize(invObj, fh) ⇒ MiqVimFolder
Returns a new instance of MiqVimFolder.
4 5 6 7 8 9 10 11 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 4 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.
2 3 4 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 2 def invObj @invObj end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
2 3 4 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 2 def name @name end |
Instance Method Details
#addStandaloneHost(hostName, userName, password, *args) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 46 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 $vim_log.info "MiqVimCluster(#{@invObj.server}, #{@invObj.username}).addStandaloneHost: calling addStandaloneHost_Task" if $vim_log taskMor = @invObj.addStandaloneHost_Task(@fMor, cspec, ah[:asConnected].to_s, ah[:license]) $vim_log.info "MiqVimCluster(#{@invObj.server}, #{@invObj.username}).addStandaloneHost: returned from addStandaloneHost_Task" if $vim_log return taskMor unless ah[:wait] waitForTask(taskMor) end |
#createFolder(fname) ⇒ Object
106 107 108 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 106 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
94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 94 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 $vim_log.info "MiqVimFolder(#{@invObj.server}, #{@invObj.username}).createVM calling createVM_Task" if $vim_log taskMor = @invObj.createVM_Task(@fMor, configSpec, pMor, hMor) $vim_log.info "MiqVimFolder(#{@invObj.server}, #{@invObj.username}).createVM returned from createVM_Task" if $vim_log $vim_log.debug "MiqVimFolder::createVM: taskMor = #{taskMor}" if $vim_log waitForTask(taskMor) end |
#fh ⇒ Object
30 31 32 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 30 def fh (@fh) end |
#fMor ⇒ Object
26 27 28 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 26 def fMor (@fMor) end |
#moveIntoFolder(vCenterObject) ⇒ Object
Places vCenterObject into current folder, removing it from other folders
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 76 def moveIntoFolder(vCenterObject) oMor = nil oMor = (vCenterObject.kind_of?(Hash) ? vCenterObject['MOR'] : vCenterObject) if vCenterObject $vim_log.info "MiqVimFolder(#{@invObj.server}, #{@invObj.username}).moveIntoFolder: calling moveIntoFolder_Task" if $vim_log taskMor = @invObj.moveIntoFolder_Task(@fMor, oMor) $vim_log.info "MiqVimFolder(#{@invObj.server}, #{@invObj.username}).moveIntoFolder: returned from moveIntoFolder_Task" if $vim_log $vim_log.debug "MiqVimFolder::moveIntoFolder: taskMor = #{taskMor}" if $vim_log waitForTask(taskMor) end |
#registerVM(path, name, pool = nil, host = nil, asTemplate = false) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 34 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 $vim_log.info "MiqVimFolder(#{@invObj.server}, #{@invObj.username}).registerVM: calling registerVM_Task" if $vim_log taskMor = @invObj.registerVM_Task(@fMor, path, name, asTemplate.to_s, pmor, hmor) $vim_log.info "MiqVimFolder(#{@invObj.server}, #{@invObj.username}).registerVM: returned from registerVM_Task" if $vim_log $vim_log.debug "MiqVimFolder::registerVM: taskMor = #{taskMor}" if $vim_log waitForTask(taskMor) end |
#release ⇒ Object Also known as: release_orig
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
18 19 20 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 18 def release # @invObj.releaseObj(self) end |
#reload ⇒ Object
22 23 24 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 22 def reload @fh = @invObj.getMoProp(@fMor) end |
#subFolderMors ⇒ Object
110 111 112 113 114 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 110 def subFolderMors fh['childEntity'].each_with_object([]) do |ce, ra| ra << ce if ce.vimType == 'Folder' end end |
#waitForTask(tmor) ⇒ Object
116 117 118 |
# File 'lib/VMwareWebService/MiqVimFolder.rb', line 116 def waitForTask(tmor) @invObj.waitForTask(tmor, self.class.to_s) end |