foreman_datacenter 1.24.1 → 1.24.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d92338ad9dbcbb8535e563a11151dc94e5f0cf0e4ca2b67aaa80cc025bf553e5
4
- data.tar.gz: 0a26582a81e88b47f3205cfe9ab278cfc7e809a864d4e1f9b4cf73ce6ccb0a82
3
+ metadata.gz: aa372e8673608cecc9343f4a2efa60d2d38dc77cb9ef37cfd55f8ec261907ccc
4
+ data.tar.gz: b806528ffcea447652114e76043f216d28eb50c2386f253ca93bd8808ab0ee35
5
5
  SHA512:
6
- metadata.gz: 829d263770d9b13f7f31ac94142e53654036eb7499debac6855e3287215d7afc389e62de47c0fe97fcc1cfd881e185887d1d765f66b62d666f9a46a32d5dcbf3
7
- data.tar.gz: 0e76d5be4b412cd6f3df9890ef45d36a5465f7b7f1ad55b1c07b2472670d5ef414e176af5f8133e311f491675a1540de09cd70da8e0ed47b4f67b14e9bfb781f
6
+ metadata.gz: 8fa308e3840207c9a77aecfaa18491b578a73f5a1307bcea72fabafa1e97d4b3dfcf6bd9386803c847bbc410e75de3515d629c1e12227d4606d5e8385096c721
7
+ data.tar.gz: 3a00433a5afb85a305c687e66f153dd4279efe62f2ec842d6c67d321085062530dc261529436076b3ea0df0e74136bed184b79b388b98cf34f39eb6ecd0066b9
@@ -92,6 +92,8 @@ module ForemanDatacenter
92
92
  'move'
93
93
  when 'racks'
94
94
  'racks'
95
+ when 'export_to_csv'
96
+ 'export_to_csv'
95
97
  else
96
98
  super
97
99
  end
@@ -3,7 +3,7 @@ module ForemanDatacenter
3
3
  include Foreman::Controller::AutoCompleteSearch
4
4
  include ForemanDatacenter::Controller::Parameters::Rack
5
5
 
6
- before_action :find_resource, only: [:show, :edit, :update, :destroy, :devices, :move]
6
+ before_action :find_resource, only: [:show, :edit, :update, :destroy, :devices, :move, :export_to_csv]
7
7
 
8
8
  def index
9
9
  @racks = resource_base_search_and_page.includes(:site, :rack_group)
@@ -64,6 +64,13 @@ module ForemanDatacenter
64
64
  process_error object: @rack, error_msg: 'Current Rack haven\'t any Devices.' if @devices.empty?
65
65
  end
66
66
 
67
+ def export_to_csv
68
+ data = @rack.format_for_csv
69
+ file = File.open("#{@rack.name}.csv", "r")
70
+ send_file(file)
71
+ file.close
72
+ end
73
+
67
74
  def update_associated_objects
68
75
  begin
69
76
  @rack = ForemanDatacenter::Rack.find(request.env['HTTP_REFERER'].split('/')[-2])
@@ -52,8 +52,42 @@ module ForemanDatacenter
52
52
  count
53
53
  end
54
54
 
55
+ def format_for_csv
56
+ positioned_devices = self.positioned_devices
57
+ unpositioned_devices = self.unpositioned_devices
58
+ csv_string = CSV.generate do |csv|
59
+ csv << ["positions", "left", "full", "right", "no side"]
60
+ positioned_devices.each do |i|
61
+ pos = i[0].map{|p| "#{p}"+"U"}.join(",")
62
+ if i[1].size > 0
63
+ sort = sort_for_csv(i[1])
64
+ csv << [pos, sort[0], sort[1], sort[2], sort[3]]
65
+ else
66
+ csv << [pos]
67
+ end
68
+ end
69
+ unless unpositioned_devices.empty?
70
+ csv << []
71
+ csv << ["Unpositioned", unpositioned_devices.map(&:name).join(",")]
72
+ end
73
+
74
+ end
75
+ File.open("#{self.name}.csv", "w") {|f| f << csv_string}
76
+ end
77
+
55
78
  private
56
79
 
80
+ def sort_for_csv(device_array)
81
+ left, full, right, no_side = "", "", "", []
82
+ device_array.each do |d|
83
+ left = d.name if d.side == "left"
84
+ right = d.name if d.side == "right"
85
+ full = d.name if d.side == "full"
86
+ no_side << d.name if d.side == nil
87
+ end
88
+ [left, full, right, no_side.join(",")]
89
+ end
90
+
57
91
  def device_sorting(devices)
