foreman_datacenter 0.1.46 → 0.1.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ced0ea1e681f01135f5bb562ed71e13028c81fe
4
- data.tar.gz: f8b9908a408b69a3f4589c3e4cebc851c85d875d
3
+ metadata.gz: 8d756ec7f3c2b8d5857f2b0c9c707f600bdbafd0
4
+ data.tar.gz: 81020401067611e0e976048b54210dc8e4a223c2
5
5
  SHA512:
6
- metadata.gz: 2ef9349d13f0042eeaf26b744c2df02c08b4a8d8526b38365df68af2c556be8d637f6140a02d85fd3d38a5e8f9f7006d34c3d8cb177dd65ad898dad1c4c16e7b
7
- data.tar.gz: 224c42313b6f122fa71e81d367cf4d87b65bd5846092eac4471ebe6976c5d4c1867713e061be54c610014ca7eda75cb4f13a6c8aafa173f7e62d9838a2e04a63
6
+ metadata.gz: c2c056dc878faf80fc08592f7e909a7c0823e5b99d710c1296179f358eedeb0677c4c2d6c06f7610bb413f64fae8c373e8fac1ebe549c7855ee9071c09db7399
7
+ data.tar.gz: c5d63932206c2fe0fc7cfefa06fcdb3acabe492d05e48217197bde6cdf0e235c585ad7b3dee4d4b1ea5e7e1bf4c18f0ee367603a33e2692fd9191f3028ef5708
@@ -0,0 +1,10 @@
1
+ .nonmarginbottom {
2
+ margin-bottom: 0px !important;
3
+ }
4
+ .nonborder {
5
+ border: 0px !important;
6
+ }
7
+ .nonbordercolor {
8
+ border-color: transparent !important;
9
+ }
10
+
@@ -16,7 +16,7 @@ module ForemanDatacenter
16
16
  def create
17
17
  @comment = @commentable.comments.new(comment_params.merge(user_id: User.current.id))
18
18
  if @comment.save
19
- process_success :success_redirect => "/datacenter/#{@resource}/#{@id}#comment-#{@comment.id}"
19
+ process_success :success_redirect => "/datacenter/#{@resource}/#{@id}#comment-#{@comment.id}", success_msg: "Comment successfully created."
20
20
  else
21
21
  process_error :redirect => "/datacenter/#{@resource}/#{@id}", :error_msg => _("Failed: %s") % (e)
22
22
  end
@@ -28,7 +28,7 @@ module ForemanDatacenter
28
28
  @submodule = parse_submodule(@comment)
29
29
  if @comment.user == @current_user or @comment.user.nil?
30
30
  if @comment.update(comment_params)
31
- process_success :success_redirect => "/datacenter/#{@submodule}/#{@comment.commentable_id}#comment-#{@comment.id}"
31
+ process_success :success_redirect => "/datacenter/#{@submodule}/#{@comment.commentable_id}#comment-#{@comment.id}", success_msg: "Comment successfully updated."
32
32
  else
33
33
  process_error :redirect => "/datacenter/#{@submodule}/#{@comment.commentable_id}#comment-#{@comment.id}", :error_msg => _("Failed: %s") % (e)
34
34
  end
@@ -41,7 +41,7 @@ module ForemanDatacenter
41
41
  @comment = Comment.find(params[:id])
42
42
  if @comment.user == @current_user or @comment.user.nil?
43
43
  if @comment.destroy
44
- process_success :success_redirect => "/datacenter/#{@resource}/#{@id}#comment-#{@comment.id}"
44
+ process_success :success_redirect => "/datacenter/#{@resource}/#{@id}#comment-#{@comment.id}", success_msg: "Comment successfully deleted."
45
45
  else
46
46
  process_error :redirect => "/datacenter/#{@resource}/#{@id}", :error_msg => _("Failed: %s") % (e)
47
47
  end
@@ -7,7 +7,8 @@ module ForemanDatacenter
7
7
  include Foreman::Controller::AutoCompleteSearch
8
8
 
