libraries/resource_provider.rb
# Helper method to apply method related to add or remove scopes in Oneview resource
Helper method to apply method related to add or remove scopes in Oneview resource
Helper method to apply method related to add or remove scopes in Oneview resource
def apply_scopes_action(action, resource_method, &ignore_scope_if)
      return Chef::Log.info("No scopes were specified to perform #{action}. Skipping") if @new_resource.scopes.nil? || @new_resource.scopes.empty?
      raise "ResourceNotFound: #{@resource_name} '#{@name}' does not exist" unless @item.retrieve!
      scopes = @new_resource.scopes.map { |scope_name| load_resource(:Scope, scope_name) }
      scopes.delete_if(&ignore_scope_if)
      return Chef::Log.info("'#{action}' with '#{@new_resource.scopes}' to #{@resource_name} '#{@name}' is not needed. Skipping") if scopes.empty?
      scope_names = scopes.map { |scope| scope['name'] }.sort
      @context.converge_by "Performing #{action} '#{scope_names}' in #{@resource_name} '#{@name}'" do
        scopes.each do |scope|
          @item.send(resource_method, scope)
        end
      end
    end
def apply_scopes_action ( action , resource_method , & ignore_scope_if ) return Chef :: Log . info ( "No scopes were specified to perform #{action}. Skipping" ) if @new_resource . scopes . nil? || @new_resource . scopes . empty? raise "ResourceNotFound: #{@resource_name} '#{@name}' does not exist" unless @item . retrieve! scopes = @new_resource . scopes . map { | scope_name | load_resource ( :Scope , scope_name ) } scopes . delete_if ( & ignore_scope_if ) return Chef :: Log . info ( "'#{action}' with '#{@new_resource.scopes}' to #{@resource_name} '#{@name}' is not needed. Skipping" ) if scopes . empty? scope_names = scopes . map { | scope | scope [ 'name' ] } . sort @context . converge_by "Performing #{action} '#{scope_names}' in #{@resource_name} '#{@name}'" do scopes . each do | scope | @item . send ( resource_method , scope ) end end end
Helper method to apply method related to add or remove scopes in Oneview resource
Helper method to apply method related to add or remove scopes in Oneview resource
action
resource_method
ignore_scope_if