58
92
  devices.reverse.map { |d| [d[0].reverse, d[1]] }
59
93
  end
@@ -63,5 +97,7 @@ module ForemanDatacenter
63
97
  devices.each{|d| devs[1] << d[1][0]}
64
98
  return devs
65
99
  end
100
+
101
+
66
102
  end
67
103
  end
@@ -1,5 +1,14 @@
1
1
  <div class="panel panel-default">
2
- <div class="panel-heading text-center"><h4 class="nonmargintop nonmarginbottom"><strong><%= link_to _("#{rack.name}"), rack_path(rack) %></strong></h4></div>
2
+ <div class="panel-heading text-center">
3
+ <h4 class="nonmargintop nonmarginbottom">
4
+ <strong>
5
+ <%= link_to _("#{rack.name}"), rack_path(rack) %>
6
+ </strong>
7
+ <strong>
8
+ <%= link_to 'Export to CSV', export_to_csv_rack_path(rack.id), class: "btn btn-primary btn-xs pull-right" %>
9
+ </strong>
10
+ </h4>
11
+ </div>
3
12
  <table class="<%= table_css_classes 'table-hover panel-body nonmarginbottom' %>">
4
13
  <tbody>
5
14
  <% rack.positioned_devices.each do |positions, devices| %>
@@ -113,6 +113,7 @@ Foreman::Application.routes.draw do
113
113
  end
114
114
  resources :racks do
115
115
  member do
116
+ get :export_to_csv
116
117
  get :move
117
118
  end
118
119
  collection do
@@ -1,3 +1,3 @@
1
1
  module ForemanDatacenter
2
- VERSION = '1.24.1'.freeze
2
+ VERSION = '1.24.2'.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: 1.24.1
4
+ version: 1.24.2
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: 2020-04-28 00:00:00.000000000 Z
12
+ date: 2020-07-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: prawn
@@ -604,61 +604,61 @@ required_rubygems_version: !ruby/object:Gem::Requirement
604
604
  version: '0'
605
605
  requirements: []
606
606
  rubyforge_project:
607
- rubygems_version: 2.7.6.2
607
+ rubygems_version: 2.7.6
608
608
  signing_key:
609
609
  specification_version: 4
610
610
  summary: A plugin that lets you document your servers in a datacenter
611
611
  test_files:
612
- - test/factories/device_role.rb
613
- - test/factories/foreman_datacenter_factories.rb
614
- - test/factories/rack.rb
615
- - test/factories/site.rb
616
- - test/factories/manufacturer.rb
617
- - test/factories/rack_group.rb
618
- - test/factories/device.rb
619
- - test/factories/device_type.rb
620
- - test/factories/platform.rb
621
- - test/test_plugin_helper.rb
622
- - test/controllers/foreman_datacenter/sites_contoller_test.rb
623
- - test/controllers/foreman_datacenter/devices_controller_test.rb
624
- - test/controllers/foreman_datacenter/rack_groups_contoller_test.rb
625
- - test/controllers/foreman_datacenter/manufacturers_controller_test.rb
626
- - test/controllers/foreman_datacenter/racks_contoller_test.rb
627
- - test/controllers/foreman_datacenter/manufacturers_contoller_test.rb
628
- - test/controllers/foreman_datacenter/platforms_contoller_test.rb
629
- - test/controllers/foreman_datacenter/device_roles_controller_test.rb
630
- - test/controllers/foreman_datacenter/power_port_templates_contoller_test.rb
631
- - test/controllers/foreman_datacenter/device_types_contoller_test.rb
632
- - test/integration/foreman_datacenter/rack_group_test.rb
633
- - test/integration/foreman_datacenter/rack_test.rb
634
- - test/integration/foreman_datacenter/device_role_test.rb
635
- - test/integration/foreman_datacenter/device_type_test.rb
636
- - test/integration/foreman_datacenter/platform_test.rb
637
- - test/integration/foreman_datacenter/site_test.rb
638
- - test/integration/foreman_datacenter/manufacturer_test.rb
639
- - test/fixtures/foreman_datacenter/platforms.yml
612
+ - test/fixtures/foreman_datacenter/device_interface_connections.yml
640
613
  - test/fixtures/foreman_datacenter/console_server_port_templates.yml
641
- - test/fixtures/foreman_datacenter/console_server_ports.yml
642
- - test/fixtures/foreman_datacenter/device_types.yml
643
- - test/fixtures/foreman_datacenter/racks.yml
644
- - test/fixtures/foreman_datacenter/power_port_templates.yml
645
614
  - test/fixtures/foreman_datacenter/rack_groups.yml
