From 592758492d822e5e3a600c1adf651a78ca35ce3c Mon Sep 17 00:00:00 2001 From: Greg Blomquist Date: Thu, 27 Aug 2015 18:17:50 -0400 Subject: [PATCH] Fix deprecated call to security_groups As the deprecation warning suggests: > Calling OpenStack[:compute].list_security_groups(server_id) is deprecated, use > .list_security_groups(:server_id => value) instead --- lib/fog/openstack/models/compute/server.rb | 2 +- .../openstack/requests/compute/list_security_groups.rb | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/fog/openstack/models/compute/server.rb b/lib/fog/openstack/models/compute/server.rb index da03efa13..be064dfbb 100644 --- a/lib/fog/openstack/models/compute/server.rb +++ b/lib/fog/openstack/models/compute/server.rb @@ -212,7 +212,7 @@ module Fog def security_groups requires :id - groups = service.list_security_groups(id).body['security_groups'] + groups = service.list_security_groups(:server_id => id).body['security_groups'] groups.map do |group| Fog::Compute::OpenStack::SecurityGroup.new group.merge({:service => service}) diff --git a/lib/fog/openstack/requests/compute/list_security_groups.rb b/lib/fog/openstack/requests/compute/list_security_groups.rb index 5c740f473..1fc7d1710 100644 --- a/lib/fog/openstack/requests/compute/list_security_groups.rb +++ b/lib/fog/openstack/requests/compute/list_security_groups.rb @@ -29,7 +29,15 @@ module Fog end class Mock - def list_security_groups(server_id = nil) + def list_security_groups(options = {}) + if options.is_a?(Hash) + server_id = options.delete(:server_id) + query = options + else + server_id = options + query = {} + end + security_groups = self.data[:security_groups].values groups = if server_id then