Permalink
Browse files

fixes #12962 - Add Xenserver to list of supported OS families.

Templates are included in community-templates repo.
  • Loading branch information...
kflavin authored and domcleal committed Mar 15, 2016
1 parent 41bad32 commit 7cac0899f5c747292e875502eb3f18aa4c9fc920
Binary file not shown.
@@ -36,6 +36,8 @@ def icon(record, opts = {})
"CoreOS"
when /NXOS/i
"NXOS"
when /XenServer/i
"XenServer"
else
return "" if record.family.blank?
record.family
@@ -39,6 +39,12 @@ def generate_pxe_template
# therefore some workaround is required to "render" the template.
@kernel = host.operatingsystem.kernel(host.arch)
@initrd = host.operatingsystem.initrd(host.arch)
# Xen requires additional boot files.
if host.operatingsystem.respond_to?(:xen)
@xen = host.operatingsystem.xen(host.arch)
end
# work around for ensuring that people can use @host as well, as tftp templates were usually confusing.
@host = self.host
if build?
@@ -76,7 +76,8 @@ class Operatingsystem < ActiveRecord::Base
'Freebsd' => %r{FreeBSD}i,
'AIX' => %r{AIX}i,
'Junos' => %r{Junos}i,
'NXOS' => %r{NX-OS}i }
'NXOS' => %r{NX-OS}i,
'Xenserver' => %r{XenServer}i }
class Jail < Safemode::Jail
allow :name, :media_url, :major, :minor, :family, :to_s, :repos, :==, :release_name, :kernel, :initrd, :pxe_type, :medium_uri, :boot_files_uri
@@ -0,0 +1,44 @@
class Xenserver < Operatingsystem
PXEFILES = {:kernel => "boot/vmlinuz", :initrd => "install.img", :xen => "boot/xen.gz"}
MBOOT = "boot/pxelinux/mboot.c32"
def mediumpath(host)
medium_uri(host).to_s
end
def pxe_type
"xenserver"
end
def pxedir
""
end
def xen(arch)
bootfile(arch,:xen)
end
def url_for_boot(file)
pxedir + "/" + PXEFILES[file]
end
def display_family
"XenServer"
end
def self.model_name
superclass.model_name
end
def bootfile(arch, type)
pxe_prefix(arch) + "-" + eval("#{self.family}::PXEFILES[:#{type}]").split("/")[-1]
end
def boot_files_uri(medium, architecture, host = nil)
raise ::Foreman::Exception.new(N_("Invalid medium for %s"), self) unless media.include?(medium)
raise ::Foreman::Exception.new(N_("Invalid architecture for %s"), self) unless architectures.include?(architecture)
eval("#{self.family}::PXEFILES").values.push(MBOOT).collect do |img|
medium_vars_to_uri("#{medium.path}/#{img}", architecture.name, self)
end
end
end
View
@@ -10,7 +10,7 @@ module Renderer
ALLOWED_HELPERS ||= ALLOWED_GENERIC_HELPERS + ALLOWED_HOST_HELPERS
ALLOWED_VARIABLES ||= [ :arch, :host, :osver, :mediapath, :mediaserver, :static,
:repos, :dynamic, :kernel, :initrd,
:repos, :dynamic, :kernel, :initrd, :xen,
:preseed_server, :preseed_path, :provisioning_type ]
def render_safe(template, allowed_methods = [], allowed_vars = {})
@@ -210,6 +210,11 @@ def ZTP_attributes
def waik_attributes
end
def xenserver_attributes
@mediapath = @host.operatingsystem.mediumpath @host
@xen = @host.operatingsystem.xen @host.arch
end
def pxe_config
@kernel = @host.operatingsystem.kernel @host.arch
@initrd = @host.operatingsystem.initrd @host.arch
@@ -172,8 +172,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", "CoreOS", "Debian", "FreeBSD", "Gentoo", "Junos", "NX-OS", "Red Hat", "SUSE", "Solaris", "Windows"], families.map(&:name).sort
assert_equal ["AIX", "Altlinux", "Archlinux", "Coreos", "Debian", "Freebsd", "Gentoo", "Junos", "NXOS", "Redhat", "Solaris", "Suse", "Windows"], families.map(&:value).sort
assert_equal ["AIX", "Altlinux", "Arch Linux", "CoreOS", "Debian", "FreeBSD", "Gentoo", "Junos", "NX-OS", "Red Hat", "SUSE", "Solaris", "Windows", "XenServer"], families.map(&:name).sort
assert_equal ["AIX", "Altlinux", "Archlinux", "Coreos", "Debian", "Freebsd", "Gentoo", "Junos", "NXOS", "Redhat", "Solaris", "Suse", "Windows", "Xenserver"], families.map(&:value).sort
end
end

0 comments on commit 7cac089

Please sign in to comment.