Module: Katello::Concerns::RedhatExtensions::ClassMethods
- Defined in:
- app/models/katello/concerns/redhat_extensions.rb
Instance Method Summary collapse
- #construct_name(family) ⇒ Object
- #create_operating_system(name, major, minor) ⇒ Object
- #find_or_create_operating_system(repo) ⇒ Object
Instance Method Details
#construct_name(family) ⇒ Object
37 38 39 40 41 42 43 |
# File 'app/models/katello/concerns/redhat_extensions.rb', line 37 def construct_name(family) if family.include? 'Red Hat' return 'RedHat' else return family.tr(' ', '_') end end |
#create_operating_system(name, major, minor) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'app/models/katello/concerns/redhat_extensions.rb', line 26 def (name, major, minor) params = { 'name' => name, 'major' => major.to_s, 'minor' => minor.to_s, 'family' => 'Redhat' } return ::Redhat.create!(params) end |
#find_or_create_operating_system(repo) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/katello/concerns/redhat_extensions.rb', line 12 def (repo) os_name = construct_name(repo.distribution_family) major, minor = repo.distribution_version.split('.') minor ||= '' # treat minor versions as empty string to not confuse with nil create_os = lambda { ::Redhat.where(:name => os_name, :major => major, :minor => minor).first_or_create! } begin create_os.call rescue ActiveRecord::RecordInvalid create_os.call end end |