Module: Aix::Group

Includes:
Beaker::CommandFactory
Included in:
Host
Defined in:
lib/beaker/host/aix/group.rb

Instance Attribute Summary

Attributes included from Beaker::CommandFactory

#assertions

Instance Method Summary collapse

Methods included from Beaker::CommandFactory

#execute, #fail_test

Instance Method Details

#group_absent(name, &block) ⇒ Object



32
33
34
# File 'lib/beaker/host/aix/group.rb', line 32

def group_absent(name, &block)
  execute("if lsgroup #{name}; then rmgroup #{name}; fi", {}, &block)
end

#group_get(name, &block) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/beaker/host/aix/group.rb', line 12

def group_get(name, &block)
  execute("lsgroup #{name}") do |result|
    fail_test "failed to get group #{name}" unless result.stdout =~ /^#{name} id/

    yield result if block_given?
  end
end

#group_gid(name) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/beaker/host/aix/group.rb', line 20

def group_gid(name)
  execute("lsgroup -a id #{name}") do |result|
    # Format is:
    # staff id=500
    result.stdout.split('=').last.strip
  end
end

#group_list(&block) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/beaker/host/aix/group.rb', line 4

def group_list(&block)
  execute("lsgroup -a ALL") do |result|
    yield result if block_given?

    result.stdout.lines.map(&:strip)
  end
end

#group_present(name, &block) ⇒ Object



28
29
30
# File 'lib/beaker/host/aix/group.rb', line 28

def group_present(name, &block)
  execute("if ! lsgroup #{name}; then mkgroup #{name}; fi", {}, &block)
end