foreman_proxmox 0.0.10 → 0.0.12

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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/foreman_proxmox/{proxmox_controller.rb → creations_controller.rb} +4 -2
  3. data/app/controllers/foreman_proxmox/hosts_controller.rb +10 -3
  4. data/app/helpers/concerns/foreman_proxmox/hosts_helper_extensions.rb +3 -3
  5. data/app/models/foreman_proxmox/proxmox_connection.rb +4 -0
  6. data/app/views/foreman_proxmox/hosts/proxmox.html.erb +15 -0
  7. data/config/routes.rb +15 -1
  8. data/config/routes/mount_engine.rb +3 -0
  9. data/db/migrate/20151006132039_create_foreman_proxmox_proxmox_connections.rb +11 -0
  10. data/lib/foreman_proxmox.rb +1 -1
  11. data/lib/foreman_proxmox/engine.rb +13 -9
  12. data/lib/foreman_proxmox/version.rb +1 -1
  13. data/lib/tasks/foreman_proxmox_tasks.rake +4 -49
  14. data/locale/en/foreman_proxmox.po +1 -2
  15. data/locale/foreman_proxmox.pot +1 -2
  16. data/test/controllers/foreman_proxmox/creations_controller_test.rb +13 -0
  17. data/test/controllers/foreman_proxmox/hosts_controller_test.rb +13 -0
  18. data/test/dummy/README.rdoc +28 -0
  19. data/test/dummy/Rakefile +6 -0
  20. data/test/dummy/app/assets/javascripts/application.js +13 -0
  21. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  22. data/test/dummy/app/controllers/application_controller.rb +5 -0
  23. data/test/dummy/app/helpers/application_helper.rb +2 -0
  24. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  25. data/test/dummy/bin/bundle +3 -0
  26. data/test/dummy/bin/rails +4 -0
  27. data/test/dummy/bin/rake +4 -0
  28. data/test/dummy/bin/setup +29 -0
  29. data/test/dummy/config.ru +4 -0
  30. data/test/dummy/config/application.rb +26 -0
  31. data/test/dummy/config/boot.rb +5 -0
  32. data/test/dummy/config/database.yml +25 -0
  33. data/test/dummy/config/environment.rb +5 -0
  34. data/test/dummy/config/environments/development.rb +41 -0
  35. data/test/dummy/config/environments/production.rb +79 -0
  36. data/test/dummy/config/environments/test.rb +42 -0
  37. data/test/dummy/config/initializers/assets.rb +11 -0
  38. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  39. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  40. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  41. data/test/dummy/config/initializers/inflections.rb +16 -0
  42. data/test/dummy/config/initializers/mime_types.rb +4 -0
  43. data/test/dummy/config/initializers/session_store.rb +3 -0
  44. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  45. data/test/dummy/config/locales/en.yml +23 -0
  46. data/test/dummy/config/routes.rb +4 -0
  47. data/test/dummy/config/secrets.yml +22 -0
  48. data/test/dummy/public/404.html +67 -0
  49. data/test/dummy/public/422.html +67 -0
  50. data/test/dummy/public/500.html +66 -0
  51. data/{app/views/foreman_proxmox/layouts/layouts/new_layout.html.erb → test/dummy/public/favicon.ico} +0 -0
  52. data/test/fixtures/foreman_proxmox/proxmox_connections.yml +11 -0
  53. data/test/foreman_proxmox_test.rb +7 -0
  54. data/test/integration/navigation_test.rb +10 -0
  55. data/test/models/foreman_proxmox/proxmox_connection_test.rb +9 -0
  56. data/test/test_helper.rb +20 -0
  57. metadata +104 -17
  58. data/app/models/concerns/foreman_proxmox/host_extensions.rb +0 -19
  59. data/app/overrides/dashboard/index/sample_override.html.erb.deface +0 -4
  60. data/app/views/dashboard/_foreman_proxmox_widget.html.erb +0 -2
  61. data/app/views/foreman_proxmox/hosts/hosts/new_action.html.erb +0 -1
  62. data/app/views/foreman_proxmox/hosts/new_action.html.erb +0 -1
  63. data/app/views/foreman_proxmox/layouts/new_layout.html.erb +0 -0
  64. data/test/factories/foreman_proxmox_factories.rb +0 -5
  65. data/test/test_plugin_helper.rb +0 -6
  66. data/test/unit/foreman_proxmox_test.rb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 595e94da1fb5e8c3494d3e87c86569e513e5b879
