Sha256: 55e1ccb1934d765d0f84247fb1d6ebe779c8a1f39493b3e7c191c7c508d0d350

Contents?: true

Size: 851 Bytes

Versions: 31

Compression:

Stored size: 851 Bytes

Contents

class TestLab
  class Container

    module 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.
      #
      # @return [TestLab::User] The primary user for the container.
      def primary_user
        if self.users.count == 0
          case self.distro.downcase
          when 'ubuntu' then
            u = TestLab::User.new "ubuntu" do
              password 'ubuntu'
            end
            u.container = self
          end
        elsif self.users.any?{ |u| u.primary == true }
          self.users.find{ |u| u.primary == true }
        else
          self.users.first
        end
      end

    end

  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
testlab-0.8.2 lib/testlab/container/user.rb
testlab-0.8.1 lib/testlab/container/user.rb
testlab-0.8.0 lib/testlab/container/user.rb
testlab-0.7.6 lib/testlab/container/user.rb
testlab-0.7.5 lib/testlab/container/user.rb
testlab-0.7.4 lib/testlab/container/user.rb
testlab-0.7.3 lib/testlab/container/user.rb
testlab-0.7.2 lib/testlab/container/user.rb
testlab-0.7.1 lib/testlab/container/user.rb
testlab-0.7.0 lib/testlab/container/user.rb
testlab-0.6.17 lib/testlab/container/user.rb
testlab-0.6.16 lib/testlab/container/user.rb
testlab-0.6.15 lib/testlab/container/user.rb
testlab-0.6.14 lib/testlab/container/user.rb
testlab-0.6.12 lib/testlab/container/user.rb
testlab-0.6.11 lib/testlab/container/user.rb
testlab-0.6.10 lib/testlab/container/user.rb
testlab-0.6.9 lib/testlab/container/user.rb
testlab-0.6.8 lib/testlab/container/user.rb
testlab-0.6.7 lib/testlab/container/user.rb