resource_pool.patch

Tino Vázquez, 04/21/2015 10:05 AM

Download (2.71 KB)

View differences:

src/vmm_mad/remotes/vcenter/vcenter_driver.rb
146 146
    # The associated resource pool for this connection
147 147
    ########################################################################
148 148
    def resource_pool
149
        return @cluster.resourcePool
149
        rp_name = @one_host["TEMPLATE/VCENTER_RESOURCE_POOL"]
150

  
151
        if rp_name.nil?
152
           @cluster.resourcePool
153
        else
154
           find_resource_pool(rp_name)
155
        end
150 156
    end
151 157

  
152 158
    ########################################################################
......
168 174

  
169 175
    ########################################################################
170 176
    # Searches the associated vmFolder of the DataCenter for the current
177
    # connection. Returns a RbVmomi::VIM::ResourcePool or the default pool
178
    # if not found
179
    # @param rpool [String] the ResourcePool Name
180
    ########################################################################
181
    def find_resource_pool(poolName)
182

  
183
        baseEntity  = @cluster
184
        entityArray = poolName.split('/')
185

  
186
        entityArray.each do |entityArrItem|
187
          next if entityArrItem == ''
188

  
189
          case baseEntity.is_a?
190
            when RbVmomi::VIM::Folder
191
              baseEntity = baseEntity.childEntity.find { |f|
192
                             f.name == entityArrItem
193
                           }
194
            when RbVmomi::VIM::ClusterComputeResource
195
              baseEntity = baseEntity.resourcePool.resourcePool.find { |f|
196
                             f.name == entityArrItem
197
                           }
198
            when RbVmomi::VIM::ResourcePool
199
              baseEntity = baseEntity.resourcePool.find { |f|
200
                             f.name == entityArrItem
201
                           }
202
            else
203
              baseEntity = nil
204
          end
205
        end
206

  
207
        if !baseEntity
208
            return @cluster.resourcePool
209
        else
210
            if not baseEntity.is_a?(RbVmomi::VIM::ResourcePool) and
211
               baseEntity.respond_to?(:resourcePool)
212
               return baseEntity.resourcePool
213
            else
214
               return baseEntity
215
        end
216
    end
217

  
218
    ########################################################################
219
    # Searches the associated vmFolder of the DataCenter for the current
171 220
    # connection. Returns a RbVmomi::VIM::VirtualMachine or nil if not found
172 221
    # @param vm_name [String] the UUID of the VM or VM Template
173 222
    ########################################################################