Sha256: d32e836bbaaf8fe045da9fc9bb0a3b37335fcdad615f719d826034251d8b6152
Contents?: true
Size: 1.31 KB
Versions: 2
Compression:
Stored size: 1.31 KB
Contents
module Vagabond module Actions module Destroy def destroy if(lxc.exists?) ui.info "#{ui.color('Vagabond:', :bold)} Destroying node: #{ui.color(name, :red)}" do_destroy ui.info ui.color(' -> DESTROYED', :red) else ui.error "Node not created: #{name}" end end private def do_destroy lxc.stop if lxc.running? com = "#{Config[:sudo]}lxc-destroy -n #{lxc.name}" debug(com) cmd = Mixlib::ShellOut.new(com, :live_stream => Config[:debug]) cmd.run_command cmd.error! if(cmd.stderr.include?('skipping')) ui.info ui.color(' -> Failed to unmount some resources. Forcing manually.', :yellow) %w(rootfs ephemeralbind).each do |mnt| com = "#{Config[:sudo]}umount /var/lib/lxc/#{lxc.name}/#{mnt}" debug(com) cmd = Mixlib::ShellOut.new(com, :live_stream => Config[:debug]) cmd.run_command com = "#{Config[:sudo]}lxc-destroy -n #{lxc.name}" debug(com) cmd = Mixlib::ShellOut.new(com, :live_stream => Config[:debug]) cmd.run_command cmd.error! internal_config[:mappings].delete(name) end internal_config.save end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vagabond-0.1.4 | lib/vagabond/actions/destroy.rb |
vagabond-0.1.2 | lib/vagabond/actions/destroy.rb |