From f17fdad0c4752195d61ddbea0ebf7372336d3541 Mon Sep 17 00:00:00 2001 From: Partha Aji Date: Wed, 14 Sep 2016 18:46:58 -0400 Subject: [PATCH] Fixes #16563 - Enables syncing atomic content from cdn Fixes include 1) Code to handle empty substitutions when enabling an atomic kickstart 2) Code to handle creation of the Red Hat Atomic host 3) Removed the Unnecessary seed script to create AH --- app/controllers/katello/products_controller.rb | 2 +- app/models/katello/concerns/redhat_extensions.rb | 4 +++- db/seeds.d/109-atomic_os.rb | 11 ----------- test/lib/tasks/seeds_test.rb | 7 ------- 4 files changed, 4 insertions(+), 20 deletions(-) delete mode 100644 db/seeds.d/109-atomic_os.rb diff --git a/app/controllers/katello/products_controller.rb b/app/controllers/katello/products_controller.rb index ac7efef80c2..021a0f448d9 100644 --- a/app/controllers/katello/products_controller.rb +++ b/app/controllers/katello/products_controller.rb @@ -72,7 +72,7 @@ def exclude_rolling_kickstart_repos(repos) repos.select do |repo| if repo[:path].include?('kickstart') variants = ['Server', 'Client', 'ComputeNode', 'Workstation'] - has_variant = variants.any? { |v| repo[:substitutions][:releasever].include?(v) } + has_variant = variants.any? { |v| repo[:substitutions][:releasever].try(:include?, v) } has_variant ? repo[:enabled] : true else true diff --git a/app/models/katello/concerns/redhat_extensions.rb b/app/models/katello/concerns/redhat_extensions.rb index 1866aa74be9..63bfba1ce6a 100644 --- a/app/models/katello/concerns/redhat_extensions.rb +++ b/app/models/katello/concerns/redhat_extensions.rb @@ -35,7 +35,9 @@ def create_operating_system(name, major, minor) end def construct_name(family) - if family.include? 'Red Hat' + if family == ::Operatingsystem::REDHAT_ATOMIC_HOST_DISTRO_NAME + return ::Operatingsystem::REDHAT_ATOMIC_HOST_OS + elsif family.include? 'Red Hat' return 'RedHat' else return family.tr(' ', '_') diff --git a/db/seeds.d/109-atomic_os.rb b/db/seeds.d/109-atomic_os.rb deleted file mode 100644 index d7f75f7204d..00000000000 --- a/db/seeds.d/109-atomic_os.rb +++ /dev/null @@ -1,11 +0,0 @@ -# This file should contain all the record creation needed to seed the database with its default values. -# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). -# -# !!! PLEASE KEEP THIS SCRIPT IDEMPOTENT !!! -# - -::User.current = ::User.anonymous_api_admin -os_attributes = {:major => "7", :minor => "2", :name => ::Operatingsystem::REDHAT_ATOMIC_HOST_OS} -Operatingsystem.where(os_attributes).first_or_create! - -::User.current = nil diff --git a/test/lib/tasks/seeds_test.rb b/test/lib/tasks/seeds_test.rb index 4476337e1f3..f90d8dccf47 100644 --- a/test/lib/tasks/seeds_test.rb +++ b/test/lib/tasks/seeds_test.rb @@ -85,11 +85,4 @@ class EnsureSyncNotificationsTest < SeedsTest seed end end - - class AtomicOsTest < SeedsTest - test "Make sure atomic OS got setup" do - seed - assert Operatingsystem.find_by(:name => Operatingsystem::REDHAT_ATOMIC_HOST_OS).present? - end - end end