2013-01-02 09:34:32 -05:00
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class RackspaceV2
|
|
|
|
class Real
|
2013-01-30 10:05:10 -05:00
|
|
|
|
|
|
|
# Sets metadata associated with a server or an image.
|
|
|
|
# @param [String<images, servers>] collection type of metadata
|
|
|
|
# @param [String] obj_id id of the object where the metadata is attached
|
|
|
|
# @param [Hash] metadata key value pairs of metadata
|
|
|
|
# @return [Excon::Response] response:
|
|
|
|
# * body [Hash]:
|
|
|
|
# * metadata [Hash]:
|
2013-03-27 10:50:30 -04:00
|
|
|
# @raise [Fog::Rackspace::Errors::NotFound] - HTTP 404
|
|
|
|
# @raise [Fog::Rackspace::Errors::BadRequest] - HTTP 400
|
|
|
|
# @raise [Fog::Rackspace::Errors::InternalServerError] - HTTP 500
|
|
|
|
# @raise [Fog::Rackspace::Errors::ServiceError]
|
2013-01-30 10:05:10 -05:00
|
|
|
# @see http://docs.rackspace.com/servers/api/v2/cs-devguide/content/Create_or_Replace_Metadata-d1e5358.html
|
2013-01-07 12:25:49 -05:00
|
|
|
def set_metadata(collection, obj_id, metadata = {})
|
2013-01-02 09:34:32 -05:00
|
|
|
request(
|
|
|
|
:expects => [200, 203],
|
|
|
|
:method => 'PUT',
|
2013-01-07 12:25:49 -05:00
|
|
|
:path => "/#{collection}/#{obj_id}/metadata",
|
2013-01-02 09:34:32 -05:00
|
|
|
:body => Fog::JSON.encode('metadata' => metadata)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
class Mock
|
2013-01-07 12:25:49 -05:00
|
|
|
def set_metadata(collection, obj_id, metadata = {})
|
|
|
|
raise Fog::Compute::RackspaceV2::NotFound if obj_id == 0
|
2013-01-02 09:34:32 -05:00
|
|
|
|
|
|
|
response = Excon::Response.new
|
|
|
|
response.status = 202
|
|
|
|
response.body = {"metadata"=>{"environment"=>"dev"}}
|
|
|
|
response
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|