libraries/resource_providers/api300/c7000/scope_provider.rb
# Adds or removes resources to a specified scope
# @note Calls the build_resource_list method to retrieve the resources
Adds or removes resources to a specified scope
Adds or removes resources to a specified scope
def change_resource_assignments
          add_or_remove = @new_resource.add.any? || @new_resource.remove.any?
          raise "Unspecified properties: 'add' and 'remove'. Please set at least one before attempting this action." unless add_or_remove
          @item.retrieve! || raise("#{@resource_name} '#{@name}' not found!")
          values_to_add = build_resource_list
          values_to_remove = build_resource_list(:remove)
          return Chef::Log.info("#{@resource_name} '#{@name}' is up to date") if values_to_add.empty? && values_to_remove.empty?
          diff = ''
          diff << "\n  Adding: #{JSON.pretty_generate(values_to_add)}" unless values_to_add.empty?
          diff << "\n  Removing: #{JSON.pretty_generate(values_to_remove)}" unless values_to_remove.empty?
          Chef::Log.info "Performing resource assignments on #{@resource_name} '#{@item['name']}':#{diff}"
          @context.converge_by "Performed resource assignments on #{@resource_name} '#{@item['name']}'" do
            @item.change_resource_assignments(add_resources: values_to_add, remove_resources: values_to_remove)
          end
        end
def change_resource_assignments add_or_remove = @new_resource . add . any? || @new_resource . remove . any? raise "Unspecified properties: 'add' and 'remove'. Please set at least one before attempting this action." unless add_or_remove @item . retrieve! || raise ( "#{@resource_name} '#{@name}' not found!" ) values_to_add = build_resource_list values_to_remove = build_resource_list ( :remove ) return Chef :: Log . info ( "#{@resource_name} '#{@name}' is up to date" ) if values_to_add . empty? && values_to_remove . empty? diff = '' diff << "\n  Adding: #{JSON.pretty_generate(values_to_add)}" unless values_to_add . empty? diff << "\n  Removing: #{JSON.pretty_generate(values_to_remove)}" unless values_to_remove . empty? Chef :: Log . info "Performing resource assignments on #{@resource_name} '#{@item['name']}':#{diff}" @context . converge_by "Performed resource assignments on #{@resource_name} '#{@item['name']}'" do @item . change_resource_assignments ( add_resources : values_to_add , remove_resources : values_to_remove ) end end
Adds or removes resources to a specified scope
Adds or removes resources to a specified scope
note
Calls the build_resource_list method to retrieve the resources
Calls the build_resource_list method to retrieve the resources