foreman/app/controllers/operatingsystems_controller.rb @ 95a66717
9eb0e160 | Ohad Levy | class OperatingsystemsController < ApplicationController
|
|
8de14697 | Ohad Levy | include Foreman::Controller::AutoCompleteSearch
|
|
32f72fd6 | Joseph Mitchell Magen | before_filter :find_os, :only => %w{edit update destroy bootfiles}
|
|
ff5ad780 | Ohad Levy | ||
66bb73ba | Ohad Levy | def index
|
|
76e5dd41 | Joseph Mitchell Magen | @operatingsystems = Operatingsystem.search_for(params[:search], :order => params[:order]).paginate(:page => params[:page])
|
|
f2c78d4a | Joseph Magen | @counter = Host.group(:operatingsystem_id).where(:operatingsystem_id => @operatingsystems.pluck(:id)).count
|
|
66bb73ba | Ohad Levy | end
|
|
def new
|
|||
@operatingsystem = Operatingsystem.new
|
|||
end
|
|||
def create
|
|||
@operatingsystem = Operatingsystem.new(params[:operatingsystem])
|
|||
if @operatingsystem.save
|
|||
b28fdce4 | Ohad Levy | process_success
|
|
66bb73ba | Ohad Levy | else
|
|
b28fdce4 | Ohad Levy | process_error
|
|
66bb73ba | Ohad Levy | end
|
|
end
|
|||
def edit
|
|||
9c3f01c5 | Ohad Levy | # Generates default OS template entries
|
|
@operatingsystem.config_templates.map(&:template_kind_id).uniq.each do |kind|
|
|||
017e1049 | Ohad Levy | if @operatingsystem.os_default_templates.where(:template_kind_id => kind).blank?
|
|
@operatingsystem.os_default_templates.build(:template_kind_id => kind)
|
|||
end
|
|||
9c3f01c5 | Ohad Levy | end if SETTINGS[:unattended]
|
|
95a66717 | Marek Hulan | @operatingsystem = generalize(@operatingsystem)
|
|
66bb73ba | Ohad Levy | end
|
|
def update
|
|||
if @operatingsystem.update_attributes(params[:operatingsystem])
|
|||
b28fdce4 | Ohad Levy | process_success
|
|
66bb73ba | Ohad Levy | else
|
|
b28fdce4 | Ohad Levy | process_error
|
|
66bb73ba | Ohad Levy | end
|
|
95a66717 | Marek Hulan | @operatingsystem = generalize(@operatingsystem)
|
|
66bb73ba | Ohad Levy | end
|
|
def destroy
|
|||
if @operatingsystem.destroy
|
|||
b28fdce4 | Ohad Levy | process_success
|
|
66bb73ba | Ohad Levy | else
|
|
b28fdce4 | Ohad Levy | process_error
|
|
66bb73ba | Ohad Levy | end
|
|
286a2207 | Ohad Levy | end
|
|
ff5ad780 | Ohad Levy | ||
private
|
|||
def find_os
|
|||
@operatingsystem = Operatingsystem.find(params[:id])
|
|||
end
|
|||
95a66717 | Marek Hulan | def generalize(os)
|
|
os.becomes(Operatingsystem).tap { |o| o.type = os.type }
|
|||
end
|
|||
286a2207 | Ohad Levy | end
|