From 414ae8da0ae637ce5059207d7834241f6421ed54 Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Fri, 18 Aug 2017 17:02:30 -0400 Subject: [PATCH] Use API level filtering for nova_security_group provider In order to speed things up and avoid pulling all the groups, we can instead provide it to the client and it will filter things at the API level speeding the process up. Change-Id: I6798218a3695bfced781056b12a192b82733eea6 --- lib/puppet/provider/nova_security_group/openstack.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/puppet/provider/nova_security_group/openstack.rb b/lib/puppet/provider/nova_security_group/openstack.rb index eb44e4999..fc0032f14 100644 --- a/lib/puppet/provider/nova_security_group/openstack.rb +++ b/lib/puppet/provider/nova_security_group/openstack.rb @@ -50,9 +50,7 @@ Puppet::Type.type(:nova_security_group).provide( # retrieve all security groups. The following helps filter it. project_id = self.nova_request('token', 'issue', nil, ['-c', 'project_id', '-f', 'value']).strip - self.nova_request('security group', 'list', nil).select do |attrs| - attrs[:project] == project_id - end.collect do |attrs| + self.nova_request('security group', 'list', nil, ['--project', project_id]).collect do |attrs| new( :ensure => :present, :id => attrs[:id],