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 21 |
# File 'lib/build-cloud/launchconfiguration.rb', line 9 def initialize ( fog_interfaces, log, = {} ) @as = fog_interfaces[:as] @log = log = @log.debug( .inspect ) (:id, :image_id, :key_name, :instance_type) require_one_of(:security_groups, :security_group_names) require_one_of(:user_data, :user_data_file, :user_data_template) end |
Instance Method Details
#create ⇒ Object
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/build-cloud/launchconfiguration.rb', line 23 def create return if exists? @log.info( "Creating launch configuration #{@options[:id]}" ) = .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 if [:user_data] [:user_data] = JSON.generate( [:user_data] ) elsif [:user_data_file] user_data_file_path = File.join( Dir.pwd, [:user_data_file]) if File.exists?( user_data_file_path ) [:user_data] = File.read( user_data_file_path ) .delete(:user_data_file) else @log.error("config lists a :user_data_file that doesn't exist at #{options[:user_data_file]}") end elsif [:user_data_template] variable_hash = [:user_data_variables] user_data_template_path = File.join( Dir.pwd, [:user_data_template]) if File.exists?( user_data_template_path ) template = File.read( user_data_template_path ) ### We set 'trim_mode' to '-', which supresses end of line white space on lines ending in '-%>' ### see http://ruby-doc.org/stdlib-2.1.2/libdoc/erb/rdoc/ERB.html#method-c-new buffer = ERB.new(template,nil,'-').result(binding) [:user_data] = buffer .delete(:user_data_variables) .delete(:user_data_template) else @log.error("config lists a :user_data_template that doesn't exist at #{options[:user_data_template]}") end end launch_config = @as.configurations.new( ) launch_config.save @log.debug( launch_config.inspect ) end |
#delete ⇒ Object
90 91 92 93 94 95 96 97 98 |
# File 'lib/build-cloud/launchconfiguration.rb', line 90 def delete return unless exists? @log.info( "Deleting Launch Configuration #{@options[:id]}" ) fog_object.destroy end |
#read ⇒ Object Also known as: fog_object
84 85 86 |
# File 'lib/build-cloud/launchconfiguration.rb', line 84 def read @as.configurations.select { |lc| lc.id == [:id] }.first end |