Class: Awsome::InstanceRequirement
- Inherits:
-
Object
- Object
- Awsome::InstanceRequirement
- Defined in:
- lib/awsome/instance_requirement.rb
Instance Attribute Summary collapse
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
Instance Method Summary collapse
- #ami_id ⇒ Object
- #availability_zone ⇒ Object
- #cnames ⇒ Object
- #elastic_ips ⇒ Object
- #elbs ⇒ Object
-
#initialize(properties, options) ⇒ InstanceRequirement
constructor
A new instance of InstanceRequirement.
- #instance_type ⇒ Object
- #key ⇒ Object
- #package_change_count(instance) ⇒ Object
- #packages ⇒ Object
- #packages_to_install(instance) ⇒ Object
- #packages_to_remove(instance) ⇒ Object
- #security_group_ids ⇒ Object
- #tags ⇒ Object
- #volume_change_count(instance) ⇒ Object
- #volumes ⇒ Object
- #volumes_to_attach(instance) ⇒ Object
- #volumes_to_detach(instance) ⇒ Object
Constructor Details
#initialize(properties, options) ⇒ InstanceRequirement
Returns a new instance of InstanceRequirement.
6 7 8 9 |
# File 'lib/awsome/instance_requirement.rb', line 6 def initialize(properties, ) @properties = properties.clone @options = end |
Instance Attribute Details
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
4 5 6 |
# File 'lib/awsome/instance_requirement.rb', line 4 def properties @properties end |
Instance Method Details
#ami_id ⇒ Object
27 28 29 |
# File 'lib/awsome/instance_requirement.rb', line 27 def ami_id @properties['ami_id'] end |
#availability_zone ⇒ Object
39 40 41 |
# File 'lib/awsome/instance_requirement.rb', line 39 def availability_zone @properties['availability_zone'] end |
#cnames ⇒ Object
19 20 21 |
# File 'lib/awsome/instance_requirement.rb', line 19 def cnames @properties['cnames'] || [] end |
#elastic_ips ⇒ Object
15 16 17 |
# File 'lib/awsome/instance_requirement.rb', line 15 def elastic_ips @properties['elastic_ips'] || [] end |
#elbs ⇒ Object
11 12 13 |
# File 'lib/awsome/instance_requirement.rb', line 11 def elbs @properties['elbs'] || [] end |
#instance_type ⇒ Object
35 36 37 |
# File 'lib/awsome/instance_requirement.rb', line 35 def instance_type @properties['instance_type'] end |
#key ⇒ Object
31 32 33 |
# File 'lib/awsome/instance_requirement.rb', line 31 def key @properties['key'] end |
#package_change_count(instance) ⇒ Object
67 68 69 |
# File 'lib/awsome/instance_requirement.rb', line 67 def package_change_count(instance) packages_to_install(instance).size + packages_to_remove(instance).size end |
#packages ⇒ Object
71 72 73 |
# File 'lib/awsome/instance_requirement.rb', line 71 def packages (@properties['packages'] || []).to_set end |
#packages_to_install(instance) ⇒ Object
59 60 61 |
# File 'lib/awsome/instance_requirement.rb', line 59 def packages_to_install(instance) packages - packages_installed_on(instance) end |
#packages_to_remove(instance) ⇒ Object
63 64 65 |
# File 'lib/awsome/instance_requirement.rb', line 63 def packages_to_remove(instance) packages_installed_on(instance) - packages end |
#security_group_ids ⇒ Object
43 44 45 |
# File 'lib/awsome/instance_requirement.rb', line 43 def security_group_ids @properties['security_group_ids'] end |
#tags ⇒ Object
23 24 25 |
# File 'lib/awsome/instance_requirement.rb', line 23 def @properties['tags'] || {} end |
#volume_change_count(instance) ⇒ Object
55 56 57 |
# File 'lib/awsome/instance_requirement.rb', line 55 def volume_change_count(instance) volumes_to_attach(instance).size + volumes_to_detach(instance).size end |
#volumes ⇒ Object
75 76 77 |
# File 'lib/awsome/instance_requirement.rb', line 75 def volumes @options.filter_volume_ids(@properties['volumes'] || []) end |
#volumes_to_attach(instance) ⇒ Object
47 48 49 |
# File 'lib/awsome/instance_requirement.rb', line 47 def volumes_to_attach(instance) (volumes - volumes_attached_to(instance)).collect { |v| @options.find_volume(v) } end |
#volumes_to_detach(instance) ⇒ Object
51 52 53 |
# File 'lib/awsome/instance_requirement.rb', line 51 def volumes_to_detach(instance) (volumes_attached_to(instance) - volumes).collect { |v| @options.find_volume(v) } end |