4
- data.tar.gz: f1b9f1007dad21ee11dd39921fb76e519eb26530
3
+ metadata.gz: 0800d3ce318e244809442420b40d30aeabb50d9c
4
+ data.tar.gz: 783e91d35f3ad3dafb49542a415d7ae75040491c
5
5
  SHA512:
6
- metadata.gz: c6dbfce6240f4e032d1cbb9b5f534ccefde123bc52f81d6beedcbf23b01a504ff9b937c2fa3ada76176a433b4a3f7f340b7b18624373c861c5b9eedce6a8f346
7
- data.tar.gz: a4e61e6db43c675a9660e488d456060f77cba1d40c331b13415da460be550955009761e913aa782c0a168104724f06cb5b393000569c0c201a53cabab02bc42a
6
+ metadata.gz: 0f507e5db2f4ae5466752f87365c85af50c729c5b2e3c2d76357bbea54f672e962ce8f6a5c2a0a267517a60426de5cbb796d2b8ca97124747c7874cd376fb375
7
+ data.tar.gz: 1b154d8cc5fb78052a067db01366f159fe24933f2bffe8c1bb0843995a573ff0f21c9885d5b1ed85e13c209eb2d6065ef1db99b4d034adcc98344f53bc3d65dd
@@ -1,9 +1,11 @@
1
+ require 'rest-client'
1
2
  module ForemanProxmox
2
- class ProxmoxController < ::ApplicationController
3
- before_filter :find_resource, :only => %w[host full_host]
3
+ class CreationsController < ::ApplicationController
4
+ before_filter :find_resource, :only => %w[host]
4
5
 
5
6
  def create_vm
6
7
 
8
+ redirect_to :back
7
9
  end
8
10
 
9
11
  private
@@ -4,8 +4,15 @@ module ForemanProxmox
4
4
  # change layout if needed
5
5
  # layout 'foreman_proxmox/layouts/new_layout'
6
6
 
7
- def new_action
8
- # automatically renders view/foreman_proxmox/hosts/new_action
7
+ def proxmox
8
+ @proxmoxconnection = ProxmoxConnection.new
9
+ end
10
+
11
+ def create
12
+ @proxmoxconnection.ip = params[:ip]
13
+ @proxmoxconnection.username = params[:username]
14
+ @proxmoxconnection.password = params[:username]
15
+ redirect_to :back
9
16
  end
10
17
  end
11
- end
18
+ end
@@ -11,13 +11,13 @@ module ForemanProxmox
11
11
  def host_title_actions_with_proxmox(*args)
12
12
  title_actions(
13
13
  button_group(
14
- display_proxmox_if_Authorized(_("Create VM"), {:controller => 'foreman_proxmox/proxmox', :action => 'create_vm',:id => @host}, :class => 'btn')
14
+ display_proxmox_if_authorized(_("Create VM"), {:controller => 'foreman_proxmox/creations', :action => 'create_vm', :id => @host}, :class => 'btn')
15
15
  )
16
16
  )
17
17
  host_title_actions_without_proxmox(*args)
18
18
  end
19
19
 
20
- def display_proxmox_if_Authorized(name, options = {}, html_options = {})
20
+ def display_proxmox_if_authorized(name, options = {}, html_options = {})
21
21
  if is_authorized(options)
22
22
  link_to(name, proxmox_url(options), html_options)
23
23
  else
@@ -26,7 +26,7 @@ module ForemanProxmox
26
26
  end
27
27
 
28
28
  def proxmox_url(options)
29
- ForemanProxmox::Engine.routes.url_for(options.merge(:only_path => true, :script_name => proxmox_create_path))
29
+ ForemanProxmox::Engine.routes.url_for(options.merge(:only_path => true, :script_name => foreman_proxmox_path))
30
30
  end
