foreman_proxmox 0.0.10 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/foreman_proxmox/{proxmox_controller.rb → creations_controller.rb} +4 -2
- data/app/controllers/foreman_proxmox/hosts_controller.rb +10 -3
- data/app/helpers/concerns/foreman_proxmox/hosts_helper_extensions.rb +3 -3
- data/app/models/foreman_proxmox/proxmox_connection.rb +4 -0
- data/app/views/foreman_proxmox/hosts/proxmox.html.erb +15 -0
- data/config/routes.rb +15 -1
- data/config/routes/mount_engine.rb +3 -0
- data/db/migrate/20151006132039_create_foreman_proxmox_proxmox_connections.rb +11 -0
- data/lib/foreman_proxmox.rb +1 -1
- data/lib/foreman_proxmox/engine.rb +13 -9
- data/lib/foreman_proxmox/version.rb +1 -1
- data/lib/tasks/foreman_proxmox_tasks.rake +4 -49
- data/locale/en/foreman_proxmox.po +1 -2
- data/locale/foreman_proxmox.pot +1 -2
- data/test/controllers/foreman_proxmox/creations_controller_test.rb +13 -0
- data/test/controllers/foreman_proxmox/hosts_controller_test.rb +13 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +26 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/{app/views/foreman_proxmox/layouts/layouts/new_layout.html.erb → test/dummy/public/favicon.ico} +0 -0
- data/test/fixtures/foreman_proxmox/proxmox_connections.yml +11 -0
- data/test/foreman_proxmox_test.rb +7 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/models/foreman_proxmox/proxmox_connection_test.rb +9 -0
- data/test/test_helper.rb +20 -0
- metadata +104 -17
- data/app/models/concerns/foreman_proxmox/host_extensions.rb +0 -19
- data/app/overrides/dashboard/index/sample_override.html.erb.deface +0 -4
- data/app/views/dashboard/_foreman_proxmox_widget.html.erb +0 -2
- data/app/views/foreman_proxmox/hosts/hosts/new_action.html.erb +0 -1
- data/app/views/foreman_proxmox/hosts/new_action.html.erb +0 -1
- data/app/views/foreman_proxmox/layouts/new_layout.html.erb +0 -0
- data/test/factories/foreman_proxmox_factories.rb +0 -5
- data/test/test_plugin_helper.rb +0 -6
- data/test/unit/foreman_proxmox_test.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0800d3ce318e244809442420b40d30aeabb50d9c
|
4
|
+
data.tar.gz: 783e91d35f3ad3dafb49542a415d7ae75040491c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f507e5db2f4ae5466752f87365c85af50c729c5b2e3c2d76357bbea54f672e962ce8f6a5c2a0a267517a60426de5cbb796d2b8ca97124747c7874cd376fb375
|
7
|
+
data.tar.gz: 1b154d8cc5fb78052a067db01366f159fe24933f2bffe8c1bb0843995a573ff0f21c9885d5b1ed85e13c209eb2d6065ef1db99b4d034adcc98344f53bc3d65dd
|
@@ -1,9 +1,11 @@
|
|
1
|
+
require 'rest-client'
|
1
2
|
module ForemanProxmox
|
2
|
-
class
|
3
|
-
before_filter :find_resource, :only => %w[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
|
8
|
-
|
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
|
-
|
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
|
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 =>
|
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,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
|
-
|
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
|
data/lib/foreman_proxmox.rb
CHANGED
@@ -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' => [:
|
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
|
-
#
|
33
|
+
#add menu entry
|
30
34
|
menu :top_menu, :template,
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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,49 +1,4 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
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
|
data/locale/foreman_proxmox.pot
CHANGED
@@ -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>.
|
data/test/dummy/Rakefile
ADDED
@@ -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,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>
|
data/test/dummy/bin/rake
ADDED
@@ -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
|