Class: Fog::Volume::OpenStack::V2::Real

Inherits:
Object
  • Object
show all
Includes:
OpenStack::Core, Real
Defined in:
lib/fog/volume/openstack/v2.rb,
lib/fog/volume/openstack/v2/requests/real.rb,
lib/fog/volume/openstack/v2/requests/real_mock.rb,
lib/fog/volume/openstack/v2/requests/list_volumes.rb,
lib/fog/volume/openstack/v2/requests/create_volume.rb,
lib/fog/volume/openstack/v2/requests/create_snapshot.rb,
lib/fog/volume/openstack/v2/requests/get_volume_details.rb,
lib/fog/volume/openstack/v2/requests/get_snapshot_details.rb,
lib/fog/volume/openstack/v2/requests/list_volumes_detailed.rb

Instance Attribute Summary

Attributes included from OpenStack::Core

#auth_token, #auth_token_expiration, #current_tenant, #current_user, #current_user_id, #openstack_cache_ttl, #openstack_domain_id, #openstack_domain_name, #openstack_identity_prefix, #openstack_project_domain, #openstack_project_domain_id, #openstack_project_id, #openstack_user_domain, #openstack_user_domain_id, #unscoped_token

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Real

#accept_transfer, #action, #create_backup, #create_transfer, #create_volume_type, #delete_backup, #delete_metadata, #delete_snapshot, #delete_snapshot_metadata, #delete_transfer, #delete_volume, #delete_volume_type, #extend_volume, #get_backup_details, #get_quota, #get_quota_defaults, #get_quota_usage, #get_snapshot_details, #get_transfer_details, #get_volume_details, #get_volume_type_details, #list_backups, #list_backups_detailed, #list_snapshots, #list_snapshots_detailed, #list_transfers, #list_transfers_detailed, #list_volume_types, #list_volumes, #list_volumes_detailed, #list_zones, #replace_metadata, #restore_backup, #set_tenant, #update_metadata, #update_quota, #update_snapshot, #update_snapshot_metadata, #update_volume, #update_volume_type

Methods included from OpenStack::Core

#credentials, #initialize_identity, #reload

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real.



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/fog/volume/openstack/v2.rb', line 156

def initialize(options = {})
  initialize_identity options

  @openstack_service_type  = options[:openstack_service_type] || ['volumev2']
  @openstack_service_name  = options[:openstack_service_name]
  @openstack_endpoint_type = options[:openstack_endpoint_type] || 'adminURL'

  @connection_options = options[:connection_options] || {}

  authenticate
  set_api_path

  @persistent = options[:persistent] || false
  @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end

Class Method Details

.not_found_classObject



152
153
154
# File 'lib/fog/volume/openstack/v2.rb', line 152

def self.not_found_class
  Fog::Volume::OpenStack::NotFound
end

Instance Method Details

#create_snapshot(volume_id, name, description, force = false) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fog/volume/openstack/v2/requests/create_snapshot.rb', line 10

def create_snapshot(volume_id, name, description, force = false)
  data = {
    'snapshot' => {
      'volume_id'   => volume_id,
      'name'        => name,
      'description' => description,
      'force'       => force.nil? ? false : force
    }
  }

  _create_snapshot(data)
end

#create_volume(name, description, size, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/volume/openstack/v2/requests/create_volume.rb', line 8

def create_volume(name, description, size, options = {})
  data = {
    'volume' => {
      'name'        => name,
      'description' => description,
      'size'        => size
    }
  }

  _create_volume(data, options)
end

#set_api_pathObject



172
173
174
175
176
177
178
179
# File 'lib/fog/volume/openstack/v2.rb', line 172

def set_api_path
  unless @path.match(SUPPORTED_VERSIONS)
    @path = Fog::OpenStack.get_supported_version_path(SUPPORTED_VERSIONS,
                                                      @openstack_management_uri,
                                                      @auth_token,
                                                      @connection_options)
  end
end