2015-08-12 18:48:17 -07:00
|
|
|
# encoding: utf-8
|
2015-09-02 04:13:59 +02:00
|
|
|
require 'uri'
|
2015-08-29 16:11:23 -07:00
|
|
|
require 'vulcano/plugins'
|
|
|
|
|
|
|
|
module Vulcano
|
|
|
|
class Backend
|
2015-09-02 04:13:59 +02:00
|
|
|
# Expose all registered backends
|
2015-08-29 16:11:23 -07:00
|
|
|
def self.registry
|
|
|
|
@registry ||= {}
|
|
|
|
end
|
|
|
|
|
2015-09-02 04:13:59 +02: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 20:43:58 +02:00
|
|
|
def self.target_config(config)
|
2015-08-29 19:46:46 -07:00
|
|
|
conf = config.dup
|
|
|
|
|
2015-09-03 14:56:08 +02:00
|
|
|
return conf if conf['target'].to_s.empty?
|
2015-08-29 19:46:46 -07:00
|
|
|
|
2015-09-05 16:07:54 +02:00
|
|
|
uri = URI.parse(conf['target'].to_s)
|
2015-09-03 14:56:08 +02: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-29 19:46:46 -07:00
|
|
|
|
|
|
|
# return the updated config
|
2015-08-29 16:11:23 -07:00
|
|
|
conf
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-02 04:13:59 +02:00
|
|
|
def self.backend(version = 1)
|
2015-08-29 16:11:23 -07:00
|
|
|
if version != 1
|
2015-09-03 23:18:28 +02:00
|
|
|
fail 'Only backend version 1 is supported!'
|
2015-08-29 16:11:23 -07:00
|
|
|
end
|
|
|
|
Vulcano::Plugins::Backend
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-08 17:58:32 +02:00
|
|
|
require 'vulcano/backend/docker'
|
2015-09-06 17:15:09 +02:00
|
|
|
require 'vulcano/backend/local'
|
2015-08-27 13:59:15 -07:00
|
|
|
require 'vulcano/backend/mock'
|
2015-08-29 17:13:07 -07:00
|
|
|
require 'vulcano/backend/specinfra'
|
2015-09-09 00:28:06 +02:00
|
|
|
require 'vulcano/backend/ssh'
|