Class: Awsome::InstanceRequirement

Inherits:
Object
  • Object
show all
Defined in:
lib/awsome/instance_requirement.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options)
  @properties = properties.clone
  @options = options
end

Instance Attribute Details

#propertiesObject (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_idObject



27
28
29
# File 'lib/awsome/instance_requirement.rb', line 27

def ami_id
  @properties['ami_id']
end

#availability_zoneObject



39
40
41
# File 'lib/awsome/instance_requirement.rb', line 39

def availability_zone
  @properties['availability_zone']
end

#cnamesObject



19
20
21
# File 'lib/awsome/instance_requirement.rb', line 19

def cnames
  @properties['cnames'] || []
end

#elastic_ipsObject



15
16
17
# File 'lib/awsome/instance_requirement.rb', line 15

def elastic_ips
  @properties['elastic_ips'] || []
end

#elbsObject



11
12
13
# File 'lib/awsome/instance_requirement.rb', line 11

def elbs
  @properties['elbs'] || []
end

#instance_typeObject



35
36
37
# File 'lib/awsome/instance_requirement.rb', line 35

def instance_type
  @properties['instance_type']
end

#keyObject



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

#packagesObject



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_idsObject



43
44
45
# File 'lib/awsome/instance_requirement.rb', line 43

def security_group_ids
  @properties['security_group_ids']
end

#tagsObject



23
24
25
# File 'lib/awsome/instance_requirement.rb', line 23

def tags
  @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

#volumesObject



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