Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature #7652 - CoreOS support #1890

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file added app/assets/images/CoreOS.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/controllers/unattended_controller.rb
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/operatingsystems_helper.rb
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions app/models/operatingsystem.rb
Expand Up @@ -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,
Expand Down
33 changes: 33 additions & 0 deletions 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
3 changes: 2 additions & 1 deletion db/seeds.d/10-installation_media.rb
Expand Up @@ -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]
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/media.yml
Expand Up @@ -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

10 changes: 10 additions & 0 deletions test/fixtures/operatingsystems.yml
Expand Up @@ -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'
52 changes: 52 additions & 0 deletions 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
4 changes: 2 additions & 2 deletions test/unit/operatingsystem_test.rb
Expand Up @@ -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

Expand Down