foreman_discovery 1.1.1 → 1.2.0.rc1

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.
Files changed (44) hide show
  1. checksums.yaml +13 -5
  2. data/README.md +19 -71
  3. data/Rakefile +15 -16
  4. data/app/controllers/discovers_controller.rb +10 -11
  5. data/app/helpers/discovers_helper.rb +9 -9
  6. data/app/models/host/discovered.rb +6 -5
  7. data/app/models/host/managed_extensions.rb +2 -2
  8. data/app/models/setting/discovered.rb +8 -2
  9. data/app/overrides/add_dashboard_table.rb +9 -4
  10. data/app/views/discovers/_discovers_list.html.erb +14 -14
  11. data/app/views/discovers/_selected_hosts.html.erb +8 -4
  12. data/app/views/discovers/multiple_destroy.html.erb +2 -1
  13. data/app/views/discovers/select_multiple_location.html.erb +2 -2
  14. data/app/views/discovers/select_multiple_organization.html.erb +2 -2
  15. data/app/views/discovers/show.html.erb +4 -4
  16. data/config/initializers/discovery_setup.rb +0 -17
  17. data/extra/ovirt-node-plugin-foreman/COPYING +340 -0
  18. data/extra/ovirt-node-plugin-foreman/Makefile.am +60 -0
  19. data/extra/ovirt-node-plugin-foreman/README.md +217 -0
  20. data/extra/ovirt-node-plugin-foreman/autogen.sh +66 -0
  21. data/extra/ovirt-node-plugin-foreman/conf/Makefile.am +29 -0
  22. data/extra/ovirt-node-plugin-foreman/conf/foreman-plugin.firewall.in +4 -0
  23. data/extra/ovirt-node-plugin-foreman/conf/foreman-plugin.logs +2 -0
  24. data/extra/ovirt-node-plugin-foreman/configure.ac +62 -0
  25. data/extra/ovirt-node-plugin-foreman/ovirt-node-plugin-foreman.spec.in +145 -0
  26. data/extra/ovirt-node-plugin-foreman/recipe/Makefile.am +33 -0
  27. data/extra/ovirt-node-plugin-foreman/recipe/foreman-plugin-iso.ks +5 -0
  28. data/extra/ovirt-node-plugin-foreman/recipe/foreman-plugin-minimizer.ks +160 -0
  29. data/extra/ovirt-node-plugin-foreman/src/Makefile.am +32 -0
  30. data/extra/ovirt-node-plugin-foreman/src/discover-host.rb.in +186 -0
  31. data/extra/ovirt-node-plugin-foreman/src/discover-host.service +14 -0
  32. data/extra/ovirt-node-plugin-foreman/src/discovery-version-fact.rb.in +25 -0
  33. data/extra/ovirt-node-plugin-foreman/src/find-missing-libs +35 -0
  34. data/lib/{tasks.rake → discovery.rake} +22 -0
  35. data/lib/foreman_discovery/engine.rb +39 -7
  36. data/lib/foreman_discovery/version.rb +1 -1
  37. data/test/functional/discovers_controller_test.rb +3 -16
  38. data/test/test_helper.rb +2 -2
  39. data/test/test_plugin_helper.rb +6 -0
  40. data/test/unit/facts.json +92 -0
  41. data/test/unit/host_discovered_test.rb +20 -2
  42. metadata +55 -37
  43. data/lib/discovery_home_helper_patch.rb +0 -18
  44. data/test/unit/facts.yml +0 -91
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 321fccd57e6e597e9d144fbdfed50b2ebf31060a
4
- data.tar.gz: d51274ca2f006f8c2ceb300a1cb7690c80eb4aeb
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ N2Q3YTViNGViOWY1MjE4NTQ3MzE2NDE2MGExYTQyYmNlOGIzMWY0YQ==
5
+ data.tar.gz: !binary |-
6
+ YmM5OTJjNDAwNmZhNTcyZTRhMzkwYjlhY2FkNzY3ZGFiNzUzYjc1ZA==
5
7
  SHA512:
