Class: Rivet::LaunchConfig
- Inherits:
-
Object
- Object
- Rivet::LaunchConfig
- Defined in:
- lib/rivet/launch_config.rb
Constant Summary collapse
- LC_ATTRIBUTES =
['key_name','image_id','instance_type','security_groups','bootstrap']
Instance Attribute Summary collapse
-
#id_prefix ⇒ Object
readonly
Returns the value of attribute id_prefix.
Instance Method Summary collapse
- #identity ⇒ Object
-
#initialize(spec, id_prefix = "rivet_") ⇒ LaunchConfig
constructor
A new instance of LaunchConfig.
- #save ⇒ Object
- #user_data ⇒ Object
Constructor Details
#initialize(spec, id_prefix = "rivet_") ⇒ LaunchConfig
Returns a new instance of LaunchConfig.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rivet/launch_config.rb', line 12 def initialize(spec,id_prefix="rivet_") @id_prefix = id_prefix LC_ATTRIBUTES.each do |a| if respond_to? "normalize_#{a}".to_sym spec[a] = self.send("normalize_#{a.to_sym}",spec[a]) end instance_variable_set("@#{a}",spec[a]) end end |
Instance Attribute Details
#id_prefix ⇒ Object (readonly)
Returns the value of attribute id_prefix.
10 11 12 |
# File 'lib/rivet/launch_config.rb', line 10 def id_prefix @id_prefix end |
Instance Method Details
#identity ⇒ Object
29 30 31 |
# File 'lib/rivet/launch_config.rb', line 29 def identity @identity ||= generate_identity end |
#save ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rivet/launch_config.rb', line 33 def save AwsUtils.verify_security_groups(security_groups) lc_collection = AWS::AutoScaling.new().launch_configurations if lc_collection[identity].exists? Rivet::Log.info("Launch configuration #{identity} already exists in AWS") else = {} [:key_pair] = key_name unless key_name.nil? [:security_groups] = security_groups unless security_groups.nil? [:user_data] = user_data unless user_data.nil? Rivet::Log.info("Saving launch configuration #{identity} to AWS") Rivet::Log.debug("Launch Config options:\n #{options.inspect}") lc_collection.create(identity,image_id,instance_type, ) end end |
#user_data ⇒ Object
25 26 27 |
# File 'lib/rivet/launch_config.rb', line 25 def user_data @user_data ||= Bootstrap.new(bootstrap).user_data end |