Class: Vagabond::Knife
- Inherits:
-
Thor
- Object
- Thor
- Vagabond::Knife
- Includes:
- Thor::Actions, Helpers
- Defined in:
- lib/vagabond/knife.rb
Constant Summary
Constants included from Helpers
Helpers::GEN_NAME_LENGTH, Helpers::RAND_CHARS
Instance Method Summary collapse
-
#initialize(*args) ⇒ Knife
constructor
A new instance of Knife.
- #knife(command, *args) ⇒ Object
Methods included from Helpers
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 38 39 40 41 42 |
# File 'lib/vagabond/knife.rb', line 19 def knife(command, *args) @options = .dup @vagabondfile = Vagabondfile.new([:vagabond_file]) [:disable_solo] = true [:sudo] = sudo Lxc.use_sudo = @vagabondfile[:sudo].nil? ? true : @vagabondfile[:sudo] @internal_config = InternalConfiguration.new(@vagabondfile, nil, ) unless([:local_server]) if(@vagabondfile[:local_chef_server] && @vagabondfile[:local_chef_server][:enabled]) srv = Lxc.new(@internal_config[:mappings][:server]) if(srv.running?) proto = @vagabondfile[:local_chef_server][:zero] ? 'http' : 'https' [:knife_opts] = " --server-url #{proto}://#{srv.container_ip(10, true)}" else [:knife_opts] = ' -s https://no-local-server' end end end command_string = [command, args.map{|s| "'#{s}'"}].flatten.compact.join(' ') if(ENV['VAGABOND_KNIFE_DEBUG']) puts "knife #{command_string} #{[:knife_opts]}" end exec("knife #{command_string} #{[:knife_opts]}") end |