Create attributes
‘Hostname’ => ”, ‘User’ => ”, ‘Memory’ => 0, ‘MemorySwap’ => 0, ‘AttachStdin’ => false, ‘AttachStdout’ => true, ‘AttachStderr’ => true, ‘PortSpecs’ => nil, ‘Tty’ => false, ‘OpenStdin’ => false, ‘StdinOnce’ => false, ‘Env’ => nil, ‘Cmd’ => [‘date’], ‘Dns’ => nil, ‘Image’ => ‘base’, ‘Volumes’ => {
'/tmp' => {}
}, ‘VolumesFrom’ => ”, ‘WorkingDir’ => ”, ‘ExposedPorts’ => {
'22/tcp' => {}
}
# File lib/fog/fogdocker/compute.rb, line 35 def initialize(options={}) require 'docker' username = options[:docker_username] password = options[:docker_password] email = options[:docker_email] url = options[:docker_url] Docker.url = url Docker.authenticate!('username' => username, 'password' => password, 'email' => email) unless username. nil? || username.empty? end
# File lib/fog/fogdocker/requests/compute/api_version.rb, line 5 def api_version Docker.version end
# File lib/fog/fogdocker/compute.rb, line 51 def camelize_hash_keys(hash) Hash[ hash.map {|k, v| [k.to_s.split('_').map {|w| w.capitalize}.join, v] }] end
# File lib/fog/fogdocker/requests/compute/container_action.rb, line 5 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 container = Docker::Container.get(options[:id]) downcase_hash_keys container.send(options[:action]).json end
filter options all – true or false, Show all containers. Only running containers are shown by default limit – Show limit last created containers, include non-running ones. since – Show only containers created since Id, include non-running ones. before – Show only containers created before Id, include non-running ones. size – true or false, Show the containers sizes
# File lib/fog/fogdocker/requests/compute/container_all.rb, line 11 def container_all(filters = {}) Docker::Container.all(filters.merge(:all => true)).map do |container| downcase_hash_keys(container.json) end end
# File lib/fog/fogdocker/requests/compute/container_commit.rb, line 5 def container_commit(options) raise ArgumentError, "instance id is a required parameter" unless options.key? :id container = Docker::Container.get(options[:id]) downcase_hash_keys container.commit(camelize_hash_keys(options)).json end
# File lib/fog/fogdocker/requests/compute/container_create.rb, line 29 def container_create(attrs) downcase_hash_keys Docker::Container.create(camelize_hash_keys(attrs)).json end
# File lib/fog/fogdocker/requests/compute/container_delete.rb, line 5 def container_delete(options = {}) raise ArgumentError, "instance id is a required parameter" unless options.key? :id container = Docker::Container.get(options[:id]) container.delete() true end
# File lib/fog/fogdocker/requests/compute/container_get.rb, line 5 def container_get(id) downcase_hash_keys Docker::Container.get(id).json end
# File lib/fog/fogdocker/compute.rb, line 46 def downcase_hash_keys(hash, k = []) return {k.join('_').gsub(/([a-z])([A-Z])/,'\1_\2').downcase => hash} unless hash.is_a?(Hash) hash.reduce({}){ |h, v| h.merge! downcase_hash_keys(v[-1], k + [v[0]]) } end
# File lib/fog/fogdocker/requests/compute/image_all.rb, line 5 def image_all(filters = {}) Docker::Image.all.map do |image| downcase_hash_keys(image.json) end end
# File lib/fog/fogdocker/requests/compute/image_create.rb, line 5 def image_create(attrs) downcase_hash_keys Docker::Image.create(attrs).json end
Generated with the Darkfish Rdoc Generator 2.