Sha256: 2598852031667ec5203be51434b333e6a6721a3a7d1c8aa6fe8b80f8b3eb36c7

Contents?: true

Size: 868 Bytes

Versions: 1

Compression:

Stored size: 868 Bytes

Contents

module Vagabond
  module Actions
    module Destroy
      def destroy
        ui.info "Destroying instance: #{name}..."
        do_destroy
        ui.info 'Complete!'
      end

      private

      def do_destroy
        lxc.stop if lxc.running?
        com = "#{Config[:sudo]}lxc-destroy -n #{lxc.name}"
        cmd = Mixlib::ShellOut.new(com)
        cmd.run_command
        cmd.error!
        if(cmd.stderr.include?('skipping'))
          ui.warn 'Failed to unmount some resource. Doing so manually'
          %w(rootfs ephemeralbind).each do |mnt|
            cmd = Mixlib::ShellOut.new("#{Config[:sudo]}umount /var/lib/lxc/#{lxc.name}/#{mnt}")
            cmd.run_command
            cmd = Mixlib::ShellOut.new("#{Config[:sudo]}lxc-destroy -n #{lxc.name}")
            cmd.run_command
            cmd.error!
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagabond-0.1.0 lib/vagabond/actions/destroy.rb