mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #3436 from daviddavis/master
[Docker] Adding multiple server support for Docker
This commit is contained in:
commit
9e197b76a3
12 changed files with 14 additions and 13 deletions
|
@ -40,8 +40,9 @@ module Fog
|
|||
email = options[:docker_email]
|
||||
url = options[:docker_url]
|
||||
|
||||
Docker.url = url
|
||||
Docker.authenticate!('username' => username, 'password' => password, 'email' => email) unless username.nil? || username.empty?
|
||||
connection_options = {:username => username, :password => password, :email => email}
|
||||
@connection = Docker::Connection.new(url, connection_options)
|
||||
Docker.authenticate!(connection_options, @connection) if username || email || password
|
||||
rescue Docker::Error::AuthenticationError => e
|
||||
raise Fog::Errors::Fogdocker::AuthenticationError.new(e.message)
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ module Fog
|
|||
def container_action(options = {})
|
||||
raise ArgumentError, "instance id is a required parameter" unless options.key? :id
|
||||
raise ArgumentError, "action is a required parameter" unless options.key? :action
|
||||
result = Docker::Container.get(options[:id]).send(options[:action], options[:options] || {})
|
||||
result = Docker::Container.get(options[:id], {}, @connection).send(options[:action], options[:options] || {})
|
||||
|
||||
if result.is_a?(Hash)
|
||||
downcase_hash_keys(result)
|
||||
|
|
|
@ -9,7 +9,7 @@ module Fog
|
|||
# before – Show only containers created before Id, include non-running ones.
|
||||
# size – true or false, Show the containers sizes
|
||||
def container_all(filters = {})
|
||||
Docker::Container.all(filters.merge(:all => true)).map do |container|
|
||||
Docker::Container.all(filters.merge(:all => true), @connection).map do |container|
|
||||
downcase_hash_keys(container.json)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ module Fog
|
|||
class Real
|
||||
def container_commit(options)
|
||||
raise ArgumentError, "instance id is a required parameter" unless options.key? :id
|
||||
container = Docker::Container.get(options[:id])
|
||||
container = Docker::Container.get(options[:id], {}, @connection)
|
||||
downcase_hash_keys container.commit(camelize_hash_keys(options)).json
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,7 +27,7 @@ module Fog
|
|||
#}
|
||||
class Real
|
||||
def container_create(attrs)
|
||||
downcase_hash_keys Docker::Container.create(camelize_hash_keys(attrs)).json
|
||||
downcase_hash_keys Docker::Container.create(camelize_hash_keys(attrs), @connection).json
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ module Fog
|
|||
class Real
|
||||
def container_delete(options = {})
|
||||
raise ArgumentError, "instance id is a required parameter" unless options.key? :id
|
||||
container = Docker::Container.get(options[:id])
|
||||
container = Docker::Container.get(options[:id], {}, @connection)
|
||||
container.delete()
|
||||
true
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class Fogdocker
|
||||
class Real
|
||||
def container_get(id)
|
||||
raw_container = Docker::Container.get(id).json
|
||||
raw_container = Docker::Container.get(id, {}, @connection).json
|
||||
processed_container = downcase_hash_keys(raw_container)
|
||||
processed_container['hostconfig_port_bindings'] = raw_container['HostConfig']['PortBindings']
|
||||
processed_container['hostconfig_links'] = raw_container['HostConfig']['Links']
|
||||
|
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class Fogdocker
|
||||
class Real
|
||||
def image_all(filters = {})
|
||||
Docker::Image.all.map do |image|
|
||||
Docker::Image.all({}, @connection).map do |image|
|
||||
downcase_hash_keys(image.json)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class Fogdocker
|
||||
class Real
|
||||
def image_create(attrs)
|
||||
downcase_hash_keys Docker::Image.create(attrs).json
|
||||
downcase_hash_keys Docker::Image.create(attrs, nil, @connection).json
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ module Fog
|
|||
class Real
|
||||
def image_delete(options = {})
|
||||
raise ArgumentError, "instance id is a required parameter" unless options.key? :id
|
||||
image = Docker::Image.get(options[:id])
|
||||
image = Docker::Image.get(options[:id], {}, @connection)
|
||||
image.remove()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class Fogdocker
|
||||
class Real
|
||||
def image_get(id)
|
||||
downcase_hash_keys Docker::Image.get(id).json
|
||||
downcase_hash_keys Docker::Image.get(id, {}, @connection).json
|
||||
end
|
||||
end
|
||||
class Mock
|
||||
|
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class Fogdocker
|
||||
class Real
|
||||
def image_search(query = {})
|
||||
Docker::Util.parse_json(Docker.connection.get('/images/search', query)).map do |image|
|
||||
Docker::Util.parse_json(@connection.get('/images/search', query)).map do |image|
|
||||
downcase_hash_keys(image)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue