Class: Vagabond::Knife

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions, Helpers
Defined in:
lib/vagabond/knife.rb

Instance Method Summary collapse

Methods included from Helpers

included

Constructor Details

#initialize(*args) ⇒ Knife

Returns a new instance of Knife.



14
15
16
# File 'lib/vagabond/knife.rb', line 14

def initialize(*args)
  super
end

Instance Method Details

#knife(command, *args) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/vagabond/knife.rb', line 19

def knife(command, *args)
  @options = options.dup
  @vagabondfile = Vagabondfile.new(options[:vagabond_file])
  options[:disable_solo] = true
  options[:sudo] = sudo
  Lxc.use_sudo = @vagabondfile[:sudo].nil? ? true : @vagabondfile[:sudo]
  @internal_config = InternalConfiguration.new(@vagabondfile, nil, options)
  unless(options[:local_server])
    if(@vagabondfile[:local_chef_server] && @vagabondfile[:local_chef_server][:enabled])
      srv = Lxc.new(@internal_config[:mappings][:server])
      if(srv.running?)
        options[:knife_opts] = " -s https://#{srv.container_ip(10, true)}"
      else
        options[:knife_opts] = ' -s https://no-local-server'
      end
    end
  end
  exec("knife #{[command, args].flatten.compact.join(' ')} #{options[:knife_opts]}")
end