Module: Capsaicin::Service::CRM
- Included in:
- Capsaicin::Service
- Defined in:
- lib/capsaicin/service/crm.rb
Constant Summary collapse
- DEFAULT_ACTIONS =
[ [ :status, '-W' ], [ :summary, "-x | awk '/^raw xml:/ { exit }; { print }'" ], [ :start, "--meta -d 'target_role'" ], [ :stop, "--meta -p 'target_role' -v 'stopped'" ] ]
- OCF_DEFAULT_ACTIONS =
[ [ :validate, '-c -C' ], [ :monitor, '-c -m' ] ]
Instance Method Summary collapse
-
#crm(id, *args) ⇒ Object
Defines a recipe to control a cluster-managed service, using heartbeat or pacemaker.
-
#crm_ocf(id, *args) ⇒ Object
Defines a recipe providing additional controls for a cluster-managed service, using the ocf_resource tool which interoperates with heartbeat or pacemaker.
Instance Method Details
#crm(id, *args) ⇒ Object
Defines a recipe to control a cluster-managed service, using heartbeat or pacemaker.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/capsaicin/service/crm.rb', line 15 def crm(id,*args) = Hash===args.last ? args.pop : {} svc_name = id.to_s svc_desc = next_description(:reset) || (svc_name.capitalize unless .delete(:hide)) svc_actions = DEFAULT_ACTIONS svc_actions += args.pop if Array === args.last namespace id do case args.first when String; id = args.shift.intern when Symbol; id = args.shift end svc_cmd = "/usr/sbin/crm_resource -r #{id.to_s.split(':').last}" desc "#{svc_desc}: #{SVC_ACTION_CAPTIONS[:status]}" if svc_desc task :default, do sudo "#{svc_cmd} -W" end svc_actions.each do |svc_action,svc_args| svc_action = svc_action.intern unless Symbol===svc_action desc "#{svc_desc}: #{SVC_ACTION_CAPTIONS[svc_action]}" if svc_desc task svc_action, do sudo "#{svc_cmd} #{svc_args}" end end instance_eval { yield } if block_given? end end |
#crm_ocf(id, *args) ⇒ Object
Defines a recipe providing additional controls for a cluster-managed service, using the ocf_resource tool which interoperates with heartbeat or pacemaker.
For more information about ocf_resource and other add-ons for heartbeat/pacemaker, see github.com/joekhoobyar/ha-tools
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/capsaicin/service/crm.rb', line 54 def crm_ocf(id,*args) = Hash===args.last ? args.pop : {} svc_name = id.to_s svc_desc = next_description(:reset) || (svc_name.capitalize unless .delete(:hide)) svc_actions = DEFAULT_ACTIONS svc_actions += args.pop if Array === args.last namespace id do case args.first when String; id = args.shift.intern when Symbol; id = args.shift end svc_cmd = "ocf_resource -g #{id.to_s.split(':').last}" svc_actions.each do |svc_action,svc_args| svc_action = svc_action.intern if String === svc_action desc "#{svc_desc}: #{SVC_ACTION_CAPTIONS[svc_action]}" if svc_desc task svc_action, do sudo "#{svc_cmd} #{svc_args}" end end instance_eval { yield } if block_given? end end |