mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[stormondemand|storage] Add Volume APIs
This commit is contained in:
parent
a42625e402
commit
8ed40ac5e4
11 changed files with 222 additions and 1 deletions
54
lib/fog/storm_on_demand/models/storage/volume.rb
Normal file
54
lib/fog/storm_on_demand/models/storage/volume.rb
Normal file
|
@ -0,0 +1,54 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Storage
|
||||
class StormOnDemand
|
||||
|
||||
class Volume < Fog::Model
|
||||
identity :uniq_id
|
||||
attribute :attachedTo
|
||||
attribute :cross_attach
|
||||
attribute :domain
|
||||
attribute :label
|
||||
attribute :size
|
||||
attribute :status
|
||||
attribute :zone
|
||||
|
||||
def initialize(attributes={})
|
||||
super
|
||||
end
|
||||
|
||||
def attach_to(server_id)
|
||||
requires :identity
|
||||
service.attach_volume_to_server(:uniq_id => identity,
|
||||
:to => server_id).body
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :identity
|
||||
service.delete_volume(:uniq_id => identity)
|
||||
true
|
||||
end
|
||||
|
||||
def detach_from(server_id)
|
||||
requires :identity
|
||||
service.detach_volume_from_server(:uniq_id => identity,
|
||||
:detach_from => server_id).body
|
||||
end
|
||||
|
||||
def resize(new_size)
|
||||
requires :identity
|
||||
service.resize_volume(:uniq_id => identity,
|
||||
:new_size => new_size).body
|
||||
end
|
||||
|
||||
def update(options={})
|
||||
requires :identity
|
||||
service.update_volume({:uniq_id => identity}.merge!(options))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
30
lib/fog/storm_on_demand/models/storage/volumes.rb
Normal file
30
lib/fog/storm_on_demand/models/storage/volumes.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/storm_on_demand/models/storage/volume'
|
||||
|
||||
module Fog
|
||||
module Storage
|
||||
class StormOnDemand
|
||||
|
||||
class Volumes < Fog::Collection
|
||||
model Fog::Storage::StormOnDemand::Volume
|
||||
|
||||
def create(options)
|
||||
vol = service.create_volume(options).body
|
||||
new(vol)
|
||||
end
|
||||
|
||||
def get(uniq_id)
|
||||
vol = service.get_volume(:uniq_id => uniq_id).body
|
||||
new(vol)
|
||||
end
|
||||
|
||||
def all(options={})
|
||||
vols = service.list_volumes(options).body['items']
|
||||
load(vols)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
module Fog
|
||||
module Storage
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def attach_volume_to_server(options={})
|
||||
request(
|
||||
:path => '/Storage/Block/Volume/attach',
|
||||
:body => Fog::JSON.encode(:params => options)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
16
lib/fog/storm_on_demand/requests/storage/create_volume.rb
Normal file
16
lib/fog/storm_on_demand/requests/storage/create_volume.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
module Fog
|
||||
module Storage
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def create_volume(options={})
|
||||
request(
|
||||
:path => '/Storage/Block/Volume/create',
|
||||
:body => Fog::JSON.encode(:params => options)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
16
lib/fog/storm_on_demand/requests/storage/delete_volume.rb
Normal file
16
lib/fog/storm_on_demand/requests/storage/delete_volume.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
module Fog
|
||||
module Storage
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def delete_volume(options={})
|
||||
request(
|
||||
:path => '/Storage/Block/Volume/delete',
|
||||
:body => Fog::JSON.encode(:params => options)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
module Fog
|
||||
module Storage
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def detach_volume_from_server(options={})
|
||||
request(
|
||||
:path => '/Storage/Block/Volume/detach',
|
||||
:body => Fog::JSON.encode(:params => options)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
16
lib/fog/storm_on_demand/requests/storage/get_volume.rb
Normal file
16
lib/fog/storm_on_demand/requests/storage/get_volume.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
module Fog
|
||||
module Storage
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def get_volume(options={})
|
||||
request(
|
||||
:path => '/Storage/Block/Volume/details',
|
||||
:body => Fog::JSON.encode(:params => options)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
16
lib/fog/storm_on_demand/requests/storage/list_volumes.rb
Normal file
16
lib/fog/storm_on_demand/requests/storage/list_volumes.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
module Fog
|
||||
module Storage
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def list_volumes(options={})
|
||||
request(
|
||||
:path => '/Storage/Block/Volume/list',
|
||||
:body => Fog::JSON.encode(:params => options)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
16
lib/fog/storm_on_demand/requests/storage/resize_volume.rb
Normal file
16
lib/fog/storm_on_demand/requests/storage/resize_volume.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
module Fog
|
||||
module Storage
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def resize_volume(options={})
|
||||
request(
|
||||
:path => '/Storage/Block/Volume/resize',
|
||||
:body => Fog::JSON.encode(:params => options)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
16
lib/fog/storm_on_demand/requests/storage/update_volume.rb
Normal file
16
lib/fog/storm_on_demand/requests/storage/update_volume.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
module Fog
|
||||
module Storage
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def update_volume(options={})
|
||||
request(
|
||||
:path => '/Storage/Block/Volume/update',
|
||||
:body => Fog::JSON.encode(:params => options)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -14,10 +14,19 @@ module Fog
|
|||
model_path 'fog/storm_on_demand/models/storage'
|
||||
model :cluster
|
||||
collection :clusters
|
||||
model :volume
|
||||
collection :volumes
|
||||
|
||||
request_path 'fog/storm_on_demand/requests/storage'
|
||||
request :list_clusters
|
||||
|
||||
request :attach_volume_to_server
|
||||
request :create_volume
|
||||
request :delete_volume
|
||||
request :detach_volume_from_server
|
||||
request :get_volume
|
||||
request :list_volumes
|
||||
request :resize_volume
|
||||
request :update_volume
|
||||
|
||||
class Mock
|
||||
|
||||
|
|
Loading…
Reference in a new issue