Class: Fog::SharedFileSystem::HuaweiCloud::Real
- Inherits:
-
Object
- Object
- Fog::SharedFileSystem::HuaweiCloud::Real
- Includes:
- HuaweiCloud::Core
- Defined in:
- lib/fog/shared_file_system/huaweicloud.rb,
lib/fog/shared_file_system/huaweicloud/requests/get_quota.rb,
lib/fog/shared_file_system/huaweicloud/requests/get_share.rb,
lib/fog/shared_file_system/huaweicloud/requests/get_limits.rb,
lib/fog/shared_file_system/huaweicloud/requests/list_shares.rb,
lib/fog/shared_file_system/huaweicloud/requests/create_share.rb,
lib/fog/shared_file_system/huaweicloud/requests/delete_share.rb,
lib/fog/shared_file_system/huaweicloud/requests/extend_share.rb,
lib/fog/shared_file_system/huaweicloud/requests/get_snapshot.rb,
lib/fog/shared_file_system/huaweicloud/requests/share_action.rb,
lib/fog/shared_file_system/huaweicloud/requests/shrink_share.rb,
lib/fog/shared_file_system/huaweicloud/requests/update_quota.rb,
lib/fog/shared_file_system/huaweicloud/requests/update_share.rb,
lib/fog/shared_file_system/huaweicloud/requests/list_snapshots.rb,
lib/fog/shared_file_system/huaweicloud/requests/create_snapshot.rb,
lib/fog/shared_file_system/huaweicloud/requests/delete_snapshot.rb,
lib/fog/shared_file_system/huaweicloud/requests/update_snapshot.rb,
lib/fog/shared_file_system/huaweicloud/requests/get_share_network.rb,
lib/fog/shared_file_system/huaweicloud/requests/grant_share_access.rb,
lib/fog/shared_file_system/huaweicloud/requests/list_shares_detail.rb,
lib/fog/shared_file_system/huaweicloud/requests/list_share_networks.rb,
lib/fog/shared_file_system/huaweicloud/requests/revoke_share_access.rb,
lib/fog/shared_file_system/huaweicloud/requests/create_share_network.rb,
lib/fog/shared_file_system/huaweicloud/requests/delete_share_network.rb,
lib/fog/shared_file_system/huaweicloud/requests/get_security_service.rb,
lib/fog/shared_file_system/huaweicloud/requests/share_network_action.rb,
lib/fog/shared_file_system/huaweicloud/requests/update_share_network.rb,
lib/fog/shared_file_system/huaweicloud/requests/list_snapshots_detail.rb,
lib/fog/shared_file_system/huaweicloud/requests/list_security_services.rb,
lib/fog/shared_file_system/huaweicloud/requests/create_security_service.rb,
lib/fog/shared_file_system/huaweicloud/requests/delete_security_service.rb,
lib/fog/shared_file_system/huaweicloud/requests/list_availability_zones.rb,
lib/fog/shared_file_system/huaweicloud/requests/list_share_access_rules.rb,
lib/fog/shared_file_system/huaweicloud/requests/update_security_service.rb,
lib/fog/shared_file_system/huaweicloud/requests/get_share_export_location.rb,
lib/fog/shared_file_system/huaweicloud/requests/list_share_networks_detail.rb,
lib/fog/shared_file_system/huaweicloud/requests/list_share_export_locations.rb,
lib/fog/shared_file_system/huaweicloud/requests/list_security_services_detail.rb,
lib/fog/shared_file_system/huaweicloud/requests/add_security_service_to_share_network.rb,
lib/fog/shared_file_system/huaweicloud/requests/remove_security_service_from_share_network.rb
Overview
rubocop:enable LineLength, Metrics/MethodLength, Metrics/ClassLength, Metrics/AbcSize
Class Method Summary collapse
Instance Method Summary collapse
- #action_prefix ⇒ Object
- #add_security_service_to_share_network(security_service_id, share_network_id) ⇒ Object
- #create_security_service(type, name, options = {}) ⇒ Object
- #create_share(protocol, size, options = {}) ⇒ Object
- #create_share_network(options = {}) ⇒ Object
- #create_snapshot(share_id, options = {}) ⇒ Object
- #delete_security_service(id) ⇒ Object
- #delete_share(id) ⇒ Object
- #delete_share_network(id) ⇒ Object
- #delete_snapshot(id) ⇒ Object
- #extend_share(share_id, new_size) ⇒ Object
- #get_limits ⇒ Object
- #get_quota(project_id) ⇒ Object
- #get_security_service(id) ⇒ Object
- #get_share(id) ⇒ Object
-
#get_share_export_location(share_id, export_location_id) ⇒ Object
For older versions v1.0-2.8 the export locations are responsed as an attribute of share (export_locations).
- #get_share_network(id) ⇒ Object
- #get_snapshot(id) ⇒ Object
- #grant_share_access(share_id, access_to = '0.0.0.0/0', access_type = 'ip', access_level = 'rw') ⇒ Object
-
#initialize(options = {}) ⇒ Real
constructor
A new instance of Real.
- #list_availability_zones ⇒ Object
- #list_security_services(options = {}) ⇒ Object
- #list_security_services_detail(options = {}) ⇒ Object
- #list_share_access_rules(share_id) ⇒ Object
-
#list_share_export_locations(share_id) ⇒ Object
For older versions v1.0-2.8 the export locations are responsed as an attribute of share (export_locations).
- #list_share_networks(options = {}) ⇒ Object
- #list_share_networks_detail(options = {}) ⇒ Object
- #list_shares(options = {}) ⇒ Object
- #list_shares_detail(options = {}) ⇒ Object
- #list_snapshots(options = {}) ⇒ Object
- #list_snapshots_detail(options = {}) ⇒ Object
- #remove_security_service_from_share_network(security_service_id, share_network_id) ⇒ Object
- #revoke_share_access(share_id, access_id) ⇒ Object
- #set_api_path ⇒ Object
- #share_action(id, options = {}, expects_status = 202) ⇒ Object
- #share_network_action(id, options = {}, expects_status = 200) ⇒ Object
- #shrink_share(share_id, new_size) ⇒ Object
- #update_quota(project_id, options = {}) ⇒ Object
- #update_security_service(id, options = {}) ⇒ Object
- #update_share(id, options = {}) ⇒ Object
- #update_share_network(id, options = {}) ⇒ Object
- #update_snapshot(id, options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
# File 'lib/fog/shared_file_system/huaweicloud.rb', line 354 def initialize( = {}) @supported_versions = SUPPORTED_VERSIONS @supported_microversion = SUPPORTED_MICROVERSION @fixed_microversion = [:huaweicloud_shared_file_system_microversion] @microversion_key = 'X-Openstack-Manila-Api-Version'.freeze initialize_identity @huaweicloud_service_type = [:huaweicloud_service_type] || ['sharev2'] @huaweicloud_service_name = [:huaweicloud_service_name] @connection_options = [:connection_options] || {} authenticate set_api_path set_microversion @persistent = [:persistent] || false @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options) end |
Class Method Details
.not_found_class ⇒ Object
350 351 352 |
# File 'lib/fog/shared_file_system/huaweicloud.rb', line 350 def self.not_found_class Fog::SharedFileSystem::HuaweiCloud::NotFound end |
Instance Method Details
#action_prefix ⇒ Object
383 384 385 |
# File 'lib/fog/shared_file_system/huaweicloud.rb', line 383 def action_prefix microversion_newer_than?('2.6') ? '' : 'os-' end |
#add_security_service_to_share_network(security_service_id, share_network_id) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/shared_file_system/huaweicloud/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 = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fog/shared_file_system/huaweicloud/requests/create_security_service.rb', line 5 def create_security_service(type, name, = {}) data = { 'type' => type, 'name' => name } = [ :description, :dns_ip, :user, :password, :domain, :server ] .select { |o| [o] }.each do |key| data[key] = [key] end request( :body => Fog::JSON.encode('security_service' => data), :expects => 200, :method => 'POST', :path => 'security-services' ) end |
#create_share(protocol, size, options = {}) ⇒ 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/shared_file_system/huaweicloud/requests/create_share.rb', line 5 def create_share(protocol, size, = {}) data = { 'share_proto' => protocol, 'size' => size } = [ :name, :description, :display_name, :display_description, :share_type, :volume_type, :snapshot_id, :is_public, :metadata, :share_network_id, :consistency_group_id, :availability_zone ] .select { |o| [o] }.each do |key| data[key] = [key] end request( :body => Fog::JSON.encode('share' => data), :expects => 200, :method => 'POST', :path => 'shares' ) end |
#create_share_network(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/fog/shared_file_system/huaweicloud/requests/create_share_network.rb', line 5 def create_share_network( = {}) data = {} = [ :name, :description, :neutron_net_id, :neutron_subnet_id, :nova_net_id ] .select { |o| [o] }.each do |key| data[key] = [key] end request( :body => Fog::JSON.encode('share_network' => data), :expects => 200, :method => 'POST', :path => 'share-networks' ) end |
#create_snapshot(share_id, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fog/shared_file_system/huaweicloud/requests/create_snapshot.rb', line 5 def create_snapshot(share_id, = {}) data = { 'share_id' => share_id } = [ :name, :description, :display_name, :display_description, :force ] .select { |o| [o] }.each do |key| data[key] = [key] end request( :body => Fog::JSON.encode('snapshot' => data), :expects => 202, :method => 'POST', :path => 'snapshots' ) end |
#delete_security_service(id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/shared_file_system/huaweicloud/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) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/shared_file_system/huaweicloud/requests/delete_share.rb', line 5 def delete_share(id) request( :expects => 202, :method => 'DELETE', :path => "shares/#{id}" ) end |
#delete_share_network(id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/shared_file_system/huaweicloud/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) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/shared_file_system/huaweicloud/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) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/shared_file_system/huaweicloud/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 ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/shared_file_system/huaweicloud/requests/get_limits.rb', line 5 def get_limits request( :expects => 200, :method => 'GET', :path => 'limits' ) end |
#get_quota(project_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/shared_file_system/huaweicloud/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) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/shared_file_system/huaweicloud/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) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/shared_file_system/huaweicloud/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) ⇒ Object
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.
8 9 10 11 12 13 14 |
# File 'lib/fog/shared_file_system/huaweicloud/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) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/shared_file_system/huaweicloud/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) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/shared_file_system/huaweicloud/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') ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/fog/shared_file_system/huaweicloud/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 ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/shared_file_system/huaweicloud/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 = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/shared_file_system/huaweicloud/requests/list_security_services.rb', line 5 def list_security_services( = {}) request( :expects => 200, :method => 'GET', :path => 'security-services', :query => ) end |
#list_security_services_detail(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/shared_file_system/huaweicloud/requests/list_security_services_detail.rb', line 5 def list_security_services_detail( = {}) request( :expects => 200, :method => 'GET', :path => 'security-services/detail', :query => ) end |
#list_share_access_rules(share_id) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/fog/shared_file_system/huaweicloud/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) ⇒ Object
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.
8 9 10 11 12 13 14 |
# File 'lib/fog/shared_file_system/huaweicloud/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 = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/shared_file_system/huaweicloud/requests/list_share_networks.rb', line 5 def list_share_networks( = {}) request( :expects => 200, :method => 'GET', :path => 'share-networks', :query => ) end |
#list_share_networks_detail(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/shared_file_system/huaweicloud/requests/list_share_networks_detail.rb', line 5 def list_share_networks_detail( = {}) request( :expects => 200, :method => 'GET', :path => 'share-networks/detail', :query => ) end |
#list_shares(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/shared_file_system/huaweicloud/requests/list_shares.rb', line 5 def list_shares( = {}) request( :expects => 200, :method => 'GET', :path => 'shares', :query => ) end |
#list_shares_detail(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/shared_file_system/huaweicloud/requests/list_shares_detail.rb', line 5 def list_shares_detail( = {}) request( :expects => 200, :method => 'GET', :path => 'shares/detail', :query => ) end |
#list_snapshots(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/shared_file_system/huaweicloud/requests/list_snapshots.rb', line 5 def list_snapshots( = {}) request( :expects => 200, :method => 'GET', :path => 'snapshots', :query => ) end |
#list_snapshots_detail(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/shared_file_system/huaweicloud/requests/list_snapshots_detail.rb', line 5 def list_snapshots_detail( = {}) request( :expects => 200, :method => 'GET', :path => 'snapshots/detail', :query => ) end |
#remove_security_service_from_share_network(security_service_id, share_network_id) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/shared_file_system/huaweicloud/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) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/shared_file_system/huaweicloud/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 |
#set_api_path ⇒ Object
374 375 376 377 378 379 380 381 |
# File 'lib/fog/shared_file_system/huaweicloud.rb', line 374 def set_api_path unless @path.match(@supported_versions) @path = Fog::HuaweiCloud.get_supported_version_path(@supported_versions, @huaweicloud_management_uri, @auth_token, @connection_options) end end |
#share_action(id, options = {}, expects_status = 202) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/shared_file_system/huaweicloud/requests/share_action.rb', line 5 def share_action(id, = {}, expects_status = 202) request( :body => Fog::JSON.encode(), :expects => expects_status, :method => 'POST', :path => "shares/#{id}/action" ) end |
#share_network_action(id, options = {}, expects_status = 200) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/shared_file_system/huaweicloud/requests/share_network_action.rb', line 5 def share_network_action(id, = {}, expects_status = 200) request( :body => Fog::JSON.encode(), :expects => expects_status, :method => 'POST', :path => "share-networks/#{id}/action" ) end |
#shrink_share(share_id, new_size) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/shared_file_system/huaweicloud/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 = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/shared_file_system/huaweicloud/requests/update_quota.rb', line 5 def update_quota(project_id, = {}) request( :body => Fog::JSON.encode('quota_set' => ), :expects => 200, :method => 'PUT', :path => "#{action_prefix}quota-sets/#{project_id}" ) end |
#update_security_service(id, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/shared_file_system/huaweicloud/requests/update_security_service.rb', line 5 def update_security_service(id, = {}) request( :body => Fog::JSON.encode('security_service' => ), :expects => 200, :method => 'PUT', :path => "security-services/#{id}" ) end |
#update_share(id, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/shared_file_system/huaweicloud/requests/update_share.rb', line 5 def update_share(id, = {}) request( :body => Fog::JSON.encode('share' => ), :expects => 200, :method => 'PUT', :path => "shares/#{id}" ) end |
#update_share_network(id, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/shared_file_system/huaweicloud/requests/update_share_network.rb', line 5 def update_share_network(id, = {}) request( :body => Fog::JSON.encode('share_network' => ), :expects => 200, :method => 'PUT', :path => "share-networks/#{id}" ) end |
#update_snapshot(id, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/shared_file_system/huaweicloud/requests/update_snapshot.rb', line 5 def update_snapshot(id, = {}) request( :body => Fog::JSON.encode('snapshot' => ), :expects => 200, :method => 'PUT', :path => "snapshots/#{id}" ) end |