def create_volume(datacenter_id, options = {})
response = Excon::Response.new
response.status = 202
if options[:size] == nil
raise Excon::Error::HTTPStatus, "Attribute 'size' is required"
end
if datacenter = data[:datacenters]['items'].find do |attrib|
attrib['id'] == datacenter_id
end
datacenter['version'] += 1 if datacenter['version']
else
raise Excon::Error::HTTPStatus, 'Resource does not exist'
end
volume_id = Fog::UUID.uuid
volume = {
'id' => volume_id,
'type' => 'volume',
'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter['id']}/volumes/#{volume_id}",
'metadata' => {
'createdDate' => '2015-03-18T19=>00=>51Z',
'createdBy' => 'test@stackpointcloud.com',
'etag' => 'c4a2fde6ba91a038ff953b939cc21efe',
'lastModifiedDate' => '2015-03-18T19=>00=>51Z',
'lastModifiedBy' => 'test@stackpointcloud.com',
'state' => 'AVAILABLE'
},
'properties' => {
'name' => options[:name],
'type' => options[:type],
'size' => options[:size],
'image' => options[:image],
'availabilityZone' => options[:availabilityZone],
'bus' => 'VIRTIO',
'licenceType' => 'OTHER',
'cpuHotPlug' => 'true',
'cpuHotUnplug' => 'false',
'ramHotPlug' => 'false',
'ramHotUnplug' => 'false',
'nicHotPlug' => 'true',
'nicHotUnplug' => 'true',
'discVirtioHotPlug' => 'true',
'discVirtioHotUnplug' => 'true',
'discScsiHotPlug' => 'false',
'discScsiHotUnplug' => 'false',
'deviceNumber' => 1
},
'datacenter_id' => datacenter['id']
}
data[:volumes]['items'] << volume
response.body = volume
response
end