Skip to content

Commit

Permalink
Merge pull request #254 from mhashizume/network-os-removal
Browse files Browse the repository at this point in the history
Remove unsupported network platforms
  • Loading branch information
joshcooper committed May 28, 2024
2 parents 04f07b6 + 3d1cce3 commit 9dbca23
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 61 deletions.
56 changes: 18 additions & 38 deletions lib/beaker-puppet/install_utils/foss_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def install_puppet_on(hosts, opts = options)
family = ::Regexp.last_match(1)
relver = ::Regexp.last_match(2)
install_puppet_from_rpm_on(host, opts.merge(release: relver, family: family))
elsif host['platform'] =~ /(ubuntu|debian|huaweios)/
elsif host['platform'] =~ /(ubuntu|debian)/
install_puppet_from_deb_on(host, opts)
elsif host['platform'] =~ /windows/
relver = opts[:version]
Expand Down Expand Up @@ -406,10 +406,10 @@ def install_puppet_agent_on(hosts, opts = {})
end

case host['platform']
when /amazon|el-|redhat|fedora|sles|centos|cisco_/
when /amazon|el-|redhat|fedora|sles|centos/
package_name = 'puppet-agent'
package_name << "-#{opts[:puppet_agent_version]}" if opts[:puppet_agent_version]
when /debian|ubuntu|huaweios/
when /debian|ubuntu/
package_name = 'puppet-agent'
if opts[:puppet_agent_version]
package_name << "=#{opts[:puppet_agent_version]}-1#{host['platform'].codename}"
Expand Down Expand Up @@ -921,9 +921,9 @@ def install_puppet_from_gem_on(hosts, opts)

unless host.check_for_command('gem')
gempkg = case host['platform']
when /solaris-11/ then 'ruby-18'
when /ubuntu-14/ then 'ruby'
when /solaris-10|ubuntu|debian|el-|huaweios/ then 'rubygems'
when /solaris-11/ then 'ruby-18'
when /ubuntu-14/ then 'ruby'
when /solaris-10|ubuntu|debian|el-/ then 'rubygems'
when /openbsd/ then 'ruby'
else
raise 'install_puppet() called with default_action ' +
Expand All @@ -937,7 +937,7 @@ def install_puppet_from_gem_on(hosts, opts)
# Link 'gem' to /usr/bin instead of adding /opt/csw/bin to PATH.
on host, 'ln -s /opt/csw/bin/gem /usr/bin/gem' if is_solaris10

if host['platform'] =~ /debian|ubuntu|solaris|huaweios/
if host['platform'] =~ /debian|ubuntu|solaris/
gem_env = YAML.load(on(host, 'gem environment').stdout)
gem_paths_array = gem_env['RubyGems Environment'].find { |h| h['GEM PATHS'] != nil }['GEM PATHS']
path_with_gem = 'export PATH=' + gem_paths_array.join(':') + ':${PATH}'
Expand Down Expand Up @@ -993,16 +993,8 @@ def install_puppetlabs_release_repo_on(hosts, repo = nil, opts = options)
opts = sanitize_opts(opts)

case variant
when /^(amazon|fedora|el|redhat|centos|sles|cisco_nexus|cisco_ios_xr)$/
when /^(amazon|fedora|el|redhat|centos|sles)$/
variant_url_value = (%w[redhat centos].include?(::Regexp.last_match(1)) ? 'el' : ::Regexp.last_match(1))
if variant == 'cisco_nexus'
variant_url_value = 'cisco-wrlinux'
version = '5'
end
if variant == 'cisco_ios_xr'
variant_url_value = 'cisco-wrlinux'
version = '7'
end
if repo_name.match(/puppet\d*/)
url = if repo_name.match(/-nightly$/)
opts[:nightly_yum_repo_url]
Expand All @@ -1028,19 +1020,11 @@ def install_puppetlabs_release_repo_on(hosts, repo = nil, opts = options)
end
end

if variant == 'cisco_nexus'
# cisco nexus requires using yum to install the repo
host.install_package(remote)
elsif variant == 'cisco_ios_xr'
# cisco ios xr requires using yum to localinstall the repo
on host, "yum -y localinstall #{remote}"
else
opts[:package_proxy] ||= false
host.install_package_with_rpm(remote, '--replacepkgs',
{ package_proxy: opts[:package_proxy] })
end
opts[:package_proxy] ||= false
host.install_package_with_rpm(remote, '--replacepkgs',
{ package_proxy: opts[:package_proxy] })

