Permalink
Browse files

Updates rm_all_assets script to new AssetGroup refactoring.

  • Loading branch information...
1 parent 6b0fce6 commit c326f94384b3a8d6fcb63039397f512f3e9a2dfe @mdaines-r7 mdaines-r7 committed Mar 4, 2013
Showing with 5 additions and 4 deletions.
  1. +5 −4 scripts/rm_all_assets_from_group.rb
@@ -1,3 +1,4 @@
+#!/usr/bin/env ruby
require 'optparse'
require 'highline/import'
require 'nexpose'
@@ -34,17 +35,17 @@ def get_password(prompt = 'Password: ')
ask(prompt) { |query| query.echo = false }
end
puts 'Upon entering a password, deletion will begin.'
-puts 'Use --dry-run to ensure only the desired assets will be deleted.'
+puts 'Use --dry-run to ensure only the desired assets will be deleted.' unless @dry_run
@password = get_password
nsc = Nexpose::Connection.new(@host, @user, @password, @port)
nsc.login
-nsc.asset_group_config(group_id).each do |device|
+Nexpose::AssetGroup.load(nsc, group_id).devices.each do |device|
if @dry_run
- puts "#{device[:address]} [ID: #{device[:device_id]}] Site: #{device[:site_id]}"
+ puts "#{device.address} [ID: #{device.id}] Site: #{device.site_id}"
else
- nsc.device_delete(device[:device_id])
+ nsc.device_delete(device.id)
end
end

0 comments on commit c326f94

Please sign in to comment.