Sha256: e6741a3b454d709e4101f9ac7a104088a6414f67a3976f82b9c4e81f9cd6a3b3

Contents?: true

Size: 888 Bytes

Versions: 75

Compression:

Stored size: 888 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 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

    end

  end
end

Version data entries

75 entries across 75 versions & 1 rubygems

Version Path
testlab-1.22.4 lib/testlab/container/user.rb
testlab-1.22.3 lib/testlab/container/user.rb
testlab-1.22.2 lib/testlab/container/user.rb
testlab-1.22.1 lib/testlab/container/user.rb
testlab-1.22.0 lib/testlab/container/user.rb
testlab-1.21.1 lib/testlab/container/user.rb
testlab-1.21.0 lib/testlab/container/user.rb
testlab-1.20.6 lib/testlab/container/user.rb
testlab-1.20.5 lib/testlab/container/user.rb
testlab-1.20.4 lib/testlab/container/user.rb
testlab-1.20.3 lib/testlab/container/user.rb
testlab-1.20.2 lib/testlab/container/user.rb
testlab-1.20.1 lib/testlab/container/user.rb
testlab-1.20.0 lib/testlab/container/user.rb
testlab-1.19.0 lib/testlab/container/user.rb
testlab-1.18.1 lib/testlab/container/user.rb
testlab-1.18.0 lib/testlab/container/user.rb
testlab-1.17.0 lib/testlab/container/user.rb
testlab-1.16.1 lib/testlab/container/user.rb
testlab-1.16.0 lib/testlab/container/user.rb