9
9
  before_action :set_device, only: [:update, :destroy, :inventory,
10
- :destroy_interfaces, :qr_code]
10
+ :destroy_interfaces, :qr_code,
11
+ :sync_interfaces_with_host]
11
12
 
12
13
  before_action :load_resource
13
14
 
@@ -107,6 +108,16 @@ module ForemanDatacenter
107
108
  type: 'application/pdf')
108
109
  end
109
110
 
111
+ def sync_interfaces_with_host
112
+ if @device.sync_interfaces_with_host
113
+ notice("Device successfully synchronized.")
114
+ redirect_to device_url(@device)
115
+ else
116
+ error("Unsuccessful synchronization.")
117
+ redirect_to device_url(@device)
118
+ end
119
+ end
120
+
110
121
  private
111
122
 
112
123
  def set_device
@@ -149,6 +149,24 @@ module ForemanDatacenter
149
149
  end
150
150
  end
151
151
 
152
+ def sync_interfaces_with_host
153
+ if host
154
+ existed_names = interfaces.map(&:name)
155
+ # abort interfaces.map(&:identifier).inspect
156
+ host.interfaces.each do |interface|
157
+ unless existed_names.include?(interface.identifier)
158
+ interfaces.create(
159
+ name: interface.identifier,
160
+ form_factor: ForemanDatacenter::DeviceInterface::DEFAULT_FORM_FACTOR,
161
+ mac_address: interface.mac,
162
+ ip_address: interface.ip,
163
+ mgmt_only: interface.identifier == 'ipmi'
164
+ )
165
+ end
166
+ end
167
+ end
168
+ end
169
+
152
170
  def create_console_ports
153
171
  device_type.console_port_templates.each do |template|
154
172
  console_ports.create(template.attrs_to_copy)
@@ -1,6 +1,6 @@
1
1
  <% stylesheet 'foreman_datacenter/comments' %>
2
2
 
3
- <table class="<%= table_css_classes 'table-hover panel-body' %>">
3
+ <table class="<%= table_css_classes 'table-hover panel-body nonmarginbottom' %>">
4
4
  <% if comments == [] %>
5
5
  <div class="col-md-2">
6
6
  <small>No comments yet...</small>
@@ -42,7 +42,7 @@
42
42
  </div>
43
43
  <% end %>
44
44
  <% else %>
45
- <%= form_for [@commentable, @comment], url: "/datacenter/devices/#{@commentable.id}/comments" do |f| %>
45
+ <%= form_for [@commentable, @comment], url: "/datacenter/devices/#{@commentable.id}/comments", html: {class: "form-horizontal well nonborder"} do |f| %>
46
46
  <div class="clearfix">
47
47
  <div class="form-group">
48
48
  <div class="col-md-5">
@@ -1,3 +1,5 @@
1
+ <% stylesheet 'foreman_datacenter/datacenter' %>
2
+
1
3
  <% title h(@device_role.name) %>
2
4
 
