allomov
6/13/2014 - 9:58 AM

clean_google_enginge_with_fog

clean_google_enginge_with_fog

# Gemfile: 
# source 'https://rubygems.org'
# gem 'fog', path: '~/work/github/fog'

require 'fog'
require 'yaml'

config = YAML.load_file('/Users/allomov/.fog.yml')
google_config = config['google']

storage = Fog::Storage::Google.new(google_config['storage'])
compute = Fog::Compute::Google.new(google_config['compute'])


storage.directories.each do |d| 
  d.files.each { |f| f.destroy }
  d.destroy
end

compute.servers.each do |s|
  s.destroy(false)
end

compute.disks.each do |d|
  d.destroy
end

compute.images.each do |i|
  i.destroy rescue nil
end