class Fog::SharedFileSystem::OpenStack::Real

rubocop:enable LineLength, Metrics/MethodLength, Metrics/ClassLength, Metrics/AbcSize

Public Class Methods

new(options = {}) click to toggle source
# File lib/fog/shared_file_system/openstack.rb, line 252
def initialize(options = {})
  initialize_identity options

  @openstack_service_type           = options[:openstack_service_type] || ['sharev2']
  @openstack_service_name           = options[:openstack_service_name]

  @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
not_found_class() click to toggle source
# File lib/fog/shared_file_system/openstack.rb, line 248
def self.not_found_class
  Fog::SharedFileSystem::OpenStack::NotFound
end

Public Instance Methods

create_share(protocol, size, options = {}) click to toggle source
# File lib/fog/shared_file_system/openstack/requests/create_share.rb, line 5
def create_share(protocol, size, options = {})
  data = {
    'share_proto' => protocol,
    'size'        => size
  }

  vanilla_options = [
    :name, :description, :display_name, :display_description, :share_type, :volume_type, :snapshot_id,
    :is_public, :metadata, :share_network_id, :consistency_group_id, :availability_zone
  ]

  vanilla_options.select { |o| options[o] }.each do |key|
    data[key] = options[key]
  end

  request(
    :body    => Fog::JSON.encode('share' => data),
    :expects => 200,
    :method  => 'POST',
    :path    => 'shares'
  )
end
create_share_network(options = {}) click to toggle source
# File lib/fog/shared_file_system/openstack/requests/create_share_network.rb, line 5
def create_share_network(options = {})
  data = {}

  vanilla_options = [
    :name, :description, :neutron_net_id, :neutron_subnet_id, :nova_net_id
  ]

  vanilla_options.select { |o| options[o] }.each do |key|
    data[key] = options[key]
  end

  request(
    :body    => Fog::JSON.encode('share_network' => data),
    :expects => 200,
    :method  => 'POST',
    :path    => 'share-networks'
  )
end
create_snapshot(share_id, options = {}) click to toggle source
# File lib/fog/shared_file_system/openstack/requests/create_snapshot.rb, line 5
def create_snapshot(share_id, options = {})
  data = {
    'share_id' => share_id
  }

  vanilla_options = [
    :name, :description, :display_name, :display_description, :force
  ]

  vanilla_options.select { |o| options[o] }.each do |key|
    data[key] = options[key]
  end

  request(
    :body    => Fog::JSON.encode('snapshot' => data),
    :expects => 202,
    :method  => 'POST',
    :path    => 'snapshots'
  )
end
delete_share(id) click to toggle source
# File lib/fog/shared_file_system/openstack/requests/delete_share.rb, line 5
def delete_share(id)
  request(
    :expects => 202,
    :method  => 'DELETE',
    :path    => "shares/#{id}"
  )
end
delete_share_network(id) click to toggle source
# File lib/fog/shared_file_system/openstack/requests/delete_share_network.rb, line 5
def delete_share_network(id)
  request(
    :expects => 202,
    :method  => 'DELETE',
    :path    => "share-networks/#{id}"
  )
end
delete_snapshot(id) click to toggle source
# File lib/fog/shared_file_system/openstack/requests/delete_snapshot.rb, line 5
def delete_snapshot(id)
  request(
    :expects => 202,
    :method  => 'DELETE',
    :path    => "snapshots/#{id}"
  )
end
get_share(id) click to toggle source
# File lib/fog/shared_file_system/openstack/requests/get_share.rb, line 5
def get_share(id)
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "shares/#{id}"
  )
end
get_share_network(id) click to toggle source
# File lib/fog/shared_file_system/openstack/requests/get_share_network.rb, line 5
def get_share_network(id)
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "share-networks/#{id}"
  )
end
get_snapshot(id) click to toggle source
# File lib/fog/shared_file_system/openstack/requests/get_snapshot.rb, line 5
def get_snapshot(id)
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "snapshots/#{id}"
  )
end
list_share_networks(options = {}) click to toggle source
# File lib/fog/shared_file_system/openstack/requests/list_share_networks.rb, line 5
def list_share_networks(options = {})
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => 'share_networks',
    :query   => options
  )
end
list_share_networks_detail(options = {}) click to toggle source
# File lib/fog/shared_file_system/openstack/requests/list_share_networks_detail.rb, line 5
def list_share_networks_detail(options = {})
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => 'share-networks/detail',
    :query   => options
  )
end
list_shares(options = {}) click to toggle source
# File lib/fog/shared_file_system/openstack/requests/list_shares.rb, line 5
def list_shares(options = {})
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => 'shares',
    :query   => options
  )
end
list_shares_detail(options = {}) click to toggle source
# File lib/fog/shared_file_system/openstack/requests/list_shares_detail.rb, line 5
def list_shares_detail(options = {})
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => 'shares/detail',
    :query   => options
  )
end
list_snapshots(options = {}) click to toggle source
# File lib/fog/shared_file_system/openstack/requests/list_snapshots.rb, line 5
def list_snapshots(options = {})
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => 'snapshots',
    :query   => options
  )
end
list_snapshots_detail(options = {}) click to toggle source
# File lib/fog/shared_file_system/openstack/requests/list_snapshots_detail.rb, line 5
def list_snapshots_detail(options = {})
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => 'snapshots/detail',
    :query   => options
  )
end
set_api_path() click to toggle source
# File lib/fog/shared_file_system/openstack.rb, line 267
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
update_share(id, options = {}) click to toggle source
# File lib/fog/shared_file_system/openstack/requests/update_share.rb, line 5
def update_share(id, options = {})
  request(
    :body    => Fog::JSON.encode('share' => options),
    :expects => 200,
    :method  => 'PUT',
    :path    => "shares/#{id}"
  )
end
update_share_network(id, options = {}) click to toggle source
# File lib/fog/shared_file_system/openstack/requests/update_share_network.rb, line 5
def update_share_network(id, options = {})
  request(
    :body    => Fog::JSON.encode('share_network' => options),
    :expects => 200,
    :method  => 'PUT',
    :path    => "share-networks/#{id}"
  )
end
update_snapshot(id, options = {}) click to toggle source
# File lib/fog/shared_file_system/openstack/requests/update_snapshot.rb, line 5
def update_snapshot(id, options = {})
  request(
    :body    => Fog::JSON.encode('snapshot' => options),
    :expects => 200,
    :method  => 'PUT',
    :path    => "snapshots/#{id}"
  )
end