Class: Vagabond::Knife

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, name_args) ⇒ Knife

Returns a new instance of Knife.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/vagabond/knife.rb', line 10

def initialize(name, name_args)
  @name_args = name_args
  @vagabondfile = Vagabondfile.new(Config[:vagabond_file])
  Config[:disable_solo] = true
  Config[:sudo] = sudo
  Lxc.use_sudo = @vagabondfile[:sudo].nil? ? true : @vagabondfile[:sudo]
  @internal_config = InternalConfiguration.new(@vagabondfile, nil)
  unless(Config[:disable_local_server])
    if(@vagabondfile[:local_chef_server] && @vagabondfile[:local_chef_server][:enabled])
      srv = Lxc.new(@internal_config[:mappings][:server])
      if(srv.running?)
        Config[:knife_opts] = " -s https://#{srv.container_ip(10, true)}"
      else
        Config[:knife_opts] = ' -s https://no-local-server'
      end
    end
  end

end

Instance Attribute Details

#name_argsObject (readonly)

Returns the value of attribute name_args.



8
9
10
# File 'lib/vagabond/knife.rb', line 8

def name_args
  @name_args
end

Instance Method Details

#executeObject



30
31
32
# File 'lib/vagabond/knife.rb', line 30

def execute
  exec("knife #{name_args.join(' ')} #{Config[:knife_opts]}")
end