Merge "fix keystone user-role-list and keystone.rb"

This commit is contained in:
Victor Galkin 2013-03-01 21:09:26 +04:00 committed by Gerrit Code Review
commit 0864741608
2 changed files with 7 additions and 2 deletions

View File

@ -69,7 +69,7 @@ class Puppet::Provider::Keystone < Puppet::Provider
# this assumes that all returned objects are of the form
# id, name, enabled_state, OTHER
# number_columns can be a Fixnum or an Array of possible values that can be returned
list = (auth_keystone("#{type}-list", args).split("\n")[3..-2] || []).select{ |line| line =~ /^\|.*\|$/ }.reject{ |line| line =~ /^\|\s+id\s+\|\s+name\s+\|\s+enabled\s+\|$/}.collect do |line|
list = (auth_keystone("#{type}-list", args).split("\n")[3..-2] || []).select{ |line| line =~ /^\|.*\|$/ }.reject{ |line| line =~ /^\|\s+id\s+.*\|$/}.collect do |line|
row = line.split(/\|/)[1..-1]
row = row.map {|x| x.strip }
@ -79,6 +79,7 @@ class Puppet::Provider::Keystone < Puppet::Provider
end
row
end
debug(list.inspect)
list
end
def self.get_keystone_object(type, id, attr)

View File

@ -131,7 +131,11 @@ Puppet::Type.type(:keystone_user_role).provide(
# id, name, enabled_state, OTHER
number_columns = 4
role_output = auth_keystone('user-role-list', '--user-id', user_id, '--tenant-id', tenant_id)
list = (role_output.split("\n")[3..-2] || []).collect do |line|
list = (role_output.split("\n")[3..-2] || []).select do
|line| line =~ /^\|.*\|$/
end.reject do
|line| line =~ /^\|\s+id\s+\|\s+name\s+\|\s+user_id\s+\|\s+tenant_id\s+\|$/
end.collect do |line|
row = line.split(/\s*\|\s*/)[1..-1]
if row.size != number_columns
raise(Puppet::Error, "Expected #{number_columns} columns for #{type} row, found #{row.size}. Line #{line}")