6
- metadata.gz: 397579ca7a041155026bfdd6d1bd4ff189319e4f980c41a9ae706dc1e7c1444eefbc70c05eeed8bf3ea812dbf394d0206850f5a91303636b5e10f064003b174b
7
- data.tar.gz: bcb39a17222301d169f9b06ec1dadf281bfe528683370d64ae2abe5fc7260fa4f6268ce1ade4641b9f26edab3323edf55e3279fff3a085297df84661418c586b
8
+ metadata.gz: !binary |-
9
+ MWZjMGJjYTNkMjYyZTY3YzhjMGQ1ZTAzYTg3YjIxMTQ2ZmI3NmY4MmIzMTgx
10
+ MGVlOGM5MjY3YzViZDZiZTFkYzVhZDMyNzNiMmI2MjYyOTk3NDdlMDVmM2U4
11
+ MDBkYWRlYWE3OGZkNzIxMWYzZWZjOTBhZjUxOWJhNzY4YjBkOGM=
12
+ data.tar.gz: !binary |-
13
+ ZjNmOTFkMzk3ZWQwNzIxODRjZGYwNjQyMjM5ODE4YTdkNGRhMDgxYjgyZWYw
14
+ MjU5YTFlYzE1NTk3ODg1OTk3YjY0Y2U5MWVjNGE2ZjVkMDEyNzYzYmEyNWE4
15
+ MzNjYTNlMTI0ODg5NDExYTJmY2MzODI5MDdkMWJlZWQ3OTgxODY=
data/README.md CHANGED
@@ -4,15 +4,21 @@ This plugin enables MaaS hardware discovery in Foreman.
4
4
 
5
5
  ## Installation
6
6
 
