Class: Fog::HP::BlockStorageV2::Real
- Inherits:
-
Object
- Object
- Fog::HP::BlockStorageV2::Real
- Includes:
- Utils
- Defined in:
- lib/fog/hp/block_storage_v2.rb,
lib/fog/hp/requests/block_storage_v2/list_volumes.rb,
lib/fog/hp/requests/block_storage_v2/create_volume.rb,
lib/fog/hp/requests/block_storage_v2/delete_volume.rb,
lib/fog/hp/requests/block_storage_v2/update_volume.rb,
lib/fog/hp/requests/block_storage_v2/list_snapshots.rb,
lib/fog/hp/requests/block_storage_v2/create_snapshot.rb,
lib/fog/hp/requests/block_storage_v2/delete_snapshot.rb,
lib/fog/hp/requests/block_storage_v2/update_snapshot.rb,
lib/fog/hp/requests/block_storage_v2/get_volume_details.rb,
lib/fog/hp/requests/block_storage_v2/list_volume_backups.rb,
lib/fog/hp/requests/block_storage_v2/list_volumes_detail.rb,
lib/fog/hp/requests/block_storage_v2/create_volume_backup.rb,
lib/fog/hp/requests/block_storage_v2/delete_volume_backup.rb,
lib/fog/hp/requests/block_storage_v2/get_snapshot_details.rb,
lib/fog/hp/requests/block_storage_v2/list_snapshots_detail.rb,
lib/fog/hp/requests/block_storage_v2/restore_volume_backup.rb,
lib/fog/hp/requests/block_storage_v2/get_volume_backup_details.rb,
lib/fog/hp/requests/block_storage_v2/list_volume_backups_detail.rb
Instance Attribute Summary collapse
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
Instance Method Summary collapse
-
#create_snapshot(volume_id, options = {}) ⇒ Object
Create a new block storage snapshot The snapshot is created in the same availability_zone as the specified volume.
-
#create_volume(options = {}) ⇒ Object
Create a new block storage volume.
-
#create_volume_backup(volume_id, options = {}) ⇒ Object
Create a new block storage volume backup.
-
#delete_snapshot(snapshot_id) ⇒ Object
Delete an existing block storage snapshot.
-
#delete_volume(volume_id) ⇒ Object
Delete an existing block storage volume.
-
#delete_volume_backup(backup_id) ⇒ Object
Delete an existing block storage volume backup.
-
#get_snapshot_details(snapshot_id) ⇒ Object
Get details for existing block storage snapshot.
-
#get_volume_backup_details(backup_id) ⇒ Object
Get details for existing block storage volume backup.
-
#get_volume_details(volume_id) ⇒ Object
Get details for existing block storage volume.
-
#initialize(options = {}) ⇒ Real
constructor
A new instance of Real.
-
#list_snapshots(options = {}) ⇒ Object
List existing block storage snapshots.
-
#list_snapshots_detail(options = {}) ⇒ Object
List existing block storage snapshots with details.
-
#list_volume_backups(options = {}) ⇒ Object
List existing block storage volume backups.
-
#list_volume_backups_detail(options = {}) ⇒ Object
List details about existing block storage volume backups.
-
#list_volumes(options = {}) ⇒ Object
List existing block storage volumes.
-
#list_volumes_detail(options = {}) ⇒ Object
List details about existing block storage volumes.
- #reload ⇒ Object
- #request(params, parse_json = true, &block) ⇒ Object
-
#restore_volume_backup(backup_id, options = {}) ⇒ Object
Restore an existing block storage volume backup to an existing or new volume.
-
#update_snapshot(snapshot_id, options = {}) ⇒ Object
Update an existing block storage snapshot.
-
#update_volume(volume_id, options = {}) ⇒ Object
Update an existing block storage volume.
Methods included from Utils
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/fog/hp/block_storage_v2.rb', line 91 def initialize(={}) @hp_access_key = [:hp_access_key] @hp_secret_key = [:hp_secret_key] @hp_auth_uri = [:hp_auth_uri] @connection_options = [:connection_options] || {} ### Set an option to use the style of authentication desired; :v1 or :v2 (default) auth_version = [:hp_auth_version] || :v2 ### Pass the service name for block storage to the authentication call [:hp_service_type] ||= "Block Storage" @hp_tenant_id = [:hp_tenant_id] @hp_avl_zone = [:hp_avl_zone] ### Make the authentication call if (auth_version == :v2) # Call the control services authentication credentials = Fog::HP.authenticate_v2(, @connection_options) # the CS service catalog returns the block storage endpoint @hp_block_uri = credentials[:endpoint_url] @credentials = credentials else # Call the legacy v1.0/v1.1 authentication credentials = Fog::HP.authenticate_v1(, @connection_options) # the user sends in the block storage endpoint @hp_block_uri = [:hp_auth_uri] end @auth_token = credentials[:auth_token] @persistent = [:persistent] || false uri = URI.parse(@hp_block_uri) @host = uri.host @path = uri.path @port = uri.port @scheme = uri.scheme @connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options) end |
Instance Attribute Details
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
89 90 91 |
# File 'lib/fog/hp/block_storage_v2.rb', line 89 def credentials @credentials end |
Instance Method Details
#create_snapshot(volume_id, options = {}) ⇒ Object
Create a new block storage snapshot The snapshot is created in the same availability_zone as the specified volume
Parameters
-
‘volume_id’<~String> - UUId of the volume to create the snapshot from
-
options<~Hash>:
-
‘display_name’<~String> - Name of the snapshot
-
‘display_description’<~String> - Description of the snapshot
-
‘force’<~Boolean> - true or false, defaults to false. It allows online snapshots (i.e. when volume is attached)
-
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
snapshot<~Hash>:
-
‘id’<~String>: - UUId for the snapshot
-
‘display_name’<~String>: - Name of the snapshot
-
‘display_description’<~String>: - Description of the snapshot
-
‘size’<~Integer>: - Size in GB for the snapshot
-
‘status’<~String>: - Status of the snapshot i.e. “available”
-
‘volume_id’<~String>: - UUId of the volume from which the snapshot was created
-
‘created_at’<~String>: - Timestamp in UTC when volume was created
-
metadata<~Hash>: Hash of metadata for the snapshot
-
-
-
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fog/hp/requests/block_storage_v2/create_snapshot.rb', line 27 def create_snapshot(volume_id, ={}) data = { 'snapshot' => { 'volume_id' => volume_id } } = ['display_name', 'display_description', 'force'] .select{|o| [o]}.each do |key| data['snapshot'][key] = [key] end request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'POST', :path => 'snapshots' ) end |
#create_volume(options = {}) ⇒ Object
Create a new block storage volume
Parameters
-
options<~Hash>:
-
‘display_name’<~String> - Name of the volume
-
‘display_description’<~String> - Description of the volume
-
‘size’<~Integer> - Size of the volume (in GBs). Size is optional only if ‘snapshot_id’ is specified.
-
‘snapshot_id’<~String> - UUId of the volume snapshot to create the volume from. The snapshot_id, imageRef and the source_volid parameters are mutually exclusive, and only one should be specified in the request.
-
‘imageRef’<~String> - UUId of the image to create the volume from. This creates a bootable volume. The snapshot_id, imageRef and the source_volid parameters are mutually exclusive, and only one should be specified in the request.
-
‘source_volid’<~String> - UUId of an ‘available’ volume to create the volume from. The request is invalid if the volume is not available. The snapshot_id, imageRef and the source_volid parameters are mutually exclusive, and only one should be specified in the request.
-
‘availability_zone’<~String> - Availability zone where the volume should be created. Defaults to ‘az1’.
-
‘volume_type’<~String> - Type of the volume
-
‘metadata’<~Hash> - Up to 5 key value pairs containing 255 bytes of info
-
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
volume<~Hash>:
-
‘id’<~String> - UUId for the volume
-
‘display_name’<~String> - Name of the volume
-
‘display_description’<~String> - Description of the volume
-
‘size’<~Integer> - Size in GB for the volume
-
‘status’<~String> - Status of the volume i.e. “creating”
-
‘volume_type’<~String> - Type of the volume
-
‘snapshot_id’<~String> - UUId of the snapshot, the volume was created from.
-
‘source_volid’<~String> - UUId of a volume, the volume was created from.
-
‘created_at’<~String> - Timestamp in UTC when volume was created
-
‘availability_zone’<~String> - Availability zone i.e. “az1”
-
attachments<~Array>: Array of hashes of attachments
-
metadata<~Hash>: Hash of metadata for the volume
-
-
-
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/fog/hp/requests/block_storage_v2/create_volume.rb', line 35 def create_volume(={}) data = { 'volume' => {} } = ['display_name', 'display_description', 'size', 'snapshot_id', 'imageRef', 'source_volid', 'availability_zone', 'volume_type', 'metadata'] .select{|o| [o]}.each do |key| data['volume'][key] = [key] end request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'POST', :path => 'volumes' ) end |
#create_volume_backup(volume_id, options = {}) ⇒ Object
Create a new block storage volume backup
Parameters
-
‘volume_id’<~String> - UUId for the volume to backup
-
options<~Hash>:
-
‘name’<~String> - Name of the volume backup
-
‘description’<~String> - Description of the volume backup
-
‘container’<~String> - The object storage container where the backup will be stored. Defaults to ‘volumebackups’, if not specified at creating time.
-
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
backup<~Hash>:
-
‘id’<~String> - UUId for the volume backup
-
‘name’<~String> - Name of the volume backup
-
‘links’<~Array> - array of volume backup links
-
-
-
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fog/hp/requests/block_storage_v2/create_volume_backup.rb', line 21 def create_volume_backup(volume_id, ={}) data = { 'backup' => { 'volume_id' => volume_id } } = ['name', 'description', 'container'] .select{|o| [o]}.each do |key| data['backup'][key] = [key] end request( :body => Fog::JSON.encode(data), :expects => 202, :method => 'POST', :path => 'backups' ) end |
#delete_snapshot(snapshot_id) ⇒ Object
Delete an existing block storage snapshot
Parameters
-
‘snapshot_id’<~String> - UUId of the snapshot to delete
10 11 12 13 14 15 16 17 |
# File 'lib/fog/hp/requests/block_storage_v2/delete_snapshot.rb', line 10 def delete_snapshot(snapshot_id) response = request( :expects => 202, :method => 'DELETE', :path => "snapshots/#{snapshot_id}" ) response end |
#delete_volume(volume_id) ⇒ Object
Delete an existing block storage volume
Parameters
-
‘volume_id’<~String> - UUId of the volume to delete
10 11 12 13 14 15 16 17 |
# File 'lib/fog/hp/requests/block_storage_v2/delete_volume.rb', line 10 def delete_volume(volume_id) response = request( :expects => 202, :method => 'DELETE', :path => "volumes/#{volume_id}" ) response end |
#delete_volume_backup(backup_id) ⇒ Object
Delete an existing block storage volume backup
Parameters
-
‘backup_id’<~String> - UUId of the volume backup to delete
10 11 12 13 14 15 16 17 |
# File 'lib/fog/hp/requests/block_storage_v2/delete_volume_backup.rb', line 10 def delete_volume_backup(backup_id) response = request( :expects => 202, :method => 'DELETE', :path => "backups/#{backup_id}" ) response end |
#get_snapshot_details(snapshot_id) ⇒ Object
Get details for existing block storage snapshot
Parameters
-
‘snapshot_id’<~String> - UUId of the snapshot to get
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
snapshot<~Hash>:
-
‘id’<~String>: - UUId for the snapshot
-
‘display_name’<~String>: - Name of the snapshot
-
‘display_description’<~String>: - Description of the snapshot
-
‘size’<~Integer>: - Size in GB for the snapshot
-
‘status’<~String>: - Status of the snapshot i.e. “available”
-
‘volume_id’<~String>: - UUId of the volume from which the snapshot was created
-
‘created_at’<~String>: - Timestamp in UTC when volume was created
-
metadata<~Hash>: Hash of metadata for the snapshot
-
-
-
22 23 24 25 26 27 28 29 |
# File 'lib/fog/hp/requests/block_storage_v2/get_snapshot_details.rb', line 22 def get_snapshot_details(snapshot_id) response = request( :expects => 200, :method => 'GET', :path => "snapshots/#{snapshot_id}" ) response end |
#get_volume_backup_details(backup_id) ⇒ Object
Get details for existing block storage volume backup
Parameters
-
‘backup_id’<~String> - UUId of the volume backup to get
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
backup<~Hash>:
-
‘id’<~String> - UUId for the volume backup
-
‘name’<~String> - Name of the volume backup
-
‘description’<~String> - Description of the volume backup
-
‘container’<~String> - The object storage container where the backup is stored. Defaults to ‘volumebackups’ if not specified at creating time.
-
‘status’<~String> - Status of the volume backup i.e. “available”
-
‘fail_reason’<~String> - Reason for failure of the volume backup
-
‘object_count’<~Integer> - Number of backups for a volume
-
‘size’<~Integer> - Size of the volume in the backup
-
‘volume_id’<~String> - UUId for the volume in the backup
-
‘created_at’<~String> - Timestamp in UTC when volume backup was created
-
‘availability_zone’<~String> - Availability zone of the backup volume. The backup is created in the same availability zone as the volume.
-
‘links’<~Array> - array of volume backup links
-
-
-
26 27 28 29 30 31 32 33 |
# File 'lib/fog/hp/requests/block_storage_v2/get_volume_backup_details.rb', line 26 def get_volume_backup_details(backup_id) response = request( :expects => 200, :method => 'GET', :path => "backups/#{backup_id}" ) response end |
#get_volume_details(volume_id) ⇒ Object
Get details for existing block storage volume
Parameters
-
‘volume_id’<~String> - UUId of the volume to get
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
volume<~Hash>:
-
‘id’<~String> - UUId for the volume
-
‘display_name’<~String> - Name of the volume
-
‘display_description’<~String> - Description of the volume
-
‘size’<~Integer> - Size in GB for the volume
-
‘status’<~String> - Status of the volume i.e. “creating”
-
‘volume_type’<~String> - Type of the volume
-
‘snapshot_id’<~String> - UUId of the snapshot, the volume was created from.
-
‘source_volid’<~String> - UUId of a volume, the volume was created from.
-
‘created_at’<~String> - Timestamp in UTC when volume was created
-
‘availability_zone’<~String> - Availability zone i.e. “az1”
-
attachments<~Array>: Array of hashes of attachments
-
metadata<~Hash>: Hash of metadata for the volume
-
-
-
26 27 28 29 30 31 32 33 |
# File 'lib/fog/hp/requests/block_storage_v2/get_volume_details.rb', line 26 def get_volume_details(volume_id) response = request( :expects => 200, :method => 'GET', :path => "volumes/#{volume_id}" ) response end |
#list_snapshots(options = {}) ⇒ Object
List existing block storage snapshots
Parameters
-
options<~Hash>: filter options
-
‘display_name’<~String> - Name of the snapshot
-
‘marker’<~String> - The ID of the last item in the previous list
-
‘limit’<~Integer> - Sets the page size
-
‘changes-since’<~DateTime> - Filters by the changes-since time. The list contains servers that have been deleted since the changes-since time.
-
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
snapshots<~Hash>:
-
‘id’<~String>: - UUId for the snapshot
-
‘display_name’<~String>: - Name of the snapshot
-
‘display_description’<~String>: - Description of the snapshot
-
‘size’<~Integer>: - Size in GB for the snapshot
-
‘status’<~String>: - Status of the snapshot i.e. ‘available’
-
‘volume_id’<~String>: - UUId of the volume from which the snapshot was created
-
‘created_at’<~String>: - Timestamp in UTC when volume was created
-
metadata<~Hash>: Hash of metadata for the snapshot
-
-
-
26 27 28 29 30 31 32 33 34 |
# File 'lib/fog/hp/requests/block_storage_v2/list_snapshots.rb', line 26 def list_snapshots(={}) response = request( :expects => 200, :method => 'GET', :path => 'snapshots', :query => ) response end |
#list_snapshots_detail(options = {}) ⇒ Object
List existing block storage snapshots with details
Parameters
-
options<~Hash>: filter options
-
‘display_name’<~String> - Name of the snapshot
-
‘marker’<~String> - The ID of the last item in the previous list
-
‘limit’<~Integer> - Sets the page size
-
‘changes-since’<~DateTime> - Filters by the changes-since time. The list contains servers that have been deleted since the changes-since time.
-
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
snapshots<~Hash>:
-
‘id’<~String>: - UUId for the snapshot
-
‘display_name’<~String>: - Name of the snapshot
-
‘display_description’<~String>: - Description of the snapshot
-
‘size’<~Integer>: - Size in GB for the snapshot
-
‘status’<~String>: - Status of the snapshot i.e. “available”
-
‘volume_id’<~String>: - UUId of the volume from which the snapshot was created
-
‘created_at’<~String>: - Timestamp in UTC when volume was created
-
metadata<~Hash>: Hash of metadata for the snapshot
-
-
-
26 27 28 29 30 31 32 33 34 |
# File 'lib/fog/hp/requests/block_storage_v2/list_snapshots_detail.rb', line 26 def list_snapshots_detail(={}) response = request( :expects => 200, :method => 'GET', :path => 'snapshots/detail', :query => ) response end |
#list_volume_backups(options = {}) ⇒ Object
List existing block storage volume backups
Parameters
-
options<~Hash>: filter options
-
‘name’<~String> - Name of the volume
-
‘marker’<~String> - The ID of the last item in the previous list
-
‘limit’<~Integer> - Sets the page size
-
‘changes-since’<~DateTime> - Filters by the changes-since time. The list contains servers that have been deleted since the changes-since time.
-
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
backups<~Hash>:
-
‘id’<~String> - UUId for the volume backup
-
‘name’<~String> - Name of the volume backup
-
‘links’<~Array> - array of volume backup links
-
-
-
21 22 23 24 25 26 27 28 29 |
# File 'lib/fog/hp/requests/block_storage_v2/list_volume_backups.rb', line 21 def list_volume_backups( = {}) response = request( :expects => 200, :method => 'GET', :path => 'backups', :query => ) response end |
#list_volume_backups_detail(options = {}) ⇒ Object
List details about existing block storage volume backups
Parameters
-
options<~Hash>: filter options
-
‘name’<~String> - Name of the volume
-
‘marker’<~String> - The ID of the last item in the previous list
-
‘limit’<~Integer> - Sets the page size
-
‘changes-since’<~DateTime> - Filters by the changes-since time. The list contains servers that have been deleted since the changes-since time.
-
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
backups<~Hash>:
-
‘id’<~String> - UUId for the volume backup
-
‘name’<~String> - Name of the volume backup
-
‘description’<~String> - Description of the volume backup
-
‘container’<~String> - The object storage container where the backup is stored. Defaults to ‘volumebackups’ if not specified at creating time.
-
‘status’<~String> - Status of the volume backup i.e. “available”
-
‘fail_reason’<~String> - Reason for failure of the volume backup
-
‘object_count’<~Integer> - Number of backups for a volume
-
‘size’<~Integer> - Size of the volume in the backup
-
‘volume_id’<~String> - UUId for the volume in the backup
-
‘created_at’<~String> - Timestamp in UTC when volume backup was created
-
‘availability_zone’<~String> - Availability zone of the backup volume. The backup is created in the same availability zone as the volume.
-
‘links’<~Array> - array of volume backup links
-
-
-
30 31 32 33 34 35 36 37 38 |
# File 'lib/fog/hp/requests/block_storage_v2/list_volume_backups_detail.rb', line 30 def list_volume_backups_detail( = {}) response = request( :expects => 200, :method => 'GET', :path => 'backups/detail', :query => ) response end |
#list_volumes(options = {}) ⇒ Object
List existing block storage volumes
Parameters
-
options<~Hash>: filter options
-
‘display_name’<~String> - Name of the volume
-
‘marker’<~String> - The ID of the last item in the previous list
-
‘limit’<~Integer> - Sets the page size
-
‘changes-since’<~DateTime> - Filters by the changes-since time. The list contains servers that have been deleted since the changes-since time.
-
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
volumes<~Hash>:
-
‘id’<~String> - UUId for the volume
-
‘display_name’<~String> - Name of the volume
-
‘display_description’<~String> - Description of the volume
-
‘size’<~Integer> - Size in GB for the volume
-
‘status’<~String> - Status of the volume i.e. “creating”
-
‘volume_type’<~String> - Type of the volume
-
‘snapshot_id’<~String> - UUId of the snapshot, the volume was created from.
-
‘source_volid’<~String> - UUId of a volume, the volume was created from.
-
‘created_at’<~String> - Timestamp in UTC when volume was created
-
‘availability_zone’<~String> - Availability zone i.e. “az1”
-
attachments<~Array>: Array of hashes of attachments
-
metadata<~Hash>: Hash of metadata for the volume
-
-
-
30 31 32 33 34 35 36 37 38 |
# File 'lib/fog/hp/requests/block_storage_v2/list_volumes.rb', line 30 def list_volumes( = {}) response = request( :expects => 200, :method => 'GET', :path => 'volumes', :query => ) response end |
#list_volumes_detail(options = {}) ⇒ Object
List details about existing block storage volumes
Parameters
-
options<~Hash>: filter options
-
‘display_name’<~String> - Name of the volume
-
‘marker’<~String> - The ID of the last item in the previous list
-
‘limit’<~Integer> - Sets the page size
-
‘changes-since’<~DateTime> - Filters by the changes-since time. The list contains servers that have been deleted since the changes-since time.
-
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
volumes<~Hash>:
-
‘id’<~String> - UUId for the volume
-
‘display_name’<~String> - Name of the volume
-
‘display_description’<~String> - Description of the volume
-
‘size’<~Integer> - Size in GB for the volume
-
‘status’<~String> - Status of the volume i.e. “creating”
-
‘volume_type’<~String> - Type of the volume
-
‘snapshot_id’<~String> - UUId of the snapshot, the volume was created from.
-
‘source_volid’<~String> - UUId of a volume, the volume was created from.
-
‘created_at’<~String> - Timestamp in UTC when volume was created
-
‘availability_zone’<~String> - Availability zone i.e. “az1”
-
attachments<~Array>: Array of hashes of attachments
-
metadata<~Hash>: Hash of metadata for the volume
-
volume_image_metadata<~Hash>: Hash of image metadata for the volume, only if the volume was created from an image.
-
-
-
31 32 33 34 35 36 37 38 39 |
# File 'lib/fog/hp/requests/block_storage_v2/list_volumes_detail.rb', line 31 def list_volumes_detail( = {}) response = request( :expects => 200, :method => 'GET', :path => 'volumes/detail', :query => ) response end |
#reload ⇒ Object
129 130 131 |
# File 'lib/fog/hp/block_storage_v2.rb', line 129 def reload @connection.reset end |
#request(params, parse_json = true, &block) ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/fog/hp/block_storage_v2.rb', line 133 def request(params, parse_json = true, &block) begin response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :path => "#{@path}/#{params[:path]}" }), &block) rescue Excon::Errors::HTTPStatusError => error raise case error when Excon::Errors::NotFound Fog::HP::BlockStorageV2::NotFound.slurp(error) else error end end if !response.body.empty? && parse_json && response.headers['Content-Type'] =~ %r{application/json} response.body = Fog::JSON.decode(response.body) end response end |
#restore_volume_backup(backup_id, options = {}) ⇒ Object
Restore an existing block storage volume backup to an existing or new volume
If a volume is specified, that volume will be overwritten with the backup data from the backup. If no volume is specified, a new volume will be created and used for the restore operation.
Parameters
-
‘backup_id’<~String> - UUId of the volume backup to delete
-
options<~Hash>:
-
‘volume_id’<~String> - UUId of the volume that will be overwritten by the backup data
-
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/fog/hp/requests/block_storage_v2/restore_volume_backup.rb', line 15 def restore_volume_backup(backup_id, ={}) data = { 'restore' => { 'backup_id' => backup_id } } = ['volume_id'] .select{|o| [o]}.each do |key| data['restore'][key] = [key] end request( :body => Fog::JSON.encode(data), :expects => 202, :method => 'POST', :path => "backups/#{backup_id}/restore" ) end |
#update_snapshot(snapshot_id, options = {}) ⇒ Object
Update an existing block storage snapshot
Parameters
-
‘snapshot_id’<~String> - UUId of the snapshot to update
-
options<~Hash>:
-
‘display_name’<~String> - Name of the snapshot
-
‘display_description’<~String> - Description of the snapshot
-
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
snapshot<~Hash>:
-
‘id’<~String>: - UUId for the snapshot
-
‘display_name’<~String>: - Name of the snapshot
-
‘display_description’<~String>: - Description of the snapshot
-
‘size’<~Integer>: - Size in GB for the snapshot
-
‘status’<~String>: - Status of the snapshot i.e. “available”
-
‘volume_id’<~String>: - UUId of the volume from which the snapshot was created
-
‘created_at’<~String>: - Timestamp in UTC when volume was created
-
metadata<~Hash>: Hash of metadata for the snapshot
-
-
-
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fog/hp/requests/block_storage_v2/update_snapshot.rb', line 25 def update_snapshot(snapshot_id, ={}) data = { 'snapshot' => {} } = ['display_name', 'display_description', 'metadata'] .select{|o| [o]}.each do |key| data['snapshot'][key] = [key] end request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'PUT', :path => "snapshots/#{snapshot_id}" ) end |
#update_volume(volume_id, options = {}) ⇒ Object
Update an existing block storage volume
Parameters
-
‘volume_id’<~String> - UUId of the volume to update
-
options<~Hash>:
-
‘display_name’<~String> - Name of the volume
-
‘display_description’<~String> - Description of the volume
-
‘metadata’<~Hash> - Up to 5 key value pairs containing 255 bytes of info
-
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
volume<~Hash>:
-
‘id’<~String> - UUId for the volume
-
‘display_name’<~String> - Name of the volume
-
‘display_description’<~String> - Description of the volume
-
‘size’<~Integer> - Size in GB for the volume
-
‘status’<~String> - Status of the volume i.e. “creating”
-
‘volume_type’<~String> - Type of the volume
-
‘snapshot_id’<~String> - UUId of the snapshot, the volume was created from.
-
‘source_volid’<~String> - UUId of a volume, the volume was created from.
-
‘created_at’<~String> - Timestamp in UTC when volume was created
-
‘availability_zone’<~String> - Availability zone i.e. “az1”
-
attachments<~Array>: Array of hashes of attachments
-
metadata<~Hash>: Hash of metadata for the volume
-
-
-
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/fog/hp/requests/block_storage_v2/update_volume.rb', line 30 def update_volume(volume_id, ={}) data = { 'volume' => {} } = ['display_name', 'display_description', 'metadata'] .select{|o| [o]}.each do |key| data['volume'][key] = [key] end request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'PUT', :path => "volumes/#{volume_id}" ) end |