Sha256: 7026bdd94b1fd0cb7f654f336cf5537d706261a5bab2cd0c5e98f335542c941c

Contents?: true

Size: 1002 Bytes

Versions: 2

Compression:

Stored size: 1002 Bytes

Contents

module OffTheGrid
  # A class to represent SGE Projects
  class Project < NamedResource
    # Get the list of SGE projects
    def self.list
      `qconf -sprjl`.chomp.split("\n").sort.collect { |name| new(name) }
    end

    def details
      `qconf -sprj #{name}`.chomp
    end

    def acls
      extract_detail(:acl).each do |acl|
        AccessList.new(acl)
      end
    end

    def xacls
      extract_detail(:xacl).each do |acl|
        AccessList.new(acl)
      end
    end

    # A Read-only list of users that can use this project
    # Uses ACL association
    def users
      acls.map(&:users).flatten.uniq
    end

    private

    # Add an SGE project
    def add
      # TODO: construct a template
      Tempfile.open do |tmpfile|
        tmpfile.puts render(Templates::Project::ERB)
        tmpfile.flush
        system("qconf -Aprj #{tmpfile.path}")
        sleep 5
      end
    end

    # Remove an SGE project
    def remove
      system("qconf -dprj #{name}")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
off_the_grid-0.0.5 lib/off_the_grid/project.rb
off_the_grid-0.0.4 lib/off_the_grid/project.rb