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
67
68
69
70
71
72
73
74
|
# File 'app/controllers/foreman_datacenter/power_ports_controller.rb', line 67
def connect
power_outlet = PowerOutlet.find(params[:power_outlet][:id])
@power_port.connect(
power_outlet,
params[:power_port][:connection_status]
)
process_success(success_msg: "Power port was successfully connected.", success_redirect: device_url(id: @power_port.device_id))
end
|
#connected ⇒ Object
49
50
51
52
|
# File 'app/controllers/foreman_datacenter/power_ports_controller.rb', line 49
def connected
@power_port.connected!
head :ok
end
|
#create ⇒ Object
23
24
25
26
27
28
29
30
31
|
# 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
process_success(success_redirect: device_url(id: @power_port.device_id))
else
process_error object: @power_port
end
end
|
#destroy ⇒ Object
41
42
43
44
45
46
47
|
# File 'app/controllers/foreman_datacenter/power_ports_controller.rb', line 41
def destroy
if @power_port.destroy
process_success(success_redirect: device_url(id: @power_port.device_id))
else
process_error object: @power_port
end
end
|
#disconnect ⇒ Object
76
77
78
79
|
# File 'app/controllers/foreman_datacenter/power_ports_controller.rb', line 76
def disconnect
@power_port.disconnect
process_success(success_msg: "Power port was successfully disconnected.", success_redirect: device_url(id: @power_port.device_id))
end
|
#edit ⇒ Object
20
21
|
# File 'app/controllers/foreman_datacenter/power_ports_controller.rb', line 20
def edit
end
|
#for_device ⇒ Object
59
60
61
62
|
# File 'app/controllers/foreman_datacenter/power_ports_controller.rb', line 59
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
64
65
|
# File 'app/controllers/foreman_datacenter/power_ports_controller.rb', line 64
def new_connection
end
|
#planned ⇒ Object
54
55
56
57
|
# File 'app/controllers/foreman_datacenter/power_ports_controller.rb', line 54
def planned
@power_port.planned!
head :ok
end
|
#update ⇒ Object
33
34
35
36
37
38
39
|
# File 'app/controllers/foreman_datacenter/power_ports_controller.rb', line 33
def update
if @power_port.update(power_port_params)
process_success(success_redirect: device_url(id: @power_port.device_id))
else
process_error object: @power_port
end
end
|