Module: TestLab::Container::User
- Included in:
- TestLab::Container
- Defined in:
- lib/testlab/container/user.rb
Instance Method Summary collapse
-
#primary_user ⇒ TestLab::User
Container primary user.
Instance Method Details
#primary_user ⇒ TestLab::User
Container primary user
Returns the primary user for the container. If the container has multiple users, this is based on which ever user is marked with the primary flag. If the container only has one user, then it is returned.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/testlab/container/user.rb', line 14 def primary_user if self.users.count == 0 case self.distro.downcase when 'ubuntu' then u = TestLab::User.new do username 'ubuntu' password 'ubuntu' end u.container = self u end elsif self.users.any?{ |u| u.primary == true } self.users.find{ |u| u.primary == true } else self.users.first end end |