31
31
 
32
32
  def is_authorized(options)
@@ -0,0 +1,4 @@
1
+ module ForemanProxmox
2
+ class ProxmoxConnection < ActiveRecord::Base
3
+ end
4
+ end
@@ -0,0 +1,15 @@
1
+ <%= form_for @proxmoxconnection, url: {action: 'create'} do |f| %>
2
+ <%= f.label :ip %>
3
+ <%= f.text_field :ip %>
4
+ <br>
5
+ <%= f.label :username %>
6
+ <%= f.text_field :username %>
7
+ <br>
8
+ <%= f.label :password %>
9
+ <%= f.text_field :password %>
10
+ <br>
11
+ <%= f.submit 'Create' %>
12
+ <% end %>
13
+ <%= @proxmoxconnection.ip %>
14
+ <%= @proxmoxconnection.username %>
15
+ <%= @proxmoxconnection.password %>
data/config/routes.rb CHANGED
@@ -1,3 +1,17 @@
1
1
  Rails.application.routes.draw do
2
- get 'proxmox/:id' => 'proxmox#create_vm'
2
+ match 'proxmox', to: 'foreman_proxmox/hosts#proxmox'
3
+
4
+ resource :hosts
5
+
6
+ end
7
+
8
+ ForemanProxmox::Engine.routes.draw do
9
+
10
+ resource :hosts
11
+
12
+ resources :creations, :only => [] do
13
+ constraints(:id => /[^\/]+/) do
14
+ get 'hosts/:id', :on => :collection, :to => 'creations#create_vm'
15
+ end
16
+ end
3
17
  end
@@ -0,0 +1,3 @@
1
+ Foreman::Application.routes.draw do
2
+ mount ForemanProxmox::Engine, :at => "/proxmox"
3
+ end
@@ -0,0 +1,11 @@
1
+ class CreateForemanProxmoxProxmoxConnections < ActiveRecord::Migration
2
+ def change
3
+ create_table :foreman_proxmox_proxmox_connections do |t|
4
+ t.string :ip
5
+ t.string :username
6
+ t.string :password
7
+
8
+ t.timestamps null: false
9
+ end
10
+ end
11
+ end
@@ -1,4 +1,4 @@
1
- require 'foreman_proxmox/engine'
1
+ require "foreman_proxmox/engine"
2
2
 
3
3
  module ForemanProxmox
4
4
  end
@@ -1,13 +1,17 @@
1
- require 'deface'
2
-
3
1
  module ForemanProxmox
4
2
  class Engine < ::Rails::Engine
5
3
  engine_name 'foreman_proxmox'
4
+ isolate_namespace ForemanProxmox
5
+
6
6
 
7
7
  config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
8
8
  config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]
9
9
  config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
10
10
  config.autoload_paths += Dir["#{config.root}/app/overrides"]
11
+
12
+ initializer 'foreman_proxmox.mount_engine', :after=> :build_middleware_stack do |app|
13
+ app.routes_reloader.paths << "#{ForemanProxmox::Engine.root}/config/routes/mount_engine.rb"
14
+ end
11
15
 
12
16
  # Add any db migrations
13
17
  initializer 'foreman_proxmox.load_app_instance_data' do |app|
@@ -20,21 +24,21 @@ module ForemanProxmox
20
24
 
21
25
  # Add permissions
22
26
  security_block :foreman_proxmox do
23
- permission :view_foreman_proxmox, :'foreman_proxmox/hosts' => [:new_action]
27
+ permission :view_foreman_proxmox, :'foreman_proxmox/hosts' => [:proxmoxn]
24
28
  end
25
29
 
26
30
  # Add a new role called 'Discovery' if it doesn't exist
27
31
  role 'ForemanProxmox', [:view_foreman_proxmox]
28
32
 
29
- # add menu entry
33
+ #add menu entry
30
34
  menu :top_menu, :template,
31
- url_hash: { controller: :'foreman_proxmox/hosts', action: :new_action },
32
- caption: 'ForemanProxmox',
33
- parent: :hosts_menu,
34
- after: :hosts
35
+ url_hash: { controller: :'foreman_proxmox/hosts', action: :proxmox },
36
+ caption: 'ForemanProxmox',
37
+ parent: :hosts_menu,
38
+ after: :hosts
35
39
 
