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','iam_instance_profile','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 24 |
# 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 Rivet::Log.debug("Setting LaunchConfig @#{a} to #{spec[a]}") 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
30 31 32 |
# File 'lib/rivet/launch_config.rb', line 30 def identity @identity ||= generate_identity end |
#save ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rivet/launch_config.rb', line 34 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? [:iam_instance_profile] = iam_instance_profile unless iam_instance_profile.nil? Rivet::Log.info("Saving launch configuration #{identity} to AWS") Rivet::Log.debug("Launch Config options:\n #{.inspect}") lc_collection.create(identity,image_id,instance_type, ) end end |