3
5
  <% title_actions display_link_if_authorized(
@@ -20,7 +22,7 @@
20
22
  <div class="panel-heading">
21
23
  <strong>Device role</strong>
22
24
  </div>
23
- <table class="<%= table_css_classes 'table-hover panel-body' %>">
25
+ <table class="<%= table_css_classes 'table-hover panel-body nonmarginbottom' %>">
24
26
  <tbody>
25
27
  <tr>
26
28
  <td>Name</td>
@@ -47,7 +49,7 @@
47
49
  <!-- Stats -->
48
50
  <div class="panel panel-default">
49
51
  <div class="panel-heading"><strong>Stats</strong></div>
50
- <table class="<%= table_css_classes 'table-hover panel-body' %>">
52
+ <table class="<%= table_css_classes 'table-hover panel-body nonmarginbottom' %>">
51
53
  <tr>
52
54
  <td>Devices</td>
53
55
  <td><%= @device_role.devices.length %></td>
@@ -1,3 +1,5 @@
1
+ <% stylesheet 'foreman_datacenter/datacenter' %>
2
+
1
3
  <% title h(@device_type.model) %>
2
4
 
3
5
  <% title_actions display_link_if_authorized(
@@ -20,7 +22,7 @@
20
22
  <div class="panel-heading">
21
23
  <strong>Chassis</strong>
22
24
  </div>
23
- <table class="<%= table_css_classes 'table-hover panel-body' %>">
25
+ <table class="<%= table_css_classes 'table-hover panel-body nonmarginbottom' %>">
24
26
  <tbody>
25
27
  <tr>
26
28
  <td>Manufacturer</td>
@@ -47,7 +49,7 @@
47
49
  <div class="panel-heading">
48
50
  <strong>Function</strong>
49
51
  </div>
50
- <table class="<%= table_css_classes 'table-hover panel-body' %>">
52
+ <table class="<%= table_css_classes 'table-hover panel-body nonmarginbottom' %>">
51
53
  <tbody>
52
54
  <tr>
53
55
  <td class="col-sm-3 text-right">
@@ -139,7 +141,7 @@
139
141
  <% if @device_type.console_port_templates.empty? %>
140
142
  <div class="panel-body">None</div>
141
143
  <% else %>
142
- <table class="<%= table_css_classes 'table-hover panel-body' %>">
144
+ <table class="<%= table_css_classes 'table-hover panel-body nonmarginbottom' %>">
143
145
  <tbody>
144
146
  <% @device_type.console_port_templates.each do |console_port| %>
145
147
  <tr>
@@ -170,7 +172,7 @@
170
172
  <% if @device_type.power_port_templates.empty? %>
171
173
  <div class="panel-body">None</div>
172
174
  <% else %>
173
- <table class="<%= table_css_classes 'table-hover panel-body' %>">
175
+ <table class="<%= table_css_classes 'table-hover panel-body nonmarginbottom' %>">
174
176
  <tbody>
175
177
  <% @device_type.power_port_templates.each do |power_port| %>
176
178
  <tr>
@@ -201,7 +203,7 @@
201
203
  <% if @device_type.management_interfaces.empty? %>
202
204
  <div class="panel-body">None</div>
203
205
  <% else %>
204
- <table class="<%= table_css_classes 'table-hover panel-body' %>">
206
+ <table class="<%= table_css_classes 'table-hover panel-body nonmarginbottom' %>">
205
207
  <tbody>
206
208
  <% @device_type.management_interfaces.each do |management_interface| %>
207
209
  <tr>
@@ -235,7 +237,7 @@
235
237
  <% if @device_type.device_bay_templates.empty? %>
236
238
  <div class="panel-body">None</div>
237
239
  <% else %>
238
- <table class="<%= table_css_classes 'table-hover panel-body' %>">
240
+ <table class="<%= table_css_classes 'table-hover panel-body nonmarginbottom' %>">
239
241
  <tbody>
240
242
  <% @device_type.device_bay_templates.each do |device_bay| %>
241
243
  <tr>
@@ -268,7 +270,7 @@
268
270
  <% if @device_type.network_interfaces.empty? %>
269
271
  <div class="panel-body">None</div>
270
272
  <% else %>
271
- <table class="<%= table_css_classes 'table-hover panel-body' %>">
273
+ <table class="<%= table_css_classes 'table-hover panel-body nonmarginbottom' %>">
272
274
  <tbody>
273
275
  <% @device_type.network_interfaces.each do |interface| %>
274
276
  <tr>
@@ -301,7 +303,7 @@
301
303
  <% if @device_type.console_server_port_templates.empty? %>
302
304
  <div class="panel-body">None</div>
303
305
  <% else %>
304
- <table class="<%= table_css_classes 'table-hover panel-body' %>">
306
+ <table class="<%= table_css_classes 'table-hover panel-body nonmarginbottom' %>">
305
307
  <tbody>
306
308
  <% @device_type.console_server_port_templates.each do |console_server_port| %>
307
309
  <tr>
@@ -334,7 +336,7 @@
334
336
  <% if @device_type.power_outlet_templates.empty? %>
335
337
  <div class="panel-body">None</div>
336
338
  <% else %>
337
- <table class="<%= table_css_classes 'table-hover panel-body' %>">
339
+ <table class="<%= table_css_classes 'table-hover panel-body nonmarginbottom' %>">
338
340
  <tbody>
339
341
  <% @device_type.power_outlet_templates.each do |power_outlet| %>
340
342
  <tr>
@@ -2,8 +2,10 @@
2
2
  <% stylesheet 'foreman_datacenter/comments' %>
3
3
 
4
4
  <% title _('Devices') %>
5
- <% title_actions display_link_if_authorized(_('New device'), hash_for_new_device_path, class: 'btn btn-success'),
6
- display_link_if_authorized(_('Import from host'), hash_for_import_to_device_path, class: 'btn btn-success') %>
5
+ <% title_actions display_link_if_authorized(_('Create device'), hash_for_new_device_path, class: 'btn btn-primary'),
6
+ display_link_if_authorized(_('Import from host'), hash_for_import_to_device_path, class: 'btn btn-success'),
7
+ help_button
8
+ %>
7
9
 
8
10
  <table class="<%= table_css_classes 'table-two-pane' %>">
9
11
  <thead>
@@ -1,5 +1,8 @@
1
1
  <% javascript 'foreman_datacenter/ajax' %>
2
2
  <% javascript 'foreman_datacenter/management_devices' %>
3
+ <% stylesheet 'foreman_datacenter/datacenter' %>
4
+
5
+ <% content_for(:title, @device.name) %>
3
6
 
4
7
  <div class="row">
5
8
  <div class="col-md-8">
@@ -42,7 +45,8 @@
42
45
  <div class="panel-heading">
43
46
  <strong>Device</strong>
44
47
  </div>
45
- <table class="<%= table_css_classes 'table-hover panel-body' %>">
48
+ <!-- table_css_classes removed purposely -->
49
+ <table class="table table-hover panel-body nonmarginbotton">
46
50
  <tbody>
47
51
  <tr>
48
52
  <td>Site</td>
@@ -81,7 +85,8 @@
81
85
  <div class="panel-heading">
82
86
  <strong>Critical Connections</strong>
83
87
  </div>
84
- <table class="<%= table_css_classes 'table-hover panel-body' %>">
88
+ <!-- table_css_classes removed purposely -->
89
+ <table class="table table-hover panel-body">
85
90
  <tbody>
86
91
  <% if @device.management_interfaces.empty? %>
87
92
  <tr class="alert-warning">
@@ -143,7 +148,7 @@
143
148
  <% end %>
144
149
  </tbody>
145
150
  </table>
146
- <div class="panel-footer text-right">
151
+ <div class="panel-footer text-right" id="pagination">
147
152
  <%= link_to new_management_device_device_interfaces_path(@device),
148
153
  class: 'btn btn-primary btn-xs' do %>
149
154
  <span class="glyphicon glyphicon-plus"></span>
@@ -169,7 +174,8 @@
169
174
  <div class="panel-heading">
170
175
  <strong>Management</strong>
171
176
  </div>
172
- <table class="<%= table_css_classes 'table-hover panel-body' %>">
177
+ <!-- table_css_classes removed purposely -->
178
+ <table class="table table-hover panel-body nonmarginbotton">
173
179
  <tbody>
174
180
  <tr>
175
181
  <td>Role</td>
@@ -322,13 +328,16 @@
322
328
  <% if @device.non_management_interfaces.empty? %>
323
329
  <div class="panel-body">None</div>
324
330
  <% else %>
325
- <table class="<%= table_css_classes 'table-hover panel-body' %>">
331
+ <!-- table_css_classes removed purposely -->
332
+ <table class="table table-hover panel-body nonmarginbotton">
326
333
  <tbody>
327
334
  <%= render partial: 'interface', collection: @device.non_management_interfaces %>
328
335
  </tbody>
329
336
  </table>
330
337
  <% end %>
331
338
  <div class="panel-footer text-right">
339
+ <%= link_to 'Sync', sync_interfaces_with_host_device_path(@device),
340
+ class: 'btn btn-primary btn-xs' %>
332
341
  <%= link_to 'Add an interface', new_device_device_interface_path(@device),
333
342
  class: 'btn btn-primary btn-xs' %>
334
343
  <%= button_tag 'Destroy selected interfaces',
@@ -1,3 +1,5 @@
1
+ <% stylesheet 'foreman_datacenter/datacenter' %>
2
+
1
3
  <% title h(@manufacturer.name) %>
2
4
 
3
5
  <% title_actions display_link_if_authorized(
@@ -20,7 +22,7 @@
20
22
  <div class="panel-heading">
21
23
  <strong>Manufacturer</strong>
22
24
  </div>
23
- <table class="<%= table_css_classes 'table-hover panel-body' %>">
25
+ <table class="<%= table_css_classes 'table-hover panel-body nonmarginbottom' %>">
24
26
  <tbody>
25
27
  <tr>
26
28
  <td>Name</td>
@@ -43,7 +45,7 @@
43
45
  <!-- Stats -->
44
46
  <div class="panel panel-default">
45
47
  <div class="panel-heading"><strong>Stats</strong></div>
46
- <table class="<%= table_css_classes 'table-hover panel-body' %>">
48
+ <table class="<%= table_css_classes 'table-hover panel-body nonmarginbottom' %>">
47
49
  <tr>
48
50
  <td>Devices types</td>
49
51
  <td><%= @manufacturer.device_types.length %></td>
@@ -1,3 +1,5 @@
1
+ <% stylesheet 'foreman_datacenter/datacenter' %>
2
+
1
3
  <% title h(@platform.name) %>
2
4
 
3
5
  <% title_actions display_link_if_authorized(
@@ -20,7 +22,7 @@
20
22
  <div class="panel-heading">
21
23
  <strong>Platform</strong>
22
24
  </div>
23
- <table class="<%= table_css_classes 'table-hover panel-body' %>">
25
+ <table class="<%= table_css_classes 'table-hover panel-body nonmarginbottom' %>">
24
26
  <tbody>
25
27
  <tr>
26
28
  <td>Name</td>
@@ -47,7 +49,7 @@
47
49
  <!-- Stats -->
48
50
  <div class="panel panel-default">
49
51
  <div class="panel-heading"><strong>Stats</strong></div>
50
- <table class="<%= table_css_classes 'table-hover panel-body' %>">
52
+ <table class="<%= table_css_classes 'table-hover panel-body nonmarginbottom' %>">
51
53
  <tr>
52
54
  <td>Devices</td>
53
55
  <td><%= @platform.devices.length %></td>
@@ -1,3 +1,5 @@
1
+ <% stylesheet 'foreman_datacenter/datacenter' %>
2
+
1
3
  <% title h(@rack_group.name) %>
2
4
 
3
5
  <% title_actions display_link_if_authorized(
@@ -19,7 +21,7 @@
19
21
  <div class="panel-heading">
20
22
  <strong>Rack Group</strong>
21
23
  </div>
22
- <table class="<%= table_css_classes 'table-hover panel-body' %>">
24
+ <table class="<%= table_css_classes 'table-hover panel-body nonmarginbottom' %>">
23
25
  <tbody>
24
26
  <tr>
25
27
  <td>Name</td>
@@ -46,7 +48,7 @@
46
48
  <!-- Stats -->
47
49
  <div class="panel panel-default">
48
50
  <div class="panel-heading"><strong>Stats</strong></div>
49
- <table class="<%= table_css_classes 'table-hover panel-body' %>">
51
+ <table class="<%= table_css_classes 'table-hover panel-body nonmarginbottom' %>">
50
52
  <tr>
51
53
  <td>Racks</td>
52
54
  <td><%= @rack_group.racks.length %></td>
@@ -1,6 +1,6 @@
1
1
  <div class="panel panel-default">
2
2
  <div class="panel-heading"><strong>Devices</strong></div>
3
- <table class="<%= table_css_classes 'table-hover panel-body' %>">
3
+ <table class="<%= table_css_classes 'table-hover panel-body nonmarginbottom' %>">
4
4
  <tbody>
5
5
  <% @rack.positioned_devices.each do |positions, devices| %>
6
6
  <tr>
@@ -1,6 +1,6 @@
1
1
  <div class="panel panel-default">
2
2
  <div class="panel-heading"><strong>Unpositioned Devices</strong></div>
3
- <table class="table table-hover panel-body">
3
+ <table class="table table-hover panel-body nonmarginbottom">
4
4
  <tbody>
5
5
  <% @rack.unpositioned_devices.each do |d| %>
6
6
  <tr>
@@ -1,4 +1,5 @@
1
1
  <% stylesheet 'foreman_datacenter/device_roles' %>
2
+ <% stylesheet 'foreman_datacenter/datacenter' %>
2
3
 
3
4
  <% title h("Rack #{@rack.name}") %>
4
5
 
@@ -22,7 +23,7 @@
22
23
  <div class="panel-heading">
23
24
  <strong>Rack</strong>
24
25
  </div>
25
- <table class="<%= table_css_classes 'table-hover panel-body' %>">
26
+ <table class="<%= table_css_classes 'table-hover panel-body nonmarginbottom' %>">
26
27
  <tbody>
27
28
  <tr>
28
29
  <td>Site</td>
@@ -1,3 +1,5 @@
1
+ <% stylesheet 'foreman_datacenter/datacenter' %>
2
+
1
3
  <% title h(@site.name) %>
2
4
 
3
5
  <% title_actions display_link_if_authorized(
@@ -20,7 +22,7 @@
20
22
  <div class="panel-heading">
21
23
  <strong>Site</strong>
22
24
  </div>
23
- <table class="<%= table_css_classes 'table-hover panel-body' %>">
25
+ <table class="<%= table_css_classes 'table-hover panel-body nonmarginbottom' %>">
24
26
  <tbody>
25
27
  <tr>
26
28
  <td>Facility</td>
@@ -56,7 +58,7 @@
56
58
  <div class="panel-heading">
57
59
  <strong>Stats</strong>
58
60
  </div>
59
- <table class="<%= table_css_classes 'table-hover panel-body' %>">
61
+ <table class="<%= table_css_classes 'table-hover panel-body nonmarginbottom' %>">
60
62
  <tbody>
61
63
  <tr>
62
64
  <td>Racks</td>
@@ -75,7 +77,7 @@
75
77
  <div class="panel-heading">
76
78
  <strong>Rack Groups</strong>
77
79
  </div>
78
- <table class="<%= table_css_classes 'table-hover panel-body' %>">
80
+ <table class="<%= table_css_classes 'table-hover panel-body nonmarginbottom' %>">
79
81
  <tbody>
80
82
  <% @site.rack_groups.each do |rack_group| %>
81
83
  <tr>
data/config/routes.rb CHANGED
@@ -41,6 +41,7 @@ Foreman::Application.routes.draw do
41
41
  get :inventory
42
42
  delete :destroy_interfaces
43
43
  get :qr_code
44
+ get :sync_interfaces_with_host
44
45
  end
45
46
  resources :device_bays, except: [:show, :index], shallow: true do
46
47
  member do
@@ -1,3 +1,3 @@
1
1
  module ForemanDatacenter
2
- VERSION = '0.1.46'.freeze
2
+ VERSION = '0.1.47'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_datacenter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.46
4
+ version: 0.1.47
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Ivanov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-02-19 00:00:00.000000000 Z
12
+ date: 2018-02-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: deface
@@ -113,6 +113,7 @@ files:
113
113
  - app/assets/javascripts/foreman_datacenter/racks.js
114
114
  - app/assets/javascripts/foreman_datacenter/shared.js
115
115
  - app/assets/stylesheets/foreman_datacenter/comments.css
116
+ - app/assets/stylesheets/foreman_datacenter/datacenter.css
116
117
  - app/assets/stylesheets/foreman_datacenter/device_interface_connections.css
117
118
  - app/assets/stylesheets/foreman_datacenter/device_roles.css
118
119
  - app/controllers/concerns/foreman_datacenter/hosts_controller_extensions.rb