Module: Fog::OpenStack::Volume::Real
- Defined in:
- lib/fog/openstack/volume/requests/list_transfers.rb,
lib/fog/openstack/volume/requests/action.rb,
lib/fog/openstack/volume/requests/get_quota.rb,
lib/fog/openstack/volume/requests/list_zones.rb,
lib/fog/openstack/volume/requests/set_tenant.rb,
lib/fog/openstack/volume/requests/list_backups.rb,
lib/fog/openstack/volume/requests/list_volumes.rb,
lib/fog/openstack/volume/requests/update_quota.rb,
lib/fog/openstack/volume/requests/create_backup.rb,
lib/fog/openstack/volume/requests/create_volume.rb,
lib/fog/openstack/volume/requests/delete_backup.rb,
lib/fog/openstack/volume/requests/delete_volume.rb,
lib/fog/openstack/volume/requests/extend_volume.rb,
lib/fog/openstack/volume/requests/list_snapshots.rb,
lib/fog/openstack/volume/requests/restore_backup.rb,
lib/fog/openstack/volume/requests/accept_transfer.rb,
lib/fog/openstack/volume/requests/create_snapshot.rb,
lib/fog/openstack/volume/requests/create_transfer.rb,
lib/fog/openstack/volume/requests/delete_metadata.rb,
lib/fog/openstack/volume/requests/delete_snapshot.rb,
lib/fog/openstack/volume/requests/delete_transfer.rb,
lib/fog/openstack/volume/requests/get_quota_usage.rb,
lib/fog/openstack/volume/requests/snapshot_action.rb,
lib/fog/openstack/volume/requests/update_metadata.rb,
lib/fog/openstack/volume/requests/update_snapshot.rb,
lib/fog/openstack/volume/requests/replace_metadata.rb,
lib/fog/openstack/volume/v1/requests/update_volume.rb,
lib/fog/openstack/volume/v2/requests/update_volume.rb,
lib/fog/openstack/volume/requests/list_volume_types.rb,
lib/fog/openstack/volume/requests/create_volume_type.rb,
lib/fog/openstack/volume/requests/delete_volume_type.rb,
lib/fog/openstack/volume/requests/get_backup_details.rb,
lib/fog/openstack/volume/requests/get_quota_defaults.rb,
lib/fog/openstack/volume/requests/get_volume_details.rb,
lib/fog/openstack/volume/requests/update_volume_type.rb,
lib/fog/openstack/volume/requests/get_snapshot_details.rb,
lib/fog/openstack/volume/requests/get_transfer_details.rb,
lib/fog/openstack/volume/requests/list_backups_detailed.rb,
lib/fog/openstack/volume/requests/list_volumes_detailed.rb,
lib/fog/openstack/volume/requests/get_volume_type_details.rb,
lib/fog/openstack/volume/requests/list_snapshots_detailed.rb,
lib/fog/openstack/volume/requests/list_transfers_detailed.rb,
lib/fog/openstack/volume/requests/delete_snapshot_metadata.rb,
lib/fog/openstack/volume/requests/update_snapshot_metadata.rb
Overview
no Mock needed, test coverage in RSpec
Instance Method Summary collapse
- #accept_transfer(transfer_id, auth_key) ⇒ Object
- #action(id, data) ⇒ Object
- #create_backup(attributes) ⇒ Object
- #create_transfer(volume_id, options = {}) ⇒ Object
- #create_volume_type(options = {}) ⇒ Object
- #delete_backup(backup_id) ⇒ Object
- #delete_metadata(volume_id, key_name) ⇒ Object
- #delete_snapshot(snapshot_id) ⇒ Object
- #delete_snapshot_metadata(snapshot_id, key_name) ⇒ Object
- #delete_transfer(transfer_id) ⇒ Object
- #delete_volume(volume_id) ⇒ Object
- #delete_volume_type(volume_type_id) ⇒ Object
- #extend_volume(volume_id, size) ⇒ Object
- #get_backup_details(backup_id) ⇒ Object
- #get_quota(tenant_id) ⇒ Object
- #get_quota_defaults(tenant_id) ⇒ Object
- #get_quota_usage(tenant_id) ⇒ Object
- #get_snapshot_details(snapshot_id) ⇒ Object
- #get_transfer_details(transfer_id) ⇒ Object
- #get_volume_details(volume_id) ⇒ Object
- #get_volume_type_details(volume_type_id) ⇒ Object
- #list_backups(options = {}) ⇒ Object
- #list_backups_detailed(options = {}) ⇒ Object
- #list_snapshots(options = true, options_deprecated = {}) ⇒ Object
- #list_snapshots_detailed(options = {}) ⇒ Object
- #list_transfers(options = {}) ⇒ Object
- #list_transfers_detailed(options = {}) ⇒ Object
- #list_volume_types(options = {}) ⇒ Object
- #list_volumes(options = true, options_deprecated = {}) ⇒ Object
- #list_volumes_detailed(options = {}) ⇒ Object
- #list_zones(options = {}) ⇒ Object
- #replace_metadata(volume_id, metadata = {}) ⇒ Object
- #restore_backup(backup_id, volume_id = nil, name = nil) ⇒ Object
- #set_tenant(tenant) ⇒ Object
- #snapshot_action(id, data) ⇒ Object
- #update_metadata(volume_id, metadata = {}) ⇒ Object
- #update_quota(tenant_id, options = {}) ⇒ Object
- #update_snapshot(snapshot_id, data = {}) ⇒ Object
- #update_snapshot_metadata(snapshot_id, metadata = {}) ⇒ Object
- #update_volume(volume_id, data = {}) ⇒ Object
- #update_volume_type(volume_type_id, options = {}) ⇒ Object
Instance Method Details
#accept_transfer(transfer_id, auth_key) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/fog/openstack/volume/requests/accept_transfer.rb', line 5 def accept_transfer(transfer_id, auth_key) data = { 'accept' => { 'auth_key' => auth_key } } request( :body => Fog::JSON.encode(data), :expects => [200, 202], :method => 'POST', :path => "os-volume-transfer/#{transfer_id}/accept" ) end |
#action(id, data) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/volume/requests/action.rb', line 5 def action(id, data) request( :body => Fog::JSON.encode(data), :expects => [200, 202], :method => 'POST', :path => "volumes/#{id}/action" ) end |
#create_backup(attributes) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fog/openstack/volume/requests/create_backup.rb', line 5 def create_backup(attributes) = [ :container, :name, :description, :volume_id, :incremental, :force, ] # Filter only allowed creation attributes data = { :backup => attributes.select { |key, _value| .include?(key.to_sym) } } request( :body => Fog::JSON.encode(data), :expects => [200, 202], :method => 'POST', :path => 'backups' ) end |
#create_transfer(volume_id, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/fog/openstack/volume/requests/create_transfer.rb', line 5 def create_transfer(volume_id, = {}) data = { 'transfer' => { 'volume_id' => volume_id } } if [:name] data['transfer']['name'] = [:name] end request( :body => Fog::JSON.encode(data), :expects => [200, 202], :method => 'POST', :path => 'os-volume-transfer' ) end |
#create_volume_type(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/fog/openstack/volume/requests/create_volume_type.rb', line 5 def create_volume_type( = {}) data = { 'volume_type' => {} } = [:name, :extra_specs] .select { |o| [o] }.each do |key| data['volume_type'][key] = [key] end request( :body => Fog::JSON.encode(data), :expects => [200, 202], :method => 'POST', :path => "types" ) end |
#delete_backup(backup_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/volume/requests/delete_backup.rb', line 5 def delete_backup(backup_id) request( :expects => 202, :method => 'DELETE', :path => "backups/#{backup_id}" ) end |
#delete_metadata(volume_id, key_name) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/volume/requests/delete_metadata.rb', line 5 def (volume_id, key_name) request( :expects => [200], :method => 'DELETE', :path => "volumes/#{volume_id}/metadata/#{key_name}" ) end |
#delete_snapshot(snapshot_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/volume/requests/delete_snapshot.rb', line 5 def delete_snapshot(snapshot_id) request( :expects => 202, :method => 'DELETE', :path => "snapshots/#{snapshot_id}" ) end |
#delete_snapshot_metadata(snapshot_id, key_name) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/volume/requests/delete_snapshot_metadata.rb', line 5 def (snapshot_id, key_name) request( :expects => [200], :method => 'DELETE', :path => "snapshots/#{snapshot_id}/metadata/#{key_name}" ) end |
#delete_transfer(transfer_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/volume/requests/delete_transfer.rb', line 5 def delete_transfer(transfer_id) request( :expects => 202, :method => 'DELETE', :path => "os-volume-transfer/#{transfer_id}" ) end |
#delete_volume(volume_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/volume/requests/delete_volume.rb', line 5 def delete_volume(volume_id) request( :expects => 202, :method => 'DELETE', :path => "volumes/#{volume_id}" ) end |
#delete_volume_type(volume_type_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/volume/requests/delete_volume_type.rb', line 5 def delete_volume_type(volume_type_id) request( :expects => 202, :method => 'DELETE', :path => "types/#{volume_type_id}" ) end |
#extend_volume(volume_id, size) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/fog/openstack/volume/requests/extend_volume.rb', line 5 def extend_volume(volume_id, size) body = {'os-extend' => {'new_size' => size}} request( :expects => 202, :method => 'POST', :path => "volumes/#{volume_id}/action", :body => Fog::JSON.encode(body) ) end |
#get_backup_details(backup_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/volume/requests/get_backup_details.rb', line 5 def get_backup_details(backup_id) request( :expects => 200, :method => 'GET', :path => "backups/#{backup_id}" ) end |
#get_quota(tenant_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/volume/requests/get_quota.rb', line 5 def get_quota(tenant_id) request( :expects => 200, :method => 'GET', :path => "/os-quota-sets/#{tenant_id}" ) end |
#get_quota_defaults(tenant_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/volume/requests/get_quota_defaults.rb', line 5 def get_quota_defaults(tenant_id) request( :expects => 200, :method => 'GET', :path => "/os-quota-sets/#{tenant_id}/defaults" ) end |
#get_quota_usage(tenant_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/volume/requests/get_quota_usage.rb', line 5 def get_quota_usage(tenant_id) request( :expects => 200, :method => 'GET', :path => "/os-quota-sets/#{tenant_id}?usage=True" ) end |
#get_snapshot_details(snapshot_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/volume/requests/get_snapshot_details.rb', line 5 def get_snapshot_details(snapshot_id) request( :expects => 200, :method => 'GET', :path => "snapshots/#{snapshot_id}" ) end |
#get_transfer_details(transfer_id) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/fog/openstack/volume/requests/get_transfer_details.rb', line 7 def get_transfer_details(transfer_id) request( :expects => 200, :method => 'GET', :path => "os-volume-transfer/#{transfer_id}" ) end |
#get_volume_details(volume_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/volume/requests/get_volume_details.rb', line 5 def get_volume_details(volume_id) request( :expects => 200, :method => 'GET', :path => "volumes/#{volume_id}" ) end |
#get_volume_type_details(volume_type_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/volume/requests/get_volume_type_details.rb', line 5 def get_volume_type_details(volume_type_id) request( :expects => 200, :method => 'GET', :path => "types/#{volume_type_id}" ) end |
#list_backups(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/volume/requests/list_backups.rb', line 5 def list_backups( = {}) request( :expects => 200, :method => 'GET', :path => 'backups', :query => ) end |
#list_backups_detailed(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/volume/requests/list_backups_detailed.rb', line 5 def list_backups_detailed( = {}) request( :expects => 200, :method => 'GET', :path => 'backups/detail', :query => ) end |
#list_snapshots(options = true, options_deprecated = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fog/openstack/volume/requests/list_snapshots.rb', line 5 def list_snapshots( = true, = {}) if .kind_of?(Hash) path = 'snapshots' query = else # Backwards compatibility layer, when 'detailed' boolean was sent as first param if Fog::Logger.deprecation('Calling OpenStack[:volume].list_snapshots(true) is deprecated, use .list_snapshots_detailed instead') else Fog::Logger.deprecation('Calling OpenStack[:volume].list_snapshots(false) is deprecated, use .list_snapshots({}) instead') end path = ? 'snapshots/detail' : 'snapshots' query = end request( :expects => 200, :method => 'GET', :path => path, :query => query ) end |
#list_snapshots_detailed(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/volume/requests/list_snapshots_detailed.rb', line 5 def list_snapshots_detailed( = {}) request( :expects => 200, :method => 'GET', :path => 'snapshots/detail', :query => ) end |
#list_transfers(options = {}) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/fog/openstack/volume/requests/list_transfers.rb', line 7 def list_transfers( = {}) request( :expects => 200, :method => 'GET', :path => 'os-volume-transfer', :query => ) end |
#list_transfers_detailed(options = {}) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/fog/openstack/volume/requests/list_transfers_detailed.rb', line 7 def list_transfers_detailed( = {}) request( :expects => 200, :method => 'GET', :path => 'os-volume-transfer/detail', :query => ) end |
#list_volume_types(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/volume/requests/list_volume_types.rb', line 5 def list_volume_types( = {}) request( :expects => 200, :method => 'GET', :path => 'types', :query => ) end |
#list_volumes(options = true, options_deprecated = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fog/openstack/volume/requests/list_volumes.rb', line 5 def list_volumes( = true, = {}) if .kind_of?(Hash) path = 'volumes' query = else # Backwards compatibility layer, when 'detailed' boolean was sent as first param if Fog::Logger.deprecation('Calling OpenStack[:volume].list_volumes(true) is deprecated, use .list_volumes_detailed instead') else Fog::Logger.deprecation('Calling OpenStack[:volume].list_volumes(false) is deprecated, use .list_volumes({}) instead') end path = ? 'volumes/detail' : 'volumes' query = end request( :expects => 200, :method => 'GET', :path => path, :query => query ) end |
#list_volumes_detailed(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/volume/requests/list_volumes_detailed.rb', line 5 def list_volumes_detailed( = {}) request( :expects => 200, :method => 'GET', :path => 'volumes/detail', :query => ) end |
#list_zones(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/volume/requests/list_zones.rb', line 5 def list_zones( = {}) request( :expects => 200, :method => 'GET', :path => 'os-availability-zone.json', :query => ) end |
#replace_metadata(volume_id, metadata = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fog/openstack/volume/requests/replace_metadata.rb', line 5 def (volume_id, = {}) data = { 'metadata' => } request( :body => Fog::JSON.encode(data), :expects => [200], :method => 'PUT', :path => "volumes/#{volume_id}/metadata" ) end |
#restore_backup(backup_id, volume_id = nil, name = nil) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/fog/openstack/volume/requests/restore_backup.rb', line 5 def restore_backup(backup_id, volume_id = nil, name = nil) data = {'restore' => {'volume_id' => volume_id, 'name' => name}} request( :expects => 202, :method => 'POST', :path => "backups/#{backup_id}/restore", :body => Fog::JSON.encode(data) ) end |
#set_tenant(tenant) ⇒ Object
5 6 7 8 9 |
# File 'lib/fog/openstack/volume/requests/set_tenant.rb', line 5 def set_tenant(tenant) @openstack_must_reauthenticate = true @openstack_tenant = tenant.to_s authenticate end |
#snapshot_action(id, data) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/volume/requests/snapshot_action.rb', line 5 def snapshot_action(id, data) request( :body => Fog::JSON.encode(data), :expects => [200, 202], :method => 'POST', :path => "snapshots/#{id}/action" ) end |
#update_metadata(volume_id, metadata = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fog/openstack/volume/requests/update_metadata.rb', line 5 def (volume_id, = {}) data = { 'metadata' => } request( :body => Fog::JSON.encode(data), :expects => [200,202], :method => 'POST', :path => "volumes/#{volume_id}/metadata" ) end |
#update_quota(tenant_id, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/volume/requests/update_quota.rb', line 5 def update_quota(tenant_id, = {}) request( :body => Fog::JSON.encode('quota_set' => ), :expects => 200, :method => 'PUT', :path => "/os-quota-sets/#{tenant_id}" ) end |
#update_snapshot(snapshot_id, data = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/volume/requests/update_snapshot.rb', line 5 def update_snapshot(snapshot_id, data = {}) request( :body => Fog::JSON.encode('snapshot' => data), :expects => 200, :method => 'PUT', :path => "snapshots/#{snapshot_id}" ) end |
#update_snapshot_metadata(snapshot_id, metadata = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fog/openstack/volume/requests/update_snapshot_metadata.rb', line 5 def (snapshot_id, = {}) data = { 'metadata' => } request( :body => Fog::JSON.encode(data), :expects => [200], :method => 'POST', :path => "snapshots/#{snapshot_id}/metadata" ) end |
#update_volume(volume_id, data = {}) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/fog/openstack/volume/v1/requests/update_volume.rb', line 8 def update_volume(volume_id, data = {}) request( :body => Fog::JSON.encode('volume' => data), :expects => 200, :method => 'PUT', :path => "volumes/#{volume_id}" ) end |
#update_volume_type(volume_type_id, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/fog/openstack/volume/requests/update_volume_type.rb', line 5 def update_volume_type(volume_type_id, = {}) data = { 'volume_type' => {} } = [:name, :extra_specs] .select { |o| [o] }.each do |key| data['volume_type'][key] = [key] end request( :body => Fog::JSON.encode(data), :expects => [200, 202], :method => 'PUT', :path => "types/#{volume_type_id}" ) end |