diff options
author | elijah <elijah@riseup.net> | 2014-06-10 10:53:19 -0700 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2014-06-10 10:53:19 -0700 |
commit | b1e995accb20e0d7c4998e99e023019a1d18d378 (patch) | |
tree | 1a44080d6202ec2931e235dda79096e76666f627 | |
parent | 8154c6f3d1aafad465ea4f2239d5f92f27f2c4f5 (diff) | |
download | leap_cli-b1e995accb20e0d7c4998e99e023019a1d18d378.tar.gz leap_cli-b1e995accb20e0d7c4998e99e023019a1d18d378.tar.bz2 |
limit `leap db destroy` to FILTER.
-rw-r--r-- | lib/leap_cli/commands/db.rb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/leap_cli/commands/db.rb b/lib/leap_cli/commands/db.rb index e3d6b55..acc2f13 100644 --- a/lib/leap_cli/commands/db.rb +++ b/lib/leap_cli/commands/db.rb @@ -2,14 +2,22 @@ module LeapCli; module Commands desc 'Database commands.' command :db do |db| - db.desc 'Destroy all the databases.' + 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.nodes[:services => 'couchdb'] - 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"') + 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"') + end + else + say 'No nodes' end end end |