2012-02-24 07:03:55 -05:00
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class OpenStack
|
|
|
|
class Real
|
|
|
|
|
|
|
|
def create_volume(name, description, size, options={})
|
|
|
|
data = {
|
|
|
|
'volume' => {
|
|
|
|
'display_name' => name,
|
|
|
|
'display_description' => description,
|
|
|
|
'size' => size
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
vanilla_options = ['snapshot_id']
|
|
|
|
vanilla_options.select{|o| options[o]}.each do |key|
|
|
|
|
data['volume'][key] = options[key]
|
|
|
|
end
|
|
|
|
request(
|
|
|
|
:body => MultiJson.encode(data),
|
|
|
|
:expects => [200, 202],
|
|
|
|
:method => 'POST',
|
|
|
|
:path => "os-volumes"
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
class Mock
|
|
|
|
|
|
|
|
def create_volume(name, description, size, options={})
|
|
|
|
response = Excon::Response.new
|
|
|
|
response.status = 202
|
|
|
|
response.body = {
|
|
|
|
'volume' => {
|
2012-09-03 02:40:34 -04:00
|
|
|
'id' => Fog::Mock.random_numbers(2),
|
2012-08-15 23:27:35 -04:00
|
|
|
'display_name' => name,
|
|
|
|
'display_description' => description,
|
2012-09-03 02:40:34 -04:00
|
|
|
'size' => size,
|
|
|
|
'status' => 'creating',
|
2012-08-15 23:27:35 -04:00
|
|
|
'snapshot_id' => '4',
|
|
|
|
'volume_type' => nil,
|
|
|
|
'availability_zone' => 'nova',
|
|
|
|
'created_at' => Time.now,
|
2012-09-03 02:40:34 -04:00
|
|
|
'attachments' => []
|
2012-02-24 07:03:55 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
response
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|