Class: ForemanDatacenter::DevicesController
- Inherits:
-
ApplicationController
show all
- Includes:
- Foreman::Controller::AutoCompleteSearch, Controller::Parameters::Device
- Defined in:
- app/controllers/foreman_datacenter/devices_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
#create ⇒ Object
44
45
46
47
48
49
50
51
52
|
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 44
def create
@device = ForemanDatacenter::Device.new(device_params.merge(host_id: params[:host_id]))
if @device.save
process_success success_redirect: device_url(@device)
else
process_error object: @device
end
end
|
#destroy ⇒ Object
62
63
64
65
66
67
68
|
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 62
def destroy
if @device.destroy
process_success success_redirect: "/datacenter/devices"
else
process_error object: @device
end
end
|
#destroy_interfaces ⇒ Object
95
96
97
98
99
100
|
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 95
def destroy_interfaces
@device.non_management_interfaces.
where(id: params[:interfaces]).
destroy_all
process_success(success_msg: "Selected interfaces were successfully destroyed.", success_redirect: device_url(id: @device))
end
|
#device_type_size ⇒ Object
75
76
77
78
|
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 75
def device_type_size
@device_type_id = params[:device_type_id]
render partial: 'device_type_size'
end
|
#device_types ⇒ Object
70
71
72
73
|
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 70
def device_types
@manufacturer_id = params[:manufacturer_id]
render partial: 'device_types'
end
|
#edit ⇒ Object
39
40
41
42
|
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 39
def edit
@device = ForemanDatacenter::Device.find(params[:id])
populate_from_host
end
|
#for_rack ⇒ Object
90
91
92
93
|
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 90
def for_rack
@rack = ForemanDatacenter::Rack.find(params[:rack_id])
render partial: 'for_rack'
end
|
#index ⇒ Object
14
15
16
|
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 14
def index
@devices = resource_base_search_and_page.includes(:device_role, :device_type, :site, :rack)
end
|
#inventory ⇒ Object
31
32
|
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 31
def inventory
end
|
#new ⇒ Object
34
35
36
37
|
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 34
def new
@device = ForemanDatacenter::Device.new
populate_from_host
end
|
#qr_code ⇒ Object
102
103
104
105
106
|
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 102
def qr_code
send_data(generate_qr_code(@device),
filename: "#{@device.name_without_fqdn}.qr.pdf",
type: 'application/pdf')
end
|
#racks ⇒ Object
80
81
82
83
|
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 80
def racks
@site_id = params[:site_id]
render partial: 'racks'
end
|
#show ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 18
def show
@device = ForemanDatacenter::Device.includes(
power_ports: [:power_outlet],
console_ports: [:console_server_port],
comments: [:user]
).find(params[:id])
@comments = @device.
@commentable = @device
@comment = ForemanDatacenter::Comment.new
@resource = request.path.split('/')[2]
@current_user = current_user
end
|
#site_racks ⇒ Object
85
86
87
88
|
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 85
def site_racks
@site = ForemanDatacenter::Site.find(params[:site_id])
render partial: 'site_racks'
end
|
#sync_interfaces_with_host ⇒ Object
108
109
110
111
112
113
114
|
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 108
def sync_interfaces_with_host
if @device.sync_interfaces_with_host
process_success(success_msg: "Device successfully synchronized.", success_redirect: device_url(id: @device))
else
process_error(error_msg: "Unsuccessfully synchronization.", redirect: device_url(@device))
end
end
|
#update ⇒ Object
54
55
56
57
58
59
60
|
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 54
def update
if @device.update(device_params)
process_success object: @device
else
process_error object: @device
end
end
|