foreman_orchestration 0.0.1

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 (40) hide show
  1. data/LICENSE +619 -0
  2. data/README.md +38 -0
  3. data/Rakefile +47 -0
  4. data/app/assets/javascripts/foreman_orchestration/stacks.js +129 -0
  5. data/app/assets/stylesheets/foreman_orchestration/stacks.css.scss +3 -0
  6. data/app/assets/stylesheets/foreman_orchestration/templates.css.scss +4 -0
  7. data/app/controllers/concerns/foreman_orchestration/compute_resources_controller_extensions.rb +17 -0
  8. data/app/controllers/foreman_orchestration/stack_templates_controller.rb +57 -0
  9. data/app/controllers/foreman_orchestration/stacks_controller.rb +75 -0
  10. data/app/controllers/foreman_orchestration/tenants_controller.rb +26 -0
  11. data/app/helpers/concerns/foreman_orchestration/layout_helper_extensions.rb +22 -0
  12. data/app/models/concerns/foreman_orchestration/openstack_extensions.rb +51 -0
  13. data/app/models/foreman_orchestration/orchestration_client.rb +51 -0
  14. data/app/models/foreman_orchestration/stack.rb +91 -0
  15. data/app/models/foreman_orchestration/stack_template.rb +31 -0
  16. data/app/views/dashboard/_foreman_orchestration_widget.html.erb +2 -0
  17. data/app/views/foreman_orchestration/stack_templates/_form.html.erb +8 -0
  18. data/app/views/foreman_orchestration/stack_templates/_with_params.html.erb +31 -0
  19. data/app/views/foreman_orchestration/stack_templates/edit.html.erb +3 -0
  20. data/app/views/foreman_orchestration/stack_templates/index.html.erb +27 -0
  21. data/app/views/foreman_orchestration/stack_templates/new.html.erb +3 -0
  22. data/app/views/foreman_orchestration/stacks/_form.html.erb +40 -0
  23. data/app/views/foreman_orchestration/stacks/all.html.erb +40 -0
  24. data/app/views/foreman_orchestration/stacks/index.html.erb +49 -0
  25. data/app/views/foreman_orchestration/stacks/new.html.erb +6 -0
  26. data/app/views/foreman_orchestration/tenants/_for_select.html.erb +21 -0
  27. data/config/routes.rb +30 -0
  28. data/db/migrate/20151112145323_create_stack_templates.rb +10 -0
  29. data/lib/foreman_orchestration.rb +4 -0
  30. data/lib/foreman_orchestration/engine.rb +71 -0
  31. data/lib/foreman_orchestration/version.rb +3 -0
  32. data/lib/tasks/foreman_orchestration_tasks.rake +39 -0
  33. data/locale/Makefile +62 -0
  34. data/locale/en/foreman_orchestration.po +19 -0
  35. data/locale/foreman_orchestration.pot +19 -0
  36. data/locale/gemspec.rb +2 -0
  37. data/test/factories/foreman_orchestration_factories.rb +5 -0
  38. data/test/test_plugin_helper.rb +6 -0
  39. data/test/unit/foreman_orchestration_test.rb +11 -0
  40. metadata +137 -0