when /^(debian|ubuntu|huaweios)$/
when /^(debian|ubuntu)$/
if repo_name.match(/puppet\d*/)
url = if repo_name.match(/-nightly$/)
opts[:nightly_apt_repo_url]
Expand Down Expand Up @@ -1111,14 +1095,10 @@ def install_repo_configs_from_url(host, repo_config_url, copy_dir = nil)
File.write(repo, contents)
end

to_path = if host[:platform] =~ /cisco_nexus/
"#{host.package_config_dir}/#{File.basename(repo)}"
else
host.package_config_dir
end
to_path = host.package_config_dir
scp_to(host, repo, to_path)

on(host, 'apt-get update') if host['platform'] =~ /ubuntu-|debian-|huaweios-/
on(host, 'apt-get update') if host['platform'] =~ /ubuntu-|debian-/
nil
end

Expand Down Expand Up @@ -1148,7 +1128,7 @@ def install_puppetlabs_dev_repo(host, package_name, build_version,
repo_configs_dir = nil,
opts = options)
variant, version, arch, codename = host['platform'].to_array
if variant !~ /^(amazon|fedora|el|redhat|centos|debian|ubuntu|huaweios|cisco_nexus|cisco_ios_xr|sles)$/
if variant !~ /^(amazon|fedora|el|redhat|centos|debian|ubuntu|sles)$/
raise "No repository installation step for #{variant} yet..."
end

Expand Down Expand Up @@ -1181,7 +1161,7 @@ def install_puppetlabs_dev_repo(host, package_name, build_version,
# @note This method is paired to be run directly after {#install_puppetlabs_dev_repo}
#
def install_packages_from_local_dev_repo(host, package_name)
if host['platform'] =~ /debian|ubuntu|huaweios/
if host['platform'] =~ /debian|ubuntu/
find_filename = '*.deb'
find_command = 'dpkg -i'
elsif host['platform'] =~ /fedora|el|redhat|centos/
Expand Down Expand Up @@ -1269,7 +1249,7 @@ def install_puppetserver_on(host, opts = {})

# We have to do some silly version munging if we're on a deb-based platform
case host['platform']
when /debian|ubuntu|huaweios/
when /debian|ubuntu/
opts[:version] = "#{opts[:version]}-1#{host['platform'].codename}" if opts[:version]
end

Expand All @@ -1291,7 +1271,7 @@ def remove_puppet_on(hosts)
cmdline_args = ''
# query packages
case host[:platform]
when /huaweios|ubuntu/
when /ubuntu/
pkgs = on(host, "dpkg-query -l | awk '{print $2}' | grep -E '(^pe-|puppet)'",
acceptable_exit_codes: [0, 1]).stdout.chomp.split(/\n+/)
when /aix|sles|el|redhat|centos|oracle|scientific/
Expand Down
22 changes: 2 additions & 20 deletions spec/beaker-puppet/install_utils/foss_utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -840,26 +840,6 @@ def logger
subject.install_puppetlabs_release_repo_on(host)
end
end

context 'on cisco platforms' do
context 'version 5' do
let(:platform) { Beaker::Platform.new('cisco_nexus-7-x86_64') }

it 'calls host.install_package' do
expect(host).to receive(:install_package).with(/\.rpm$/)
subject.install_puppetlabs_release_repo_on(host)
end
end

context 'version 7' do
let(:platform) { Beaker::Platform.new('cisco_ios_xr-6-x86_64') }

it 'uses yum localinstall to install the package' do
expect(subject).to receive(:on).with(host, /^yum.*localinstall.*\.rpm$/)
subject.install_puppetlabs_release_repo_on(host)
end
end
end
end

describe '#install_puppetlabs_dev_repo' do
Expand All @@ -884,6 +864,8 @@ def logger
allow(rez).to receive(:exit_code) { 0 }
allow(subject).to receive(:link_exists?).and_return(true)
expect(subject).to receive(:scp_to).with(host, repo_config, /.*/).ordered
allow(File).to receive(:read).and_call_original
allow(File).to receive(:read).with('repoconfig').and_return('')
subject.install_puppetlabs_dev_repo host, package_name, package_version
end
end
Expand Down
4 changes: 1 addition & 3 deletions spec/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ def make_instance(instance_data = {})
end

module PlatformHelpers
DEBIANPLATFORMS = %w[debian
ubuntu
huaweios]
DEBIANPLATFORMS = %w[debian ubuntu]

FEDORASYSTEMD = (14..29).to_a.collect! { |i| "fedora-#{i}" }

Expand Down

0 comments on commit 9dbca23

Please sign in to comment.