Class: Redhat

Inherits:
Operatingsystem show all
Defined in:
app/models/redhat.rb

Constant Summary collapse

PXEFILES =
{:kernel => "vmlinuz", :initrd => "initrd.img"}

Constants inherited from Operatingsystem

Operatingsystem::FAMILIES

Instance Method Summary collapse

Methods inherited from Operatingsystem

#as_json, #boot_filename, #bootfile, families, families_as_collection, #family, #family=, #fullname, #image_extension, #initrd, #interpolate_medium_vars, #kernel, #medium_uri, #medium_vars_to_uri, #pxe_files, #pxe_prefix, #pxe_variant, #release, #repos, #require_nfs_access_to_medium, #supports_image, #template_kind, #to_label, #to_s, #use_release_name?

Methods included from Authorization

#enforce_create_permissions, #enforce_destroy_permissions, #enforce_edit_permissions, #enforce_permissions, included, #permission_failed?

Instance Method Details

#classObject

Override the class representation, as this breaks many rails helpers


44
45
46
# File 'app/models/redhat.rb', line 44

def class
  Operatingsystem
end

#epel(host) ⇒ Object

installs the epel repo


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/models/redhat.rb', line 21

def epel host
  epel_url = "http://dl.fedoraproject.org/pub/epel/$major/$arch/epel-release-$os.noarch.rpm"

  case host.operatingsystem.major
  when "4"
    epel_url.gsub!("$os","4-10")
  when "5"
    epel_url.gsub!("$os","5-4")
  when "6"
     epel_url.gsub!("$os","6-8")
  else
    return ""
  end
  "su -c 'rpm -Uvh #{medium_uri(host, epel_url)}'"
end

#mediumpath(host) ⇒ Object

outputs kickstart installation medium based on the medium type (NFS or URL) it also convert the $arch string to the current host architecture


7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/models/redhat.rb', line 7

def mediumpath host
  uri    = medium_uri(host)

  case uri.scheme
    when 'http', 'https', 'ftp'
       "url --url #{uri}"
    else
      server = uri.select(:host, :port).compact.join(':')
      dir    = uri.select(:path, :query).compact.join('?')
      "nfs --server #{server} --dir #{dir}"
  end
end

#pxe_typeObject

The PXE type to use when generating actions and evaluating attributes. jumpstart, kickstart and preseed are currently supported.


49
50
51
# File 'app/models/redhat.rb', line 49

def pxe_type
  "kickstart"
end

#pxedirObject


53
54
55
# File 'app/models/redhat.rb', line 53

def pxedir
  "images/pxeboot"
end

#url_for_boot(file) ⇒ Object


57
58
59
# File 'app/models/redhat.rb', line 57

def url_for_boot(file)
  pxedir + "/" + PXEFILES[file]
end

#yumrepo(host) ⇒ Object


37
38
39
40
41
# File 'app/models/redhat.rb', line 37

def yumrepo host
  if host.respond_to? :yumrepo
    "--enablerepo #{repo}"
  end
end