class Fog::OpenStack::SharedFileSystem::Real

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

Public Class Methods

new(options = {}) click to toggle source
Calls superclass method Fog::OpenStack::Core::new
# File lib/fog/openstack/shared_file_system.rb, line 362
def initialize(options = {})
  @supported_versions     = SUPPORTED_VERSIONS
  @supported_microversion = SUPPORTED_MICROVERSION
  @fixed_microversion     = options[:openstack_shared_file_system_microversion]
  @microversion_key       = 'X-Openstack-Manila-Api-Version'.freeze
  super
end
not_found_class() click to toggle source
# File lib/fog/openstack/shared_file_system.rb, line 350
def self.not_found_class
  Fog::OpenStack::SharedFileSystem::NotFound
end

Public Instance Methods

action_prefix() click to toggle source
# File lib/fog/openstack/shared_file_system.rb, line 354
def action_prefix
  microversion_newer_than?('2.6') ? '' : 'os-'
end
add_security_service_to_share_network(security_service_id, share_network_id) click to toggle source
# File lib/fog/openstack/shared_file_system/requests/add_security_service_to_share_network.rb, line 5
def add_security_service_to_share_network(security_service_id, share_network_id)
  action = {
    'add_security_service' => {
      'security_service_id' => security_service_id
    }
  }
  share_network_action(share_network_id, action)
end
create_security_service(type, name, options = {}) click to toggle source
# File lib/fog/openstack/shared_file_system/requests/create_security_service.rb, line 5
def create_security_service(type, name, options = {})
  data = {
    'type' => type,
    'name' => name
  }

  vanilla_options = [
    :description, :dns_ip, :user, :password, :domain, :server
  ]

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

  request(
    :body    => Fog::JSON.encode('security_service' => data),
    :expects => 200,
    :method  => 'POST',
    :path    => 'security-services'
  )
end
create_share(protocol, size, options = {}) click to toggle source
# File lib/fog/openstack/shared_file_system/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/openstack/shared_file_system/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/openstack/shared_file_system/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
default_service_type() click to toggle source
# File lib/fog/openstack/shared_file_system.rb, line 358
def default_service_type
  %w[sharev2]
end
delete_security_service(id) click to toggle source
# File lib/fog/openstack/shared_file_system/requests/delete_security_service.rb, line 5
def delete_security_service(id)
  request(
    :expects => 202,
    :method  => 'DELETE',
    :path    => "security-services/#{id}"
  )
end
delete_share(id) click to toggle source
# File lib/fog/openstack/shared_file_system/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/openstack/shared_file_system/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/openstack/shared_file_system/requests/delete_snapshot.rb, line 5
def delete_snapshot(id)
  request(
    :expects => 202,
    :method  => 'DELETE',
    :path    => "snapshots/#{id}"
  )
end
extend_share(share_id, new_size) click to toggle source
# File lib/fog/openstack/shared_file_system/requests/extend_share.rb, line 5
def extend_share(share_id, new_size)
  action = {
    "#{action_prefix}extend" => {
      'new_size' => new_size
    }
  }
  share_action(share_id, action)
end
get_limits() click to toggle source
# File lib/fog/openstack/shared_file_system/requests/get_limits.rb, line 5
def get_limits
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => 'limits'
  )
end
get_quota(project_id) click to toggle source
# File lib/fog/openstack/shared_file_system/requests/get_quota.rb, line 5
def get_quota(project_id)
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "#{action_prefix}quota-sets/#{project_id}"
  )
end
get_security_service(id) click to toggle source
# File lib/fog/openstack/shared_file_system/requests/get_security_service.rb, line 5
def get_security_service(id)
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "security-services/#{id}"
  )
end
get_share(id) click to toggle source
# File lib/fog/openstack/shared_file_system/requests/get_share.rb, line 5
def get_share(id)
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "shares/#{id}"
  )
end
get_share_export_location(share_id,export_location_id) click to toggle source

For older versions v1.0-2.8 the export locations are responsed as an attribute of share (export_locations). For newer API versions (>= 2.9) it is available in separate APIs. This method returns the export location detail.

# File lib/fog/openstack/shared_file_system/requests/get_share_export_location.rb, line 8
def get_share_export_location(share_id,export_location_id)
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "shares/#{share_id}/export_locations/​{export_location_id}​"
  )
end
get_share_network(id) click to toggle source
# File lib/fog/openstack/shared_file_system/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/openstack/shared_file_system/requests/get_snapshot.rb, line 5
def get_snapshot(id)
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "snapshots/#{id}"
  )
end
grant_share_access(share_id, access_to = '0.0.0.0/0', access_type = 'ip', access_level = 'rw') click to toggle source
# File lib/fog/openstack/shared_file_system/requests/grant_share_access.rb, line 5
def grant_share_access(share_id, access_to = '0.0.0.0/0', access_type = 'ip', access_level = 'rw')
  action = {
    "#{action_prefix}allow_access" => {
      'access_to'    => access_to,
      'access_type'  => access_type,
      'access_level' => access_level
    }
  }
  share_action(share_id, action, 200)
