Sha256: 9c968e01f5e68bf70b1410781c2199ef2be81b02c94b8d91b54d8117b7cddfea
Contents?: true
Size: 1.6 KB
Versions: 84
Compression:
Stored size: 1.6 KB
Contents
module Fog module Rackspace module Servers class Real # Create an image from a running server # # ==== Parameters # * server_id<~Integer> - Id of server to create image from # * options<~Hash> - Name # # ==== Returns # * response<~Excon::Response>: # * 'image'<~Hash>: # * 'id'<~Integer> - Id of image # * 'name'<~String> - Name of image # * 'serverId'<~Integer> - Id of server def create_image(server_id, options = {}) data = { 'image' => { 'serverId' => server_id } } if options['name'] data['image']['name'] = options['name'] end request( :body => data.to_json, :expects => 202, :method => 'POST', :path => "images" ) end end class Mock def create_image(server_id, options = {}) response = Excon::Response.new response.status = 202 now = Time.now data = { 'created' => now, 'id' => 123456, 'name' => options['name'] || '', 'serverId' => server_id, 'status' => 'SAVING', 'updated' => now, } @data[:last_modified][:images][data['id']] = now @data[:images][data['id']] = data response.body = { 'image' => data.reject {|key, value| !['id', 'name', 'serverId'].include?(key)} } response end end end end end
Version data entries
84 entries across 84 versions & 2 rubygems