foreman_datacenter 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/foreman_datacenter/devices_controller.rb +17 -2
- data/app/controllers/foreman_datacenter/racks_controller.rb +1 -0
- data/app/models/foreman_datacenter/device.rb +16 -27
- data/app/views/foreman_datacenter/devices/_interface.html.erb +2 -0
- data/app/views/foreman_datacenter/devices/show.html.erb +52 -46
- data/config/routes.rb +2 -0
- data/db/migrate/20160909205537_add_name_index_to_racks.rb +5 -0
- data/db/migrate/20160920221011_remove_index_from_devices.rb +5 -0
- data/lib/foreman_datacenter/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55c54f423e2c5622ddac9c470546d27f08649452
|
4
|
+
data.tar.gz: 5551738810f1db7684a93a2eaf1fa43233210f17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e188f2ccc8702b861b6127d8df91d9dd06da2c1b3a3af69b20e092c46454a2155625e19a1f8ae77fc07eaf31ce243ed87185f975bf9a2fef0ef0a82a6c9fa669
|
7
|
+
data.tar.gz: 538df56b14e630eef7535cc2c2ce1806d3f31c88b76dc632b099cada2f4309e79feb55986810a7659b45da30a31b625a7c55a8270b8bf022f5f0167235920ff6
|
@@ -1,9 +1,17 @@
|
|
1
1
|
module ForemanDatacenter
|
2
2
|
class DevicesController < ApplicationController
|
3
|
-
|
3
|
+
include Foreman::Controller::AutoCompleteSearch
|
4
|
+
|
5
|
+
before_action :set_device, only: [:update, :destroy, :inventory, :destroy_interfaces]
|
4
6
|
|
5
7
|
def index
|
6
|
-
|
8
|
+
begin
|
9
|
+
search = resource_base.search_for(params[:search], :order => params[:order])
|
10
|
+
rescue => e
|
11
|
+
error e.to_s
|
12
|
+
search = resource_base.search_for ''
|
13
|
+
end
|
14
|
+
@devices = search.includes(:ipmi_interface, :device_role, :device_type, :site, :rack).
|
7
15
|
paginate(:page => params[:page])
|
8
16
|
end
|
9
17
|
|
@@ -71,6 +79,13 @@ module ForemanDatacenter
|
|
71
79
|
render partial: 'for_rack'
|
72
80
|
end
|
73
81
|
|
82
|
+
def destroy_interfaces
|
83
|
+
@device.non_management_interfaces.
|
84
|
+
where(id: params[:interfaces]).
|
85
|
+
destroy_all
|
86
|
+
redirect_to device_url(@device)
|
87
|
+
end
|
88
|
+
|
74
89
|
private
|
75
90
|
|
76
91
|
def set_device
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module ForemanDatacenter
|
2
2
|
class Device < ActiveRecord::Base
|
3
|
+
include ScopedSearchExtensions
|
4
|
+
|
3
5
|
belongs_to :device_type, :class_name => 'ForemanDatacenter::DeviceType'
|
4
6
|
belongs_to :device_role, :class_name => 'ForemanDatacenter::DeviceRole'
|
5
7
|
belongs_to :platform, :class_name => 'ForemanDatacenter::Platform'
|
@@ -22,13 +24,14 @@ module ForemanDatacenter
|
|
22
24
|
:class_name => 'ForemanDatacenter::DeviceInterface'
|
23
25
|
belongs_to_host
|
24
26
|
has_one :management_device, :class_name => 'ForemanDatacenter::ManagementDevice'
|
27
|
+
has_one :site, :through => :rack
|
25
28
|
|
26
29
|
enum face: [:front, :rear]
|
27
30
|
enum status: [:active, :offline]
|
28
31
|
|
29
32
|
validates :device_type_id, presence: true
|
30
33
|
validates :device_role_id, presence: true
|
31
|
-
validates :name, presence: true,
|
34
|
+
validates :name, presence: true, length: { maximum: 50 }
|
32
35
|
validates :serial, length: { maximum: 50 }
|
33
36
|
validates :rack_id, presence: true
|
34
37
|
validates :position, numericality: { only_integer: true }, allow_nil: true
|
@@ -41,38 +44,24 @@ module ForemanDatacenter
|
|
41
44
|
after_create :create_power_outlets
|
42
45
|
after_create :create_device_bays
|
43
46
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
+
scoped_search on: :name, complete_value: true, default_order: true
|
48
|
+
scoped_search on: :status, complete_value: { active: 0, offline: 1 },
|
49
|
+
default_order: true
|
50
|
+
scoped_search in: :site, on: :name, complete_value: true, rename: :site
|
51
|
+
scoped_search in: :rack, on: :name, complete_value: true, rename: :rack
|
52
|
+
scoped_search in: :device_role, on: :name, complete_value: true, rename: :role
|
53
|
+
scoped_search in: :device_type, on: :model, complete_value: true, rename: :type
|
47
54
|
|
48
|
-
|
49
|
-
|
50
|
-
|
55
|
+
delegate :site_id, to: :rack, allow_nil: true
|
56
|
+
delegate :mac_address, to: :ipmi_interface, allow_nil: true
|
57
|
+
delegate :manufacturer_id, :is_console_server, :is_pdu, :is_network_device,
|
58
|
+
to: :device_type, allow_nil: true
|
59
|
+
delegate :console_url, :login, :password, to: :management_device
|
51
60
|
|
52
61
|
def ip_address
|
53
62
|
ipmi_interface.try(:ip_address) || primary_ip4
|
54
63
|
end
|
55
64
|
|
56
|
-
def mac_address
|
57
|
-
ipmi_interface.try(:mac_address)
|
58
|
-
end
|
59
|
-
|
60
|
-
def manufacturer_id
|
61
|
-
device_type.try(:manufacturer_id)
|
62
|
-
end
|
63
|
-
|
64
|
-
def is_console_server
|
65
|
-
device_type.try(:is_console_server)
|
66
|
-
end
|
67
|
-
|
68
|
-
def is_pdu
|
69
|
-
device_type.try(:is_pdu)
|
70
|
-
end
|
71
|
-
|
72
|
-
def is_network_device
|
73
|
-
device_type.try(:is_network_device)
|
74
|
-
end
|
75
|
-
|
76
65
|
def parent?
|
77
66
|
device_type.try(:subdevice_role) == 'Parent'
|
78
67
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
<tr>
|
2
2
|
<% if interface.connected? %>
|
3
3
|
<td>
|
4
|
+
<%= check_box_tag 'interfaces[]', interface.id %>
|
4
5
|
<span class="glyphicon glyphicon-transfer"></span>
|
5
6
|
<%= interface.name %>
|
6
7
|
</td>
|
@@ -45,6 +46,7 @@
|
|
45
46
|
</td>
|
46
47
|
<% else %>
|
47
48
|
<td>
|
49
|
+
<%= check_box_tag 'interfaces[]', interface.id %>
|
48
50
|
<span class="glyphicon glyphicon-transfer"></span>
|
49
51
|
<%= interface.name %>
|
50
52
|
</td>
|
@@ -219,62 +219,63 @@
|
|
219
219
|
<% end %>
|
220
220
|
</td>
|
221
221
|
</tr>
|
222
|
-
</tbody>
|
223
|
-
</table>
|
224
|
-
</div>
|
225
222
|
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
<table class="table table-hover panel-body">
|
232
|
-
<tbody>
|
223
|
+
<!-- Management device -->
|
224
|
+
<tr>
|
225
|
+
<td><strong>Management device</strong></td>
|
226
|
+
<td></td>
|
227
|
+
</tr>
|
233
228
|
<% if @device.management_device %>
|
234
229
|
<tr>
|
235
230
|
<td>Console URL</td>
|
236
|
-
<td><%= h @device.
|
231
|
+
<td><%= h @device.console_url %></td>
|
237
232
|
</tr>
|
238
233
|
<tr>
|
239
234
|
<td>Login</td>
|
240
|
-
<td><%= h @device.
|
235
|
+
<td><%= h @device.login %></td>
|
241
236
|
</tr>
|
242
237
|
<tr>
|
243
238
|
<td>Password</td>
|
244
239
|
<td>
|
245
|
-
<button class="btn btn-primary btn-xs" data-reveal-password data-password="<%= h @device.
|
240
|
+
<button class="btn btn-primary btn-xs" data-reveal-password data-password="<%= h @device.password %>">
|
246
241
|
Reveal
|
247
242
|
</button>
|
248
243
|
</td>
|
249
244
|
</tr>
|
245
|
+
<tr>
|
246
|
+
<td></td>
|
247
|
+
<td class="text-right">
|
248
|
+
<%= link_to edit_management_device_path(@device.management_device),
|
249
|
+
class: 'btn btn-success btn-xs' do %>
|
250
|
+
<span class="glyphicon glyphicon-pencil"></span>
|
251
|
+
Edit
|
252
|
+
<% end %>
|
253
|
+
<%= link_to management_device_path(@device.management_device),
|
254
|
+
class: 'btn btn-danger btn-xs',
|
255
|
+
data: { confirm: 'Are you sure?' }, method: :delete do %>
|
256
|
+
<i class="glyphicon glyphicon-trash"></i>
|
257
|
+
Destroy
|
258
|
+
<% end %>
|
259
|
+
</td>
|
260
|
+
</tr>
|
250
261
|
<% else %>
|
251
262
|
<tr>
|
252
263
|
<td>None</td>
|
264
|
+
<td></td>
|
265
|
+
</tr>
|
266
|
+
<tr>
|
267
|
+
<td></td>
|
268
|
+
<td class="text-right">
|
269
|
+
<%= link_to new_device_management_device_path(@device),
|
270
|
+
class: 'btn btn-primary btn-xs' do %>
|
271
|
+
<span class="glyphicon glyphicon-plus"></span>
|
272
|
+
Add
|
273
|
+
<% end %>
|
274
|
+
</td>
|
253
275
|
</tr>
|
254
276
|
<% end %>
|
255
277
|
</tbody>
|
256
278
|
</table>
|
257
|
-
<div class="panel-footer text-right">
|
258
|
-
<% if @device.management_device %>
|
259
|
-
<%= link_to edit_management_device_path(@device.management_device),
|
260
|
-
class: 'btn btn-success btn-xs' do %>
|
261
|
-
<span class="glyphicon glyphicon-pencil"></span>
|
262
|
-
Edit
|
263
|
-
<% end %>
|
264
|
-
<%= link_to management_device_path(@device.management_device),
|
265
|
-
class: 'btn btn-danger btn-xs',
|
266
|
-
data: { confirm: 'Are you sure?' }, method: :delete do %>
|
267
|
-
<i class="glyphicon glyphicon-trash"></i>
|
268
|
-
Destroy
|
269
|
-
<% end %>
|
270
|
-
<% else %>
|
271
|
-
<%= link_to new_device_management_device_path(@device),
|
272
|
-
class: 'btn btn-primary btn-xs' do %>
|
273
|
-
<span class="glyphicon glyphicon-plus"></span>
|
274
|
-
Add
|
275
|
-
<% end %>
|
276
|
-
<% end %>
|
277
|
-
</div>
|
278
279
|
</div>
|
279
280
|
|
280
281
|
<!-- Comments -->
|
@@ -317,19 +318,24 @@
|
|
317
318
|
<div class="panel-heading">
|
318
319
|
<strong>Interfaces</strong>
|
319
320
|
</div>
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
321
|
+
<%= form_tag destroy_interfaces_device_path(@device), method: :delete do %>
|
322
|
+
<% if @device.non_management_interfaces.empty? %>
|
323
|
+
<div class="panel-body">None</div>
|
324
|
+
<% else %>
|
325
|
+
<table class="table table-hover panel-body">
|
326
|
+
<tbody>
|
327
|
+
<%= render partial: 'interface', collection: @device.non_management_interfaces %>
|
328
|
+
</tbody>
|
329
|
+
</table>
|
330
|
+
<% end %>
|
331
|
+
<div class="panel-footer text-right">
|
332
|
+
<%= link_to 'Add an interface', new_device_device_interface_path(@device),
|
333
|
+
class: 'btn btn-primary btn-xs' %>
|
334
|
+
<%= button_tag 'Destroy selected interfaces',
|
335
|
+
class: 'btn btn-danger btn-xs',
|
336
|
+
data: {confirm: 'Are you sure?'} %>
|
337
|
+
</div>
|
328
338
|
<% end %>
|
329
|
-
<div class="panel-footer text-right">
|
330
|
-
<%= link_to 'Add an interface', new_device_device_interface_path(@device),
|
331
|
-
class: 'btn btn-primary btn-xs' %>
|
332
|
-
</div>
|
333
339
|
</div>
|
334
340
|
<% end %>
|
335
341
|
|
data/config/routes.rb
CHANGED
@@ -31,9 +31,11 @@ Foreman::Application.routes.draw do
|
|
31
31
|
resources :devices do
|
32
32
|
collection do
|
33
33
|
get :device_types, :racks, :for_rack
|
34
|
+
get :auto_complete_search
|
34
35
|
end
|
35
36
|
member do
|
36
37
|
get :inventory
|
38
|
+
delete :destroy_interfaces
|
37
39
|
end
|
38
40
|
resources :device_bays, except: [:show, :index], shallow: true do
|
39
41
|
member do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_datacenter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Ivanov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deface
|
@@ -280,6 +280,8 @@ files:
|
|
280
280
|
- db/migrate/20160828200938_add_ip_address_to_device_interfaces.rb
|
281
281
|
- db/migrate/20160905211522_create_management_devices.rb
|
282
282
|
- db/migrate/20160906205605_rename_field_in_management_devices.rb
|
283
|
+
- db/migrate/20160909205537_add_name_index_to_racks.rb
|
284
|
+
- db/migrate/20160920221011_remove_index_from_devices.rb
|
283
285
|
- lib/foreman_datacenter/engine.rb
|
284
286
|
- lib/foreman_datacenter/version.rb
|
285
287
|
- lib/foreman_datacenter.rb
|