/usr/share/pcsd/pcsd_action_command.rb is in pcs 0.9.164-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 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 47 48 49 50 51 52 53 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 81 82 83 84 85 86 87 88 89 90 91 92 | require 'pcsd_exchange_format.rb'
require 'settings.rb'
require 'pcs.rb' #(enable|disable|start|stop)_service,
module PcsdActionCommand
class ActionType
def initialize(id, action)
@id = id
@action = action
end
def validate()
end
def process()
end
end
class ServiceCommand < ActionType
@@services = {
"pacemaker_remote" => [
"enable",
"disable",
"start",
"stop",
]
}
def error(message)
return PcsdExchangeFormat::Error.for_item("action", @id, message)
end
def validate()
unless @action.has_key?(:service)
raise self.error("'service' is missing")
end
unless @action.has_key?(:command)
raise self.error("'command' is missing")
end
unless @@services.key?(@action[:service])
raise self.error(
"unsupported 'service' ('#{@action[:service]}')"+
" supported are #{@@services.keys.sort}"
)
end
unless @@services[@action[:service]].include?(@action[:command])
raise self.error(
"unsupported 'command' ('#{@action[:command]}') for service "+
"'#{@action[:service]}',"+
" supported are #{@@services[@action[:service]].sort}"
)
end
end
def run_service_command()
#validate here required or else there could be entered a disallowed
#@action[:service]
self.validate()
case @action[:command]
when "enable"
return enable_service(@action[:service])
when "disable"
return disable_service(@action[:service])
when "start"
return start_service(@action[:service])
when "stop"
return stop_service(@action[:service])
else
#a mistake in @@services?
raise self.error(
"unsupported 'command' ('#{@action[:command]}') for service "+
"'#{@action[:service]}'"
)
end
end
def process()
return PcsdExchangeFormat::result(
self.run_service_command() ? :success : :fail
)
end
end
TYPES = {
"service_command" => ServiceCommand,
}
end
|