vagrant-ec-sandbox 0.1.0.Preview

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +7 -0
  2. data/lib/vagrant-ec-sandbox/action/base.rb +53 -0
  3. data/lib/vagrant-ec-sandbox/action/check_dir.rb +41 -0
  4. data/lib/vagrant-ec-sandbox/action/check_file.rb +41 -0
  5. data/lib/vagrant-ec-sandbox/action/code/install.rb +0 -0
  6. data/lib/vagrant-ec-sandbox/action/code/prepare_dist.rb +37 -0
  7. data/lib/vagrant-ec-sandbox/action/code/remove.rb +0 -0
  8. data/lib/vagrant-ec-sandbox/action/code.rb +15 -0
  9. data/lib/vagrant-ec-sandbox/action/dist/check_artifact.rb +26 -0
  10. data/lib/vagrant-ec-sandbox/action/dist/check_wildfly_installer.rb +28 -0
  11. data/lib/vagrant-ec-sandbox/action/dist/clear_contents.rb +34 -0
  12. data/lib/vagrant-ec-sandbox/action/dist/config_ec.rb +92 -0
  13. data/lib/vagrant-ec-sandbox/action/dist/deploy_ecapp.rb +44 -0
  14. data/lib/vagrant-ec-sandbox/action/dist/get_vbuild.rb +39 -0
  15. data/lib/vagrant-ec-sandbox/action/dist/get_vnexus.rb +65 -0
  16. data/lib/vagrant-ec-sandbox/action/dist/install_wildfly.rb +40 -0
  17. data/lib/vagrant-ec-sandbox/action/dist/make_contents.rb +36 -0
  18. data/lib/vagrant-ec-sandbox/action/dist.rb +44 -0
  19. data/lib/vagrant-ec-sandbox/action/init/env_config_confirm.rb +18 -0
  20. data/lib/vagrant-ec-sandbox/action/init/init_dir.rb +31 -0
  21. data/lib/vagrant-ec-sandbox/action/init/init_vagrant.rb +67 -0
  22. data/lib/vagrant-ec-sandbox/action/init.rb +11 -0
  23. data/lib/vagrant-ec-sandbox/action/select_db.rb +51 -0
  24. data/lib/vagrant-ec-sandbox/action/up_vagrant.rb +23 -0
  25. data/lib/vagrant-ec-sandbox/action/use_app_server.rb +27 -0
  26. data/lib/vagrant-ec-sandbox/action/wildfly/get_isinstalled.rb +50 -0
  27. data/lib/vagrant-ec-sandbox/action/wildfly/redirect_dirs.rb +56 -0
  28. data/lib/vagrant-ec-sandbox/action/wildfly/reload.rb +45 -0
  29. data/lib/vagrant-ec-sandbox/action/wildfly/reload_admin.rb +38 -0
  30. data/lib/vagrant-ec-sandbox/action/wildfly/remove.rb +32 -0
  31. data/lib/vagrant-ec-sandbox/action/wildfly/start.rb +42 -0
  32. data/lib/vagrant-ec-sandbox/action/wildfly/start_admin.rb +36 -0
  33. data/lib/vagrant-ec-sandbox/action/wildfly/status.rb +36 -0
  34. data/lib/vagrant-ec-sandbox/action/wildfly/stop.rb +42 -0
  35. data/lib/vagrant-ec-sandbox/action/wildfly/switch_db.rb +48 -0
  36. data/lib/vagrant-ec-sandbox/action/wildfly.rb +79 -0
  37. data/lib/vagrant-ec-sandbox/action.rb +129 -0
  38. data/lib/vagrant-ec-sandbox/command/as/config_db.rb +34 -0
  39. data/lib/vagrant-ec-sandbox/command/as/install.rb +34 -0
  40. data/lib/vagrant-ec-sandbox/command/as/restart.rb +33 -0
  41. data/lib/vagrant-ec-sandbox/command/as/show_status.rb +32 -0
  42. data/lib/vagrant-ec-sandbox/command/as/start.rb +33 -0
  43. data/lib/vagrant-ec-sandbox/command/as/stop.rb +32 -0
  44. data/lib/vagrant-ec-sandbox/command/as/test.rb +32 -0
  45. data/lib/vagrant-ec-sandbox/command/base.rb +52 -0
  46. data/lib/vagrant-ec-sandbox/command/init.rb +29 -0
  47. data/lib/vagrant-ec-sandbox/command/root.rb +101 -0
  48. data/lib/vagrant-ec-sandbox/communicator_extender.rb +45 -0
  49. data/lib/vagrant-ec-sandbox/config/sandbox_config.rb +235 -0
  50. data/lib/vagrant-ec-sandbox/db_selector/db_info.rb +8 -0
  51. data/lib/vagrant-ec-sandbox/db_selector/db_selector.rb +20 -0
  52. data/lib/vagrant-ec-sandbox/db_selector/direct_selector.rb +30 -0
  53. data/lib/vagrant-ec-sandbox/db_selector/direct_selector_config.rb +37 -0
  54. data/lib/vagrant-ec-sandbox/db_selector/manual_input_selector.rb +32 -0
  55. data/lib/vagrant-ec-sandbox/db_selector/oracle_db_info.rb +19 -0
  56. data/lib/vagrant-ec-sandbox/db_selector/selector_config.rb +22 -0
  57. data/lib/vagrant-ec-sandbox/dir_structure.rb +306 -0
  58. data/lib/vagrant-ec-sandbox/errors.rb +33 -0
  59. data/lib/vagrant-ec-sandbox/helpers.rb +11 -0
  60. data/lib/vagrant-ec-sandbox/plugin.rb +29 -0
  61. data/lib/vagrant-ec-sandbox/resource/hg_clone_provider.rb +46 -0
  62. data/lib/vagrant-ec-sandbox/resource/hg_clone_provider_config.rb +29 -0
  63. data/lib/vagrant-ec-sandbox/resource/local_provider.rb +19 -0
  64. data/lib/vagrant-ec-sandbox/resource/local_provider_config.rb +20 -0
  65. data/lib/vagrant-ec-sandbox/resource/maven_provider.rb +51 -0
  66. data/lib/vagrant-ec-sandbox/resource/maven_provider_config.rb +20 -0
  67. data/lib/vagrant-ec-sandbox/resource/provider_config.rb +10 -0
  68. data/lib/vagrant-ec-sandbox/resource/resource_provider.rb +20 -0
  69. data/lib/vagrant-ec-sandbox/server/app_server/as.rb +18 -0
  70. data/lib/vagrant-ec-sandbox/server/app_server/as_config.rb +38 -0
  71. data/lib/vagrant-ec-sandbox/server/server.rb +18 -0
  72. data/lib/vagrant-ec-sandbox/session.rb +146 -0
  73. data/lib/vagrant-ec-sandbox/util/host/dir_util.rb +39 -0
  74. data/lib/vagrant-ec-sandbox/util/host/file_util.rb +67 -0
  75. data/lib/vagrant-ec-sandbox/util/host/hg_clone.rb +32 -0
  76. data/lib/vagrant-ec-sandbox/util/host/mvn.rb +54 -0
  77. data/lib/vagrant-ec-sandbox/util/name.rb +22 -0
  78. data/lib/vagrant-ec-sandbox/util/output_buffer.rb +58 -0
  79. data/lib/vagrant-ec-sandbox/util/sandbox/get_user_processes.rb +85 -0
  80. data/lib/vagrant-ec-sandbox/util/sandbox/system_command.rb +91 -0
  81. data/lib/vagrant-ec-sandbox/util/sandbox/wildfly/add-user.rb +48 -0
  82. data/lib/vagrant-ec-sandbox/util/sandbox/wildfly/deploy.rb +34 -0
  83. data/lib/vagrant-ec-sandbox/util/sandbox/wildfly/response.rb +32 -0
  84. data/lib/vagrant-ec-sandbox/util/sandbox/wildfly/run_cli.rb +86 -0
  85. data/lib/vagrant-ec-sandbox/version.rb +5 -0
  86. data/lib/vagrant-ec-sandbox.rb +113 -0
  87. data/templates/action/dist/install_wildfly.sh.erb +23 -0
  88. data/templates/action/hello.sh.erb +1 -0
  89. data/templates/action/init/Vagrantfile.erb +91 -0
  90. data/templates/action/init/provision.sh.erb +71 -0
  91. data/templates/action/init/resources/settings.xml.erb +118 -0
  92. data/templates/action/wildfly/config_ec.sh.erb +5 -0
  93. data/templates/action/wildfly/deloy.cli.erb +0 -0
  94. data/templates/action/wildfly/open_interface.cli.erb +3 -0
  95. data/templates/action/wildfly/redirect_log.cli.erb +3 -0
  96. data/templates/action/wildfly/switch_db.cli.erb +43 -0
  97. data/templates/locales/en.yml +35 -0
  98. metadata +168 -0
