Class: VSphereCloud::VMAttributeManager
- Inherits:
-
Object
- Object
- VSphereCloud::VMAttributeManager
- Defined in:
- lib/cloud/vsphere/drs_rules/vm_attribute_manager.rb
Instance Method Summary collapse
- #create(name) ⇒ Object
- #delete(name) ⇒ Object
- #find_by_name(name) ⇒ Object
-
#initialize(custom_fields_manager, logger) ⇒ VMAttributeManager
constructor
A new instance of VMAttributeManager.
Constructor Details
#initialize(custom_fields_manager, logger) ⇒ VMAttributeManager
Returns a new instance of VMAttributeManager.
5 6 7 8 |
# File 'lib/cloud/vsphere/drs_rules/vm_attribute_manager.rb', line 5 def initialize(custom_fields_manager, logger) @custom_fields_manager = custom_fields_manager @logger = logger end |
Instance Method Details
#create(name) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/cloud/vsphere/drs_rules/vm_attribute_manager.rb', line 14 def create(name) @logger.debug("Creating DRS rule attribute: #{name}") @custom_fields_manager.add_field_definition( name, VimSdk::Vim::VirtualMachine, policy, policy ) end |
#delete(name) ⇒ Object
24 25 26 27 28 |
# File 'lib/cloud/vsphere/drs_rules/vm_attribute_manager.rb', line 24 def delete(name) @logger.debug("Deleting DRS rule attribute: #{name}") custom_field = find_by_name(name) @custom_fields_manager.remove_field_definition(custom_field.key) if custom_field end |
#find_by_name(name) ⇒ Object
10 11 12 |
# File 'lib/cloud/vsphere/drs_rules/vm_attribute_manager.rb', line 10 def find_by_name(name) @custom_fields_manager.field.find { |f| f.name == name } end |