36
40
  # add dashboard widget
37
- widget 'foreman_proxmox_widget', name: N_('Foreman plugin template widget'), sizex: 4, sizey: 1
41
+ # widget 'foreman_proxmox_widget', name: N_('Foreman plugin template widget'), sizex: 4, sizey: 1
38
42
  end
39
43
  end
40
44
 
@@ -1,3 +1,3 @@
1
1
  module ForemanProxmox
2
- VERSION = '0.0.10'
2
+ VERSION = "0.0.12"
3
3
  end
@@ -1,49 +1,4 @@
1
- # Tasks
2
- namespace :foreman_proxmox 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 ForemanProxmox'
14
- Rake::TestTask.new(:foreman_proxmox) 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_proxmox do
23
- task :rubocop do
24
- begin
25
- require 'rubocop/rake_task'
26
- RuboCop::RakeTask.new(:rubocop_foreman_proxmox) do |task|
27
- task.patterns = ["#{ForemanProxmox::Engine.root}/app/**/*.rb",
28
- "#{ForemanProxmox::Engine.root}/lib/**/*.rb",
29
- "#{ForemanProxmox::Engine.root}/test/**/*.rb"]
30
- end
31
- rescue
32
- puts 'Rubocop not loaded.'
33
- end
34
-
35
- Rake::Task['rubocop_foreman_proxmox'].invoke
36
- end
37
- end
38
-
39
- Rake::Task[:test].enhance do
40
- Rake::Task['test:foreman_proxmox'].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_proxmox'].invoke
47
- Rake::Task['foreman_proxmox:rubocop'].invoke
48
- end
49
- end
1
+ # desc "Explaining what the task does"
2
+ # task :foreman_proxmox do
3
+ # # Task goes here
4
+ # end
@@ -15,5 +15,4 @@ msgstr ""
15
15
  "MIME-Version: 1.0\n"
16
16
  "Content-Type: text/plain; charset=UTF-8\n"
17
17
  "Content-Transfer-Encoding: 8bit\n"
18
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
19
-
18
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
@@ -15,5 +15,4 @@ msgstr ""
15
15
  "MIME-Version: 1.0\n"
16
16
  "Content-Type: text/plain; charset=UTF-8\n"
17
17
  "Content-Transfer-Encoding: 8bit\n"
18
- "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
19
-
18
+ "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
@@ -0,0 +1,13 @@
1
+ require 'test_helper'
2
+
3
+ module ForemanProxmox
4
+ class CreationsControllerTest < ActionController::TestCase
5
+ setup do
6
+ @routes = Engine.routes
7
+ end
8
+
9
+ # test "the truth" do
10
+ # assert true
11
+ # end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require 'test_helper'
2
+
3
+ module ForemanProxmox
4
+ class HostsControllerTest < ActionController::TestCase
5
+ setup do
6
+ @routes = Engine.routes
7
+ end
8
+
9
+ # test "the truth" do
10
+ # assert true
11
+ # end
12
+ end
13
+ end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+
4
+ # path to your application root.
5
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
+
7
+ Dir.chdir APP_ROOT do
8
+ # This script is a starting point to setup your application.
9
+ # Add necessary setup steps to this file:
10
+
11
+ puts "== Installing dependencies =="
12
+ system "gem install bundler --conservative"
13
+ system "bundle check || bundle install"
14
+
15
+ # puts "\n== Copying sample files =="
16
+ # unless File.exist?("config/database.yml")
17
+ # system "cp config/database.yml.sample config/database.yml"
18
+ # end
19
+
20
+ puts "\n== Preparing database =="
21
+ system "bin/rake db:setup"
22
+
23
+ puts "\n== Removing old logs and tempfiles =="
24
+ system "rm -f log/*"
25
+ system "rm -rf tmp/cache"
26
+
27
+ puts "\n== Restarting application server =="
28
+ system "touch tmp/restart.txt"
29
+ end