@@ -0,0 +1,235 @@
1
+ module VagrantPlugins
2
+ module ECSandbox
3
+ module Config
4
+ class SandboxConfig < Vagrant.plugin("2", "config")
5
+ attr_accessor :default_db_selector_id
6
+
7
+ def initialize
8
+ @__server_configs = {} # hash of {id, config_block}
9
+ @__servers = {} # hash of {id, name}
10
+ @__db_selector_configs = {} # hash of {id, config_block}
11
+ @__db_selectors = {} # hash of {id, name}
12
+ @__resource_provider_configs = {} # hash of {resource path, config_block}
13
+ @__resource_provider_paths = {} # hash of {resource path, [paths]}
14
+
15
+ @__compiled_server_configs = {}
16
+ @__compiled_db_selector_configs = {}
17
+ @__compiled_resource_provider_configs = {} #hash of {resource path, config}
18
+ @__resource_provider_names = {}
19
+ @__finalized = false
20
+ end
21
+
22
+ def server(name, &block)
23
+ name = name.to_sym
24
+ id = "#{name}_#{@__servers.size + 1}"
25
+
26
+ @__server_configs[id] = block
27
+ @__servers[id] = name
28
+
29
+ id
30
+ end
31
+
32
+ def db_selector(name, &block)
33
+ name = name.to_sym
34
+ id = "#{name}_#{@__db_selectors.size + 1}"
35
+
36
+ @__db_selector_configs[id] = block
37
+ @__db_selectors[id] = name
38
+
39
+ id
40
+ end
41
+
42
+ def artifact(name, &block)
43
+ internal_name = __get_resource_internal_name(:artifact, name)
44
+ @__resource_provider_configs[internal_name] = block
45
+ @__resource_provider_paths[internal_name] = [:artifact, name]
46
+ end
47
+
48
+ def code(name, &block)
49
+ internal_name = __get_resource_internal_name(:code, name)
50
+ @__resource_provider_configs[internal_name] = block
51
+ @__resource_provider_paths[internal_name] = [:code, name]
52
+ end
53
+
54
+ def __get_resource_internal_name(category, name)
55
+ category = category.to_s if category.is_a?(Symbol)
56
+ name = name.to_s if name.is_a?(Symbol)
57
+ name = "#{category}_#{name}"
58
+
59
+ name.to_sym
60
+ end
61
+
62
+ def get_servers
63
+ raise "Must finalize first." if !@__finalized
64
+ return @__servers
65
+ end
66
+
67
+ def get_db_selectors
68
+ raise "Must finalize first." if !@__finalized
69
+ return @__db_selectors
70
+ end
71
+
72
+ def get_resources
73
+ raise "Must finalize first." if !@__finalized
74
+ return @__resource_provider_paths.values
75
+ end
76
+
77
+
78
+ def get_server_config(id)
79
+ raise "Must finalize first." if !@__finalized
80
+ return @__compiled_server_configs[id]
81
+ end
82
+
83
+ def get_db_selector_config(id)
84
+ raise "Must finalize first." if !@__finalized
85
+ return @__compiled_db_selector_configs[id]
86
+ end
87
+
88
+ def get_resource_config(category, name)
89
+ internal_name = __get_resource_internal_name(category, name)
90
+ return @__compiled_resource_provider_configs[internal_name]
91
+ end
92
+
93
+ def get_resource_provider_name(category, name)
94
+ internal_name = __get_resource_internal_name(category, name)
95
+ return @__resource_provider_names[internal_name]
96
+ end
97
+
98
+
99
+ def merge(other)
100
+ super.tap do |result|
101
+ other_resource_provider_configs = other.instance_variable_get(:@__resource_provider_configs) || {}
102
+ other_resource_provider_paths = other.instance_variable_get(:@__resource_provider_paths) || {}
103
+ other_server_configs = other.instance_variable_get(:@__server_configs) || {}
104
+ other_servers = other.instance_variable_get(:@__servers) || {}
105
+ other_db_selector_configs = other.instance_variable_get(:@__db_selector_configs) || {}
106
+ other_db_selectors = other.instance_variable_get(:@__db_selectors) || {}
107
+
108
+ new_resource_provider_configs = other_resource_provider_configs.dup.merge(@__resource_provider_configs)
109
+ new_resource_provider_paths = other_resource_provider_paths.dup.merge(@__resource_provider_paths)
110
+ new_server_configs = other_server_configs.dup.merge(@__server_configs)
111
+ new_servers = other_servers.dup.merge(@__servers)
112
+ new_db_selector_configs = other_db_selector_configs.dup.merge(@__db_selector_configs)
113
+ new_db_selectors = other_db_selectors.dup.merge(@__db_selectors)
114
+
115
+ result.instance_variable_set(:@__resource_provider_configs, new_resource_provider_configs)
116
+ result.instance_variable_set(:@__resource_provider_paths, new_resource_provider_paths)
117
+ result.instance_variable_set(:@__server_configs, new_server_configs)
118
+ result.instance_variable_set(:@__servers, new_servers)
119
+ result.instance_variable_set(:@__db_selector_configs, new_db_selector_configs)
120
+ result.instance_variable_set(:@__db_selectors, new_db_selectors)
121
+ end
122
+ end
123
+
124
+ def finalize!
125
+ @__resource_provider_configs.each do |id, block|
126
+ paths = @__resource_provider_paths[id]
127
+ compile_resource_provider_config(paths[0], paths[1], block)
128
+ end
129
+
130
+
131
+ @__server_configs.each do |id, block|
132
+ name = @__servers[id]
133
+ compile_server_config(id, name, block)
134
+ end
135
+
136
+
137
+ manual_selector_found = false
138
+ @__db_selector_configs.each do |id, block|
139
+ name = @__db_selectors[id]
140
+ if name == :manual
141
+ manual_selector_found = true
142
+ end
143
+ compile_db_selector_config(id, name, block)
144
+ end
145
+
146
+ unless manual_selector_found
147
+ id = db_selector('manual')
148
+ compile_db_selector_config(id, :manual, nil)
149
+ end
150
+
151
+ @__finalized = true
152
+ end
153
+
154
+ def compile_server_config(id, name, block)
155
+ config_class = VagrantPlugins::ECSandbox.server_configs[name]
156
+ config_class ||= Vagrant::Config::V2::DummyConfig
157
+
158
+ # load the config and apply blocks on it
159
+
160
+ begin
161
+ config = config_class.new
162
+ block.call(config, Vagrant::Config::V2::DummyConfig.new)
163
+ rescue Exception => e
164
+ raise Vagrant::Errors::VagrantfileLoadError,
165
+ path: "<server config: #{name}>",
166
+ message: e.message
167
+ end
168
+
169
+ config.finalize!
170
+ @__compiled_server_configs[id] = config
171
+ end
172
+
173
+ def compile_db_selector_config(id, name, block)
174
+ config_class = VagrantPlugins::ECSandbox.db_selector_configs[name]
175
+ config_class ||= Vagrant::Config::V2::DummyConfig
176
+
177
+ # load the config and apply blocks on it
178
+ begin
179
+ config = config_class.new
180
+ block.call(config, Vagrant::Config::V2::DummyConfig.new) if block
181
+ rescue Exception => e
182
+ raise Vagrant::Errors::VagrantfileLoadError,
183
+ path: "<db_selector config: #{name}>",
184
+ message: e.message
185
+ end
186
+
187
+ config.finalize!
188
+ @__compiled_db_selector_configs[id] = config
189
+ @default_db_selector_id = id if config.is_default == true
190
+ end
191
+
192
+ def compile_resource_provider_config(category, name, block)
193
+ configurator = ResourceConfigirator.new
194
+ block.call(configurator) if block
195
+ internal_name = __get_resource_internal_name(category, name)
196
+
197
+ @__compiled_resource_provider_configs[internal_name] = configurator.get_config
198
+ @__resource_provider_names[internal_name] = configurator.get_provider_name
199
+ end
200
+
201
+ class ResourceConfigirator
202
+ def use(provider_name)
203
+ @provider_name = provider_name.chop
204
+ @provider_name = provider_name.to_sym unless provider_name.is_a?(Symbol)
205
+ config_class = VagrantPlugins::ECSandbox.resource_provider_configs[@provider_name]
206
+ config_class ||= Vagrant::Config::V2::DummyConfig
207
+
208
+ # load the config and apply blocks on it
209
+ begin
210
+ @config = config_class.new
211
+ rescue Exception => e
212
+ raise Vagrant::Errors::VagrantfileLoadError,
213
+ path: "<resource config: #{use}>",
214
+ message: e.message
215
+ end
216
+ end
217
+
218
+ def config
219
+ @config
220
+ end
221
+
222
+ def get_config
223
+ raise "need to specify a provider with 'use' method first" unless @provider_name
224
+ config.finalize!
225
+ config
226
+ end
227
+
228
+ def get_provider_name
229
+ @provider_name
230
+ end
231
+ end
232
+ end
233
+ end
234
+ end
235
+ end
@@ -0,0 +1,8 @@
1
+ module VagrantPlugins
2
+ module ECSandbox
3
+ module DBSelector
4
+ class DBInfo
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,20 @@
1
+ module VagrantPlugins
2
+ module ECSandbox
3
+ module DBSelector
4
+ class DBSelector
5
+ attr_reader :id
6
+ attr_reader :config
7
+ attr_reader :name
8
+
9
+ def initialize(id, config)
10
+ @id = id
11
+ @config = config
12
+ @name = config.name if config.name.is_a?(String)
13
+ end
14
+
15
+ def select(env)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,30 @@
1
+ require_relative 'db_selector'
2
+ require_relative 'oracle_db_info'
3
+
4
+ module VagrantPlugins
5
+ module ECSandbox
6
+ module DBSelector
7
+ class DirectSelector < DBSelector
8
+ def self.name
9
+ "direct"
10
+ end
11
+
12
+ def self.source
13
+ "Pre-defined"
14
+ end
15
+
16
+
17
+ def select(env)
18
+ info = OracleDBInfo.new
19
+ info.host = @config.host
20
+ info.port = @config.port
21
+ info.service = @config.serv
22
+ info.user = @config.user
23
+ info.password = @config.pw
24
+
25
+ info
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,37 @@
1
+ require "vagrant"
2
+ require_relative "selector_config"
3
+
4
+ module VagrantPlugins
5
+ module ECSandbox
6
+ module DBSelector
7
+ class DirectSelectorConfig < SelectorConfig
8
+ attr_accessor :name
9
+ attr_accessor :host
10
+ attr_accessor :port
11
+ attr_accessor :serv
12
+ attr_accessor :user
13
+ attr_accessor :pw
14
+
15
+ def initialize
16
+ super
17
+ @name = UNSET_VALUE
18
+ @host = UNSET_VALUE
19
+ @port = UNSET_VALUE
20
+ @serv = UNSET_VALUE
21
+ @user = UNSET_VALUE
22
+ @pw = UNSET_VALUE
23
+ end
24
+
25
+ def finalize!
26
+ super
27
+ @name = nil if @name == UNSET_VALUE
28
+ @host = nil if @host == UNSET_VALUE
29
+ @port = '1521' if @port == UNSET_VALUE
30
+ @serv = nil if @serv == UNSET_VALUE
31
+ @user = nil if @user == UNSET_VALUE
32
+ @pw = 'energy' if @pw == UNSET_VALUE
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,32 @@
1
+ require_relative 'db_selector'
2
+
3
+ module VagrantPlugins
4
+ module ECSandbox
5
+ module DBSelector
6
+ class ManualInputSelector < DBSelector
7
+ def self.name
8
+ "manual"
9
+ end
10
+
11
+ def self.source
12
+ "Manual input"
13
+ end
14
+
15
+
16
+ def select(env)
17
+ ui = env[:ui]
18
+ info = OracleDBInfo.new
19
+
20
+ ui.info('Manually input a database connection info:')
21
+ info.host = ui.ask('Host: ')
22
+ info.port = ui.ask('Port [1521]: ') || '1521'
23
+ info.service = ui.ask('Service: ')
24
+ info.user = ui.ask('User: ')
25
+ info.password = ui.ask('Password [energy]: ', echo:false) || 'energy'
26
+
27
+ info
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,19 @@
1
+ require_relative "db_info"
2
+
3
+ module VagrantPlugins
4
+ module ECSandbox
5
+ module DBSelector
6
+ class OracleDBInfo < DBInfo
7
+ attr_accessor :host
8
+ attr_accessor :port
9
+ attr_accessor :service
10
+ attr_accessor :user
11
+ attr_accessor :password
12
+
13
+ def initialize
14
+ @port = '1521'
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,22 @@
1
+ require "vagrant"
2
+
3
+ module VagrantPlugins
4
+ module ECSandbox
5
+ module DBSelector
6
+ class SelectorConfig < Vagrant.plugin("2", "config")
7
+ attr_accessor :is_default
8
+ attr_accessor :name
9
+
10
+ def initialize
11
+ @is_default = UNSET_VALUE
12
+ @name = UNSET_VALUE
13
+ end
14
+
15
+ def finalize!
16
+ @is_default = false if @is_default == UNSET_VALUE
17
+ @name = nil if @name == UNSET_VALUE
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end