end
list_availability_zones() click to toggle source
# File lib/fog/openstack/shared_file_system/requests/list_availability_zones.rb, line 5
def list_availability_zones()
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => microversion_newer_than?('2.6') ? 'availability-zones' : 'os-availability-zone'
  )
end
list_security_services(options = {}) click to toggle source
# File lib/fog/openstack/shared_file_system/requests/list_security_services.rb, line 5
def list_security_services(options = {})
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => 'security-services',
    :query   => options
  )
end
list_security_services_detail(options = {}) click to toggle source
# File lib/fog/openstack/shared_file_system/requests/list_security_services_detail.rb, line 5
def list_security_services_detail(options = {})
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => 'security-services/detail',
    :query   => options
  )
end
list_share_access_rules(share_id) click to toggle source
# File lib/fog/openstack/shared_file_system/requests/list_share_access_rules.rb, line 5
def list_share_access_rules(share_id)
  action = {
    "#{action_prefix}access_list" => nil
  }
  share_action(share_id, action, 200)
end
list_share_export_locations(share_id) click to toggle source

For older versions v1.0-2.8 the export locations are responsed as an attribute of share (export_locations). For newer API versions (>= 2.9) it is available in separate APIs. This method returns a list of the export locations.

# File lib/fog/openstack/shared_file_system/requests/list_share_export_locations.rb, line 8
def list_share_export_locations(share_id)
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "shares/#{share_id}/export_locations"
  )
end
list_share_networks(options = {}) click to toggle source
# File lib/fog/openstack/shared_file_system/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/openstack/shared_file_system/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/openstack/shared_file_system/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/openstack/shared_file_system/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/openstack/shared_file_system/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/openstack/shared_file_system/requests/list_snapshots_detail.rb, line 5
def list_snapshots_detail(options = {})
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => 'snapshots/detail',
    :query   => options
  )
end
remove_security_service_from_share_network(security_service_id, share_network_id) click to toggle source
# File lib/fog/openstack/shared_file_system/requests/remove_security_service_from_share_network.rb, line 5
def remove_security_service_from_share_network(security_service_id, share_network_id)
  action = {
    'remove_security_service' => {
      'security_service_id' => security_service_id
    }
  }
  share_network_action(share_network_id, action)
end
revoke_share_access(share_id, access_id) click to toggle source
# File lib/fog/openstack/shared_file_system/requests/revoke_share_access.rb, line 5
def revoke_share_access(share_id, access_id)
  action = {
    "#{action_prefix}deny_access" => {
      'access_id' => access_id
    }
  }
  share_action(share_id, action)
end
share_action(id, options = {}, expects_status = 202) click to toggle source
# File lib/fog/openstack/shared_file_system/requests/share_action.rb, line 5
def share_action(id, options = {}, expects_status = 202)
  request(
    :body    => Fog::JSON.encode(options),
    :expects => expects_status,
    :method  => 'POST',
    :path    => "shares/#{id}/action"
  )
end
share_network_action(id, options = {}, expects_status = 200) click to toggle source
# File lib/fog/openstack/shared_file_system/requests/share_network_action.rb, line 5
def share_network_action(id, options = {}, expects_status = 200)
  request(
    :body    => Fog::JSON.encode(options),
    :expects => expects_status,
    :method  => 'POST',
    :path    => "share-networks/#{id}/action"
  )
end
shrink_share(share_id, new_size) click to toggle source
# File lib/fog/openstack/shared_file_system/requests/shrink_share.rb, line 5
def shrink_share(share_id, new_size)
  action = {
    "#{action_prefix}shrink" => {
      'new_size' => new_size
    }
  }
  share_action(share_id, action)
end
update_quota(project_id, options = {}) click to toggle source
# File lib/fog/openstack/shared_file_system/requests/update_quota.rb, line 5
def update_quota(project_id, options = {})
  request(
    :body    => Fog::JSON.encode('quota_set' => options),
    :expects => 200,
    :method  => 'PUT',
    :path    => "#{action_prefix}quota-sets/#{project_id}"
  )
end
update_security_service(id, options = {}) click to toggle source
# File lib/fog/openstack/shared_file_system/requests/update_security_service.rb, line 5
def update_security_service(id, options = {})
  request(
    :body    => Fog::JSON.encode('security_service' => options),
    :expects => 200,
    :method  => 'PUT',
    :path    => "security-services/#{id}"
  )
end
update_share(id, options = {}) click to toggle source
# File lib/fog/openstack/shared_file_system/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/openstack/shared_file_system/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/openstack/shared_file_system/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