nova_flavor: Accept array format about access_project_ids

The latest openstackclient doesn't show none but empty array([]) when
no access_project_ids is set for an flavor.
This change ensure that array format is properly handled to avoid
error during updating nova flavor using the nova_flavor resource.

Closes-Bug: #1924222
Change-Id: I976f70f1f4015536201c6c3acac3f1e4dbca4ccb
This commit is contained in:
Takashi Kajinami 2021-04-15 14:30:43 +09:00
parent 4a4d5a8772
commit 86764de9cd
1 changed files with 8 additions and 2 deletions

View File

@ -89,11 +89,17 @@ Puppet::Type.type(:nova_flavor).provide(
def self.instances
request('flavor', 'list', ['--long', '--all']).collect do |attrs|
project = request('flavor', 'show', [attrs[:id], '-c', 'access_project_ids'])
access_project_ids = project[:access_project_ids]
# Client can return None and this should be considered as ''
if project[:access_project_ids].downcase.chomp == 'none'
if access_project_ids.downcase.chomp == 'none'
project_value = ''
# If the ids are formatted as Array, surrounding [] should be removed
elsif access_project_ids.start_with?('[') and access_project_ids.end_with?(']')
# TODO(tkajinam): We'd need to consider multiple projects can be returned
project_value = access_project_ids[1..-2]
else
project_value = project[:access_project_ids]
project_value = access_project_ids
end
properties = Hash[attrs[:properties].scan(/(\S+)='([^']*)'/)] rescue nil
new(