2015-08-13 01:48:17 +00:00
|
|
|
# encoding: utf-8
|
2015-09-02 02:13:59 +00:00
|
|
|
require 'uri'
|
2015-08-29 23:11:23 +00:00
|
|
|
require 'vulcano/plugins'
|
|
|
|
|
|
|
|
module Vulcano
|
|
|
|
class Backend
|
2015-09-02 02:13:59 +00:00
|
|
|
# Expose all registered backends
|
2015-08-29 23:11:23 +00:00
|
|
|
def self.registry
|
|
|
|
@registry ||= {}
|
|
|
|
end
|
|
|
|
|
2015-09-02 02:13:59 +00:00
|
|
|
# Resolve target configuration in URI-scheme into
|
|
|
|
# all respective fields and merge with existing configuration.
|
|
|
|
# e.g. ssh://bob@remote => backend: ssh, user: bob, host: remote
|
2015-09-03 18:43:58 +00:00
|
|
|
def self.target_config(config)
|
2015-08-30 02:46:46 +00:00
|
|
|
conf = config.dup
|
|
|
|
|
2015-09-03 12:56:08 +00:00
|
|
|
return conf if conf['target'].to_s.empty?
|
2015-08-30 02:46:46 +00:00
|
|
|
|
2015-09-05 14:07:54 +00:00
|
|
|
uri = URI.parse(conf['target'].to_s)
|
2015-09-03 12:56:08 +00:00
|
|
|
conf['backend'] = conf['backend'] || uri.scheme
|
|
|
|
conf['host'] = conf['host'] || uri.host
|
|
|
|
conf['port'] = conf['port'] || uri.port
|
|
|
|
conf['user'] = conf['user'] || uri.user
|
|
|
|
conf['password'] = conf['password'] || uri.password
|
2015-08-30 02:46:46 +00:00
|
|
|
|
|
|
|
# return the updated config
|
2015-08-29 23:11:23 +00:00
|
|
|
conf
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-02 02:13:59 +00:00
|
|
|
def self.backend(version = 1)
|
2015-08-29 23:11:23 +00:00
|
|
|
if version != 1
|
2015-09-03 21:18:28 +00:00
|
|
|
fail 'Only backend version 1 is supported!'
|
2015-08-29 23:11:23 +00:00
|
|
|
end
|
|
|
|
Vulcano::Plugins::Backend
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-06 15:15:09 +00:00
|
|
|
require 'vulcano/backend/local'
|
2015-08-27 20:59:15 +00:00
|
|
|
require 'vulcano/backend/mock'
|
2015-08-30 00:13:07 +00:00
|
|
|
require 'vulcano/backend/specinfra'
|