7
- See [How_to_Install_a_Plugin](http://projects.theforeman.org/projects/foreman/wiki/How_to_Install_a_Plugin)
8
- for how to install Foreman plugins
7
+ Please see the Foreman wiki for appropriate instructions:
8
+
9
+ * [Foreman: How to Install a Plugin](http://projects.theforeman.org/projects/foreman/wiki/How_to_Install_a_Plugin)
10
+
11
+ The gem name is "foreman_discovery".
12
+
13
+ RPM users can install the "ruby193-rubygem-foreman_discovery" or
14
+ "rubygem-foreman_discovery" packages.
9
15
 
10
16
  ## Compatibility
11
17
 
12
- | Foreman Version | Plugin Version |
13
- | --------------- | --------------:|
14
- | <= 1.2 | 1.0.2 |
15
- | >= 1.3 | 1.1.0 |
18
+ | Foreman Version | Plugin Version | oVirt Image Version |
19
+ | --------------- | --------------:| -------------------:|
20
+ | <= 1.2 | 1.0.2 | N/A |
21
+ | >= 1.3 | 1.1.0 | 0.1.0 |
16
22
 
17
23
  ## Latest code
18
24
 
@@ -20,77 +26,18 @@ You can get the develop branch of the plugin by specifying your Gemfile in this
20
26
 
21
27
  gem 'foreman_discovery', :git => "https://github.com/theforeman/foreman_discovery.git"
22
28
 
23
- # Building the Discovery PXE Image
29
+ # Building or downloading an image
24
30
 
25
- There is a rake task for the discovery image. It requires Ruby 1.8, but should
26
- appropriately detect and use ruby1.8 even if the system default is 1.9. If you
27
- have trouble building it, try a ruby1.8-only system.
31
+ There are two options at the moment:
28
32
 
29
- Run this rake task to create the image:
33
+ * [Build or download Tiny Core Linux based image](README.tcl_image.md)
34
+ * [Build or download oVirt Node based image](README.ovirt_image.md)
30
35
 
31
- foreman-rake discovery:build_image
32
-
33
- You image will be in ./discovery\_image. Run the rake task as root, or with passwordless
34
- sudo, as the password prompts may get lost in the ruby->bash forking process.
36
+ The TCL image has the same version as the Foreman Discovery plugin, the oVirt
37
+ Node image has different versioning scheme.
35
38
 
36
39
  # Configuration
37
40
 
38
- ## Image configuration
39
-
40
- The PXE image has two configuration options during build:
41
-
42
- * By default it will have an automatic login to the 'tc' user and start ssh so you can
43
- ssh to `tc@<ip>` with password test1234. By specifying `mode=prod` on the rake task,
44
- you can disable both of these - the image will have no accounts that can be logged in
45
- * If you need to add additional files to the image, put them in `./additional_build_files/` -
46
- these will be copied to `/additional_build_files/` in the image
47
-
48
- Also, it will attempt todownload `/discovery_init.sh` from your Foreman server and run
49
- it. This is entirely optional - if the server cannot be reached or the file cannot be
50
- found, the image has a fallback script built in.
51
-
52
- You can find an example script [here](extra/discovery_init.sh.example) - place your
53
- modified version in the `public/` directory on your Foreman server.
54
-
55
- ## PXE config
56
-
57
- Configure the PXE default to boot the Discovery Image built above, eg:
58
-
59
- DEFAULT menu
60
- PROMPT 0
61
- MENU TITLE PXE Menu
62
- TIMEOUT 200
63
- TOTALTIMEOUT 6000
64
- ONTIMEOUT discovery
65
-
66
- LABEL discovery
67
- MENU LABEL Boot Discovery
68
- TEXT HELP
69
- Boot the Foreman Discovery Image
70
- Use TAB to edit options for specific needs.
71
- ENDTEXT
72
- KERNEL /boot/TinyCore-vmlinuz
73
- APPEND initrd=/boot/TinyCore-initrd.gz foreman.ip=192.168.122.1:3000
74
-
75
- Be sure to alter the foreman.ip appropriately. You can also use foreman.server to
76
- specify a DNS record (`foreman.server=myforemanhost`) but in this case the port will
77
- be assumed to be http (80). If all else fails (say, USB boot where we can't provide
78
- options) it will look for a DNS record of `foreman`
79
-
80
- ### Known Issues with the image
81
-
82
- On some multi-core systems the TinyCore kernel may segfault on boot with an error message similar to :
83
-
84
- "Fixing recursive fault but reboot is needed!"
85
-
86
- If this happens, it can be fixed by changing the KERNEL line in the PXE config above to read :
87
-
88
- KERNEL /boot/TinyCore-vmlinuz maxcpus=1
89
-
90
- More information on the maxcpus kernel parameter can be found at <https://www.kernel.org/doc/Documentation/kernel-parameters.txt>
91
-
92
- A currently unavoidable side effect of this setting is that the initial facts gathered during discovery will only show a single processor, since that is all that is visible to the kernel.
93
-
94
41
  ## UI config
95
42
 
96
43
  No configuration of the Foreman UI is required. If you are using Locations and/or Organisations,
@@ -128,6 +75,7 @@ assign the `:perform_discovery` permission to an existing Role.
128
75
 
129
76
  # TODO
130
77
 
78
+ * Support for downloading shell script for oVirt Node image
131
79
  * Add more Tests
132
80
  * Add API
133
81
  * Add proper Location/Organization handling (via a Wizard maybe?)
data/Rakefile CHANGED
@@ -6,11 +6,15 @@ require 'fileutils'
6
6
 
7
7
  task :default => :test
8
8
 
9
+ PLUGIN_NAME = "discovery"
9
10
  ENGINE_DIR = File.expand_path('..', __FILE__)
10
- FOREMAN_DIR = 'test/foreman_app'
11
+ FOREMAN_DIR = '.foreman_app'
11
12
 
12
- namespace :test do
13
- desc "Download latest foreman devel source and install dependencies"
13
+ ENV['TEXTDOMAIN'] = PLUGIN_NAME
14
+ import "#{FOREMAN_DIR}/Rakefile" if File.exists? "#{FOREMAN_DIR}/Rakefile"
15
+
16
+ namespace :setup do
17
+ desc "Download latest foreman core devel source and install dependencies"
14
18
  task :foreman_prepare do
15
19
  foreman_repo = 'https://github.com/theforeman/foreman.git'
16
20
  foreman_gemfile = File.join(FOREMAN_DIR, "Gemfile")
@@ -19,20 +23,12 @@ namespace :test do
19
23
  puts "Downloading latest Foreman development branch into #{FOREMAN_DIR}..."
20
24
  FileUtils.mkdir_p(FOREMAN_DIR)
21
25
 
22
- unless system("git clone #{foreman_repo} #{FOREMAN_DIR}")
26
+ unless system("git clone --depth 1 #{foreman_repo} #{FOREMAN_DIR}")
23
27
  puts "Error while getting latest Foreman code from #{foreman_repo} into #{FOREMAN_DIR}"
24
28
  fail
25
29
  end
26
30
  end
27
31
 
28
- gemfile_content = File.read(foreman_gemfile)
29
- unless gemfile_content.include?('FOREMAN_GEMFILE')
30
- puts 'Preparing Gemfile'
31
- gemfile_content.gsub!('__FILE__', 'FOREMAN_GEMFILE')
32
- gemfile_content.insert(0, "FOREMAN_GEMFILE = __FILE__ unless defined? FOREMAN_GEMFILE\n")
33
- File.open(foreman_gemfile, 'w') { |f| f << gemfile_content }
34
- end
35
-
36
32
  settings_file = "#{FOREMAN_DIR}/config/settings.yaml"
37
33
  unless File.exists?(settings_file)
38
34
  puts 'Preparing settings file'
@@ -79,7 +75,7 @@ GEMFILE
79
75
  puts <<MESSAGE
80
76
  Foreman source code not prepared. Run
81
77
 
82
- rake test:foreman_prepare
78
+ rake setup:foreman_prepare
83
79
 
84
80
  to download foreman source and its dependencies
85
81
  MESSAGE
@@ -96,16 +92,19 @@ MESSAGE
96
92
  FileUtils.cd(pwd)
97
93
  end
98
94
 
95
+ task :all => [:foreman_prepare, :db_prepare]
96
+ end
97
+
98
+ namespace :test do
99
99
  task :set_loadpath do
100
100
  %w[lib test].each do |dir|
101
101
  $:.unshift(File.expand_path(dir, ENGINE_DIR))
102
102
  end
103
103
  end
104
104
 
105
- task :all => [:db_prepare, :set_loadpath] do
106
- Dir.glob('test/**/*_test.rb') { |f| require f.sub('test/','') unless f.include? '/foreman_app/' }
105
+ task :all => ['setup:db_prepare', 'test:set_loadpath'] do
106
+ Dir.glob('test/**/*_test.rb') { |f| require f.sub('test/','') unless f.include? '.foreman_app/' }
107
107
  end
108
-
109
108
  end
110
109
 
111
110
  task :test => 'test:all'
@@ -82,9 +82,9 @@ class DiscoversController < ::ApplicationController
82
82
 
83
83
  def refresh_facts
84
84
  if @host.is_a?(::Host::Discovered) and @host.refresh_facts
85
- process_success :success_msg => "Facts refreshed for #{@host.name}", :success_redirect => :back
85
+ process_success :success_msg => _("Facts refreshed for %s") % @host.name, :success_redirect => :back
86
86
  else
87
- process_error :error_msg => "Failed to refresh facts for #{@host.name}", :redirect => :back
87
+ process_error :error_msg => _("Failed to refresh facts for %s") % @host.name, :redirect => :back
88
88
  end
89
89
  end
90
90
 
@@ -97,9 +97,9 @@ class DiscoversController < ::ApplicationController
97
97
 
98
98
  missed_hosts = @hosts.map(&:name).join('<br/>')
99
99
  if @hosts.empty?
100
- notice "Destroyed selected hosts"
100
+ notice _("Destroyed selected hosts")
101
101
  else
102
- error "The following hosts were not deleted: #{missed_hosts}"
102
+ error _("The following hosts were not deleted: %s") % missed_hosts
103
103
  end
104
104
  redirect_to(discovers_path)
105
105
  end
@@ -154,16 +154,16 @@ class DiscoversController < ::ApplicationController
154
154
  if params[:host_names].present? or params[:host_ids].present?
155
155
  @hosts = Host::Discovered.where("id IN (?) or name IN (?)", params[:host_ids], params[:host_names] )
156
156
  if @hosts.empty?
157
- error 'No hosts were found with that id or name'
157
+ error _('No hosts were found with that id or name')
158
158
  redirect_to(discovers_path) and return false
159
159
  end
160
160
  else
161
- error 'No Hosts selected'
161
+ error _('No hosts selected')
162
162
  redirect_to(discovers_path) and return false
163
163
  end
164
164
 
165
165
  rescue => e
166
- error "Something went wrong while selecting hosts - #{e}"
166
+ error _("Something went wrong while selecting hosts - %s") % e
167
167
  redirect_to discovers_path
168
168
  end
169
169
 
@@ -177,15 +177,14 @@ class DiscoversController < ::ApplicationController
177
177
  # Check for explicit parameter override
178
178
  ip = params.delete('ip') if params.include?('ip')
179
179
 
180
- Rails.logger.info ip.inspect
181
180
  # in case we got back multiple ips (see #1619)
182
181
  ip = ip.split(',').first
183
182
  end
184
183
 
185
184
  def taxonomy_scope
186
- if params[:host]
187
- @organization = Organization.find_by_id(params[:host][:organization_id])
188
- @location = Location.find_by_id(params[:host][:location_id])
185
+ if @host
186
+ @organization = @host.organization
187
+ @location = @host.location
189
188
  end
190
189
 
191
190
  if SETTINGS[:organizations_enabled]
@@ -1,31 +1,31 @@
1
1
  module DiscoversHelper
2
2
 
3
3
  def disc_report_column(record)
4
- return record.last_report? ? time_ago_in_words(record.last_report.getlocal) +" ago": ""
4
+ record.last_report? ? (_("%s ago") % time_ago_in_words(record.last_report.getlocal)) : ""
5
5
  end
6
6
 
7
7
  def discovers_title_actions(host)
8
8
  title_actions(
9
9
  button_group(
10
- link_to("Provision", hash_for_edit_discover_path(:id => host), :class => 'btn-primary')
10
+ link_to(_("Provision"), hash_for_edit_discover_path(:id => host), :class => 'btn-primary')
11
11
  ),
12
12
  button_group(
13
- link_to("Refresh Facts", hash_for_refresh_facts_discover_path(:id => host))
13
+ link_to(_("Refresh facts"), hash_for_refresh_facts_discover_path(:id => host))
14
14
  ),
15
15
  button_group(
16
- link_to("Delete", hash_for_discover_path(:id => host),
17
- :class => "btn btn-danger", :confirm => 'Are you sure?', :method => :delete)
16
+ link_to(_("Delete"), hash_for_discover_path(:id => host),
17
+ :class => "btn btn-danger", :confirm => _('Are you sure?'), :method => :delete)
18
18
  )
19
19
  )
20
20
  end
21
21
 
22
22
  def multiple_discovers_actions_select
23
- actions = [['Delete Hosts', multiple_destroy_discovers_path, 'trash']]
24
- actions << ['Assign Organization', select_multiple_organization_discovers_path, 'tags'] if SETTINGS[:organizations_enabled]
25
- actions << ['Assign Location', select_multiple_location_discovers_path, 'map-marker'] if SETTINGS[:locations_enabled]
23
+ actions = [[_('Delete hosts'), multiple_destroy_discovers_path, 'trash']]
24
+ actions << [_('Assign Organization'), select_multiple_organization_discovers_path, 'tags'] if SETTINGS[:organizations_enabled]
25
+ actions << [_('Assign Location'), select_multiple_location_discovers_path, 'map-marker'] if SETTINGS[:locations_enabled]
26
26
 
27
27
  content_tag :span, :id => 'submit_multiple' do
28
- select_action_button( _("Select Action"), actions.map do |action|
28
+ select_action_button( _("Select action"), actions.map do |action|
29
29
  link_to(icon_text(action[2], action[0]) , action[1], :class=>'btn', :title => _("%s - The following hosts are about to be changed") % action[0])
30
30
  end.flatten)
31
31
  end
@@ -23,16 +23,17 @@ class Host::Discovered < ::Host::Base
23
23
 
24
24
  def self.importHostAndFacts facts
25
25
  raise(::Foreman::Exception.new("Invalid Facts, must be a Hash")) unless facts.is_a?(Hash)
26
- hostname = facts["macaddress_eth0"].try(:downcase).try(:gsub,/:/,'')
27
- raise(::Foreman::Exception.new("Invalid facts: hash does not contain macaddress_eth0 to use as hostname")) unless hostname
26
+ fact_name = Setting[:discovery_fact] || 'macaddress'
27
+ hostname = facts[fact_name].try(:downcase).try(:gsub,/:/,'')
28
+ raise(::Foreman::Exception.new("Invalid facts: hash does not contain the required fact '#{fact_name}'")) unless hostname
28
29
 
29
30
  # filter facts
30
- facts.reject!{|k,v| k =~ /kernel|operatingsystem|osfamily|ruby|path|time|swap|free|filesystem|version/i }
31
+ facts.reject!{|k,v| k =~ /kernel|operatingsystem|osfamily|ruby|path|time|swap|free|filesystem/i }
31
32
 
32
33
  h = ::Host::Discovered.find_by_name hostname
33
34
  h ||= Host.new :name => hostname, :type => "Host::Discovered"
34
35
  h.type = "Host::Discovered"
35
- h.mac = facts["macaddress_eth0"].try(:downcase)
36
+ h.mac = facts[fact_name].try(:downcase)
36
37
 
37
38
  if SETTINGS[:locations_enabled]
38
39
  begin
@@ -77,7 +78,7 @@ class Host::Discovered < ::Host::Base
77
78
  logger.debug "retrieving facts from proxy on ip: #{self.ip}"
78
79
  facts = ForemanDiscovery::Facts.new(:url => "http://#{self.ip}:8443").facts
79
80
  rescue Exception => e
80
- raise "Could not get facts from Proxy: #{e}"
81
+ raise _("Could not get facts from proxy: %s") % e
81
82
  end
82
83
 
83
84
  return self.class.importHostAndFacts facts
@@ -9,7 +9,7 @@ module Host::ManagedExtensions
9
9
  def queue_reboot
10
10
  return if new_record? # Discovered Hosts already exist, and new_records will break `find`
11
11
  return unless type_changed? and ::Host::Base.find(self.id).type == "Host::Discovered"
12
- post_queue.create(:name => "Rebooting #{self}", :priority => 10000,
12
+ post_queue.create(:name => _("Rebooting %s") % self, :priority => 10000,
13
13
  :action => [self, :setReboot])
14
14
  end
15
15
 
@@ -21,7 +21,7 @@ module Host::ManagedExtensions
21
21
  logger.info "ForemanDiscovery: reboot result: failed"
22
22
  end
23
23
  rescue => e
24
- failure "Failed to reboot: #{proxy_error e}"
24
+ failure _("Failed to reboot: %s") % proxy_error(e)
25
25
  end
26
26
 
27
27
  def delReboot
@@ -6,17 +6,23 @@ class Setting::Discovered < ::Setting
6
6
  # Check the table exists
7
7
  return unless super
8
8
 
9
+ Setting.transaction do
10
+ [
11
+ self.set('discovery_fact', _("The default fact name to use for the MAC of the system"), "macaddress"),
12
+ ].compact.each { |s| self.create s.update(:category => "Setting::Discovered")}
13
+ end
14
+
9
15
  if SETTINGS[:locations_enabled]
10
16
  Setting.transaction do
11
17
  [
12
- self.set('discovery_location', "The default Location to place Discovered Hosts in", ""),
18
+ self.set('discovery_location', _("The default location to place discovered hosts in"), ""),
13
19
  ].compact.each { |s| self.create s.update(:category => "Setting::Discovered")}
14
20
  end
15
21
  end
16
22
  if SETTINGS[:organizations_enabled]
17
23
  Setting.transaction do
18
24
  [
19
- self.set('discovery_organization', "The default Organization to place Discovered Hosts in", "" ),
25
+ self.set('discovery_organization', _("The default organization to place discovered hosts in"), "" ),
20
26
  ].compact.each { |s| self.create s.update(:category => "Setting::Discovered")}
21
27
  end
22
28
  end
@@ -1,11 +1,16 @@
1
1
  Deface::Override.new(:virtual_path => "dashboard/_status_table",
2
2
  :name => "add_dashboard_table",
3
3
  :insert_after => "ul:last",
4
- :text => '
5
- <h4 class="header"><%= "Host Pool" -%></h4>
4
+ :text => ("
5
+ <h4 class='header'><%= _('Host Pool') %></h4>
6
6
  <ul>
7
7
  <li>
8
- <%= link_to("Unassigned Hosts", discovers_path, :class=>"dashboard-links" ) %>
8
+ <%= link_to(_('Unassigned hosts'), discovers_path, :class=>'dashboard-links' ) %>
9
9
  <h4><%= Host::Discovered.count %></h4>
10
10
  </li>
11
- </ul>')
11
+ </ul>"))
12
+
13
+ # strings used above, for the purposes of extraction only, as they're not
14
+ # detected within the full override template string above
15
+ N_('Host Pool')
16
+ N_('Unassigned hosts')
@@ -1,18 +1,18 @@
1
1
  <%= javascript "jquery.cookie", "host_checkbox" %>
2
- <% title 'Discovered Hosts' %>
2
+ <% title _('Discovered hosts') %>
3
3
  <table class="table table-bordered table-striped table-condensed" >
4
4
  <tr>
5
5
  <th class="ca"><%= check_box_tag "check_all", "", false, { :onclick => "toggleCheck()", :'check-title' => _("Select all items in this page"), :'uncheck-title'=> _("items selected. Uncheck to Clear") } %></th>
6
- <th class=''><%= sort :name %></th>
7
- <th class="hidden-tablet hidden-phone"><%= sort :model %></th>
6
+ <th class=''><%= sort :name, :as => _('Name') %></th>
7
+ <th class="hidden-tablet hidden-phone"><%= sort :model, :as => _('Model') %></th>
8
8
  <% if SETTINGS[:locations_enabled] -%>
9
- <th class="hidden-tablet hidden-phone"><%= sort :location %></th>
9
+ <th class="hidden-tablet hidden-phone"><%= sort :location, :as => _('Location') %></th>
10
10
  <% end -%>
11
11
  <% if SETTINGS[:organizations_enabled] -%>
12
- <th class="hidden-tablet hidden-phone"><%= sort :organization %></th>
12
+ <th class="hidden-tablet hidden-phone"><%= sort :organization, :as => _('Organization') %></th>
13
13
  <% end -%>
14
- <th class="hidden-tablet hidden-phone"><%= sort :subnet, :as => "Subnet" %></th>
15
- <th class="hidden-tablet hidden-phone"><%= sort :last_report, :as => "Facts last received" %></th>
14
+ <th class="hidden-tablet hidden-phone"><%= sort :subnet, :as => _("Subnet") %></th>
15
+ <th class="hidden-tablet hidden-phone"><%= sort :last_report, :as => _("Last facts upload") %></th>
16
16
  <th></th>
17
17
  </tr>
18
18
  <% @hosts.each do |host| -%>
@@ -32,9 +32,9 @@
32
32
  <td class="hidden-tablet hidden-phone"><%= disc_report_column(host) %></td>
33
33
  <td>
34
34
  <%= action_buttons(
35
- link_to("Provision", hash_for_edit_discover_path(:id => host)),
36
- link_to("Refresh Facts", hash_for_refresh_facts_discover_path(:id => host)),
37
- display_delete_if_authorized(hash_for_discover_path(:id => host), :confirm => "Delete #{host.name}?", :action => :destroy))%>
35
+ link_to(_("Provision"), hash_for_edit_discover_path(:id => host)),
36
+ link_to(_("Refresh facts"), hash_for_refresh_facts_discover_path(:id => host)),
37
+ display_delete_if_authorized(hash_for_discover_path(:id => host), :confirm => _("Delete %s?") % host.name, :action => :destroy))%>
38
38
  </td>
39
39
  </tr>
40
40
  <% end -%>
@@ -43,14 +43,14 @@
43
43
  <div id="confirmation-modal" class="modal hide fade">
44
44
  <div class="modal-header">
45
45
  <a href="#" class="close" data-dismiss="modal">×</a>
46
- <h3>Please Confirm</h3>
46
+ <h3><%= _('Please Confirm') %></h3>
47
47
  </div>
48
48
  <div class="modal-body"></div>
49
49
  <div class="modal-footer">
50
- <a href="#" class="btn btn-primary">Submit</a>
51
- <a href="#" class="btn secondary">Cancel</a>
50
+ <a href="#" class="btn btn-primary"><%= _('Submit') %></a>
51
+ <a href="#" class="btn secondary"><%= _('Cancel') %></a>
52
52
  </div>
53
53
  </div>
54
54
 
55
- <%= page_entries_info @hosts, :model => 'Hosts' %>
55
+ <%= page_entries_info @hosts %>
56
56
  <%= will_paginate @hosts %>
@@ -4,10 +4,14 @@
4
4
  <table class="table table-bordered table-striped">
5
5
  <thead>
6
6
  <tr>
7
- <th> Name </th>
8
- <th> Model </th>
9
- <%= raw("<th>Location</th>") if SETTINGS[:locations_enabled]%>
10
- <%= raw("<th>Organization</th>") if SETTINGS[:organizations_enabled]%>
7
+ <th><%= _('Name') %></th>
8
+ <th><%= _('Model') %></th>
9
+ <% if SETTINGS[:locations_enabled] %>
10
+ <th><%= _('Location') %></th>
11
+ <% end %>
12
+ <% if SETTINGS[:organizations_enabled] %>
13
+ <th><%= _('Organization') %></th>
14
+ <% end %>
11
15
  </tr>
12
16
  </thead>
13
17
  <tbody>
@@ -1,5 +1,6 @@
1
1
  <%= render 'selected_hosts', :hosts => @hosts %>
2
2
 
3
3
  <%= form_tag submit_multiple_destroy_hosts_path(:host_ids => params[:host_ids]), :onsubmit => "resetSelection()" do -%>
4
- <span class="label label-warning">Warning</span> This might take a while, as all hosts, facts and reports will be destroyed as well
4
+ <span class="label label-warning"><%= _('Warning') -%></span>
5
+ <%= _('This might take a while, as all hosts, facts and reports will be destroyed as well') %>
5
6
  <% end %>
@@ -2,9 +2,9 @@
2
2
  <div class="row">
3
3
  <div class="span8">
4
4
  <%= form_for :location, :url => update_multiple_location_hosts_path(:host_ids => params[:host_ids]) do |f| %>
5
- <%= f.select :id, Location.all.map{|e| [e.name, e.id]},{:include_blank => "Select Location"},
5
+ <%= f.select :id, Location.all.map{|e| [e.name, e.id]},{:include_blank => _("Select location")},
6
6
  :onchange => "toggle_multiple_ok_button(this)" %>
7
7
  <%= f.hidden_field :optimistic_import, :value => "yes" %>
8
8
  <% end %>
9
9
  </div>
10
- </div>
10
+ </div>
@@ -2,9 +2,9 @@
2
2
  <div class="row">
3
3
  <div class="span8">
4
4
  <%= form_for :organization, :url => update_multiple_organization_hosts_path(:host_ids => params[:host_ids]) do |f| %>
5
- <%= f.select :id, Organization.all.map{|e| [e.name, e.id]},{:include_blank => "Select Organization"},
5
+ <%= f.select :id, Organization.all.map{|e| [e.name, e.id]},{:include_blank => _("Select organization")},
6
6
  :onchange => "toggle_multiple_ok_button(this)" %>
7
7
  <%= f.hidden_field :optimistic_import, :value => "yes" %>
8
8
  <% end %>
9
9
  </div>
10
- </div>
10
+ </div>
@@ -1,12 +1,12 @@
1
- <% title "Discovered Host: #{@host.to_label}" %>
1
+ <% title(_("Discovered host: %s") % @host.to_label) %>
2
2
 
3
3
  <%= discovers_title_actions(@host) %>
4
4
 
5
- <h3> Facts Discovered on this Host </h3>
5
+ <h3><%= _('Facts discovered on this host') -%></h3>
6
6
  <table class="table table-bordered table-striped table-condensed">
7
7
  <tr>
8
- <th>Fact</th>
9
- <th>Value</th>
8
+ <th><%= _('Fact') -%></th>
9
+ <th><%= _('Value') -%></th>
10
10
  <% @host.facts_hash.sort.each do |fact| -%>
11
11
  <tr>
12
12
  <td><%= fact[0] %></td>
@@ -1,18 +1 @@
1
- # Add permissions
2
- Foreman::AccessControl.map do |map|
3
- map.security_block :discovery do |map|
4
- map.permission :perform_discovery, {:discovers => [:index, :show, :update, :new,
5
- :edit, :destroy, :create, :auto_complete_search, :select_multiple_organization,
6
- :update_multiple_organization, :select_multiple_location, :refresh_facts,
7
- :update_multiple_location, :submit_multiple_destroy, :multiple_destroy]}
8
- end
9
- end
10
1
 
11
- begin
12
- # Add a new role called 'Discovery' if it doesn't exist
13
- Role.transaction do
14
- role = Role.find_or_create_by_name("Discovery")
15
- role.update_attribute :permissions, [:perform_discovery] if role.permissions.empty?
16
- end
17
- rescue
18
- end