From 3d1cce326e65a1f975dfc2a6d4a6a2e37f9c941f Mon Sep 17 00:00:00 2001 From: Michael Hashizume Date: Thu, 23 May 2024 14:26:26 -0700 Subject: [PATCH] Remove unsupported network platforms --- lib/beaker-puppet/install_utils/foss_utils.rb | 56 ++++++------------- .../install_utils/foss_utils_spec.rb | 22 +------- spec/helpers.rb | 4 +- 3 files changed, 21 insertions(+), 61 deletions(-) diff --git a/lib/beaker-puppet/install_utils/foss_utils.rb b/lib/beaker-puppet/install_utils/foss_utils.rb index eb07bad..3e743a8 100644 --- a/lib/beaker-puppet/install_utils/foss_utils.rb +++ b/lib/beaker-puppet/install_utils/foss_utils.rb @@ -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] @@ -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}" @@ -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 ' + @@ -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}' @@ -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] @@ -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] @@ -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 @@ -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 @@ -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/ @@ -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 @@ -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/ diff --git a/spec/beaker-puppet/install_utils/foss_utils_spec.rb b/spec/beaker-puppet/install_utils/foss_utils_spec.rb index d3e1f8e..dad6b8d 100644 --- a/spec/beaker-puppet/install_utils/foss_utils_spec.rb +++ b/spec/beaker-puppet/install_utils/foss_utils_spec.rb @@ -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 @@ -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 diff --git a/spec/helpers.rb b/spec/helpers.rb index 5e8fa55..0ced5b3 100644 --- a/spec/helpers.rb +++ b/spec/helpers.rb @@ -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}" }