Object
# File lib/fog/rackspace/block_storage.rb, line 71 def initialize(options = {}) @rackspace_api_key = options[:rackspace_api_key] @rackspace_username = options[:rackspace_username] @rackspace_auth_url = options[:rackspace_auth_url] @rackspace_must_reauthenticate = false @connection_options = options[:connection_options] || {} endpoint = options[:rackspace_endpoint] || DFW_ENDPOINT uri = URI.parse(endpoint) @host = uri.host @persistent = options[:persistent] || false @path = uri.path @port = uri.port @scheme = uri.scheme authenticate @connection = Fog::Connection.new(uri.to_s, @persistent, @connection_options) end
# File lib/fog/rackspace/requests/block_storage/create_snapshot.rb, line 5 def create_snapshot(volume_id, options = {}) data = { 'snapshot' => { 'volume_id' => volume_id } } data['snapshot']['display_name'] = options[:display_name] unless options[:display_name].nil? data['snapshot']['display_description'] = options[:display_description] unless options[:display_description].nil? data['snapshot']['force'] = options[:force] unless options[:force].nil? request( :body => Fog::JSON.encode(data), :expects => [200], :method => 'POST', :path => "snapshots" ) end
# File lib/fog/rackspace/requests/block_storage/create_volume.rb, line 5 def create_volume(size, options = {}) data = { 'volume' => { 'size' => size } } data['volume']['display_name'] = options[:display_name] unless options[:display_name].nil? data['volume']['display_description'] = options[:display_description] unless options[:display_description].nil? data['volume']['volume_type'] = options[:volume_type] unless options[:volume_type].nil? data['volume']['availability_zone'] = options[:availability_zone] unless options[:availability_zone].nil? request( :body => Fog::JSON.encode(data), :expects => [200], :method => 'POST', :path => "volumes" ) end
# File lib/fog/rackspace/requests/block_storage/delete_snapshot.rb, line 5 def delete_snapshot(snapshot_id) request( :expects => [202], :method => 'DELETE', :path => "snapshots/#{snapshot_id}" ) end
# File lib/fog/rackspace/requests/block_storage/delete_volume.rb, line 5 def delete_volume(volume_id) request( :expects => [202], :method => 'DELETE', :path => "volumes/#{volume_id}" ) end
# File lib/fog/rackspace/requests/block_storage/get_snapshot.rb, line 5 def get_snapshot(snapshot_id) request( :expects => [200], :method => 'GET', :path => "snapshots/#{snapshot_id}" ) end
# File lib/fog/rackspace/requests/block_storage/get_volume.rb, line 5 def get_volume(volume_id) request( :expects => [200], :method => 'GET', :path => "volumes/#{volume_id}" ) end
# File lib/fog/rackspace/requests/block_storage/get_volume_type.rb, line 5 def get_volume_type(volume_type_id) request( :expects => [200], :method => 'GET', :path => "types/#{volume_type_id}" ) end
# File lib/fog/rackspace/requests/block_storage/list_snapshots.rb, line 5 def list_snapshots request( :expects => [200], :method => 'GET', :path => 'snapshots' ) end
# File lib/fog/rackspace/requests/block_storage/list_volume_types.rb, line 5 def list_volume_types request( :expects => [200], :method => 'GET', :path => 'types' ) end
# File lib/fog/rackspace/requests/block_storage/list_volumes.rb, line 5 def list_volumes request( :expects => [200], :method => 'GET', :path => 'volumes' ) end
# File lib/fog/rackspace/block_storage.rb, line 92 def request(params) begin response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, :path => "#{@path}/#{params[:path]}" })) rescue Excon::Errors::NotFound => error raise NotFound.slurp error rescue Excon::Errors::BadRequest => error raise BadRequest.slurp error rescue Excon::Errors::InternalServerError => error raise InternalServerError.slurp error rescue Excon::Errors::HTTPStatusError => error raise ServiceError.slurp error end unless response.body.empty? response.body = Fog::JSON.decode(response.body) end response end
Generated with the Darkfish Rdoc Generator 2.