Class: Rivet::LaunchConfig
- Inherits:
-
Object
- Object
- Rivet::LaunchConfig
- Defined in:
- lib/rivet/launch_config.rb
Constant Summary collapse
- ATTRIBUTES =
[ :bootstrap, :iam_instance_profile, :image_id, :instance_type, :key_name, :security_groups, :associate_public_ip_address, :detailed_instance_monitoring, :block_device_mappings, :kernel_id, :ramdisk_id, :spot_price ].each { |a| attr_reader a }
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#id_prefix ⇒ Object
readonly
Returns the value of attribute id_prefix.
Instance Method Summary collapse
- #identity ⇒ Object
-
#initialize(config, id_prefix = 'rivet_') ⇒ LaunchConfig
constructor
A new instance of LaunchConfig.
- #save ⇒ Object
- #user_data ⇒ Object
Constructor Details
#initialize(config, id_prefix = 'rivet_') ⇒ LaunchConfig
Returns a new instance of LaunchConfig.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rivet/launch_config.rb', line 23 def initialize(config, id_prefix = 'rivet_') @config = config @id_prefix = id_prefix ATTRIBUTES.each do |a| if config.respond_to?(a) Rivet::Log.debug "Setting LaunchConfig @#{a} to #{config.send(a)}" instance_variable_set("@#{a}", config.send(a)) end end end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
21 22 23 |
# File 'lib/rivet/launch_config.rb', line 21 def config @config end |
#id_prefix ⇒ Object (readonly)
Returns the value of attribute id_prefix.
21 22 23 |
# File 'lib/rivet/launch_config.rb', line 21 def id_prefix @id_prefix end |
Instance Method Details
#identity ⇒ Object
39 40 41 |
# File 'lib/rivet/launch_config.rb', line 39 def identity @identity ||= generate_identity end |
#save ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/rivet/launch_config.rb', line 43 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? [:associate_public_ip_address] = associate_public_ip_address unless associate_public_ip_address.nil? [:detailed_instance_monitoring] = detailed_instance_monitoring unless detailed_instance_monitoring.nil? [:block_device_mappings] = block_device_mappings unless block_device_mappings.nil? [:kernel_id] = kernel_id unless kernel_id.nil? [:ramdisk_id] = ramdisk_id unless ramdisk_id.nil? [:spot_price] = spot_price unless spot_price.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
35 36 37 |
# File 'lib/rivet/launch_config.rb', line 35 def user_data @user_data ||= Bootstrap.new(@config).user_data end |