646
- - test/fixtures/foreman_datacenter/power_outlet_templates.yml
647
- - test/fixtures/foreman_datacenter/device_bay_templates.yml
648
- - test/fixtures/foreman_datacenter/device_modules.yml
649
- - test/fixtures/foreman_datacenter/console_ports.yml
650
615
  - test/fixtures/foreman_datacenter/device_bays.yml
616
+ - test/fixtures/foreman_datacenter/device_roles.yml
617
+ - test/fixtures/foreman_datacenter/racks.yml
618
+ - test/fixtures/foreman_datacenter/comments.yml
651
619
  - test/fixtures/foreman_datacenter/sites.yml
652
- - test/fixtures/foreman_datacenter/manufacturers.yml
653
- - test/fixtures/foreman_datacenter/power_ports.yml
654
- - test/fixtures/foreman_datacenter/console_port_templates.yml
655
- - test/fixtures/foreman_datacenter/power_outlets.yml
656
620
  - test/fixtures/foreman_datacenter/management_devices.yml
657
- - test/fixtures/foreman_datacenter/devices.yml
658
- - test/fixtures/foreman_datacenter/device_roles.yml
659
621
  - test/fixtures/foreman_datacenter/interface_templates.yml
622
+ - test/fixtures/foreman_datacenter/device_modules.yml
660
623
  - test/fixtures/foreman_datacenter/device_interfaces.yml
661
- - test/fixtures/foreman_datacenter/comments.yml
662
- - test/fixtures/foreman_datacenter/device_interface_connections.yml
624
+ - test/fixtures/foreman_datacenter/power_ports.yml
625
+ - test/fixtures/foreman_datacenter/devices.yml
626
+ - test/fixtures/foreman_datacenter/power_outlet_templates.yml
627
+ - test/fixtures/foreman_datacenter/platforms.yml
628
+ - test/fixtures/foreman_datacenter/device_bay_templates.yml
629
+ - test/fixtures/foreman_datacenter/power_port_templates.yml
630
+ - test/fixtures/foreman_datacenter/console_ports.yml
631
+ - test/fixtures/foreman_datacenter/console_port_templates.yml
632
+ - test/fixtures/foreman_datacenter/device_types.yml
633
+ - test/fixtures/foreman_datacenter/power_outlets.yml
634
+ - test/fixtures/foreman_datacenter/console_server_ports.yml
635
+ - test/fixtures/foreman_datacenter/manufacturers.yml
636
+ - test/controllers/foreman_datacenter/manufacturers_contoller_test.rb
637
+ - test/controllers/foreman_datacenter/rack_groups_contoller_test.rb
638
+ - test/controllers/foreman_datacenter/device_roles_controller_test.rb
639
+ - test/controllers/foreman_datacenter/power_port_templates_contoller_test.rb
640
+ - test/controllers/foreman_datacenter/devices_controller_test.rb
641
+ - test/controllers/foreman_datacenter/sites_contoller_test.rb
642
+ - test/controllers/foreman_datacenter/device_types_contoller_test.rb
643
+ - test/controllers/foreman_datacenter/platforms_contoller_test.rb
644
+ - test/controllers/foreman_datacenter/manufacturers_controller_test.rb
645
+ - test/controllers/foreman_datacenter/racks_contoller_test.rb
646
+ - test/test_plugin_helper.rb
663
647
  - test/unit/foreman_datacenter_test.rb
664
648
  - test/datacenter_helper.rb
649
+ - test/factories/foreman_datacenter_factories.rb
650
+ - test/factories/rack.rb
651
+ - test/factories/device_role.rb
652
+ - test/factories/site.rb
653
+ - test/factories/device_type.rb
654
+ - test/factories/device.rb
655
+ - test/factories/rack_group.rb
656
+ - test/factories/manufacturer.rb
657
+ - test/factories/platform.rb
658
+ - test/integration/foreman_datacenter/device_role_test.rb
659
+ - test/integration/foreman_datacenter/manufacturer_test.rb
660
+ - test/integration/foreman_datacenter/rack_test.rb
661
+ - test/integration/foreman_datacenter/site_test.rb
662
+ - test/integration/foreman_datacenter/platform_test.rb
663
+ - test/integration/foreman_datacenter/rack_group_test.rb
664
+ - test/integration/foreman_datacenter/device_type_test.rb