mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[rackspace|blockstorage] Add volume types to block storage.
This commit is contained in:
parent
c149d80988
commit
82034ce6b1
6 changed files with 75 additions and 1 deletions
|
@ -4,7 +4,7 @@ class Rackspace < Fog::Bin
|
|||
def class_for(key)
|
||||
case key
|
||||
when :block_storage
|
||||
Fog::Rackspace::BlockStorage.new
|
||||
Fog::Rackspace::BlockStorage
|
||||
when :cdn
|
||||
Fog::CDN::Rackspace
|
||||
when :compute
|
||||
|
|
|
@ -19,12 +19,17 @@ module Fog
|
|||
model_path 'fog/rackspace/models/block_storage'
|
||||
model :volume
|
||||
collection :volumes
|
||||
model :volume_type
|
||||
collection :volume_types
|
||||
|
||||
request_path 'fog/rackspace/requests/block_storage'
|
||||
request :create_volume
|
||||
request :delete_volume
|
||||
request :get_volume
|
||||
request :list_volumes
|
||||
request :get_volume_type
|
||||
request :list_volume_types
|
||||
|
||||
|
||||
class Mock
|
||||
def request(params)
|
||||
|
|
14
lib/fog/rackspace/models/block_storage/volume_type.rb
Normal file
14
lib/fog/rackspace/models/block_storage/volume_type.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Rackspace
|
||||
class BlockStorage
|
||||
class VolumeType < Fog::Model
|
||||
identity :id
|
||||
|
||||
attribute :name
|
||||
attribute :extra_specs
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
25
lib/fog/rackspace/models/block_storage/volume_types.rb
Normal file
25
lib/fog/rackspace/models/block_storage/volume_types.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/rackspace/models/block_storage/volume_type'
|
||||
|
||||
module Fog
|
||||
module Rackspace
|
||||
class BlockStorage
|
||||
class VolumeTypes < Fog::Collection
|
||||
|
||||
model Fog::Rackspace::BlockStorage::VolumeType
|
||||
|
||||
def all
|
||||
data = connection.list_volume_types.body['volume_types']
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(volume_type_id)
|
||||
data = connection.get_volume_type(volume_type_id).body['volume_type']
|
||||
new(data)
|
||||
rescue Fog::Rackspace::BlockStorage::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
15
lib/fog/rackspace/requests/block_storage/get_volume_type.rb
Normal file
15
lib/fog/rackspace/requests/block_storage/get_volume_type.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
module Fog
|
||||
module Rackspace
|
||||
class BlockStorage
|
||||
class Real
|
||||
def get_volume_type(volume_type_id)
|
||||
request(
|
||||
:expects => [200],
|
||||
:method => 'GET',
|
||||
:path => "/types/#{volume_type_id}"
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,15 @@
|
|||
module Fog
|
||||
module Rackspace
|
||||
class BlockStorage
|
||||
class Real
|
||||
def list_volume_types
|
||||
request(
|
||||
:expects => [200],
|
||||
:method => 'GET',
|
||||
:path => '/types'
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue