Class: RbVmomi::PBM::PbmCapabilityProfile
- Inherits:
-
Object
- Object
- RbVmomi::PBM::PbmCapabilityProfile
- Includes:
- InventoryObject, PbmHelperModule
- Defined in:
- lib/rvc/modules/spbm.rb
Instance Method Summary collapse
- #children ⇒ Object
- #display_info ⇒ Object
- #rvc_children_datastores ⇒ Object
- #rvc_children_vms ⇒ Object
Methods included from PbmHelperModule
Instance Method Details
#children ⇒ Object
265 266 267 268 269 270 |
# File 'lib/rvc/modules/spbm.rb', line 265 def children { 'datastores' => RVC::FakeFolder.new(self, :rvc_children_datastores), 'vms' => RVC::FakeFolder.new(self, :rvc_children_vms), } end |
#display_info ⇒ Object
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
# File 'lib/rvc/modules/spbm.rb', line 305 def display_info super puts "Name: #{name}" puts "Description:" puts description puts "ProfileId: #{profileId.uniqueId}" puts "Type: #{resourceType.resourceType} - #{profileCategory}" puts "Rule-Sets:" constraints.subProfiles.each_with_index do |sub, i| puts " Rule-Set ##{i + 1}:" sub.capability.each do |rule| instances = rule.constraint.map{|c| c.propertyInstance}.flatten if instances.length > 1 raise "Can't deal with multiple constraints in single rule" end value = instances[0].value if value.is_a?(RbVmomi::PBM::PbmCapabilityRange) value = "#{value.min} - #{value.max}" end puts " #{rule.name}: #{value}" end end end |
#rvc_children_datastores ⇒ Object
291 292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'lib/rvc/modules/spbm.rb', line 291 def rvc_children_datastores pbm = @connection vim = @dc._connection pc = vim.propertyCollector _catch_spbm_resets(vim) do solver = pbm.serviceContent.placementSolver datastores = solver.find_compatible_datastores @dc.datastore, [profileId] props = pc.collectMultiple(datastores, 'name') Hash[props.map do |ds, ds_props| [ds_props['name'], ds] end] end end |
#rvc_children_vms ⇒ Object
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/rvc/modules/spbm.rb', line 272 def rvc_children_vms pbm = @connection vim = @dc._connection pc = vim.propertyCollector pm = pbm.serviceContent.profileManager vms = pm.PbmQueryAssociatedEntity( :profile => self.profileId, :entityType => 'virtualMachine' ) vms = vms.map do |ref| VIM::VirtualMachine(vim, ref.key) end props = pc.collectMultiple(vms, 'name') Hash[props.map do |vm, vm_props| [vm_props['name'], vm] end] end |