Class: Kiel::Implementation
- Inherits:
-
Object
- Object
- Kiel::Implementation
- Defined in:
- lib/kiel.rb
Overview
:nodoc: all
Instance Method Summary collapse
- #add_versions(steps) ⇒ Object
-
#create_task(step, steps) ⇒ Object
this function creates the rake task, by first checking if the image already exists and then starting the base image and running the setup step.
-
#expand_path(file_name) ⇒ Object
fully expands the given file_name or array of file names.
-
#initialize(defaults) ⇒ Implementation
constructor
A new instance of Implementation.
Constructor Details
#initialize(defaults) ⇒ Implementation
Returns a new instance of Implementation.
28 29 30 |
# File 'lib/kiel.rb', line 28 def initialize defaults @defaults = defaults.dup end |
Instance Method Details
#add_versions(steps) ⇒ Object
120 121 122 123 124 125 |
# File 'lib/kiel.rb', line 120 def add_versions steps steps.collect() do | step | name = step[ :scm_name ] == '*' ? '*' : ( step[ :scm_name ] ) step.merge( version: scm.version( name ) ) end end |
#create_task(step, steps) ⇒ Object
this function creates the rake task, by first checking if the image already exists and then starting the base image and running the setup step
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/kiel.rb', line 85 def create_task step, steps task = Rake::Task::define_task( step[ :task ] => steps.collect{ | s | s[ :task ] } ) do | task, arguments | = step, steps if cloud.exists? puts "image \'#{step[ :name ]}\' already up to date and exists:" .each{ | key, value | puts "\'#{key}\' => \'#{value}\'" } else puts "starting instance for: \'#{step[ :name ]}\'" instance = cloud.start_instance initial_image_id( step, steps ) puts "instance for: \'#{step[ :name ]}\' started." begin dns_name = cloud.dns_name instance = step.dup.merge( setup_name: ( step[ :setup_name ] ) ) [ :tags ] = puts "excuting installation for: \'#{step[ :name ]}\'" setup.execute , dns_name puts "installation for: \'#{step[ :name ]}\' done." puts "storing image for: \'#{step[ :name ]}\'" cloud.store_image instance, puts "image for: \'#{step[ :name ]}\' stored" rescue cloud.stop_instance instance raise end end end task.add_description( step[ :description ] ) if step.key? :description task end |
#expand_path(file_name) ⇒ Object
fully expands the given file_name or array of file names
55 56 57 58 59 60 61 62 63 |
# File 'lib/kiel.rb', line 55 def file_name @defaults[ :root_dir ] ||= Dir.pwd if file_name.kind_of? Array file_name.collect { |f| File. f, @defaults[ :root_dir ] } else File. file_name, @defaults[ :root_dir ] end end |