Sha256: 6e5b4f836fb0498b8a2d6e850821fc835eda3240575c5052b7402ebef1b878b7

Contents?: true

Size: 1008 Bytes

Versions: 1

Compression:

Stored size: 1008 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).collect do |acl|
        AccessList.new(acl)
      end
    end

    def xacls
      extract_detail(:xacl).collect 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

1 entries across 1 versions & 1 rubygems

Version Path
off_the_grid-0.0.6 lib/off_the_grid/project.rb