Class: RbVmomi::PBM::PbmPlacementSolver

Inherits:
Object
  • Object
show all
Defined in:
lib/rvc/modules/spbm.rb

Instance Method Summary collapse

Instance Method Details

#find_compatible_datastores(datastores, profileIds) ⇒ Object



230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/rvc/modules/spbm.rb', line 230

def find_compatible_datastores datastores, profileIds
  if profileIds.length > 1
    raise Exception("Passing in more than one profile currently not supported")
  end
  dsMoMap = Hash[datastores.map{|x| [x._ref, x]}]
  results = self.PbmSolve(
    :hubsToSearch => datastores.map{|x| x.to_pbmhub}, 
    :requirements => [
      {
        :subject => PBM.PbmPlacementSubject(
          :subjectType=>"VirtualMachine", 
          :subjectId=>"fake"
        ), 
        :requirement => [
          PBM::PbmPlacementCapabilityProfileRequirement(
            :requirementType => "type", 
            :mandatory => true, 
            :profileId => profileIds[0]
          )
        ],
      }
    ], 
    :partialSolution => false
  )
  compatibleDsList = results.map do |x| 
    dsMoMap[x.subjectAssignment[0].hub.hubId]
  end
end