Class: OperatingsystemsController

Inherits:
ApplicationController show all
Includes:
Foreman::Controller::AutoCompleteSearch
Defined in:
app/controllers/operatingsystems_controller.rb

Instance Method Summary collapse

Methods included from Foreman::Controller::AutoCompleteSearch

#auto_complete_search, #invalid_search_query

Methods inherited from ApplicationController

#api_request?, #welcome

Methods included from Foreman::ThreadSession::Cleaner

#clear_thread, included

Instance Method Details

#bootfilesObject


60
61
62
63
64
65
66
67
68
69
70
# File 'app/controllers/operatingsystems_controller.rb', line 60

def bootfiles
  medium = Medium.find_by_name(params[:medium])
  arch =  Architecture.find_by_name(params[:architecture])
  respond_to do |format|
    format.json { render :json => @operatingsystem.pxe_files(medium, arch)}
  end
rescue => e
  respond_to do |format|
    format.json { render :json => e.to_s, :status => :unprocessable_entity }
  end
end

#createObject


26
27
28
29
30
31
32
33
# File 'app/controllers/operatingsystems_controller.rb', line 26

def create
  @operatingsystem = Operatingsystem.new(params[:operatingsystem])
  if @operatingsystem.save
    process_success
  else
    process_error
  end
end

#destroyObject


52
53
54
55
56
57
58
# File 'app/controllers/operatingsystems_controller.rb', line 52

def destroy
  if @operatingsystem.destroy
    process_success
  else
    process_error
  end
end

#editObject


35
36
37
38
39
40
41
42
# File 'app/controllers/operatingsystems_controller.rb', line 35

def edit
  # Generates default OS template entries
  @operatingsystem.config_templates.map(&:template_kind_id).uniq.each do |kind|
    if @operatingsystem.os_default_templates.where(:template_kind_id => kind).blank?
      @operatingsystem.os_default_templates.build(:template_kind_id => kind)
    end
  end if SETTINGS[:unattended]
end

#indexObject


5
6
7
8
9
10
11
12
13
14
# File 'app/controllers/operatingsystems_controller.rb', line 5

def index
  values = Operatingsystem.search_for(params[:search], :order => params[:order])
  respond_to do |format|
    format.html do
      @operatingsystems = values.paginate(:page => params[:page])
      @counter = Host.count(:group => :operatingsystem_id, :conditions => {:operatingsystem_id => @operatingsystems.all})
    end
    format.json { render :json => values.all(:include => [:media, :architectures, :ptables]) }
  end
end

#newObject


16
17
18
# File 'app/controllers/operatingsystems_controller.rb', line 16

def new
  @operatingsystem = Operatingsystem.new
end

#showObject


20
21
22
23
24
# File 'app/controllers/operatingsystems_controller.rb', line 20

def show
  respond_to do |format|
    format.json { render :json => @operatingsystem }
  end
end

#updateObject


44
45
46
47
48
49
50
# File 'app/controllers/operatingsystems_controller.rb', line 44

def update
  if @operatingsystem.update_attributes(params[:operatingsystem])
    process_success
  else
    process_error
  end
end