Class: Larrow::Runner::Model::App
- Inherits:
-
Object
- Object
- Larrow::Runner::Model::App
- Includes:
- Service
- Defined in:
- lib/larrow/runner/model/app.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
Returns the value of attribute configuration.
-
#node ⇒ Object
Returns the value of attribute node.
-
#vcs ⇒ Object
Returns the value of attribute vcs.
Instance Method Summary collapse
- #action(group) ⇒ Object
- #allocate ⇒ Object
- #assign(arg) ⇒ Object
- #build_image ⇒ Object
- #deploy ⇒ Object
- #dump ⇒ Object
-
#initialize(vcs, attributes = {}) ⇒ App
constructor
A new instance of App.
Constructor Details
#initialize(vcs, attributes = {}) ⇒ App
Returns a new instance of App.
6 7 8 9 10 |
# File 'lib/larrow/runner/model/app.rb', line 6 def initialize vcs, attributes={} self.vcs = vcs self.configuration = Manifest.configuration vcs self.assign attributes unless attributes.empty? end |
Instance Attribute Details
#configuration ⇒ Object
Returns the value of attribute configuration.
5 6 7 |
# File 'lib/larrow/runner/model/app.rb', line 5 def configuration @configuration end |
#node ⇒ Object
Returns the value of attribute node.
5 6 7 |
# File 'lib/larrow/runner/model/app.rb', line 5 def node @node end |
#vcs ⇒ Object
Returns the value of attribute vcs.
5 6 7 |
# File 'lib/larrow/runner/model/app.rb', line 5 def vcs @vcs end |
Instance Method Details
#action(group) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/larrow/runner/model/app.rb', line 18 def action group verbose = RunOption.key?(:debug) ? true : nil configuration.steps_for(group) do |a_step| RunLogger.title "[#{a_step.title}]" begin_at = Time.new a_step.run_on node, verbose: verbose during = sprintf('%.2f',Time.new - begin_at) RunLogger.level(1).info "#{a_step.title} complete (#{during}s)" end end |
#allocate ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/larrow/runner/model/app.rb', line 29 def allocate RunLogger.title 'allocate resource' begin_at = Time.new option = {image_id: configuration.image} self.node = Node.new(*Session.cloud.create(option).first) during = sprintf('%.2f', Time.new - begin_at) RunLogger.level(1).detail "allocated(#{during}s)" end |
#assign(arg) ⇒ Object
12 13 14 15 16 |
# File 'lib/larrow/runner/model/app.rb', line 12 def assign arg arg.each_pair do |k,v| self.send "#{k}=".to_sym, v end end |
#build_image ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/larrow/runner/model/app.rb', line 38 def build_image action :image node.stop new_image = Session.cloud.create_image node.instance.id RunLogger.level(1).detail "New Image Id: #{new_image.id}" [ "To reduce the system setup, you might want to change larrow.yml.", " You can replace init step with the follow contents:", " image: #{new_image.id}" ].each{|s| RunLogger.level(1).detail s} new_image end |
#deploy ⇒ Object
52 53 54 55 56 |
# File 'lib/larrow/runner/model/app.rb', line 52 def deploy action :deploy RunLogger.level(1).detail "application is deploy on: #{node.host}" node end |
#dump ⇒ Object
58 59 60 |
# File 'lib/larrow/runner/model/app.rb', line 58 def dump {nodes:[node.dump]} end |