Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/beaker/host/unix/pkg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def check_for_package(name, opts = {})
self[:sles_rpmkeys_nightly_pl_imported] = true
end
result = execute("zypper --gpg-auto-import-keys se -i --match-exact #{name}", opts) { |result| result }
when /amazon|fedora|centos|redhat|el-/
when /amazon|fedora|centos|redhat|el-|azure/
result = execute("rpm -q #{name}", opts) { |result| result }
when /ubuntu|debian/
result = execute("dpkg -s #{name}", opts) { |result| result }
Expand Down Expand Up @@ -87,7 +87,7 @@ def install_package(name, cmdline_args = '', version = nil, opts = {})
case self['platform']
when /opensuse|sles-/
execute("zypper --non-interactive --gpg-auto-import-keys in #{name}", opts)
when /amazon(fips)?-2023|el-(8|9|1[0-9])|fedora/
when /amazon(fips)?-2023|el-(8|9|1[0-9])|fedora|azure/
name = "#{name}-#{version}" if version
execute("dnf -y #{cmdline_args} install #{name}", opts)
when /amazon-(2|7)|centos|redhat|el-[1-7]-/
Expand Down Expand Up @@ -170,7 +170,7 @@ def uninstall_package(name, cmdline_args = '', opts = {})
case self['platform']
when /opensuse|sles-/
execute("zypper --non-interactive rm #{name}", opts)
when /amazon(fips)?-2023|el-(8|9|1[0-9])|fedora/
when /amazon(fips)?-2023|el-(8|9|1[0-9])|fedora|azure/
execute("dnf -y #{cmdline_args} remove #{name}", opts)
when /amazon-(2|7)|centos|redhat|el-[1-7]-/
execute("yum -y #{cmdline_args} remove #{name}", opts)
Expand Down Expand Up @@ -198,7 +198,7 @@ def upgrade_package(name, cmdline_args = '', opts = {})
case self['platform']
when /opensuse|sles-/
execute("zypper --non-interactive --no-gpg-checks up #{name}", opts)
when /fedora/
when /fedora|azure/
execute("dnf -y #{cmdline_args} update #{name}", opts)
when /centos|redhat|el-/
execute("yum -y #{cmdline_args} update #{name}", opts)
Expand Down
45 changes: 4 additions & 41 deletions lib/beaker/platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Beaker
# all String methods while adding several platform-specific use cases.
class Platform < String
# Supported platforms
PLATFORMS = /^(alpine|amazon(fips)?|(free|open)bsd|osx|centos|fedora|debian|oracle|redhat|redhatfips|scientific|opensuse|sles|ubuntu|windows|solaris|aix|archlinux|el)\-.+\-.+$/
PLATFORMS = /^(alpine|amazon(fips)?|(free|open)bsd|osx|centos|fedora|debian|oracle|redhat|redhatfips|scientific|opensuse|sles|ubuntu|windows|solaris|aix|archlinux|el|azure)\-.+\-.+$/
# Platform version numbers vs. codenames conversion hash
PLATFORM_VERSION_CODES =
{ :debian => { "forky" => "14",
Expand Down Expand Up @@ -34,29 +34,6 @@ class Platform < String
# A string with the cpu architecture of the platform.
attr_reader :arch

# Creates the Platform object. Checks to ensure that the platform String
# provided meets the platform formatting rules. Platforms name must be of
# the format /^OSFAMILY-VERSION-ARCH.*$/ where OSFAMILY is one of:
# * amazon
# * amazonfips
# * freebsd
# * openbsd
# * osx
# * centos
# * fedora
# * debian
# * oracle
# * redhat
# * redhatfips
# * scientific
# * opensuse
# * sles
# * ubuntu
# * windows
# * solaris
# * aix
# * el
# * archlinux
def initialize(name)
raise ArgumentError, "Unsupported platform name #{name}" if !PLATFORMS.match?(name)

Expand All @@ -80,24 +57,14 @@ def initialize(name)
end
end

# Returns array of attributes to allow single line assignment to local
# variables in DSL and test case methods.
def to_array
return @variant, @version, @arch, @codename
end

# Returns the platform string with the platform version as a codename. If no conversion is
# necessary then the original, unchanged platform String is returned.
# @example Platform.new('debian-7-xxx').with_version_codename == 'debian-wheezy-xxx'
# @return [String] the platform string with the platform version represented as a codename
def with_version_codename
[@variant, @codename || @version, @arch].join('-')
end

# Returns the platform string with the platform version as a number. If no conversion is necessary
# then the original, unchanged platform String is returned.
# @example Platform.new('debian-wheezy-xxx').with_version_number == 'debian-7-xxx'
# @return [String] the platform string with the platform version represented as a number
def with_version_number
[@variant, @version, @arch].join('-')
end
Expand All @@ -113,9 +80,6 @@ def uses_chrony?
end
end

# Return a list of packages that should always be present.
#
# @return [Array<String>] A list of packages to install
def base_packages
case @variant
when 'el'
Expand All @@ -128,7 +92,7 @@ def base_packages
@version.to_i >= 11 ? %w[curl] : %w[CSWcurl wget]
when 'archlinux'
%w[curl net-tools openssh]
when 'amazon', 'amazonfips', 'fedora'
when 'amazon', 'amazonfips', 'fedora', 'azure'
['iputils']
when 'aix', 'osx', 'windows'
[]
Expand All @@ -137,9 +101,6 @@ def base_packages
end
end

# Return a list of packages that are needed for timesync
#
# @return [Array<String>] A list of packages to install for timesync
def timesync_packages
return ['chrony'] if uses_chrony?

Expand All @@ -152,6 +113,8 @@ def timesync_packages
@version.to_i >= 11 ? %w[ntp] : []
when 'solaris'
@version.to_i >= 11 ? %w[ntp] : %w[CSWntp]
when 'azure'
['ntpdate']
else
%w[ntpdate]
end
Expand Down