Class: Fog::Orchestration::HuaweiCloud::Real
- Inherits:
-
Object
- Object
- Fog::Orchestration::HuaweiCloud::Real
- Includes:
- HuaweiCloud::Core
- Defined in:
- lib/fog/orchestration/huaweicloud.rb,
lib/fog/orchestration/huaweicloud/requests/build_info.rb,
lib/fog/orchestration/huaweicloud/requests/list_events.rb,
lib/fog/orchestration/huaweicloud/requests/patch_stack.rb,
lib/fog/orchestration/huaweicloud/requests/create_stack.rb,
lib/fog/orchestration/huaweicloud/requests/delete_stack.rb,
lib/fog/orchestration/huaweicloud/requests/update_stack.rb,
lib/fog/orchestration/huaweicloud/requests/abandon_stack.rb,
lib/fog/orchestration/huaweicloud/requests/cancel_update.rb,
lib/fog/orchestration/huaweicloud/requests/preview_stack.rb,
lib/fog/orchestration/huaweicloud/requests/list_resources.rb,
lib/fog/orchestration/huaweicloud/requests/list_stack_data.rb,
lib/fog/orchestration/huaweicloud/requests/list_stack_events.rb,
lib/fog/orchestration/huaweicloud/requests/validate_template.rb,
lib/fog/orchestration/huaweicloud/requests/get_stack_template.rb,
lib/fog/orchestration/huaweicloud/requests/show_event_details.rb,
lib/fog/orchestration/huaweicloud/requests/show_resource_data.rb,
lib/fog/orchestration/huaweicloud/requests/show_stack_details.rb,
lib/fog/orchestration/huaweicloud/requests/list_resource_types.rb,
lib/fog/orchestration/huaweicloud/requests/list_resource_events.rb,
lib/fog/orchestration/huaweicloud/requests/show_resource_schema.rb,
lib/fog/orchestration/huaweicloud/requests/show_resource_metadata.rb,
lib/fog/orchestration/huaweicloud/requests/show_resource_template.rb,
lib/fog/orchestration/huaweicloud/requests/list_stack_data_detailed.rb
Class Method Summary collapse
Instance Method Summary collapse
- #abandon_stack(stack) ⇒ Object
- #build_info ⇒ Object
- #cancel_update(stack) ⇒ Object
-
#create_stack(arg1, arg2 = nil) ⇒ Object
Create a stack.
-
#delete_stack(arg1, arg2 = nil) ⇒ Excon::Response
Delete a stack.
- #get_stack_template(stack) ⇒ Object
-
#initialize(options = {}) ⇒ Real
constructor
A new instance of Real.
- #list_events(options = {}) ⇒ Object
- #list_resource_events(stack, resource, options = {}) ⇒ Object
- #list_resource_types(_options = {}) ⇒ Object
- #list_resources(options = {}, options_deprecated = {}) ⇒ Object
- #list_stack_data(options = {}) ⇒ Object
- #list_stack_data_detailed(options = {}) ⇒ Object
- #list_stack_events(stack, options = {}) ⇒ Object
-
#patch_stack(stack, options = {}) ⇒ Object
patch a stack.
- #preview_stack(options = {}) ⇒ Object
- #show_event_details(stack, resource, event_id) ⇒ Object
- #show_resource_data(stack_name, stack_id, resource_name) ⇒ Object
- #show_resource_metadata(stack, resource_name) ⇒ Object
- #show_resource_schema(name) ⇒ Object
- #show_resource_template(name) ⇒ Object
- #show_stack_details(name, id) ⇒ Object
-
#update_stack(arg1, arg2 = nil, arg3 = nil) ⇒ Object
Update a stack.
- #validate_template(options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/fog/orchestration/huaweicloud.rb', line 138 def initialize( = {}) initialize_identity @huaweicloud_identity_service_type = [:huaweicloud_identity_service_type] || 'identity' @huaweicloud_service_type = [:huaweicloud_service_type] || ['orchestration'] @huaweicloud_service_name = [:huaweicloud_service_name] @connection_options = [:connection_options] || {} authenticate @persistent = [:persistent] || false @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options) end |
Class Method Details
.not_found_class ⇒ Object
134 135 136 |
# File 'lib/fog/orchestration/huaweicloud.rb', line 134 def self.not_found_class Fog::Orchestration::HuaweiCloud::NotFound end |
Instance Method Details
#abandon_stack(stack) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/orchestration/huaweicloud/requests/abandon_stack.rb', line 5 def abandon_stack(stack) request( :expects => [200], :method => 'DELETE', :path => "stacks/#{stack.stack_name}/#{stack.id}/abandon" ) end |
#build_info ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/orchestration/huaweicloud/requests/build_info.rb', line 5 def build_info request( :expects => [200], :method => 'GET', :path => 'build_info' ) end |
#cancel_update(stack) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/fog/orchestration/huaweicloud/requests/cancel_update.rb', line 6 def cancel_update(stack) request( :expects => 200, :method => 'POST', :path => "stacks/#{stack.stack_name}/#{stack.id}/actions", :body => Fog::JSON.encode('cancel_update' => nil) ) end |
#create_stack(arg1, arg2 = nil) ⇒ Object
Create a stack.
-
options [Hash]:
-
:stack_name [String] Name of the stack to create.
-
:template [String] Structure containing the template body.
or (one of the two Template parameters is required)
-
:template_url [String] URL of file containing the template body.
-
:files [Hash] Hash with files resources.
-
:disable_rollback [Boolean] Controls rollback on stack creation failure, defaults to false.
-
:parameters [Hash] Hash of providers to supply to template
-
:timeout_mins [Integer] Minutes to wait before status is set to CREATE_FAILED
-
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fog/orchestration/huaweicloud/requests/create_stack.rb', line 20 def create_stack(arg1, arg2 = nil) if arg1.kind_of?(Hash) # Normal use: create_stack(options) = arg1 else # Deprecated: create_stack(stack_name, options = {}) Fog::Logger.deprecation("#create_stack(stack_name, options) is deprecated, use #create_stack(options) instead [light_black](#{caller.first})[/]") = { :stack_name => arg1 }.merge(arg2.nil? ? {} : arg2) end # Templates should always: # - be strings # - contain URI references instead of relative paths. # Passing :template_url may not work well with `get_file` and remote `type`: # the python client implementation in shade retrieves from :template_uri # and replaces it with :template. # see https://github.com/openstack-infra/shade/blob/master/shade/openstackcloud.py#L1201 # see https://developer.openstack.org/api-ref/orchestration/v1/index.html#create-stack file_resolver = Util::RecursiveHotFileLoader.new([:template] || [:template_url], [:files]) [:template] = file_resolver.template [:files] = file_resolver.files unless file_resolver.files.empty? request( :expects => 201, :path => 'stacks', :method => 'POST', :body => Fog::JSON.encode() ) end |
#delete_stack(arg1, arg2 = nil) ⇒ Excon::Response
Delete a stack.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fog/orchestration/huaweicloud/requests/delete_stack.rb', line 13 def delete_stack(arg1, arg2 = nil) if arg1.kind_of?(Stack) # Normal use: delete_stack(stack) stack = arg1 stack_name = stack.stack_name stack_id = stack.id else # Deprecated: delete_stack(stack_name, stack_id) Fog::Logger.deprecation("#delete_stack(stack_name, stack_id) is deprecated, use #delete_stack(stack) instead [light_black](#{caller.first})[/]") stack_name = arg1 stack_id = arg2 end request( :expects => 204, :path => "stacks/#{stack_name}/#{stack_id}", :method => 'DELETE' ) end |
#get_stack_template(stack) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/orchestration/huaweicloud/requests/get_stack_template.rb', line 5 def get_stack_template(stack) request( :method => 'GET', :path => "stacks/#{stack.stack_name}/#{stack.id}/template", :expects => 200 ) end |
#list_events(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fog/orchestration/huaweicloud/requests/list_events.rb', line 5 def list_events( = {}) if !.key?(:stack) && !(.key?(:stack_name) && .key?(:stack_id)) raise(ArgumentError, "Missing required options keys: :stack or :stack_name and :stack_id, while calling "\ " .list_events(options)") end stack = .delete(:stack) stack_name = .delete(:stack_name) stack_name ||= stack.stack_name if stack && stack.respond_to?(:stack_name) stack_id = .delete(:stack_id) stack_id ||= stack.id if stack && stack.respond_to?(:id) resource = .delete(:resource) resource_name = .delete(:resource_name) resource_name ||= resource.resource_name if resource && resource.respond_to?(:resource_name) path = if resource_name "stacks/#{stack_name}/#{stack_id}/resources/#{resource_name}/events" else "stacks/#{stack_name}/#{stack_id}/events" end request(:method => 'GET', :path => path, :expects => 200, :query => ) end |
#list_resource_events(stack, resource, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/fog/orchestration/huaweicloud/requests/list_resource_events.rb', line 5 def list_resource_events(stack, resource, = {}) Fog::Logger.deprecation('Calling HuaweiCloud[:orchestration].list_resource_events(stack, resource, options)'\ ' is deprecated, call .list_events(:stack => stack, :resource => resource) or '\ ' .list_events(:stack_name => value, :stack_id => value, :resource_name => value)'\ ' instead') uri = "stacks/#{stack.stack_name}/#{stack.id}/resources/#{resource.resource_name}/events" request(:method => 'GET', :path => uri, :expects => 200, :query => ) end |
#list_resource_types(_options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/orchestration/huaweicloud/requests/list_resource_types.rb', line 5 def list_resource_types( = {}) request( :method => 'GET', :path => "resource_types", :expects => 200, :query => {} ) end |
#list_resources(options = {}, options_deprecated = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fog/orchestration/huaweicloud/requests/list_resources.rb', line 5 def list_resources( = {}, = {}) if .kind_of?(Hash) if !.key?(:stack) && !(.key?(:stack_name) && .key?(:stack_id)) raise(ArgumentError, "Missing required options keys: :stack or :stack_name and :stack_id, while calling "\ " .list_resources(options)") end stack = .delete(:stack) stack_name = .delete(:stack_name) stack_name ||= stack.stack_name if stack && stack.respond_to?(:stack_name) stack_id = .delete(:stack_id) stack_id ||= stack.id if stack && stack.respond_to?(:id) path = "stacks/#{stack_name}/#{stack_id}/resources" params = else Fog::Logger.deprecation('Calling HuaweiCloud[:orchestration].list_resources(stack, options) is deprecated, '\ ' call .list_resources(:stack => stack) or '\ ' .list_resources(:stack_name => value, :stack_id => value) instead') path = "stacks/#{.stack_name}/#{.id}/resources" params = end request(:method => 'GET', :path => path, :expects => 200, :query => params) end |
#list_stack_data(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/orchestration/huaweicloud/requests/list_stack_data.rb', line 5 def list_stack_data( = {}) request( :method => 'GET', :path => 'stacks', :expects => 200, :query => ) end |
#list_stack_data_detailed(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/orchestration/huaweicloud/requests/list_stack_data_detailed.rb', line 5 def list_stack_data_detailed( = {}) request( :method => 'GET', :path => 'stacks/detail', :expects => 200, :query => ) end |
#list_stack_events(stack, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/orchestration/huaweicloud/requests/list_stack_events.rb', line 5 def list_stack_events(stack, = {}) Fog::Logger.deprecation('Calling HuaweiCloud[:orchestration].list_stack_events(stack, options)'\ ' is deprecated, call .list_events(:stack => stack) or '\ ' .list_events(:stack_name => value, :stack_id => value) instead') uri = "stacks/#{stack.stack_name}/#{stack.id}/events" request(:method => 'GET', :path => uri, :expects => 200, :query => ) end |
#patch_stack(stack, options = {}) ⇒ Object
patch a stack.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fog/orchestration/huaweicloud/requests/patch_stack.rb', line 14 def patch_stack(stack, = {}) stack_name = stack.stack_name stack_id = stack.id request( :expects => 202, :path => "stacks/#{stack_name}/#{stack_id}", :method => 'PATCH', :body => Fog::JSON.encode() ) end |
#preview_stack(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/orchestration/huaweicloud/requests/preview_stack.rb', line 5 def preview_stack( = {}) request( :body => Fog::JSON.encode(), :expects => [200], :method => 'POST', :path => 'stacks/preview' ) end |
#show_event_details(stack, resource, event_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/orchestration/huaweicloud/requests/show_event_details.rb', line 5 def show_event_details(stack, resource, event_id) request( :method => 'GET', :path => "stacks/#{stack.stack_name}/#{stack.id}/resources/#{resource.resource_name}/events/#{event_id}", :expects => 200 ) end |
#show_resource_data(stack_name, stack_id, resource_name) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/orchestration/huaweicloud/requests/show_resource_data.rb', line 5 def show_resource_data(stack_name, stack_id, resource_name) request( :method => 'GET', :path => "stacks/#{stack_name}/#{stack_id}/resources/#{resource_name}", :expects => 200 ) end |
#show_resource_metadata(stack, resource_name) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/orchestration/huaweicloud/requests/show_resource_metadata.rb', line 5 def (stack, resource_name) request( :method => 'GET', :path => "stacks/#{stack.stack_name}/#{stack.id}/resources/#{resource_name}/metadata", :expects => 200 ) end |
#show_resource_schema(name) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/orchestration/huaweicloud/requests/show_resource_schema.rb', line 5 def show_resource_schema(name) request( :method => 'GET', :path => "resource_types/#{name}", :expects => 200 ) end |
#show_resource_template(name) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/orchestration/huaweicloud/requests/show_resource_template.rb', line 5 def show_resource_template(name) request( :method => 'GET', :path => "resource_types/#{name}/template", :expects => 200 ) end |
#show_stack_details(name, id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/orchestration/huaweicloud/requests/show_stack_details.rb', line 5 def show_stack_details(name, id) request( :method => 'GET', :path => "stacks/#{name}/#{id}", :expects => 200 ) end |
#update_stack(arg1, arg2 = nil, arg3 = nil) ⇒ Object
Update a stack.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fog/orchestration/huaweicloud/requests/update_stack.rb', line 15 def update_stack(arg1, arg2 = nil, arg3 = nil) if arg1.kind_of?(Stack) # Normal use, update_stack(stack, options = {}) stack = arg1 stack_name = stack.stack_name stack_id = stack.id = arg2.nil? ? {} : arg2 else # Deprecated, update_stack(stack_id, stack_name, options = {}) Fog::Logger.deprecation("#update_stack(stack_id, stack_name, options) is deprecated, use #update_stack(stack, options) instead [light_black](#{caller.first})[/]") stack_id = arg1 stack_name = arg2 = { :stack_name => stack_name }.merge(arg3.nil? ? {} : arg3) end # Templates should always: # - be strings # - contain URI references instead of relative paths. # Passing :template_url may not work well with `get_file` and remote `type`: # the python client implementation in shade retrieves from :template_uri # and replaces it with :template. # see https://github.com/openstack-infra/shade/blob/master/shade/openstackcloud.py#L1201 # see https://developer.openstack.org/api-ref/orchestration/v1/index.html#create-stack file_resolver = Util::RecursiveHotFileLoader.new([:template] || [:template_url], [:files]) [:template] = file_resolver.template [:files] = file_resolver.files unless file_resolver.files.empty? request( :expects => 202, :path => "stacks/#{stack_name}/#{stack_id}", :method => 'PUT', :body => Fog::JSON.encode() ) end |
#validate_template(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/orchestration/huaweicloud/requests/validate_template.rb', line 5 def validate_template( = {}) request( :body => Fog::JSON.encode(), :expects => [200], :method => 'POST', :path => 'validate' ) end |