@@ -0,0 +1,10 @@
1
+ class CreateStackTemplates < ActiveRecord::Migration
2
+ def change
3
+ create_table :stack_templates do |t|
4
+ t.string :name
5
+ t.text :template
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,4 @@
1
+ require 'foreman_orchestration/engine'
2
+
3
+ module ForemanOrchestration
4
+ end
@@ -0,0 +1,71 @@
1
+ require 'deface'
2
+
3
+ module ForemanOrchestration
4
+ class Engine < ::Rails::Engine
5
+ engine_name 'foreman_orchestration'
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
+
11
+ # Add any db migrations
12
+ initializer 'foreman_orchestration.load_app_instance_data' do |app|
13
+ ForemanOrchestration::Engine.paths['db/migrate'].existent.each do |path|
14
+ app.config.paths['db/migrate'] << path
15
+ end
16
+ end
17
+
18
+ initializer 'foreman_orchestration.register_plugin', after: :finisher_hook do |_app|
19
+ Foreman::Plugin.register :foreman_orchestration do
20
+ requires_foreman '>= 1.4'
21
+
22
+ # TODO: Add permissions
23
+
24
+ sub_menu :top_menu, :orchestration, :after=> :infrastructure_menu do
25
+ menu :top_menu, :all_stacks, :url_hash => { controller: :'foreman_orchestration/stacks', action: :all }
26
+ menu :top_menu, :new_stack, :url_hash => { controller: :'foreman_orchestration/stacks', action: :new }
27
+ menu :top_menu, :stack_templates, :url_hash => { controller: :'foreman_orchestration/stack_templates', action: :index }
28
+ end
29
+ end
30
+ end
31
+
32
+ # Precompile any JS or CSS files under app/assets/
33
+ # If requiring files from each other, list them explicitly here to avoid precompiling the same
34
+ # content twice.
35
+ assets_to_precompile =
36
+ Dir.chdir(root) do
37
+ Dir['app/assets/javascripts/**/*', 'app/assets/stylesheets/**/*'].map do |f|
38
+ f.split(File::SEPARATOR, 4).last
39
+ end
40
+ end
41
+ initializer 'foreman_orchestration.assets.precompile' do |app|
42
+ app.config.assets.precompile += assets_to_precompile
43
+ end
44
+ initializer 'foreman_orchestration.configure_assets', group: :assets do
45
+ SETTINGS[:foreman_orchestration] = { assets: { precompile: assets_to_precompile } }
46
+ end
47
+
48
+ # Include concerns in this config.to_prepare block
49
+ config.to_prepare do
50
+ begin
51
+ LayoutHelper.send(:include, ForemanOrchestration::LayoutHelperExtensions)
52
+ ComputeResourcesController.send(:include, ForemanOrchestration::ComputeResourcesControllerExtensions)
53
+ Foreman::Model::Openstack.send(:include, ForemanOrchestration::OpenstackExtensions)
54
+ rescue => e
55
+ Rails.logger.warn "ForemanOrchestration: skipping engine hook (#{e})"
56
+ end
57
+ end
58
+
59
+ rake_tasks do
60
+ Rake::Task['db:seed'].enhance do
61
+ ForemanOrchestration::Engine.load_seed
62
+ end
63
+ end
64
+
65
+ initializer 'foreman_orchestration.register_gettext', after: :load_config_initializers do |_app|
66
+ locale_dir = File.join(File.expand_path('../../..', __FILE__), 'locale')
67
+ locale_domain = 'foreman_orchestration'
68
+ Foreman::Gettext::Support.add_text_domain locale_domain, locale_dir
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,3 @@
1
+ module ForemanOrchestration
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,39 @@
1
+ # Tests
2
+ namespace :test do
3
+ desc 'Test ForemanOrchestration'
4
+ Rake::TestTask.new(:foreman_orchestration) do |t|
5
+ test_dir = File.join(File.dirname(__FILE__), '../..', 'test')
6
+ t.libs << ['test', test_dir]
7
+ t.pattern = "#{test_dir}/**/*_test.rb"
8
+ t.verbose = true
9
+ end
10
+ end
11
+
12
+ namespace :foreman_orchestration do
13
+ task :rubocop do
14
+ begin
15
+ require 'rubocop/rake_task'
16
+ RuboCop::RakeTask.new(:rubocop_foreman_orchestration) do |task|
17
+ task.patterns = ["#{ForemanOrchestration::Engine.root}/app/**/*.rb",
18
+ "#{ForemanOrchestration::Engine.root}/lib/**/*.rb",
19
+ "#{ForemanOrchestration::Engine.root}/test/**/*.rb"]
20
+ end
21
+ rescue
22
+ puts 'Rubocop not loaded.'
23
+ end
24
+
25
+ Rake::Task['rubocop_foreman_orchestration'].invoke
26
+ end
27
+ end
28
+
29
+ Rake::Task[:test].enhance do
30
+ Rake::Task['test:foreman_orchestration'].invoke
31
+ end
32
+
33
+ load 'tasks/jenkins.rake'
34
+ if Rake::Task.task_defined?(:'jenkins:unit')
35
+ Rake::Task['jenkins:unit'].enhance do
36
+ Rake::Task['test:foreman_orchestration'].invoke
37
+ Rake::Task['foreman_orchestration:rubocop'].invoke
38
+ end
39
+ 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_orchestration
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_orchestration
2
+ #
3
+ # This file is distributed under the same license as foreman_orchestration.
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_orchestration
2
+ #
3
+ # This file is distributed under the same license as foreman_orchestration.
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_orchestration.gemspec
2
+ _('Orchestration plugin for foreman')
@@ -0,0 +1,5 @@
1
+ FactoryGirl.define do
2
+ factory :host do
3
+ name 'foreman_orchestration'
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 ForemanOrchestrationTest < 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,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: foreman_orchestration
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Zdenek Janda
9
+ - Pavel Ivanov
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2016-02-18 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: deface
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: rubocop
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ type: :development
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rdoc
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ description: Orchestration plugin for foreman
64
+ email:
65
+ - ivpavig@gmail.com
66
+ - management@cloudevelops.com
67
+ executables: []
68
+ extensions: []
69
+ extra_rdoc_files: []
70
+ files:
71
+ - app/assets/javascripts/foreman_orchestration/stacks.js
72
+ - app/assets/stylesheets/foreman_orchestration/stacks.css.scss
73
+ - app/assets/stylesheets/foreman_orchestration/templates.css.scss
74
+ - app/controllers/concerns/foreman_orchestration/compute_resources_controller_extensions.rb
75
+ - app/controllers/foreman_orchestration/stack_templates_controller.rb
76
+ - app/controllers/foreman_orchestration/stacks_controller.rb
77
+ - app/controllers/foreman_orchestration/tenants_controller.rb
78
+ - app/helpers/concerns/foreman_orchestration/layout_helper_extensions.rb
79
+ - app/models/concerns/foreman_orchestration/openstack_extensions.rb
80
+ - app/models/foreman_orchestration/orchestration_client.rb
81
+ - app/models/foreman_orchestration/stack.rb
82
+ - app/models/foreman_orchestration/stack_template.rb
83
+ - app/views/dashboard/_foreman_orchestration_widget.html.erb
84
+ - app/views/foreman_orchestration/stack_templates/_form.html.erb
85
+ - app/views/foreman_orchestration/stack_templates/_with_params.html.erb
86
+ - app/views/foreman_orchestration/stack_templates/edit.html.erb
87
+ - app/views/foreman_orchestration/stack_templates/index.html.erb
88
+ - app/views/foreman_orchestration/stack_templates/new.html.erb
89
+ - app/views/foreman_orchestration/stacks/_form.html.erb
90
+ - app/views/foreman_orchestration/stacks/all.html.erb
91
+ - app/views/foreman_orchestration/stacks/index.html.erb
92
+ - app/views/foreman_orchestration/stacks/new.html.erb
93
+ - app/views/foreman_orchestration/tenants/_for_select.html.erb
94
+ - config/routes.rb
95
+ - db/migrate/20151112145323_create_stack_templates.rb
96
+ - lib/foreman_orchestration/engine.rb
97
+ - lib/foreman_orchestration/version.rb
98
+ - lib/foreman_orchestration.rb
99
+ - lib/tasks/foreman_orchestration_tasks.rake
100
+ - locale/en/foreman_orchestration.po
101
+ - locale/foreman_orchestration.pot
102
+ - locale/gemspec.rb
103
+ - locale/Makefile
104
+ - LICENSE
105
+ - Rakefile
106
+ - README.md
107
+ - test/factories/foreman_orchestration_factories.rb
108
+ - test/test_plugin_helper.rb
109
+ - test/unit/foreman_orchestration_test.rb
110
+ homepage: https://github.com/cloudevelops/foreman_orchestration
111
+ licenses: []
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 1.8.23.2
131
+ signing_key:
132
+ specification_version: 3
133
+ summary: Orchestration plugin for foreman
134
+ test_files:
135
+ - test/factories/foreman_orchestration_factories.rb
136
+ - test/test_plugin_helper.rb
137
+ - test/unit/foreman_orchestration_test.rb