Skip to content

Commit

Permalink
Merge pull request #17358 from NickLaMuro/refactor_MiqRequestWorkflow…
Browse files Browse the repository at this point in the history
…_get_ems_folders

Refactor get_ems_folders to create less strings
  • Loading branch information
gmcculloug authored May 22, 2018
2 parents d4f111c + 1e0d6af commit 7060b2d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions app/models/miq_request_workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -860,19 +860,25 @@ def ems_has_clusters?
end

def get_ems_folders(folder, dh = {}, full_path = "")
path = full_path
if folder.evm_object_class == :EmsFolder
if folder.hidden
return dh if folder.name != 'vm'
else
full_path += full_path.blank? ? folder.name.to_s : " / #{folder.name}"
dh[folder.id] = full_path unless folder.type == "Datacenter"
path = full_path.dup
if path.blank?
path << folder.name.to_s
else
path << " / ".freeze << folder.name
end
dh[folder.id] = path unless folder.type == "Datacenter".freeze
end
end

# Process child folders
@_get_ems_folders_prefix ||= _log.prefix
node = load_ems_node(folder, @_get_ems_folders_prefix)
node.children.each { |child| get_ems_folders(child.attributes[:object], dh, full_path) } unless node.nil?
node.children.each { |child| get_ems_folders(child.attributes[:object], dh, path) } unless node.nil?

dh
end
Expand Down

0 comments on commit 7060b2d

Please sign in to comment.