Class: ForemanDatacenter::PowerPortsController
- Inherits:
-
ApplicationController
show all
- Includes:
- Foreman::Controller::AutoCompleteSearch, Controller::Parameters::PowerPort
- Defined in:
- app/controllers/foreman_datacenter/power_ports_controller.rb
Instance Method Summary
collapse
#action_permission, #controller_permission, #find_resource, #not_found, #resource_class, #resource_class_for, #resource_finder, #resource_name, #resource_scope, #scope_for
Instance Method Details
#connect ⇒ Object
70
71
72
73
74
75
76
77
78
|
# File 'app/controllers/foreman_datacenter/power_ports_controller.rb', line 70
def connect
power_outlet = PowerOutlet.find(params[:power_outlet][:id])
@power_port.connect(
power_outlet,
params[:power_port][:connection_status]
)
redirect_to device_url(id: @power_port.device_id),
notice: 'Power port was successfully connected.'
end
|
#connected ⇒ Object
52
53
54
55
|
# File 'app/controllers/foreman_datacenter/power_ports_controller.rb', line 52
def connected
@power_port.connected!
head :ok
end
|
#create ⇒ Object
23
24
25
26
27
28
29
30
31
32
|
# File 'app/controllers/foreman_datacenter/power_ports_controller.rb', line 23
def create
@power_port = ForemanDatacenter::PowerPort.new(power_port_params.merge(device_id: params[:device_id]))
if @power_port.save
redirect_to device_url(id: @power_port.device_id),
notice: 'Power port was successfully created.'
else
process_error object: @power_port
end
end
|
#destroy ⇒ Object
43
44
45
46
47
48
49
50
|
# File 'app/controllers/foreman_datacenter/power_ports_controller.rb', line 43
def destroy
if @power_port.destroy
redirect_to device_url(id: @power_port.device_id),
notice: 'Power port was successfully destroyed.'
else
process_error object: @power_port
end
end
|
#disconnect ⇒ Object
80
81
82
83
84
|
# File 'app/controllers/foreman_datacenter/power_ports_controller.rb', line 80
def disconnect
@power_port.disconnect
redirect_to device_url(id: @power_port.device_id),
notice: 'Power port was successfully disconnected.'
end
|
#edit ⇒ Object
20
21
|
# File 'app/controllers/foreman_datacenter/power_ports_controller.rb', line 20
def edit
end
|
#for_device ⇒ Object
62
63
64
65
|
# File 'app/controllers/foreman_datacenter/power_ports_controller.rb', line 62
def for_device
@device = Device.find(params[:device_id])
render partial: 'for_device'
end
|
#index ⇒ Object
10
11
12
|
# File 'app/controllers/foreman_datacenter/power_ports_controller.rb', line 10
def index
@power_ports = resource_base_search_and_page.where.not(power_outlet_id: nil).includes(:device, power_outlet: [:device])
end
|
#new ⇒ Object
14
15
16
17
18
|
# File 'app/controllers/foreman_datacenter/power_ports_controller.rb', line 14
def new
@power_port = ForemanDatacenter::PowerPort.new(
device: Device.find(params[:device_id])
)
end
|
#new_connection ⇒ Object
67
68
|
# File 'app/controllers/foreman_datacenter/power_ports_controller.rb', line 67
def new_connection
end
|
#planned ⇒ Object
57
58
59
60
|
# File 'app/controllers/foreman_datacenter/power_ports_controller.rb', line 57
def planned
@power_port.planned!
head :ok
end
|
#update ⇒ Object
34
35
36
37
38
39
40
41
|
# File 'app/controllers/foreman_datacenter/power_ports_controller.rb', line 34
def update
if @power_port.update(power_port_params)
redirect_to device_url(id: @power_port.device_id),
notice: 'Power port was successfully updated.'
else
process_error object: @power_port
end
end
|