Class: Kuzushi

Inherits:
Object
  • Object
show all
Defined in:
lib/kuzushi.rb

Overview

firewall until ready ruby 1.9 compatibility nested configs user configs

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url = nil) ⇒ Kuzushi

Returns a new instance of Kuzushi.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/kuzushi.rb', line 21

def initialize(url = nil)
  if url
    @url = url
    @base_url = File.dirname(url)
    if @url =~ /s3.amazonaws.com.*\/([^\/]*)[.](\d+)[.]tar[.]gz/
      @name = $1
      @version = $2
    end
    @scripts = true
  end
  @configs = []
  @packages = []
  @tasks = []
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



16
17
18
# File 'lib/kuzushi.rb', line 16

def config
  @config
end

Class Method Details

.versionObject



18
19
# File 'lib/kuzushi.rb', line 18

def self.version
end

Instance Method Details

#bootObject



41
42
43
44
45
# File 'lib/kuzushi.rb', line 41

def boot
  shell "mkdir -p /tmp/kuzushi/"
  shell "cd /tmp/kuzushi/ ; curl --silent '#{@url}' | tar xzv"
  @config = JSON.parse(File.read("/tmp/kuzushi/#{@name}/config.json"))
end

#execute_tasksObject



69
70
71
72
73
74
75
76
# File 'lib/kuzushi.rb', line 69

def execute_tasks
  log "---- BEGIN KUZUSHI "
  @tasks.each do |t|
    log "TASK: #{t[:description]}"
    t[:blk].call
  end
  log "---- END KUZUSHI "
end

#initObject



36
37
38
39
# File 'lib/kuzushi.rb', line 36

def init
  @init = true
  start
end

#runObject



64
65
66
67
# File 'lib/kuzushi.rb', line 64

def run
  process_stack
  execute_tasks
end

#setupObject



53
54
55
56
57
58
59
60
61
62
# File 'lib/kuzushi.rb', line 53

def setup
  @init    = (ENV['JUDO_FIRST_BOOT'] == "true")
  @config  = JSON.parse(File.read("config.json"))
  @scripts = false

  process :packages
  process :volumes

  execute_tasks
end

#startObject



47
48
49
50
51
# File 'lib/kuzushi.rb', line 47

def start
#    load_config_stack(@name)
  boot
  run
end