Sha256: f186dca69691293c1d31fe6b15b64aba8c8c7035312f9f2b00a0635b84dcbb11

Contents?: true

Size: 1004 Bytes

Versions: 1

Compression:

Stored size: 1004 Bytes

Contents

module LeapCli; module Commands

  desc 'Database commands.'
  command :db do |db|
    db.desc 'Destroy all the databases. If present, limit to FILTER nodes.'
    db.arg_name 'FILTER', :optional => true
    db.command :destroy do |destroy|
      destroy.action do |global_options,options,args|
        say 'You are about to permanently destroy all database data.'
        return unless agree("Continue? ")
        nodes = manager.filter(args)
        if nodes.any?
          nodes = nodes[:services => 'couchdb']
        end
        if nodes.any?
          ssh_connect(nodes, connect_options(options)) do |ssh|
            ssh.run('/etc/init.d/bigcouch stop && test ! -z "$(ls /opt/bigcouch/var/lib/ 2> /dev/null)" && rm -r /opt/bigcouch/var/lib/* && echo "db destroyed" || echo "db already destroyed"')
            ssh.run('grep ^seq_file /etc/leap/tapicero.yaml | cut -f2 -d\" | xargs rm -v')
          end
        else
          say 'No nodes'
        end
      end
    end
  end

  private

end; end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
leap_cli-1.6.2 lib/leap_cli/commands/db.rb