diff --git a/app/assets/images/CoreOS.png b/app/assets/images/CoreOS.png new file mode 100644 index 00000000000..7481632baba Binary files /dev/null and b/app/assets/images/CoreOS.png differ diff --git a/app/controllers/unattended_controller.rb b/app/controllers/unattended_controller.rb index d63816ccf4c..a811fc0d507 100644 --- a/app/controllers/unattended_controller.rb +++ b/app/controllers/unattended_controller.rb @@ -231,6 +231,9 @@ def preseed_attributes def yast_attributes end + def coreos_attributes + end + def aif_attributes os = @host.operatingsystem @mediapath = os.mediumpath @host diff --git a/app/helpers/operatingsystems_helper.rb b/app/helpers/operatingsystems_helper.rb index 10ba49e41c1..ec26fc1b2ce 100644 --- a/app/helpers/operatingsystems_helper.rb +++ b/app/helpers/operatingsystems_helper.rb @@ -32,6 +32,8 @@ def icon(record, opts = {}) "Junos" when /OracleLinux/i "OracleLinux" + when /CoreOS/i + "CoreOS" else return "" if record.family.blank? record.family diff --git a/app/models/operatingsystem.rb b/app/models/operatingsystem.rb index e62735e6aac..c3beafc8b8f 100644 --- a/app/models/operatingsystem.rb +++ b/app/models/operatingsystem.rb @@ -60,6 +60,7 @@ class Operatingsystem < ActiveRecord::Base 'Windows' => %r{Windows}i, 'Altlinux' => %r{Altlinux}i, 'Archlinux' => %r{Archlinux}i, + 'Coreos' => %r{CoreOS}i, 'Gentoo' => %r{Gentoo}i, 'Solaris' => %r{Solaris}i, 'Freebsd' => %r{FreeBSD}i, diff --git a/app/models/operatingsystems/coreos.rb b/app/models/operatingsystems/coreos.rb new file mode 100644 index 00000000000..9161fd8e48d --- /dev/null +++ b/app/models/operatingsystems/coreos.rb @@ -0,0 +1,33 @@ +class Coreos < Operatingsystem + PXEFILES = {:kernel => 'coreos_production_pxe.vmlinuz', :initrd => 'coreos_production_pxe_image.cpio.gz'} + + def pxe_type + 'coreos' + end + + def url_for_boot(file) + PXEFILES[file] + end + + def pxedir + 'amd64-usr/' + [self.major, self.minor ].compact.join('.') + end + + def display_family + 'CoreOS' + end + + def boot_files_uri(medium, architecture, host = nil) + super(medium, architecture, host) + end + + # Does this OS family use release_name in its naming scheme + def use_release_name? + true + end + + def self.model_name + superclass.model_name + end + +end \ No newline at end of file diff --git a/db/seeds.d/10-installation_media.rb b/db/seeds.d/10-installation_media.rb index 11882349bec..a97dcb3f18e 100644 --- a/db/seeds.d/10-installation_media.rb +++ b/db/seeds.d/10-installation_media.rb @@ -8,7 +8,8 @@ { :name => "Fedora mirror", :os_family => "Redhat", :path => "http://dl.fedoraproject.org/pub/fedora/linux/releases/$major/Fedora/$arch/os/" }, { :name => "FreeBSD mirror", :os_family => "Freebsd", :path => "http://ftp.freebsd.org/pub/FreeBSD/releases/$arch/$major.$minor-RELEASE/" }, { :name => "OpenSUSE mirror", :os_family => "Suse", :path => "http://download.opensuse.org/distribution/$major.$minor/repo/oss", :operatingsystems => os_suse }, - { :name => "Ubuntu mirror", :os_family => "Debian", :path => "http://archive.ubuntu.com/ubuntu/" } + { :name => "Ubuntu mirror", :os_family => "Debian", :path => "http://archive.ubuntu.com/ubuntu/" }, + { :name => "CoreOS mirror", :os_family => "Coreos", :path => "http://$release.release.core-os.net" } ].each do |input| next if Medium.where(['name = ? OR path = ?', input[:name], input[:path]]).any? next if audit_modified? Medium, input[:name] diff --git a/test/fixtures/media.yml b/test/fixtures/media.yml index 583be78b4c9..541cd04fdba 100644 --- a/test/fixtures/media.yml +++ b/test/fixtures/media.yml @@ -23,3 +23,7 @@ suse: name: OpenSuse Mirror path: "http://mirror.isoc.org.il/pub/opensuse/distribution/$major.$minor/repo/oss" +coreos: + name: CoreOS Mirror + path: http://$release.release.core-os.net + diff --git a/test/fixtures/operatingsystems.yml b/test/fixtures/operatingsystems.yml index cab5917f156..d1883797321 100644 --- a/test/fixtures/operatingsystems.yml +++ b/test/fixtures/operatingsystems.yml @@ -55,3 +55,13 @@ no_hosts_os: minor: 1 type: Redhat title: 'NoHosts 1.1' + +coreos: + name: CoreOS + major: 494 + minor: 5.0 + type: Coreos + release_name: stable + architectures: x86_64 + media: coreos + title: 'CoreOS 494.5.0' \ No newline at end of file diff --git a/test/unit/coreos_test.rb b/test/unit/coreos_test.rb new file mode 100644 index 00000000000..39d1a092ab0 --- /dev/null +++ b/test/unit/coreos_test.rb @@ -0,0 +1,52 @@ +require 'test_helper' + +class CoreosTest < ActiveSupport::TestCase + + test "os label for coreos" do + assert_equal "CoreOS 494.5.0", operatingsystems(:coreos).to_label + end + + test "pxedir for coreos" do + host = FactoryGirl.create(:host, :operatingsystem => operatingsystems(:coreos), + :architecture => architectures(:x86_64)) + pxedir ='amd64-usr/' + [host.os.major, host.os.minor ].compact.join('.') + assert_equal pxedir, host.os.pxedir + end + + test "kernel location for 64bit coreos" do + host = FactoryGirl.create(:host, :operatingsystem => operatingsystems(:coreos), + :architecture => architectures(:x86_64)) + assert_equal "boot/CoreOS-494.5.0-x86_64-coreos_production_pxe.vmlinuz", host.os.kernel(host.arch) + end + + test "initrd location for 64bit coreos" do + host = FactoryGirl.create(:host, :operatingsystem => operatingsystems(:coreos), + :architecture => architectures(:x86_64)) + assert_equal "boot/CoreOS-494.5.0-x86_64-coreos_production_pxe_image.cpio.gz", host.os.initrd(host.arch) + end + + test "pxe prefix for coreos" do + host = FactoryGirl.create(:host, :operatingsystem => operatingsystems(:coreos), + :architecture => architectures(:x86_64)) + prefix = host.os.pxe_prefix(host.arch) + assert_equal "boot/CoreOS-494.5.0-x86_64", prefix + end + + test "pxe files for coreos" do + host = FactoryGirl.create(:host, :with_medium, + :operatingsystem => operatingsystems(:coreos), + :architecture => architectures(:x86_64), + :medium => media(:coreos) ) + host.medium.operatingsystems << host.os + host.arch.operatingsystems << host.os + + prefix = host.os.pxe_prefix(host.arch).to_sym + pxe_files = host.os.pxe_files(host.medium, host.arch) + + kernel = { prefix => "http://stable.release.core-os.net/amd64-usr/494.5.0/coreos_production_pxe.vmlinuz" } + initrd = { prefix => "http://stable.release.core-os.net/amd64-usr/494.5.0/coreos_production_pxe_image.cpio.gz" } + assert pxe_files.include?(kernel) + assert pxe_files.include?(initrd) + end + +end diff --git a/test/unit/operatingsystem_test.rb b/test/unit/operatingsystem_test.rb index 66d33c5ca95..10af7d87012 100644 --- a/test/unit/operatingsystem_test.rb +++ b/test/unit/operatingsystem_test.rb @@ -182,8 +182,8 @@ class OperatingsystemTest < ActiveSupport::TestCase test "families_as_collection contains correct names and values" do families = Operatingsystem.families_as_collection - assert_equal ["AIX", "Altlinux", "Arch Linux", "Debian", "FreeBSD", "Gentoo", "Junos", "Red Hat", "SUSE", "Solaris", "Windows"], families.map(&:name).sort - assert_equal ["AIX", "Altlinux", "Archlinux", "Debian", "Freebsd", "Gentoo", "Junos", "Redhat", "Solaris", "Suse", "Windows"], families.map(&:value).sort + assert_equal ["AIX", "Altlinux", "Arch Linux", "CoreOS", "Debian", "FreeBSD", "Gentoo", "Junos", "Red Hat", "SUSE", "Solaris", "Windows"], families.map(&:name).sort + assert_equal ["AIX", "Altlinux", "Archlinux", "Coreos", "Debian", "Freebsd", "Gentoo", "Junos", "Redhat", "Solaris", "Suse", "Windows"], families.map(&:value).sort end end