# class Puppet::Resource::Ral

### Public Instance Methods

find( request ) click to toggle source

    # File lib/puppet/indirector/resource/ral.rb, line 8
    def find( request )
      # find by name
      res   = type(request).instances.find { |o| o.name == resource_name(request) }
      res ||= type(request).new(:name => resource_name(request), :audit => type(request).properties.collect { |s| s.name })

      res.to_resource
    end

save( request ) click to toggle source

    # File lib/puppet/indirector/resource/ral.rb, line 29
    def save( request )
      # In RAL-land, to "save" means to actually try to change machine state
      res = request.instance
      ral_res = res.to_ral

      catalog = Puppet::Resource::Catalog.new
      catalog.add_resource ral_res
      transaction = catalog.apply

      [ral_res.to_resource, transaction.report]
    end

search( request ) click to toggle source

    # File lib/puppet/indirector/resource/ral.rb, line 16
    def search( request )
      conditions = request.options.dup
      conditions[:name] = resource_name(request) if resource_name(request)

      type(request).instances.map do |res|
        res.to_resource
      end.find_all do |res|
        conditions.all? {|property, value| res.to_resource[property].to_s == value.to_s}
      end.sort do |a,b|
        a.title <=> b.title
      end
    end