Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crowbar: Remove forgotten nodes from proposals #1116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion crowbar_framework/app/models/deployer_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,33 @@ def transition(inst, name, state)
end

if state == "delete"
# Do more work here - one day.
# Remove node from all applied proposals
RoleObject.all.select(&:proposal?).each do |applied_proposal|
save = false
attributes = applied_proposal.override_attributes[applied_proposal.barclamp]
["elements", "elements_expanded"].each do |element_key|
next unless attributes.key?(element_key)
attributes[element_key].each do |role_name, elements|
next unless elements.include?(name)
elements.delete(name)
attributes[element_key][role_name] = elements
save = true
end
end
applied_proposal.save if save
end

# Remove node from all proposals
Proposal.all.each do |proposal|
save = false
proposal.elements.each do |role_name, elements|
next unless elements.include?(name)
elements.delete(name)
proposal.elements[role_name] = elements
save = true
end
proposal.save if save
end
end

@logger.debug("Deployer transition: exiting: #{name} for #{state}")
Expand Down