-
Notifications
You must be signed in to change notification settings - Fork 4
/
init.rb
104 lines (91 loc) · 3.36 KB
/
init.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
require 'redmine'
Rails.logger.info 'Starting initr plugin for Redmine'
require 'initr'
require 'initr/plugin'
require 'initr/klass_definition'
require 'access_control_patch'
require 'project_patch'
require 'user_patch'
require 'redmine_plugin_patch'
Rails.configuration.to_prepare do
Project.send(:include, ProjectInitrPatch)
User.send(:include, UserInitrPatch)
Redmine::Plugin.send(:include,RedminePluginPatch)
end
Redmine::Plugin.register :initr do
name 'initr'
author 'Ingent'
description 'A fronted for puppet modules'
version '0.1'
settings :default => {
'puppetmaster' => 'puppet',
'puppetmaster_ip' => '127.0.0.1',
'puppetmaster_port' => '8140'
},
:partial => '/initr/settings'
# This plugin adds a project module
# It can be enabled/disabled at project level (Project settings -> Modules)
project_module :initr do
permission :add_nodes,
{:node => [:new,:scan_puppet_hosts]},
:require => :member
permission :add_templates,
{:node => [:new_template]},
:require => :loggedin
permission :view_nodes,
{:node => [:list,:facts,:report,:resource,:get_services],
:klass => [:list]}
permission :view_own_nodes,
{:node => [:list,:facts,:report,:resource],
:klass => [:list]},
:require => :loggedin
permission :edit_nodes,
{:node => [:destroy_exported_resources],
:klass => [:create, :move, :destroy, :apply_template,:activate]},
:require => :member
permission :edit_own_nodes,
{:node => [:destroy_exported_resources],
:klass => [:create, :move, :destroy, :apply_template,:activate]},
:require => :loggedin
permission :delete_nodes,
{:node => [:destroy]},
:require => :member
permission :delete_own_nodes,
{:node => [:destroy]},
:require => :loggedin
permission :edit_klasses,
{:klass => [:configure]},
:require => :member
permission :edit_klasses_of_own_nodes,
{},
:require => :loggedin
end
# A new item is added to the project menu
menu :project_menu, :initr, { :controller => 'node', :action => 'list' }, :caption => 'Initr'
# A new item is added to the aplication menu
menu :application_menu, :initr, { :controller => 'node', :action => 'list' }, :caption => 'Initr'
end
# # Load initr plugins when all is initialized
#RedmineApp::Application.config.after_initialize do
Initr::Plugin.load
# puts ActiveSupport::Dependencies.autoload_paths
# dump to a file some server info need by scripts (see initr_login)
# must be done after_initialize to avoid accessing Setting[] before all
# plugins are loaded, which produces missing settings
open("#{Rails.root}/plugins/initr/server_info.yml",'w') do |f|
f.puts "# Autogenerated from initr/init.rb"
f.puts "# Changes will be lost"
f.puts "Rails.root: #{Rails.root}"
f.puts "Rails.env: #{Rails.env}"
begin
f.puts "DOMAIN: #{Setting[:protocol]}://#{Setting[:host_name]}"
rescue
# redmine has no settings table yet
f.puts "DOMAIN: http://localhost:3000"
end
end
# Deprecated Klasses
# ActiveRecord::Base.connection.execute("delete from klasses where type='InitrWpkg';")
# ActiveRecord::Base.connection.execute("delete from klasses where type='Initr::RemoteBackup';")
# ActiveRecord::Base.connection.execute("delete from klasses where type='Initr::RemoteBackupServer';")
#end