From a1374e9aa5cc0b3c6276185ed642a53efcc42969 Mon Sep 17 00:00:00 2001 From: geemus Date: Mon, 11 Oct 2010 13:45:26 -0700 Subject: [PATCH] [aws|compute] model level warnings/fixes for filters --- lib/fog/aws/models/compute/addresses.rb | 4 ++++ lib/fog/aws/models/compute/key_pairs.rb | 4 ++++ lib/fog/aws/models/compute/security_groups.rb | 4 ++++ lib/fog/aws/models/compute/servers.rb | 4 ++++ lib/fog/aws/models/compute/snapshots.rb | 7 ++++--- lib/fog/aws/models/compute/volumes.rb | 4 ++++ 6 files changed, 24 insertions(+), 3 deletions(-) diff --git a/lib/fog/aws/models/compute/addresses.rb b/lib/fog/aws/models/compute/addresses.rb index 78498769e..29e8dc25f 100644 --- a/lib/fog/aws/models/compute/addresses.rb +++ b/lib/fog/aws/models/compute/addresses.rb @@ -18,6 +18,10 @@ module Fog end def all(filters = @filters) + unless filters.is_a?(Hash) + Formatador.display_line("[yellow][WARN] all with #{filters.class} param is deprecated, use all('public-ip' => []) instead[/] [light_black](#{caller.first})[/]") + filters = {'public-ip' => [*filters]} + end @filters = filters data = connection.describe_addresses(filters).body load( diff --git a/lib/fog/aws/models/compute/key_pairs.rb b/lib/fog/aws/models/compute/key_pairs.rb index 77ed1d360..9063dcd7f 100644 --- a/lib/fog/aws/models/compute/key_pairs.rb +++ b/lib/fog/aws/models/compute/key_pairs.rb @@ -17,6 +17,10 @@ module Fog end def all(filters = @filters) + unless filters.is_a?(Hash) + Formatador.display_line("[yellow][WARN] all with #{filters.class} param is deprecated, use all('key-name' => []) instead[/] [light_black](#{caller.first})[/]") + filters = {'key-name' => [*filters]} + end @filters = filters data = connection.describe_key_pairs(filters).body load(data['keySet']) diff --git a/lib/fog/aws/models/compute/security_groups.rb b/lib/fog/aws/models/compute/security_groups.rb index 1a4abe87b..6f19b652c 100644 --- a/lib/fog/aws/models/compute/security_groups.rb +++ b/lib/fog/aws/models/compute/security_groups.rb @@ -17,6 +17,10 @@ module Fog end def all(filters = @filters) + unless filters.is_a?(Hash) + Formatador.display_line("[yellow][WARN] all with #{filters.class} param is deprecated, use all('group-name' => []) instead[/] [light_black](#{caller.first})[/]") + filters = {'group-name' => [*filters]} + end @filters = filters data = connection.describe_security_groups(@filters).body load(data['securityGroupInfo']) diff --git a/lib/fog/aws/models/compute/servers.rb b/lib/fog/aws/models/compute/servers.rb index 926b96bd5..2df8c06e6 100644 --- a/lib/fog/aws/models/compute/servers.rb +++ b/lib/fog/aws/models/compute/servers.rb @@ -19,6 +19,10 @@ module Fog end def all(filters = @filters) + unless filters.is_a?(Hash) + Formatador.display_line("[yellow][WARN] all with #{filters.class} param is deprecated, use all('instance-id' => []) instead[/] [light_black](#{caller.first})[/]") + filters = {'instance-id' => [*filters]} + end @filters = filters data = connection.describe_instances(filters).body load( diff --git a/lib/fog/aws/models/compute/snapshots.rb b/lib/fog/aws/models/compute/snapshots.rb index 0d20a2359..9e8447ec4 100644 --- a/lib/fog/aws/models/compute/snapshots.rb +++ b/lib/fog/aws/models/compute/snapshots.rb @@ -18,10 +18,11 @@ module Fog end def all(filters = @filters, options = {}) - unless options.empty? - Formatador.display_line("[yellow][WARN] describe_snapshots with a second param is deprecated, use describe_snapshots(options) instead[/] [light_black](#{caller.first})[/]") - filters.merge!(options) + unless filters.is_a?(Hash) + Formatador.display_line("[yellow][WARN] all with #{filters.class} param is deprecated, use all('snapshot-id' => []) instead[/] [light_black](#{caller.first})[/]") + filters = {'snapshot-id' => [*filters]} end + @filters = filters data = connection.describe_snapshots(filters.merge!(options)).body load(data['snapshotSet']) if volume diff --git a/lib/fog/aws/models/compute/volumes.rb b/lib/fog/aws/models/compute/volumes.rb index 3d5e1f763..31a697992 100644 --- a/lib/fog/aws/models/compute/volumes.rb +++ b/lib/fog/aws/models/compute/volumes.rb @@ -18,6 +18,10 @@ module Fog end def all(filters = @filters) + unless filters.is_a?(Hash) + Formatador.display_line("[yellow][WARN] all with #{filters.class} param is deprecated, use all('volume-id' => []) instead[/] [light_black](#{caller.first})[/]") + filters = {'volume-id' => [*filters]} + end @filters = filters data = connection.describe_volumes(@filters).body load(data['volumeSet'])