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: Generate an event when a cluster config is changed #171

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
26 changes: 26 additions & 0 deletions crowbar_framework/app/models/pacemaker_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# limitations under the License.
#

require "set"

class PacemakerService < ServiceObject
def initialize(thelogger)
super(thelogger)
Expand Down Expand Up @@ -439,6 +441,30 @@ def apply_role_post_chef_call(old_role, role, all_nodes)

apply_cluster_roles_to_new_nodes_post_chef_call(role)

# let's not consider the first time the proposal is applied as worth
# sending an event
if !old_role.nil? && !role.nil?
old_attributes = old_role.default_attributes["pacemaker"]
new_attributes = role.default_attributes["pacemaker"]

changed_attributes = Set.new

if old_attributes["haproxy"]["public_name"] != new_attributes["haproxy"]["public_name"]
changed_attributes.add("haproxy.public_name")
end
if old_attributes["haproxy"]["admin_name"] != new_attributes["haproxy"]["admin_name"]
changed_attributes.add("haproxy.admin_name")
end

unless changed_attributes.empty?
details = {
cluster: "#{PacemakerServiceObject.cluster_key}:#{role.inst}",
attributes: changed_attributes
}
Crowbar::EventDispatcher.trigger_hooks("cluster_changed", details)
end
end

@logger.debug("Pacemaker apply_role_post_chef_call: leaving")
end

Expand Down