foreman_salt 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/app/controllers/foreman_salt/concerns/hosts_controller_extensions.rb +5 -3
- data/app/controllers/foreman_salt/salt_environments_controller.rb +45 -0
- data/app/models/concerns/foreman_salt/host_managed_extensions.rb +1 -0
- data/app/models/concerns/foreman_salt/hostgroup_extensions.rb +14 -0
- data/app/models/concerns/foreman_salt/orchestration/salt.rb +4 -3
- data/app/models/foreman_salt/salt_environment.rb +21 -0
- data/app/models/foreman_salt/salt_module.rb +1 -1
- data/app/overrides/foreman/salt_modules/_host_tab.html.erb +1 -1
- data/app/overrides/foreman/salt_modules/_host_tab_pane.html.erb +2 -2
- data/app/overrides/salt_environment_selector.rb +13 -0
- data/app/views/foreman_salt/salt_environments/_form.html.erb +15 -0
- data/app/views/foreman_salt/salt_environments/edit.html.erb +4 -0
- data/app/views/foreman_salt/salt_environments/index.html.erb +23 -0
- data/app/views/foreman_salt/salt_environments/new.html.erb +4 -0
- data/app/views/foreman_salt/salt_modules/_form.html.erb +1 -1
- data/app/views/foreman_salt/salt_modules/edit.html.erb +1 -1
- data/app/views/foreman_salt/salt_modules/index.html.erb +2 -2
- data/app/views/foreman_salt/salt_modules/new.html.erb +1 -1
- data/config/routes.rb +7 -1
- data/db/migrate/20140920232200_create_salt_environments.rb +19 -0
- data/lib/foreman_salt/engine.rb +19 -5
- data/lib/foreman_salt/version.rb +1 -1
- data/test/integration/salt_environment_test.rb +27 -0
- data/test/integration/salt_module_test.rb +2 -2
- data/test/unit/salt_modules_test.rb +17 -0
- metadata +62 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e2b2790368b1ac4ecfb5b3fcd19bfcdb0274acc
|
4
|
+
data.tar.gz: 987a376ba11c90087cee57d7fed8c824c3465fe7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f505bfe69b144df567bebed2b5ae9c188ded36f39ac3bce3bf5801a8856c26f53724bac9f3dd5fddeafb82c76d66455886531354882a56da5a9f35075bffc2c
|
7
|
+
data.tar.gz: 23ba6cec5f63d40124c02ba81b4aabb4e272ae87ce6939d625c1dc9f1db53424a667f8f8eee224ba4a71e3f43caadd0af57ade326092df3a16d8bab0f3ad0a39
|
@@ -24,10 +24,12 @@ module ForemanSalt
|
|
24
24
|
begin
|
25
25
|
@host = resource_base.find_by_name(params[:name])
|
26
26
|
enc = {}
|
27
|
+
env = @host.salt_environment.blank? ? 'base' : @host.salt_environment
|
27
28
|
enc["classes"] = @host.salt_modules.any? ? @host.salt_modules.map(&:name) : []
|
28
29
|
enc["parameters"] = @host.info["parameters"]
|
30
|
+
enc["environment"] = env
|
29
31
|
respond_to do |format|
|
30
|
-
format.html { render :text => "<pre>#{ERB::Util.html_escape(enc.to_yaml)}</pre>" }
|
32
|
+
format.html { render :text => "<pre>#{ERB::Util.html_escape(enc.to_yaml)}</pre>" }
|
31
33
|
format.yml { render :text => enc.to_yaml }
|
32
34
|
end
|
33
35
|
rescue
|
@@ -40,7 +42,7 @@ module ForemanSalt
|
|
40
42
|
@hostgroup = Hostgroup.find(params[:host][:hostgroup_id]) if params[:host][:hostgroup_id].to_i > 0
|
41
43
|
return head(:not_found) unless @hostgroup
|
42
44
|
|
43
|
-
@salt_modules = @host.salt_modules if @host
|
45
|
+
@salt_modules = @host.salt_modules if @host
|
44
46
|
@inherited_salt_modules = @hostgroup.salt_modules
|
45
47
|
process_hostgroup_without_salt_modules
|
46
48
|
end
|
@@ -60,7 +62,7 @@ module ForemanSalt
|
|
60
62
|
|
61
63
|
def load_vars_for_ajax_with_salt_modules
|
62
64
|
return unless @host
|
63
|
-
@salt_modules = @host.salt_modules
|
65
|
+
@salt_modules = @host.salt_modules
|
64
66
|
@inherited_salt_modules = @host.hostgroup.salt_modules if @host.hostgroup
|
65
67
|
load_vars_for_ajax_without_salt_modules
|
66
68
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module ForemanSalt
|
2
|
+
class SaltEnvironmentsController < ::ApplicationController
|
3
|
+
include Foreman::Controller::AutoCompleteSearch
|
4
|
+
|
5
|
+
before_filter :find_by_name, :only => [:edit, :update, :destroy]
|
6
|
+
|
7
|
+
def index
|
8
|
+
@salt_environments = resource_base.search_for(params[:search], :order => params[:order]).paginate(:page => params[:page])
|
9
|
+
end
|
10
|
+
|
11
|
+
def new
|
12
|
+
@salt_environment = SaltEnvironment.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def create
|
16
|
+
logger.info("Params: #{params.inspect}")
|
17
|
+
@salt_environment = SaltEnvironment.new(params[:foreman_salt_salt_environment])
|
18
|
+
if @salt_environment.save
|
19
|
+
process_success
|
20
|
+
else
|
21
|
+
process_error
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def edit
|
26
|
+
end
|
27
|
+
|
28
|
+
def update
|
29
|
+
if @salt_environment.update_attributes(params[:foreman_salt_salt_environment])
|
30
|
+
notice _("Successfully updated %s." % @salt_environment.to_s)
|
31
|
+
redirect_to salt_environments_path
|
32
|
+
else
|
33
|
+
process_error
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def destroy
|
38
|
+
if @salt_environment.destroy
|
39
|
+
process_success
|
40
|
+
else
|
41
|
+
process_error
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -5,6 +5,7 @@ module ForemanSalt
|
|
5
5
|
included do
|
6
6
|
has_and_belongs_to_many :salt_modules, :class_name => "ForemanSalt::SaltModule", :join_table => "hosts_salt_modules", :foreign_key => "host_id"
|
7
7
|
belongs_to :salt_proxy, :class_name => "SmartProxy"
|
8
|
+
belongs_to :salt_environment, :class_name => "ForemanSalt::SaltEnvironment"
|
8
9
|
alias_method_chain :params, :salt_proxy
|
9
10
|
alias_method_chain :set_hostgroup_defaults, :salt_proxy
|
10
11
|
alias_method_chain :smart_proxy_ids, :salt_proxy
|
@@ -5,6 +5,7 @@ module ForemanSalt
|
|
5
5
|
included do
|
6
6
|
has_and_belongs_to_many :salt_modules, :class_name => "ForemanSalt::SaltModule"
|
7
7
|
belongs_to :salt_proxy, :class_name => "SmartProxy"
|
8
|
+
belongs_to :salt_environment, :class_name => "ForemanSalt::SaltEnvironment"
|
8
9
|
end
|
9
10
|
|
10
11
|
def salt_modules
|
@@ -42,6 +43,19 @@ module ForemanSalt
|
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
46
|
+
def salt_environment
|
47
|
+
return super unless ancestry.present?
|
48
|
+
ForemanSalt::SaltEnvironment.find_by_id(inherited_salt_environment_id)
|
49
|
+
end
|
50
|
+
|
51
|
+
def inherited_salt_environment_id
|
52
|
+
if ancestry.present?
|
53
|
+
read_attribute(:salt_environment_id) || self.class.sort_by_ancestry(ancestors.where("salt_environment_id is not NULL")).last.try(:salt_environment_id)
|
54
|
+
else
|
55
|
+
self.salt_environment_id
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
45
59
|
def salt_master
|
46
60
|
salt_proxy.to_s
|
47
61
|
end
|
@@ -34,6 +34,7 @@ module ForemanSalt
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def queue_salt_destroy
|
37
|
+
return unless salt? && errors.empty?
|
37
38
|
queue.create(:name => _("Remove autosign entry for %s") % self, :priority => 50, :action => [self, :salt_autosign_remove])
|
38
39
|
queue.create(:name => _("Delete existing salt key for %s") % self, :priority => 50, :action => [self, :salt_key_delete])
|
39
40
|
end
|
@@ -49,7 +50,7 @@ module ForemanSalt
|
|
49
50
|
salt_key_delete # if there's already an existing key
|
50
51
|
@salt_api.autosign_create name
|
51
52
|
rescue => e
|
52
|
-
failure _("Failed to create %{name}'s Salt autosign entry: %{e}") % { :name => name, :e =>
|
53
|
+
failure _("Failed to create %{name}'s Salt autosign entry: %{e}") % { :name => name, :e => e }
|
53
54
|
end
|
54
55
|
|
55
56
|
def salt_autosign_remove
|
@@ -57,7 +58,7 @@ module ForemanSalt
|
|
57
58
|
initialize_salt
|
58
59
|
@salt_api.autosign_remove name
|
59
60
|
rescue => e
|
60
|
-
failure _("Failed to remove %{name}'s Salt autosign entry: %{e}") % { :name => name, :e =>
|
61
|
+
failure _("Failed to remove %{name}'s Salt autosign entry: %{e}") % { :name => name, :e => e }
|
61
62
|
end
|
62
63
|
|
63
64
|
def salt_key_delete
|
@@ -65,7 +66,7 @@ module ForemanSalt
|
|
65
66
|
initialize_salt
|
66
67
|
@salt_api.key_delete name
|
67
68
|
rescue => e
|
68
|
-
failure _("Failed to delete %{name}'s Salt key: %{e}") % { :name => name, :e =>
|
69
|
+
failure _("Failed to delete %{name}'s Salt key: %{e}") % { :name => name, :e => e }
|
69
70
|
end
|
70
71
|
end
|
71
72
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module ForemanSalt
|
2
|
+
class SaltEnvironment < ActiveRecord::Base
|
3
|
+
include Taxonomix
|
4
|
+
include Authorizable
|
5
|
+
|
6
|
+
before_destroy EnsureNotUsedBy.new(:hosts, :hostgroups)
|
7
|
+
|
8
|
+
has_many :hosts, :class_name => "::Host::Managed"
|
9
|
+
has_many :hostgroups, :class_name => "::Hostgroup"
|
10
|
+
|
11
|
+
validates :name, :uniqueness => true, :presence => true, :format => { :with => /\A[\w\d\.]+\z/, :message => N_("is alphanumeric and cannot contain spaces") }
|
12
|
+
|
13
|
+
default_scope lambda {
|
14
|
+
order("salt_environments.name")
|
15
|
+
}
|
16
|
+
|
17
|
+
scoped_search :on => :name, :complete_value => true
|
18
|
+
scoped_search :in => :hostgroups, :on => :name, :complete_value => true, :rename => :hostgroup
|
19
|
+
scoped_search :in => :hosts, :on => :name, :complete_value => true, :rename => :host
|
20
|
+
end
|
21
|
+
end
|
@@ -9,7 +9,7 @@ module ForemanSalt
|
|
9
9
|
|
10
10
|
has_and_belongs_to_many :hostgroups, :class_name => "::Hostgroup", :join_table => "hostgroups_salt_modules"
|
11
11
|
|
12
|
-
validates :name, :uniqueness => true, :presence => true, :format => { :with => /\A[\w\d]
|
12
|
+
validates :name, :uniqueness => true, :presence => true, :format => { :with => /\A(?:[\w\d]+\.{0,1})+[^\.]\z/, :message => N_("must be alphanumeric, can contain dots and must not contain spaces") }
|
13
13
|
|
14
14
|
default_scope lambda {
|
15
15
|
order("salt_modules.name")
|
@@ -1,2 +1,2 @@
|
|
1
|
-
<li><a href="#salt_modules" data-toggle="tab"><%= _('Salt
|
1
|
+
<li><a href="#salt_modules" data-toggle="tab"><%= _('Salt States') %></a></li>
|
2
2
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<div class="tab-pane" id="salt_modules">
|
3
3
|
<div class="row">
|
4
4
|
<div class="col-md-4">
|
5
|
-
<h3>Inherited
|
5
|
+
<h3>Inherited States</h3>
|
6
6
|
<ul>
|
7
7
|
<% @inherited_salt_modules.sort.each do |salt_module| -%>
|
8
8
|
<li title="Inherited from hostgroup"><%= salt_module.name -%></li>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
</ul>
|
11
11
|
</div>
|
12
12
|
<div class="col-md-8">
|
13
|
-
<h3>Salt
|
13
|
+
<h3>Salt States</h3>
|
14
14
|
<% if @inherited_salt_modules.blank? -%>
|
15
15
|
<%= multiple_selects f, :salt_module, ::ForemanSalt::SaltModule, @salt_modules.try(:map, &:id), :label => "" %>
|
16
16
|
<% else -%>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
selector_text = "<%= select_f f, :salt_environment_id, ForemanSalt::SaltEnvironment.all, :id, :name,
|
2
|
+
{ :include_blank => blank_or_inherit_f(f, :salt_environment) },
|
3
|
+
{ :label => _('Salt Environment') } %>"
|
4
|
+
|
5
|
+
Deface::Override.new(:virtual_path => "hosts/_form",
|
6
|
+
:name => "add_salt_environment_to_host",
|
7
|
+
:insert_bottom => 'div#primary',
|
8
|
+
:text => selector_text)
|
9
|
+
|
10
|
+
Deface::Override.new(:virtual_path => "hostgroups/_form",
|
11
|
+
:name => "add_salt_environment_to_hostgroup",
|
12
|
+
:insert_bottom => 'div#primary',
|
13
|
+
:text => selector_text)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%= form_for @salt_environment, :url => (@salt_environment.new_record? ? salt_environments_path : salt_environment_path(:id => @salt_environment.id)) do |f| %>
|
2
|
+
<%= base_errors_for @salt_environment %>
|
3
|
+
<ul class="nav nav-tabs" data-tabs="tabs">
|
4
|
+
<li class="active"><a href="#primary" data-toggle="tab"><%= _('Salt Environments') %></a></li>
|
5
|
+
</ul>
|
6
|
+
|
7
|
+
<div class="tab-content">
|
8
|
+
<div class="tab-pane active" id="primary">
|
9
|
+
<%= text_f f, :name %>
|
10
|
+
</div>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<%= submit_or_cancel f %>
|
14
|
+
<% end %>
|
15
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<% title _("Salt Environments") %>
|
2
|
+
|
3
|
+
<% title_actions button_group(display_link_if_authorized(_("New Salt Environment"), hash_for_new_salt_environment_path)) %>
|
4
|
+
|
5
|
+
<table class="table table-bordered table-striped">
|
6
|
+
<tr>
|
7
|
+
<th><%= sort :name, :as => s_("SaltEnvironment|Name") %></th>
|
8
|
+
<th></th>
|
9
|
+
</tr>
|
10
|
+
<% for salt_environment in @salt_environments %>
|
11
|
+
<tr>
|
12
|
+
<td><%=link_to_if_authorized h(salt_environment.name), hash_for_edit_salt_environment_path(:id => salt_environment).merge(:auth_object => salt_environment, :authorizer => authorizer) %></td>
|
13
|
+
<td>
|
14
|
+
<%= action_buttons(display_delete_if_authorized hash_for_salt_environment_path(:id => salt_environment).merge(:auth_object => salt_environment, :authorizer => authorizer),
|
15
|
+
:confirm => _("Delete %s?") % salt_environment.name) %>
|
16
|
+
</td>
|
17
|
+
</tr>
|
18
|
+
<% end %>
|
19
|
+
</table>
|
20
|
+
|
21
|
+
<%= page_entries_info @salt_environments %>
|
22
|
+
<%= will_paginate @salt_environments %>
|
23
|
+
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<%= form_for @salt_module, :url => (@salt_module.new_record? ? salt_modules_path : salt_module_path(:id => @salt_module.id)) do |f| %>
|
2
2
|
<%= base_errors_for @salt_module %>
|
3
3
|
<ul class="nav nav-tabs" data-tabs="tabs">
|
4
|
-
<li class="active"><a href="#primary" data-toggle="tab"><%= _('Salt
|
4
|
+
<li class="active"><a href="#primary" data-toggle="tab"><%= _('Salt States') %></a></li>
|
5
5
|
</ul>
|
6
6
|
|
7
7
|
<div class="tab-content">
|
@@ -1,6 +1,6 @@
|
|
1
|
-
<% title _("Salt
|
1
|
+
<% title _("Salt States") %>
|
2
2
|
|
3
|
-
<% title_actions button_group(display_link_if_authorized(_("New Salt
|
3
|
+
<% title_actions button_group(display_link_if_authorized(_("New Salt State"), hash_for_new_salt_module_path)) %>
|
4
4
|
|
5
5
|
<table class="table table-bordered table-striped">
|
6
6
|
<tr>
|
data/config/routes.rb
CHANGED
@@ -3,7 +3,13 @@ Rails.application.routes.draw do
|
|
3
3
|
scope :salt, :path => '/salt' do
|
4
4
|
match "/node/:name" => 'hosts#salt_external_node', :constraints => { :name => /[^\.][\w\.-]+/ }
|
5
5
|
|
6
|
-
resources :
|
6
|
+
resources :salt_environments, :controller => 'foreman_salt/salt_environments' do
|
7
|
+
collection do
|
8
|
+
get 'auto_complete_search'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
resources :salt_modules, :controller => 'foreman_salt/salt_modules' do
|
7
13
|
collection do
|
8
14
|
get 'auto_complete_search'
|
9
15
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class CreateSaltEnvironments < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :salt_environments do |t|
|
4
|
+
t.string :name, :default => "", :null => false
|
5
|
+
t.timestamps
|
6
|
+
end
|
7
|
+
|
8
|
+
add_column :hosts, :salt_environment_id, :integer
|
9
|
+
add_column :hostgroups, :salt_environment_id, :integer
|
10
|
+
|
11
|
+
add_index :salt_environments, :name, :unique => true
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.down
|
15
|
+
remove_column :hosts, :salt_environment_id
|
16
|
+
remove_column :hostgroups, :salt_environment_id
|
17
|
+
drop_table :salt_environments
|
18
|
+
end
|
19
|
+
end
|
data/lib/foreman_salt/engine.rb
CHANGED
@@ -19,9 +19,15 @@ module ForemanSalt
|
|
19
19
|
Foreman::Plugin.register :foreman_salt do
|
20
20
|
requires_foreman '>= 1.6'
|
21
21
|
|
22
|
-
menu :top_menu, :
|
22
|
+
menu :top_menu, :salt_environments,
|
23
|
+
:url_hash => {:controller => :'foreman_salt/salt_environments', :action => :index },
|
24
|
+
:caption => 'Environments',
|
25
|
+
:parent => :configure_menu,
|
26
|
+
:after => :common_parameters
|
27
|
+
|
28
|
+
menu :top_menu, :salt_modules,
|
23
29
|
:url_hash => {:controller => :'foreman_salt/salt_modules', :action => :index },
|
24
|
-
:caption => '
|
30
|
+
:caption => 'States',
|
25
31
|
:parent => :configure_menu,
|
26
32
|
:after => :common_parameters
|
27
33
|
|
@@ -34,6 +40,13 @@ module ForemanSalt
|
|
34
40
|
permission :view_hosts, {:hosts => [:salt_external_node]}, :resource_type => 'Host'
|
35
41
|
end
|
36
42
|
|
43
|
+
security_block :salt_environments do |map|
|
44
|
+
permission :create_salt_environments, {:'foreman_salt/salt_environments' => [:new, :create]}, :resource_type => "ForemanSalt::SaltEnvironment"
|
45
|
+
permission :view_salt_environments, {:'foreman_salt/salt_environments' => [:index, :show, :auto_complete_search]}, :resource_type => "ForemanSalt::SaltEnvironment"
|
46
|
+
permission :edit_salt_environments, {:'foreman_salt/salt_environments' => [:update, :edit]},:resource_type => "ForemanSalt::SaltEnvironment"
|
47
|
+
permission :destroy_salt_environments, {:'foreman_salt/salt_environments' => [:destroy]}, :resource_type => "ForemanSalt::SaltEnvironment"
|
48
|
+
end
|
49
|
+
|
37
50
|
security_block :salt_modules do |map|
|
38
51
|
permission :create_salt_modules, {:'foreman_salt/salt_modules' => [:new, :create]}, :resource_type => "ForemanSalt::SaltModule"
|
39
52
|
permission :view_salt_modules, {:'foreman_salt/salt_modules' => [:index, :show, :auto_complete_search]}, :resource_type => "ForemanSalt::SaltModule"
|
@@ -54,9 +67,10 @@ module ForemanSalt
|
|
54
67
|
end
|
55
68
|
|
56
69
|
role "Salt admin", [:saltrun_hosts, :create_salt_modules, :view_salt_modules, :edit_salt_modules, :destroy_salt_modules,
|
57
|
-
:view_smart_proxies_salt_keys, :destroy_smart_proxies_salt_keys, :edit_smart_proxies_salt_keys,
|
58
|
-
:create_smart_proxies_salt_autosign, :view_smart_proxies_salt_autosign, :destroy_smart_proxies_salt_autosign
|
59
|
-
|
70
|
+
:view_smart_proxies_salt_keys, :destroy_smart_proxies_salt_keys, :edit_smart_proxies_salt_keys,
|
71
|
+
:create_smart_proxies_salt_autosign, :view_smart_proxies_salt_autosign, :destroy_smart_proxies_salt_autosign,
|
72
|
+
:create_salt_environments, :view_salt_environments, :edit_salt_environments, :destroy_salt_environments]
|
73
|
+
|
60
74
|
end
|
61
75
|
end
|
62
76
|
|
data/lib/foreman_salt/version.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'test_plugin_helper'
|
2
|
+
|
3
|
+
module ForemanSalt
|
4
|
+
class SaltEnvironmentTest < ActionDispatch::IntegrationTest
|
5
|
+
|
6
|
+
test "index page" do
|
7
|
+
FactoryGirl.create_list :salt_environment, 50
|
8
|
+
assert_index_page(salt_environments_path, "Salt Environment", "New Salt Environment")
|
9
|
+
end
|
10
|
+
|
11
|
+
test "create new page" do
|
12
|
+
assert_new_button(salt_environments_path, "New Salt Environment", new_salt_environment_path)
|
13
|
+
fill_in "foreman_salt_salt_environment_name", :with => "common"
|
14
|
+
assert_submit_button(salt_environments_path)
|
15
|
+
assert page.has_link? 'common'
|
16
|
+
end
|
17
|
+
|
18
|
+
test "edit page" do
|
19
|
+
salt_environment = FactoryGirl.create :salt_environment
|
20
|
+
visit salt_environments_path
|
21
|
+
click_link salt_environment.name
|
22
|
+
fill_in "foreman_salt_salt_environment_name", :with => "some_other_name"
|
23
|
+
assert_submit_button(salt_environments_path)
|
24
|
+
assert page.has_link? 'some_other_name'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -5,11 +5,11 @@ module ForemanSalt
|
|
5
5
|
|
6
6
|
test "index page" do
|
7
7
|
FactoryGirl.create_list :salt_module, 50
|
8
|
-
assert_index_page(salt_modules_path, "Salt
|
8
|
+
assert_index_page(salt_modules_path, "Salt State", "New Salt State")
|
9
9
|
end
|
10
10
|
|
11
11
|
test "create new page" do
|
12
|
-
assert_new_button(salt_modules_path, "New Salt
|
12
|
+
assert_new_button(salt_modules_path, "New Salt State", new_salt_module_path)
|
13
13
|
fill_in "foreman_salt_salt_module_name", :with => "common"
|
14
14
|
assert_submit_button(salt_modules_path)
|
15
15
|
assert page.has_link? 'common'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test_plugin_helper'
|
2
|
+
|
3
|
+
class SaltKeysTest < ActiveSupport::TestCase
|
4
|
+
setup do
|
5
|
+
User.current = User.find_by_login "admin"
|
6
|
+
end
|
7
|
+
|
8
|
+
test "salt module has a valid name" do
|
9
|
+
salt_module = ForemanSalt::SaltModule.new(:name => 'foo.bar.baz')
|
10
|
+
assert_valid salt_module
|
11
|
+
end
|
12
|
+
|
13
|
+
test "salt module has invalid name" do
|
14
|
+
salt_module = ForemanSalt::SaltModule.new(:name => "&bad$name")
|
15
|
+
refute_valid salt_module, :name, /alphanumeric/
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_salt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Benjamin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deface
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
description: Foreman Plug-in for Salt
|
@@ -31,59 +31,69 @@ executables: []
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
-
-
|
35
|
-
-
|
34
|
+
- LICENSE
|
35
|
+
- README.md
|
36
|
+
- Rakefile
|
37
|
+
- app/controllers/foreman_salt/concerns/hostgroups_controller_extensions.rb
|
38
|
+
- app/controllers/foreman_salt/concerns/hosts_controller_extensions.rb
|
39
|
+
- app/controllers/foreman_salt/concerns/smart_proxy_auth_extensions.rb
|
40
|
+
- app/controllers/foreman_salt/concerns/unattended_controller_extensions.rb
|
41
|
+
- app/controllers/foreman_salt/salt_autosign_controller.rb
|
42
|
+
- app/controllers/foreman_salt/salt_environments_controller.rb
|
43
|
+
- app/controllers/foreman_salt/salt_keys_controller.rb
|
44
|
+
- app/controllers/foreman_salt/salt_modules_controller.rb
|
36
45
|
- app/helpers/concerns/foreman_salt/hosts_helper_extensions.rb
|
37
|
-
- app/
|
46
|
+
- app/helpers/concerns/foreman_salt/smart_proxies_helper_extensions.rb
|
47
|
+
- app/helpers/foreman_salt/salt_keys_helper.rb
|
48
|
+
- app/lib/proxy_api/salt.rb
|
49
|
+
- app/models/concerns/foreman_salt/host_managed_extensions.rb
|
50
|
+
- app/models/concerns/foreman_salt/hostgroup_extensions.rb
|
51
|
+
- app/models/concerns/foreman_salt/orchestration/salt.rb
|
52
|
+
- app/models/foreman_salt/fact_name.rb
|
53
|
+
- app/models/foreman_salt/salt_environment.rb
|
54
|
+
- app/models/foreman_salt/salt_module.rb
|
38
55
|
- app/overrides/foreman/salt_modules/_host_tab.html.erb
|
39
56
|
- app/overrides/foreman/salt_modules/_host_tab_pane.html.erb
|
57
|
+
- app/overrides/salt_environment_selector.rb
|
58
|
+
- app/overrides/salt_modules_selector.rb
|
40
59
|
- app/overrides/salt_proxy_selector.rb
|
41
|
-
- app/
|
42
|
-
- app/
|
43
|
-
- app/views/foreman_salt/
|
44
|
-
- app/views/foreman_salt/salt_modules/edit.html.erb
|
45
|
-
- app/views/foreman_salt/salt_keys/index.erb
|
60
|
+
- app/services/foreman_salt/fact_importer.rb
|
61
|
+
- app/services/foreman_salt/smart_proxies/salt_keys.rb
|
62
|
+
- app/views/foreman_salt/salt_autosign/_form.html.erb
|
46
63
|
- app/views/foreman_salt/salt_autosign/index.html.erb
|
47
64
|
- app/views/foreman_salt/salt_autosign/new.html.erb
|
48
|
-
- app/views/foreman_salt/
|
49
|
-
- app/
|
50
|
-
- app/
|
51
|
-
- app/
|
52
|
-
- app/
|
53
|
-
- app/
|
54
|
-
- app/
|
55
|
-
- app/
|
56
|
-
- app/
|
57
|
-
- app/controllers/foreman_salt/salt_autosign_controller.rb
|
58
|
-
- app/controllers/foreman_salt/salt_keys_controller.rb
|
59
|
-
- app/controllers/foreman_salt/concerns/hostgroups_controller_extensions.rb
|
60
|
-
- app/controllers/foreman_salt/concerns/smart_proxy_auth_extensions.rb
|
61
|
-
- app/controllers/foreman_salt/concerns/hosts_controller_extensions.rb
|
62
|
-
- app/controllers/foreman_salt/concerns/unattended_controller_extensions.rb
|
63
|
-
- app/lib/proxy_api/salt.rb
|
65
|
+
- app/views/foreman_salt/salt_environments/_form.html.erb
|
66
|
+
- app/views/foreman_salt/salt_environments/edit.html.erb
|
67
|
+
- app/views/foreman_salt/salt_environments/index.html.erb
|
68
|
+
- app/views/foreman_salt/salt_environments/new.html.erb
|
69
|
+
- app/views/foreman_salt/salt_keys/index.erb
|
70
|
+
- app/views/foreman_salt/salt_modules/_form.html.erb
|
71
|
+
- app/views/foreman_salt/salt_modules/edit.html.erb
|
72
|
+
- app/views/foreman_salt/salt_modules/index.html.erb
|
73
|
+
- app/views/foreman_salt/salt_modules/new.html.erb
|
64
74
|
- config/routes.rb
|
65
|
-
- db/
|
75
|
+
- db/migrate/20140813081913_add_salt_proxy_to_host_and_host_group.rb
|
66
76
|
- db/migrate/20140817210214_create_salt_modules.rb
|
67
77
|
- db/migrate/20140829210214_add_salt_modules_to_hostgroups.rb
|
68
|
-
- db/migrate/
|
78
|
+
- db/migrate/20140920232200_create_salt_environments.rb
|
79
|
+
- db/seeds.d/75-salt-seeds.rb
|
80
|
+
- lib/foreman_salt.rb
|
69
81
|
- lib/foreman_salt/engine.rb
|
70
82
|
- lib/foreman_salt/version.rb
|
71
83
|
- lib/tasks/foreman_salt_tasks.rake
|
72
|
-
-
|
73
|
-
-
|
74
|
-
-
|
75
|
-
-
|
84
|
+
- test/factories/foreman_salt_factories.rb
|
85
|
+
- test/functional/hosts_controller_test.rb
|
86
|
+
- test/integration/salt_autosign_test.rb
|
87
|
+
- test/integration/salt_environment_test.rb
|
76
88
|
- test/integration/salt_keys_test.rb
|
77
89
|
- test/integration/salt_module_test.rb
|
78
|
-
- test/
|
79
|
-
- test/unit/salt_keys_test.rb
|
90
|
+
- test/test_plugin_helper.rb
|
80
91
|
- test/unit/grains_centos.json
|
81
|
-
- test/unit/host_extensions_test.rb
|
82
92
|
- test/unit/grains_importer_test.rb
|
93
|
+
- test/unit/host_extensions_test.rb
|
83
94
|
- test/unit/hostgroup_extensions_test.rb
|
84
|
-
- test/
|
85
|
-
- test/
|
86
|
-
- test/functional/hosts_controller_test.rb
|
95
|
+
- test/unit/salt_keys_test.rb
|
96
|
+
- test/unit/salt_modules_test.rb
|
87
97
|
homepage: http://github.com/theforeman/foreman_salt
|
88
98
|
licenses:
|
89
99
|
- GPL-3
|
@@ -94,29 +104,31 @@ require_paths:
|
|
94
104
|
- lib
|
95
105
|
required_ruby_version: !ruby/object:Gem::Requirement
|
96
106
|
requirements:
|
97
|
-
- -
|
107
|
+
- - ">="
|
98
108
|
- !ruby/object:Gem::Version
|
99
109
|
version: '0'
|
100
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
111
|
requirements:
|
102
|
-
- -
|
112
|
+
- - ">="
|
103
113
|
- !ruby/object:Gem::Version
|
104
114
|
version: '0'
|
105
115
|
requirements: []
|
106
116
|
rubyforge_project:
|
107
|
-
rubygems_version: 2.
|
117
|
+
rubygems_version: 2.2.2
|
108
118
|
signing_key:
|
109
119
|
specification_version: 4
|
110
120
|
summary: Foreman Plug-in for Salt
|
111
121
|
test_files:
|
112
|
-
- test/
|
113
|
-
- test/integration/salt_module_test.rb
|
114
|
-
- test/integration/salt_autosign_test.rb
|
115
|
-
- test/unit/salt_keys_test.rb
|
116
|
-
- test/unit/grains_centos.json
|
122
|
+
- test/factories/foreman_salt_factories.rb
|
117
123
|
- test/unit/host_extensions_test.rb
|
124
|
+
- test/unit/salt_keys_test.rb
|
118
125
|
- test/unit/grains_importer_test.rb
|
119
126
|
- test/unit/hostgroup_extensions_test.rb
|
120
|
-
- test/
|
121
|
-
- test/
|
127
|
+
- test/unit/salt_modules_test.rb
|
128
|
+
- test/unit/grains_centos.json
|
122
129
|
- test/functional/hosts_controller_test.rb
|
130
|
+
- test/integration/salt_autosign_test.rb
|
131
|
+
- test/integration/salt_keys_test.rb
|
132
|
+
- test/integration/salt_environment_test.rb
|
133
|
+
- test/integration/salt_module_test.rb
|
134
|
+
- test/test_plugin_helper.rb
|