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
This commit is contained in:
Mohammed Naser
2017-08-18 17:02:30 -04:00
parent d0c3607d54
commit 414ae8da0a

View File

@@ -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],