Class: CORL::Node::Vagrant

Inherits:
Object
  • Object
show all
Defined in:
lib/CORL/node/vagrant.rb

Instance Method Summary collapse

Instance Method Details

#bootstrap_scriptObject



80
81
82
# File 'lib/CORL/node/vagrant.rb', line 80

def bootstrap_script
  cache_setting(:bootstrap, nil)  
end

#bootstrap_script=(bootstrap) ⇒ Object




76
77
78
# File 'lib/CORL/node/vagrant.rb', line 76

def bootstrap_script=bootstrap
  set_cache_setting(:bootstrap, bootstrap)
end

#build(options = {}) ⇒ Object


Node operations



105
106
107
# File 'lib/CORL/node/vagrant.rb', line 105

def build(options = {})
  super(Config.ensure(options).import({ :save => false }))  
end

#build_timeObject



70
71
72
# File 'lib/CORL/node/vagrant.rb', line 70

def build_time
  cache_setting(:build, nil)
end

#build_time=(time) ⇒ Object




66
67
68
# File 'lib/CORL/node/vagrant.rb', line 66

def build_time=time
  set_cache_setting(:build, time)
end

#create(options = {}) ⇒ Object




111
112
113
114
115
116
117
118
# File 'lib/CORL/node/vagrant.rb', line 111

def create(options = {})
  super do |op, config|
    if op == :config
      config.import(exec_options(:create))
      config[:provision_enabled] = false
    end     
  end
end

#create_image(options = {}) ⇒ Object




183
184
185
186
187
188
189
# File 'lib/CORL/node/vagrant.rb', line 183

def create_image(options = {})
  super do |op, config|
    if op == :config
      config.import(exec_options(:image))
    end
  end
end

#destroy(options = {}) ⇒ Object




205
206
207
208
209
210
211
# File 'lib/CORL/node/vagrant.rb', line 205

def destroy(options = {})    
  super do |op, config|
    if op == :config
      config.import(exec_options(:destroy))
    end
  end
end

#download(remote_path, local_path, options = {}) ⇒ Object




122
123
124
125
126
127
128
# File 'lib/CORL/node/vagrant.rb', line 122

def download(remote_path, local_path, options = {})
  super do |op, config|
    if op == :config
      config.import(exec_options(:download))
    end
  end
end

#exec(options = {}) ⇒ Object




142
143
144
145
146
147
148
# File 'lib/CORL/node/vagrant.rb', line 142

def exec(options = {})
  super do |op, config|
    if op == :config
      config.import(exec_options(:exec))
    end
  end
end

#exec_options(name, options = {}) ⇒ Object




98
99
100
# File 'lib/CORL/node/vagrant.rb', line 98

def exec_options(name, options = {})
  extended_config(name, options).export
end

#filter_output(type, data) ⇒ Object




225
226
227
228
229
230
231
232
233
234
# File 'lib/CORL/node/vagrant.rb', line 225

def filter_output(type, data)
  data = super
  
  if type == :error
    if data.include?('stdin: is not a tty') || data.include?('unable to re-open stdin')
      data = ''  
    end
  end
  data  
end

#image_id(image) ⇒ Object


Image utilities



252
253
254
# File 'lib/CORL/node/vagrant.rb', line 252

def image_id(image)
  image.id
end

#image_search_text(image) ⇒ Object




264
265
266
# File 'lib/CORL/node/vagrant.rb', line 264

def image_search_text(image)
  image.to_s
end

#init_sharesObject


Utilities



216
217
218
219
220
221
# File 'lib/CORL/node/vagrant.rb', line 216

def init_shares
  shares.each do |name, info|
    local_dir = info[:local]
    network.ignore(local_dir)      
  end
end

#machine_configObject


Settings groups



87
88
89
90
91
92
93
94
# File 'lib/CORL/node/vagrant.rb', line 87

def machine_config
  super do |config|        
    config[:vm]     = vm
    config[:shares] = shares
    
    yield(config) if block_given?
  end
end

#machine_type_id(machine_type) ⇒ Object


Machine type utilities



239
240
241
# File 'lib/CORL/node/vagrant.rb', line 239

def machine_type_id(machine_type)
  machine_type
end

#normalize(reload) ⇒ Object


Node plugin interface



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/CORL/node/vagrant.rb', line 9

def normalize(reload)
  super
  
  unless reload
    machine_provider = :vagrant
    machine_provider = yield if block_given?
                      
    myself.machine = create_machine(:machine, machine_provider, machine_config)
  end
  
  network.ignore([ '.vagrant', 'boxes' ])
  init_shares
end

#reload(options = {}) ⇒ Object




172
173
174
175
176
177
178
179
# File 'lib/CORL/node/vagrant.rb', line 172

def reload(options = {})
  super do |op, config|
    if op == :config
      config.import(exec_options(:reload))
      config[:provision_enabled] = false
    end
  end
end

#render_image(image) ⇒ Object




258
259
260
# File 'lib/CORL/node/vagrant.rb', line 258

def render_image(image)
  ''  
end

#render_machine_type(machine_type) ⇒ Object




245
246
247
# File 'lib/CORL/node/vagrant.rb', line 245

def render_machine_type(machine_type)
  machine_type.to_s
end

#save(options = {}) ⇒ Object




152
153
154
155
156
157
# File 'lib/CORL/node/vagrant.rb', line 152

def save(options = {})
  super do
    id(true)
    delete_setting(:machine_type)  
  end  
end

#sharesObject



60
61
62
# File 'lib/CORL/node/vagrant.rb', line 60

def shares
  hash(myself[:shares])
end

#shares=(shares) ⇒ Object




55
56
57
58
# File 'lib/CORL/node/vagrant.rb', line 55

def shares=shares
  myself[:shares] = shares
  init_shares
end

#sshObject



49
50
51
# File 'lib/CORL/node/vagrant.rb', line 49

def ssh
  hash(myself[:ssh])
end

#ssh=(ssh) ⇒ Object




45
46
47
# File 'lib/CORL/node/vagrant.rb', line 45

def ssh=ssh
  myself[:ssh] = ssh
end

#start(options = {}) ⇒ Object




161
162
163
164
165
166
167
168
# File 'lib/CORL/node/vagrant.rb', line 161

def start(options = {})
  super do |op, config|
    if op == :config
      config.import(exec_options(:start))
      config[:provision_enabled] = false
    end
  end
end

#state(reset = false) ⇒ Object


Property accessors / modifiers



29
30
31
# File 'lib/CORL/node/vagrant.rb', line 29

def state(reset = false)
  machine.state
end

#stop(options = {}) ⇒ Object




193
194
195
196
197
198
199
200
201
# File 'lib/CORL/node/vagrant.rb', line 193

def stop(options = {})
  super do |op, config|
    if op == :config
      config.import(exec_options(:stop))
    elsif op == :finalize
      true
    end
  end
end

#upload(local_path, remote_path, options = {}) ⇒ Object




132
133
134
135
136
137
138
# File 'lib/CORL/node/vagrant.rb', line 132

def upload(local_path, remote_path, options = {})
  super do |op, config|
    if op == :config
      config.import(exec_options(:upload))
    end
  end
end

#vmObject



39
40
41
# File 'lib/CORL/node/vagrant.rb', line 39

def vm
  hash(myself[:vm])
end

#vm=(vm) ⇒ Object




35
36
37
# File 'lib/CORL/node/vagrant.rb', line 35

def vm=vm
  myself[:vm] = vm
end