Skip to content

Commit

Permalink
crowbar: Generate an event when a cluster config is changed
Browse files Browse the repository at this point in the history
For now, we're only interested in changes in the public/admin name of
haproxy. This event will be consumed by OpenStack barclamp so they know
that the endpoint is changing.

We may add other relevant attributes to the event later on if required.
  • Loading branch information
vuntz committed Jan 6, 2017
1 parent b5cb68d commit 9016f01
Showing 1 changed file with 26 additions and 0 deletions.
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

0 comments on commit 9016f01

Please sign in to comment.