2015-08-29 23:11:23 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
|
2015-09-01 22:50:52 +00:00
|
|
|
require 'digest'
|
2015-08-29 23:11:23 +00:00
|
|
|
|
2015-09-01 22:50:52 +00:00
|
|
|
module Vulcano::Plugins
|
|
|
|
class Backend
|
2015-09-08 10:59:36 +00:00
|
|
|
autoload :FileCommon, 'vulcano/plugins/backend_file_common'
|
|
|
|
autoload :LinuxFile, 'vulcano/plugins/backend_linux_file'
|
2015-09-20 11:34:06 +00:00
|
|
|
autoload :OSCommon, 'vulcano/plugins/backend_os_common'
|
2015-09-08 15:58:32 +00:00
|
|
|
CommandResult = Struct.new(:stdout, :stderr, :exit_status)
|
2015-09-08 10:59:36 +00:00
|
|
|
|
2015-09-05 14:07:54 +00:00
|
|
|
def self.name(name)
|
2015-09-01 22:50:52 +00:00
|
|
|
Vulcano::Plugins::Backend.__register(name, self)
|
|
|
|
end
|
|
|
|
|
2015-09-06 18:26:09 +00:00
|
|
|
# raise errors for all missing methods
|
|
|
|
%w{ file run_command os }.each do |m|
|
2015-09-08 12:36:12 +00:00
|
|
|
define_method(m.to_sym) do |*_|
|
|
|
|
fail NotImplementedError, "Backend must implement the #{m}() method."
|
2015-09-02 09:53:25 +00:00
|
|
|
end
|
2015-09-06 18:26:09 +00:00
|
|
|
end
|
2015-09-02 15:30:49 +00:00
|
|
|
|
2015-09-06 18:26:09 +00:00
|
|
|
def self.__register(id, obj)
|
2015-09-03 14:17:52 +00:00
|
|
|
Vulcano::Backend.registry[id] = obj
|
2015-09-01 22:50:52 +00:00
|
|
|
end
|
2015-08-29 23:11:23 +00:00
|
|
|
end
|
|
|
|
end
|