Class: BuildCloud::LaunchConfiguration
- Inherits:
-
Object
- Object
- BuildCloud::LaunchConfiguration
- Includes:
- Component
- Defined in:
- lib/build-cloud/launchconfiguration.rb
Constant Summary collapse
- @@objects =
[]
Instance Method Summary collapse
- #create ⇒ Object
- #delete ⇒ Object
-
#initialize(fog_interfaces, log, options = {}) ⇒ LaunchConfiguration
constructor
A new instance of LaunchConfiguration.
- #read ⇒ Object (also: #fog_object)
Methods included from Component
Constructor Details
#initialize(fog_interfaces, log, options = {}) ⇒ LaunchConfiguration
Returns a new instance of LaunchConfiguration.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/build-cloud/launchconfiguration.rb', line 9 def initialize ( fog_interfaces, log, = {} ) @as = fog_interfaces[:as] @log = log @options = @log.debug( .inspect ) (:id, :image_id, :key_name, :user_data, :instance_type) require_one_of(:security_groups, :security_group_names) end |
Instance Method Details
#create ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/build-cloud/launchconfiguration.rb', line 22 def create return if exists? @log.info( "Creating launch configuration #{@options[:id]}" ) = @options.dup unless [:security_groups] [:security_groups] = [] [:security_group_names].each do |sg| [:security_groups] << BuildCloud::SecurityGroup.get_id_by_name( sg ) end .delete(:security_group_names) end [:user_data] = JSON.generate( @options[:user_data] ) launch_config = @as.configurations.new( ) launch_config.save @log.debug( launch_config.inspect ) end |
#delete ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/build-cloud/launchconfiguration.rb', line 57 def delete return unless exists? @log.info( "Deleting Launch Configuration #{@options[:id]}" ) fog_object.destroy end |
#read ⇒ Object Also known as: fog_object
51 52 53 |
# File 'lib/build-cloud/launchconfiguration.rb', line 51 def read @as.configurations.select { |lc| lc.id == @options[:id] }.first end |