foreman-hosts 0.0.1dev

Sign up to get free protection for your applications and to get access to all the features.
data/bin/foreman-hosts ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ foreman_root = "/usr/share/foreman"
4
+ require File.expand_path('./config/application', foreman_root)
5
+ ForemanUsers::Dynflow::Daemon.new.run_background(ARGV.last, :foreman_root => foreman_root)
data/config/routes.rb ADDED
@@ -0,0 +1,5 @@
1
+ Rails.application.routes.draw do
2
+ match 'new_action', to: 'foreman_hosts/hosts#new_action'
3
+ match 'export', to: 'foreman_hosts/hosts#export'
4
+ match 'report_index', to: 'foreman_hosts/hosts#report_index'
5
+ end
@@ -0,0 +1,4 @@
1
+ require 'foreman_hosts/engine'
2
+
3
+ module ForemanHosts
4
+ end
@@ -0,0 +1,86 @@
1
+ require 'deface'
2
+
3
+ module ForemanHosts
4
+ class Engine < ::Rails::Engine
5
+ engine_name 'foreman_hosts'
6
+
7
+ config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
8
+ config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]
9
+ config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
10
+ config.autoload_paths += Dir["#{config.root}/app/overrides"]
11
+
12
+ # Add any db migrations
13
+ initializer 'foreman_hosts.load_app_instance_data' do |app|
14
+ app.config.paths['db/migrate'] += ForemanHosts::Engine.paths['db/migrate'].existent
15
+ end
16
+
17
+ initializer 'foreman_hosts.register_plugin', after: :finisher_hook do |_app|
18
+ Foreman::Plugin.register :foreman_hosts do
19
+ requires_foreman '>= 1.4'
20
+
21
+ # Add permissions
22
+ security_block :foreman_hosts do
23
+ permission :view_foreman_hosts, :'foreman_hosts/hosts' => [:new_action]
24
+ permission :view_foreman_hosts, :'foreman_hosts/hosts' => [:export]
25
+ permission :view_foreman_hosts, :'foreman_hosts/hosts' => [:report_index]
26
+ end
27
+
28
+ # Add a new role called 'Discovery' if it doesn't exist
29
+ role 'ForemanHosts', [:view_foreman_hosts]
30
+
31
+ # add menu entry
32
+ menu :top_menu, :template,
33
+ url_hash: { controller: :'foreman_hosts/hosts', action: :new_action },
34
+ url_hash: { controller: :'foreman_hosts/hosts', action: :export },
35
+ url_hash: { controller: :'foreman_hosts/hosts', action: :report_index },
36
+ caption: 'ForemanHosts',
37
+ parent: :hosts_menu,
38
+ after: :hosts
39
+
40
+ # add dashboard widget
41
+ widget 'foreman_hosts_widget', name: N_('Foreman plugin template widget'), sizex: 4, sizey: 1
42
+ end
43
+ end
44
+
45
+ # Precompile any JS or CSS files under app/assets/
46
+ # If requiring files from each other, list them explicitly here to avoid precompiling the same
47
+ # content twice.
48
+ assets_to_precompile =
49
+ Dir.chdir(root) do
50
+ Dir['app/assets/javascripts/**/*', 'app/assets/stylesheets/**/*'].map do |f|
51
+ f.split(File::SEPARATOR, 4).last
52
+ end
53
+ end
54
+ initializer 'foreman_hosts.assets.precompile' do |app|
55
+ app.config.assets.precompile += assets_to_precompile
56
+ end
57
+ initializer 'foreman_hosts.configure_assets', group: :assets do
58
+ SETTINGS[:foreman_hosts] = { assets: { precompile: assets_to_precompile } }
59
+ end
60
+
61
+ # Include concerns in this config.to_prepare block
62
+ config.to_prepare do
63
+ begin
64
+ Host::Managed.send(:include, ForemanHosts::HostExtensions)
65
+ HostsHelper.send(:include, ForemanHosts::HostsHelperExtensions)
66
+ rescue => e
67
+ Rails.logger.warn "ForemanHosts: skipping engine hook (#{e})"
68
+ end
69
+ end
70
+
71
+ rake_tasks do
72
+ Rake::Task['db:seed'].enhance do
73
+ ForemanHosts::Engine.load_seed
74
+ end
75
+ end
76
+
77
+ initializer 'foreman_hosts.register_gettext', after: :load_config_initializers do |_app|
78
+ locale_dir = File.join(File.expand_path('../../..', __FILE__), 'locale')
79
+ locale_domain = 'foreman_hosts'
80
+ Foreman::Gettext::Support.add_text_domain locale_domain, locale_dir
81
+ end
82
+ initializer "foreman_chef.load_app_instance_data" do |app|
83
+ app.config.paths['db/migrate'] += PluginTemplate::Engine.paths['db/migrate'].existent
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,3 @@
1
+ module ForemanHosts
2
+ VERSION = '0.0.1dev'
3
+ end
@@ -0,0 +1,49 @@
1
+ # Tasks
2
+ namespace :foreman_hosts do
3
+ namespace :example do
4
+ desc 'Example Task'
5
+ task task: :environment do
6
+ # Task goes here
7
+ end
8
+ end
9
+ end
10
+
11
+ # Tests
12
+ namespace :test do
13
+ desc 'Test ForemanHosts'
14
+ Rake::TestTask.new(:foreman_hosts) do |t|
15
+ test_dir = File.join(File.dirname(__FILE__), '../..', 'test')
16
+ t.libs << ['test', test_dir]
17
+ t.pattern = "#{test_dir}/**/*_test.rb"
18
+ t.verbose = true
19
+ end
20
+ end
21
+
22
+ namespace :foreman_hosts do
23
+ task :rubocop do
24
+ begin
25
+ require 'rubocop/rake_task'
26
+ RuboCop::RakeTask.new(:rubocop_foreman_hosts) do |task|
27
+ task.patterns = ["#{ForemanHosts::Engine.root}/app/**/*.rb",
28
+ "#{ForemanHosts::Engine.root}/lib/**/*.rb",
29
+ "#{ForemanHosts::Engine.root}/test/**/*.rb"]
30
+ end
31
+ rescue
32
+ puts 'Rubocop not loaded.'
33
+ end
34
+
35
+ Rake::Task['rubocop_foreman_hosts'].invoke
36
+ end
37
+ end
38
+
39
+ Rake::Task[:test].enhance do
40
+ Rake::Task['test:foreman_hosts'].invoke
41
+ end
42
+
43
+ load 'tasks/jenkins.rake'
44
+ if Rake::Task.task_defined?(:'jenkins:unit')
45
+ Rake::Task['jenkins:unit'].enhance do
46
+ Rake::Task['test:foreman_hosts'].invoke
47
+ Rake::Task['foreman_hosts:rubocop'].invoke
48
+ end
49
+ end
data/locale/Makefile ADDED
@@ -0,0 +1,62 @@
1
+ #
2
+ # Makefile for PO merging and MO generation. More info in the README.
3
+ #
4
+ # make all-mo (default) - generate MO files
5
+ # make check - check translations using translate-tool
6
+ # make tx-update - download and merge translations from Transifex
7
+ # make clean - clean everything
8
+ #
9
+ DOMAIN = foreman_hosts
10
+ VERSION = $(shell ruby -e 'require "rubygems";spec = Gem::Specification::load(Dir.glob("../*.gemspec")[0]);puts spec.version')
11
+ POTFILE = $(DOMAIN).pot
12
+ MOFILE = $(DOMAIN).mo
13
+ POFILES = $(shell find . -name '*.po')
14
+ MOFILES = $(patsubst %.po,%.mo,$(POFILES))
15
+ POXFILES = $(patsubst %.po,%.pox,$(POFILES))
16
+
17
+ %.mo: %.po
18
+ mkdir -p $(shell dirname $@)/LC_MESSAGES
19
+ msgfmt -o $(shell dirname $@)/LC_MESSAGES/$(MOFILE) $<
20
+
21
+ # Generate MO files from PO files
22
+ all-mo: $(MOFILES)
23
+
24
+ # Check for malformed strings
25
+ %.pox: %.po
26
+ msgfmt -c $<
27
+ pofilter --nofuzzy -t variables -t blank -t urls -t emails -t long -t newlines \
28
+ -t endwhitespace -t endpunc -t puncspacing -t options -t printf -t validchars --gnome $< > $@
29
+ cat $@
30
+ ! grep -q msgid $@
31
+
32
+ check: $(POXFILES)
33
+ msgfmt -c ${POTFILE}
34
+
35
+ # Merge PO files
36
+ update-po:
37
+ for f in $(shell find ./ -name "*.po") ; do \
38
+ msgmerge -N --backup=none -U $$f ${POTFILE} ; \
39
+ done
40
+
41
+ # Unify duplicate translations
42
+ uniq-po:
43
+ for f in $(shell find ./ -name "*.po") ; do \
44
+ msguniq $$f -o $$f ; \
45
+ done
46
+
47
+ tx-pull:
48
+ tx pull -f
49
+ for f in $(POFILES) ; do \
50
+ sed -i 's/^\("Project-Id-Version: \).*$$/\1$(DOMAIN) $(VERSION)\\n"/' $$f; \
51
+ done
52
+ -git commit -a -m "i18n - pulling from tx"
53
+
54
+ reset-po:
55
+ # merging po files is unnecessary when using transifex.com
56
+ git checkout -- ../locale/*/*po
57
+
58
+ tx-update: tx-pull reset-po $(MOFILES)
59
+ # amend mo files
60
+ git add ../locale/*/LC_MESSAGES
61
+ git commit -a --amend -m "i18n - pulling from tx"
62
+ -echo Changes commited!
@@ -0,0 +1,19 @@
1
+ # foreman_hosts
2
+ #
3
+ # This file is distributed under the same license as foreman_hosts.
4
+ #
5
+ #, fuzzy
6
+ msgid ""
7
+ msgstr ""
8
+ "Project-Id-Version: version 0.0.1\n"
9
+ "Report-Msgid-Bugs-To: \n"
10
+ "POT-Creation-Date: 2014-08-20 08:46+0100\n"
11
+ "PO-Revision-Date: 2014-08-20 08:54+0100\n"
12
+ "Last-Translator: Foreman Team <foreman-dev@googlegroups.com>\n"
13
+ "Language-Team: Foreman Team <foreman-dev@googlegroups.com>\n"
14
+ "Language: \n"
15
+ "MIME-Version: 1.0\n"
16
+ "Content-Type: text/plain; charset=UTF-8\n"
17
+ "Content-Transfer-Encoding: 8bit\n"
18
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
19
+
@@ -0,0 +1,19 @@
1
+ # foreman_hosts
2
+ #
3
+ # This file is distributed under the same license as foreman_hosts.
4
+ #
5
+ #, fuzzy
6
+ msgid ""
7
+ msgstr ""
8
+ "Project-Id-Version: version 0.0.1\n"
9
+ "Report-Msgid-Bugs-To: \n"
10
+ "POT-Creation-Date: 2014-08-20 08:46+0100\n"
11
+ "PO-Revision-Date: 2014-08-20 08:46+0100\n"
12
+ "Last-Translator: Foreman Team <foreman-dev@googlegroups.com>\n"
13
+ "Language-Team: Foreman Team <foreman-dev@googlegroups.com>\n"
14
+ "Language: \n"
15
+ "MIME-Version: 1.0\n"
16
+ "Content-Type: text/plain; charset=UTF-8\n"
17
+ "Content-Transfer-Encoding: 8bit\n"
18
+ "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
19
+
data/locale/gemspec.rb ADDED
@@ -0,0 +1,2 @@
1
+ # Matches foreman_hosts.gemspec
2
+ _('TODO: Description of ForemanHosts.')
@@ -0,0 +1,5 @@
1
+ FactoryGirl.define do
2
+ factory :host do
3
+ name 'foreman_hosts'
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ # This calls the main test_helper in Foreman-core
2
+ require 'test_helper'
3
+
4
+ # Add plugin to FactoryGirl's paths
5
+ FactoryGirl.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
6
+ FactoryGirl.reload
@@ -0,0 +1,11 @@
1
+ require 'test_plugin_helper'
2
+
3
+ class ForemanHostsTest < ActiveSupport::TestCase
4
+ setup do
5
+ User.current = User.find_by_login 'admin'
6
+ end
7
+
8
+ test 'the truth' do
9
+ assert true
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: foreman-hosts
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1dev
5
+ prerelease: 5
6
+ platform: ruby
7
+ authors:
8
+ - jianbo
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-09-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rubocop
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rdoc
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Description of ForemanHosts.
47
+ email:
48
+ - jianbo.ji@shinyinfo.com.cn
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - app/models/concerns/foreman_hosts/host_extensions.rb
54
+ - app/overrides/dashboard/index/sample_override.html.erb.deface
55
+ - app/helpers/concerns/foreman_hosts/hosts_helper_extensions.rb
56
+ - app/views/dashboard/_foreman_hosts_widget.html.erb
57
+ - app/views/foreman_hosts/layouts/layouts/new_layout.html.erb
58
+ - app/views/foreman_hosts/layouts/new_layout.html.erb
59
+ - app/views/foreman_hosts/hosts/new_action.html.erb
60
+ - app/views/foreman_hosts/hosts/report_index.html.erb
61
+ - app/views/foreman_hosts/hosts/export.xlsx.axlsx
62
+ - app/views/foreman_hosts/hosts/hosts/new_action.html.erb
63
+ - app/controllers/foreman_hosts/hosts_controller.rb
64
+ - bin/foreman-hosts
65
+ - config/routes.rb
66
+ - lib/foreman_hosts.rb
67
+ - lib/foreman_hosts/engine.rb
68
+ - lib/foreman_hosts/version.rb
69
+ - lib/tasks/foreman_hosts_tasks.rake
70
+ - locale/gemspec.rb
71
+ - locale/foreman_hosts.pot
72
+ - locale/en/foreman_hosts.po
73
+ - locale/Makefile
74
+ - LICENSE
75
+ - Rakefile
76
+ - README.md
77
+ - test/factories/foreman_hosts_factories.rb
78
+ - test/unit/foreman_hosts_test.rb
79
+ - test/test_plugin_helper.rb
80
+ homepage: https://github.com/stdtnt/foreman_hosts
81
+ licenses: []
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ! '>'
96
+ - !ruby/object:Gem::Version
97
+ version: 1.3.1
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 1.8.23
101
+ signing_key:
102
+ specification_version: 3
103
+ summary: Summary of ForemanHosts.
104
+ test_files:
105
+ - test/factories/foreman_hosts_factories.rb
106
+ - test/unit/foreman_hosts_test.rb
107
+ - test/test_plugin_helper.rb