Class: DiscoveryRulesController

Inherits:
ApplicationController
  • Object
show all
Includes:
Foreman::Controller::Parameters::DiscoveryRule
Defined in:
app/controllers/discovery_rules_controller.rb

Instance Method Summary collapse

Instance Method Details

#cloneObject



22
23
24
25
# File 'app/controllers/discovery_rules_controller.rb', line 22

def clone
  @discovery_rule = @discovery_rule.deep_clone except: [:name, :priority], include: [:organizations, :locations]
  @discovery_rule.priority = DiscoveryRule.suggest_priority
end

#createObject



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

def create
  @discovery_rule = DiscoveryRule.new(discovery_rule_params)
  if @discovery_rule.save
    process_success
  else
    process_error
  end
end

#destroyObject



47
48
49
50
51
52
53
# File 'app/controllers/discovery_rules_controller.rb', line 47

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

#disableObject



59
60
61
# File 'app/controllers/discovery_rules_controller.rb', line 59

def disable
  set_enabled false
end

#editObject



36
37
# File 'app/controllers/discovery_rules_controller.rb', line 36

def edit
end

#enableObject



55
56
57
# File 'app/controllers/discovery_rules_controller.rb', line 55

def enable
  set_enabled true
end

#indexObject



13
14
15
16
# File 'app/controllers/discovery_rules_controller.rb', line 13

def index
  base = resource_base.search_for(params[:search], :order => (params[:order]))
  @discovery_rules = base.paginate(:page => params[:page], :per_page => params[:per_page]).includes(:hostgroup)
end

#model_of_controllerObject



9
10
11
# File 'app/controllers/discovery_rules_controller.rb', line 9

def model_of_controller
  DiscoveryRule
end

#newObject



18
19
20
# File 'app/controllers/discovery_rules_controller.rb', line 18

def new
  @discovery_rule = DiscoveryRule.new(:priority => DiscoveryRule.suggest_priority)
end

#updateObject



39
40
41
42
43
44
45
# File 'app/controllers/discovery_rules_controller.rb', line 39

def update
  if @discovery_rule.update(discovery_rule_params)
    process_success
  else
    process_error
  end
end