Class: Central::Machine::Vagrant::MasterDestroyer
- Inherits:
-
Object
- Object
- Central::Machine::Vagrant::MasterDestroyer
- Defined in:
- lib/central/machine/vagrant/master_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) ⇒ MasterDestroyer
constructor
A new instance of MasterDestroyer.
- #run! ⇒ Object
Constructor Details
#initialize(api_client) ⇒ MasterDestroyer
Returns a new instance of MasterDestroyer.
10 11 12 |
# File 'lib/central/machine/vagrant/master_destroyer.rb', line 10 def initialize(api_client) @api_client = api_client end |
Instance Attribute Details
#api_client ⇒ Object (readonly)
Returns the value of attribute api_client.
7 8 9 |
# File 'lib/central/machine/vagrant/master_destroyer.rb', line 7 def api_client @api_client end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/central/machine/vagrant/master_destroyer.rb', line 7 def client @client end |
Instance Method Details
#run! ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/central/machine/vagrant/master_destroyer.rb', line 14 def run! if api_client.get('stacks')['stacks'].size > 0 abort('Cannot remove central-machine because it has stacks'.colorize(:red)) end vagrant_path = "#{Dir.home}/.central/vagrant_master" Dir.chdir(vagrant_path) do ShellSpinner 'Terminating Vagrant central-machine ' do Open3.popen2('vagrant destroy -f') do |_stdin, output, wait| while o = output.gets puts o if ENV['DEBUG'] end FileUtils.remove_entry_secure(vagrant_path) if wait.value == 0 end end end end |