Class: Kontena::Machine::Vagrant::NodeDestroyer
- Inherits:
-
Object
- Object
- Kontena::Machine::Vagrant::NodeDestroyer
- Includes:
- Cli::ShellSpinner, Common, RandomName
- Defined in:
- lib/kontena/machine/vagrant/node_destroyer.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
readonly
Returns the value of attribute api_client.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#initialize(api_client) ⇒ NodeDestroyer
constructor
A new instance of NodeDestroyer.
- #run!(grid, name) ⇒ Object
Methods included from Common
Constructor Details
#initialize(api_client) ⇒ NodeDestroyer
Returns a new instance of NodeDestroyer.
14 15 16 |
# File 'lib/kontena/machine/vagrant/node_destroyer.rb', line 14 def initialize(api_client) @api_client = api_client end |
Instance Attribute Details
#api_client ⇒ Object (readonly)
Returns the value of attribute api_client.
11 12 13 |
# File 'lib/kontena/machine/vagrant/node_destroyer.rb', line 11 def api_client @api_client end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
11 12 13 |
# File 'lib/kontena/machine/vagrant/node_destroyer.rb', line 11 def client @client end |
Instance Method Details
#run!(grid, name) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/kontena/machine/vagrant/node_destroyer.rb', line 18 def run!(grid, name) vagrant_path = "#{Dir.home}/.kontena/#{grid}/#{name}" Dir.chdir(vagrant_path) do spinner "Triggering termination of Vagrant machine #{name.colorize(:cyan)}" run_command('vagrant destroy -f') FileUtils.remove_entry_secure(vagrant_path) end node = api_client.get("grids/#{grid}/nodes")['nodes'].find{|n| n['name'] == name} if node spinner "Removing node #{name.colorize(:cyan)} from grid #{grid.colorize(:cyan)} " do api_client.delete("nodes/#{grid}/#{name}") end end end |