vagrant-ec-sandbox 0.1.0.Preview
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/vagrant-ec-sandbox/action/base.rb +53 -0
- data/lib/vagrant-ec-sandbox/action/check_dir.rb +41 -0
- data/lib/vagrant-ec-sandbox/action/check_file.rb +41 -0
- data/lib/vagrant-ec-sandbox/action/code/install.rb +0 -0
- data/lib/vagrant-ec-sandbox/action/code/prepare_dist.rb +37 -0
- data/lib/vagrant-ec-sandbox/action/code/remove.rb +0 -0
- data/lib/vagrant-ec-sandbox/action/code.rb +15 -0
- data/lib/vagrant-ec-sandbox/action/dist/check_artifact.rb +26 -0
- data/lib/vagrant-ec-sandbox/action/dist/check_wildfly_installer.rb +28 -0
- data/lib/vagrant-ec-sandbox/action/dist/clear_contents.rb +34 -0
- data/lib/vagrant-ec-sandbox/action/dist/config_ec.rb +92 -0
- data/lib/vagrant-ec-sandbox/action/dist/deploy_ecapp.rb +44 -0
- data/lib/vagrant-ec-sandbox/action/dist/get_vbuild.rb +39 -0
- data/lib/vagrant-ec-sandbox/action/dist/get_vnexus.rb +65 -0
- data/lib/vagrant-ec-sandbox/action/dist/install_wildfly.rb +40 -0
- data/lib/vagrant-ec-sandbox/action/dist/make_contents.rb +36 -0
- data/lib/vagrant-ec-sandbox/action/dist.rb +44 -0
- data/lib/vagrant-ec-sandbox/action/init/env_config_confirm.rb +18 -0
- data/lib/vagrant-ec-sandbox/action/init/init_dir.rb +31 -0
- data/lib/vagrant-ec-sandbox/action/init/init_vagrant.rb +67 -0
- data/lib/vagrant-ec-sandbox/action/init.rb +11 -0
- data/lib/vagrant-ec-sandbox/action/select_db.rb +51 -0
- data/lib/vagrant-ec-sandbox/action/up_vagrant.rb +23 -0
- data/lib/vagrant-ec-sandbox/action/use_app_server.rb +27 -0
- data/lib/vagrant-ec-sandbox/action/wildfly/get_isinstalled.rb +50 -0
- data/lib/vagrant-ec-sandbox/action/wildfly/redirect_dirs.rb +56 -0
- data/lib/vagrant-ec-sandbox/action/wildfly/reload.rb +45 -0
- data/lib/vagrant-ec-sandbox/action/wildfly/reload_admin.rb +38 -0
- data/lib/vagrant-ec-sandbox/action/wildfly/remove.rb +32 -0
- data/lib/vagrant-ec-sandbox/action/wildfly/start.rb +42 -0
- data/lib/vagrant-ec-sandbox/action/wildfly/start_admin.rb +36 -0
- data/lib/vagrant-ec-sandbox/action/wildfly/status.rb +36 -0
- data/lib/vagrant-ec-sandbox/action/wildfly/stop.rb +42 -0
- data/lib/vagrant-ec-sandbox/action/wildfly/switch_db.rb +48 -0
- data/lib/vagrant-ec-sandbox/action/wildfly.rb +79 -0
- data/lib/vagrant-ec-sandbox/action.rb +129 -0
- data/lib/vagrant-ec-sandbox/command/as/config_db.rb +34 -0
- data/lib/vagrant-ec-sandbox/command/as/install.rb +34 -0
- data/lib/vagrant-ec-sandbox/command/as/restart.rb +33 -0
- data/lib/vagrant-ec-sandbox/command/as/show_status.rb +32 -0
- data/lib/vagrant-ec-sandbox/command/as/start.rb +33 -0
- data/lib/vagrant-ec-sandbox/command/as/stop.rb +32 -0
- data/lib/vagrant-ec-sandbox/command/as/test.rb +32 -0
- data/lib/vagrant-ec-sandbox/command/base.rb +52 -0
- data/lib/vagrant-ec-sandbox/command/init.rb +29 -0
- data/lib/vagrant-ec-sandbox/command/root.rb +101 -0
- data/lib/vagrant-ec-sandbox/communicator_extender.rb +45 -0
- data/lib/vagrant-ec-sandbox/config/sandbox_config.rb +235 -0
- data/lib/vagrant-ec-sandbox/db_selector/db_info.rb +8 -0
- data/lib/vagrant-ec-sandbox/db_selector/db_selector.rb +20 -0
- data/lib/vagrant-ec-sandbox/db_selector/direct_selector.rb +30 -0
- data/lib/vagrant-ec-sandbox/db_selector/direct_selector_config.rb +37 -0
- data/lib/vagrant-ec-sandbox/db_selector/manual_input_selector.rb +32 -0
- data/lib/vagrant-ec-sandbox/db_selector/oracle_db_info.rb +19 -0
- data/lib/vagrant-ec-sandbox/db_selector/selector_config.rb +22 -0
- data/lib/vagrant-ec-sandbox/dir_structure.rb +306 -0
- data/lib/vagrant-ec-sandbox/errors.rb +33 -0
- data/lib/vagrant-ec-sandbox/helpers.rb +11 -0
- data/lib/vagrant-ec-sandbox/plugin.rb +29 -0
- data/lib/vagrant-ec-sandbox/resource/hg_clone_provider.rb +46 -0
- data/lib/vagrant-ec-sandbox/resource/hg_clone_provider_config.rb +29 -0
- data/lib/vagrant-ec-sandbox/resource/local_provider.rb +19 -0
- data/lib/vagrant-ec-sandbox/resource/local_provider_config.rb +20 -0
- data/lib/vagrant-ec-sandbox/resource/maven_provider.rb +51 -0
- data/lib/vagrant-ec-sandbox/resource/maven_provider_config.rb +20 -0
- data/lib/vagrant-ec-sandbox/resource/provider_config.rb +10 -0
- data/lib/vagrant-ec-sandbox/resource/resource_provider.rb +20 -0
- data/lib/vagrant-ec-sandbox/server/app_server/as.rb +18 -0
- data/lib/vagrant-ec-sandbox/server/app_server/as_config.rb +38 -0
- data/lib/vagrant-ec-sandbox/server/server.rb +18 -0
- data/lib/vagrant-ec-sandbox/session.rb +146 -0
- data/lib/vagrant-ec-sandbox/util/host/dir_util.rb +39 -0
- data/lib/vagrant-ec-sandbox/util/host/file_util.rb +67 -0
- data/lib/vagrant-ec-sandbox/util/host/hg_clone.rb +32 -0
- data/lib/vagrant-ec-sandbox/util/host/mvn.rb +54 -0
- data/lib/vagrant-ec-sandbox/util/name.rb +22 -0
- data/lib/vagrant-ec-sandbox/util/output_buffer.rb +58 -0
- data/lib/vagrant-ec-sandbox/util/sandbox/get_user_processes.rb +85 -0
- data/lib/vagrant-ec-sandbox/util/sandbox/system_command.rb +91 -0
- data/lib/vagrant-ec-sandbox/util/sandbox/wildfly/add-user.rb +48 -0
- data/lib/vagrant-ec-sandbox/util/sandbox/wildfly/deploy.rb +34 -0
- data/lib/vagrant-ec-sandbox/util/sandbox/wildfly/response.rb +32 -0
- data/lib/vagrant-ec-sandbox/util/sandbox/wildfly/run_cli.rb +86 -0
- data/lib/vagrant-ec-sandbox/version.rb +5 -0
- data/lib/vagrant-ec-sandbox.rb +113 -0
- data/templates/action/dist/install_wildfly.sh.erb +23 -0
- data/templates/action/hello.sh.erb +1 -0
- data/templates/action/init/Vagrantfile.erb +91 -0
- data/templates/action/init/provision.sh.erb +71 -0
- data/templates/action/init/resources/settings.xml.erb +118 -0
- data/templates/action/wildfly/config_ec.sh.erb +5 -0
- data/templates/action/wildfly/deloy.cli.erb +0 -0
- data/templates/action/wildfly/open_interface.cli.erb +3 -0
- data/templates/action/wildfly/redirect_log.cli.erb +3 -0
- data/templates/action/wildfly/switch_db.cli.erb +43 -0
- data/templates/locales/en.yml +35 -0
- metadata +168 -0
@@ -0,0 +1,306 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module ECSandbox
|
3
|
+
class DirStructure
|
4
|
+
attr_reader :is_sandboxed_dev
|
5
|
+
attr_reader :is_dev
|
6
|
+
attr_reader :project_dir
|
7
|
+
|
8
|
+
def self.of(env_name, opts=nil)
|
9
|
+
# init!
|
10
|
+
new_opts = {
|
11
|
+
dev?:!Vagrant.in_installer?,
|
12
|
+
dev_sandbox?:(!Vagrant.in_installer?)&&File.path(opts[:working_dir]) == "/home/vagrant/repo/.dev-playground",
|
13
|
+
working_dir:opts[:working_dir],
|
14
|
+
dir:[
|
15
|
+
[:project, :vagrantfile, "Vagrantfile"],
|
16
|
+
[:resource, :artifacts, :distribution, "distribution/ec-app-install-distribution.zip"],
|
17
|
+
[:internal, :vagrant, "vagrant"],
|
18
|
+
[:internal, :vagrant, :provision_script, "provision.sh"],
|
19
|
+
[:internal, :tmp, "tmp"],
|
20
|
+
[:internal, :logs, "logs"],
|
21
|
+
[:status, :app_server, :logs, "logs"]
|
22
|
+
]
|
23
|
+
}.merge({} || opts)
|
24
|
+
|
25
|
+
if env_name == :host
|
26
|
+
result = HostDir.configure(new_opts)
|
27
|
+
elsif env_name == :sandbox
|
28
|
+
result = SandboxDir.configure(new_opts)
|
29
|
+
end
|
30
|
+
|
31
|
+
result
|
32
|
+
end
|
33
|
+
|
34
|
+
# def self.of(env_name)
|
35
|
+
# init!
|
36
|
+
# @@dirs[env_name]
|
37
|
+
# end
|
38
|
+
|
39
|
+
def resource(*name)
|
40
|
+
path = _find_path(@dirs, :resource, name)
|
41
|
+
#_prepare_path(path, opts)
|
42
|
+
path
|
43
|
+
end
|
44
|
+
|
45
|
+
def internal(*name)
|
46
|
+
path = _find_path(@dirs, :internal, name)
|
47
|
+
#_prepare_path(path, opts)
|
48
|
+
path
|
49
|
+
end
|
50
|
+
|
51
|
+
def project(*name)
|
52
|
+
path = _find_path(@dirs, :project, name)
|
53
|
+
#_prepare_path(path, opts)
|
54
|
+
path
|
55
|
+
end
|
56
|
+
|
57
|
+
def status(*name)
|
58
|
+
path = _find_path(@dirs, :status, name)
|
59
|
+
#_prepare_path(path, opts)
|
60
|
+
path
|
61
|
+
end
|
62
|
+
|
63
|
+
def using(contents, opts=nil, &block)
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
def initialize(opts=nil)
|
68
|
+
@dirs = {}
|
69
|
+
@is_dev = opts[:dev?]
|
70
|
+
@is_sandboxed_dev = opts[:dev_sandbox?]
|
71
|
+
@project_dir = opts[:working_dir]
|
72
|
+
|
73
|
+
for dir in (opts[:dir] || [])
|
74
|
+
current_dir = @dirs
|
75
|
+
|
76
|
+
for d in 0 .. dir.length - 1
|
77
|
+
path_el = dir[d]
|
78
|
+
if d == dir.length - 1
|
79
|
+
current_dir[:__root__] = path_el.to_s
|
80
|
+
else
|
81
|
+
d_symbol = path_el.is_a?(Symbol) ? path_el : path_el.to_sym
|
82
|
+
current_dir[d_symbol] ||= {}
|
83
|
+
current_dir = current_dir[d_symbol]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def _find_path(dir, start, names)
|
90
|
+
current_dir = start ? dir[start] : dir
|
91
|
+
current_path = start ? current_dir[:__root__] : @project_dir
|
92
|
+
|
93
|
+
for n in names
|
94
|
+
if n.is_a?(Symbol)
|
95
|
+
raise "cannot find parent dir of #{n.to_s}" unless current_dir
|
96
|
+
|
97
|
+
current_dir = current_dir[n];
|
98
|
+
if current_dir
|
99
|
+
current_path = _expend_path_str(
|
100
|
+
current_dir[:__root__] || n.to_s, current_path)
|
101
|
+
else
|
102
|
+
raise "cannot find dir with symbol :#{n} under path #{current_path}"
|
103
|
+
end
|
104
|
+
elsif n.is_a?(String)
|
105
|
+
current_dir = nil
|
106
|
+
n_str = n.to_s
|
107
|
+
current_path = _expend_path_str(n_str, current_path)
|
108
|
+
else
|
109
|
+
raise "wrong input, does not support class #{n.class}"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
Pathname.new(current_path)
|
114
|
+
end
|
115
|
+
|
116
|
+
def expend_path(dir, base)
|
117
|
+
Pathname.new(_expend_path_str(dir, base))
|
118
|
+
end
|
119
|
+
|
120
|
+
def _expend_path_str(dir, base)
|
121
|
+
end
|
122
|
+
|
123
|
+
def _prepare_path(path, opts)
|
124
|
+
path.create if !path.exist? && opts[:create]
|
125
|
+
end
|
126
|
+
|
127
|
+
# def self.init!
|
128
|
+
# return if defined?(@_init)
|
129
|
+
# @@dirs = {}
|
130
|
+
# @_init = true
|
131
|
+
# end
|
132
|
+
|
133
|
+
def make_all
|
134
|
+
end
|
135
|
+
|
136
|
+
# Merge one dir_structure with another and return a completely new
|
137
|
+
# dir_structure.
|
138
|
+
def merge(other)
|
139
|
+
self.class.new.tap do |result|
|
140
|
+
result.merge!(self)
|
141
|
+
result.merge!(other)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
# Like #{merge} but merges into self.
|
146
|
+
def merge!(other)
|
147
|
+
@dirs.merge(other.instance_variable_get(:@dirs))
|
148
|
+
@is_dev = other.instance_variable_get(:@is_dev)
|
149
|
+
@is_sandboxed_dev = other.instance_variable_get(:@is_sandboxed_dev)
|
150
|
+
@project_dir = other.instance_variable_get(:@project_dir)
|
151
|
+
|
152
|
+
self
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
class HostDir < DirStructure
|
157
|
+
def self.configure(opts=nil)
|
158
|
+
new_opts = opts || {}
|
159
|
+
new_opts[:dir] << [:project, opts[:working_dir]]
|
160
|
+
new_opts[:dir] << [:resource, "#{new_opts[:working_dir]}/resources"]
|
161
|
+
new_opts[:dir] << [:internal, "#{new_opts[:working_dir]}/.sandbox-app"]
|
162
|
+
new_opts[:dir] << [:status, "#{new_opts[:working_dir]}/status"]
|
163
|
+
new_opts[:dir] << [:internal, :sandbox_dotvagrant,
|
164
|
+
(new_opts[:dev_sandbox?] ? "/home/vagrant/.dev-playground-dotvagrant" : "#{new_opts[:working_dir]}/.vagrant")]
|
165
|
+
new_opts[:dir] << [:resource, :config, :maven, :settings_file, "settings.xml"]
|
166
|
+
new_opts[:dir] << [:resource, :code, "code"]
|
167
|
+
|
168
|
+
HostDir.new(new_opts)
|
169
|
+
end
|
170
|
+
|
171
|
+
def _expend_path_str(dir, base)
|
172
|
+
File.expand_path(dir, base)
|
173
|
+
end
|
174
|
+
|
175
|
+
def make_all
|
176
|
+
FileUtils.mkdir_p(resource(:artifacts, :distribution).dirname)
|
177
|
+
FileUtils.mkdir_p(status(:app_server, :logs).dirname)
|
178
|
+
end
|
179
|
+
|
180
|
+
def using(contents, opts=nil, &block)
|
181
|
+
new_opts = {
|
182
|
+
file_name_base:nil,
|
183
|
+
category:nil,
|
184
|
+
use_unit_line_ending:nil
|
185
|
+
}.merge(opts || {})
|
186
|
+
|
187
|
+
use_unit_line_ending = new_opts[:use_unit_line_ending] || false
|
188
|
+
category = new_opts[:category] || 'any'
|
189
|
+
file_name_base = new_opts[:file_name_base] || 'sandbox'
|
190
|
+
file_name = File.basename(file_name_base, ".*")
|
191
|
+
ext_name = File.extname(file_name_base)
|
192
|
+
|
193
|
+
final_file_name = VagrantPlugins::ECSandbox::Util::Name.unique(base:file_name, suffix:ext_name)
|
194
|
+
final_path = internal(:tmp, category, final_file_name)
|
195
|
+
|
196
|
+
VagrantPlugins::ECSandbox::Util::Host::FileUtil.create(
|
197
|
+
final_path, contents, make_dir:true, delete_existing:true, use_unit_line_ending:use_unit_line_ending)
|
198
|
+
block.call(final_path)
|
199
|
+
# TODO: windows permission issue when deleting a file
|
200
|
+
#delete(path)
|
201
|
+
end
|
202
|
+
|
203
|
+
|
204
|
+
def tmp(name, opts=nil)
|
205
|
+
internal(:tmp, name)
|
206
|
+
end
|
207
|
+
|
208
|
+
def vagrantfile(opts=nil)
|
209
|
+
project(:vagrantfile)
|
210
|
+
end
|
211
|
+
|
212
|
+
def provision_script(opts=nil)
|
213
|
+
internal(:vagrant, :provision_script)
|
214
|
+
end
|
215
|
+
|
216
|
+
def mvn_settings(opts=nil)
|
217
|
+
resource(:config, :maven, :settings_file)
|
218
|
+
end
|
219
|
+
|
220
|
+
def sandbox_dotvagrant(opts=nil)
|
221
|
+
internal(:sandbox_dotvagrant)
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
class SandboxDir < DirStructure
|
226
|
+
def self.configure(opts=nil)
|
227
|
+
new_opts = opts || {}
|
228
|
+
new_opts[:dir] << [:project, '/home/vagrant/sandbox']
|
229
|
+
new_opts[:dir] << [:resource, '/home/vagrant/sandbox/resources']
|
230
|
+
new_opts[:dir] << [:internal, '/home/vagrant/.sandbox']
|
231
|
+
new_opts[:dir] << [:status, '/home/vagrant/status']
|
232
|
+
new_opts[:dir] << [:internal, :app, "app"]
|
233
|
+
new_opts[:dir] << [:internal, :app, :as, "as"]
|
234
|
+
new_opts[:dir] << [:resource, :config, :maven, :settings_file, "settings.xml"]
|
235
|
+
|
236
|
+
SandboxDir.new(new_opts)
|
237
|
+
end
|
238
|
+
|
239
|
+
def _expend_path_str(dir, base)
|
240
|
+
path = File.expand_path(dir, base)
|
241
|
+
|
242
|
+
if Vagrant::Util::Platform.windows?
|
243
|
+
path = path.gsub("\\", "/")
|
244
|
+
if (cidx = path.index(':'))
|
245
|
+
path = path[cidx + 1..path.size]
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
path
|
250
|
+
end
|
251
|
+
|
252
|
+
def using(contents, opts=nil, &block)
|
253
|
+
new_opts = {
|
254
|
+
file_name_base:nil,
|
255
|
+
category:nil,
|
256
|
+
use_unit_line_ending:nil,
|
257
|
+
communicator:nil,
|
258
|
+
permissions:nil,
|
259
|
+
host_dir_structure:nil
|
260
|
+
}.merge(opts || {})
|
261
|
+
|
262
|
+
raise "no communicator provided" unless new_opts[:communicator]
|
263
|
+
communicator = new_opts[:communicator]
|
264
|
+
permissions = '755' || new_opts[:permissions]
|
265
|
+
|
266
|
+
raise "no host dir structure provided" unless new_opts[:host_dir_structure]
|
267
|
+
host_dir_structure = new_opts[:host_dir_structure]
|
268
|
+
|
269
|
+
use_unit_line_ending = new_opts[:use_unit_line_ending] || false
|
270
|
+
category = new_opts[:category] || 'any'
|
271
|
+
file_name_base = new_opts[:file_name_base] || 'sandbox'
|
272
|
+
file_name = File.basename(file_name_base, ".*")
|
273
|
+
ext_name = File.extname(file_name_base)
|
274
|
+
|
275
|
+
final_file_name = VagrantPlugins::ECSandbox::Util::Name.unique(base:file_name, suffix:ext_name)
|
276
|
+
final_path_p = internal(:tmp, category)
|
277
|
+
final_path = _expend_path_str(final_file_name, final_path_p)
|
278
|
+
|
279
|
+
host_dir_structure.using(contents, opts) do |file|
|
280
|
+
communicator.execute("mkdir -p #{final_path_p}")
|
281
|
+
communicator.upload(file, final_path)
|
282
|
+
block.call(final_path)
|
283
|
+
communicator.execute("sudo rm #{final_path}")
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
|
288
|
+
def tmp(name, opts=nil)
|
289
|
+
internal(:tmp, name)
|
290
|
+
end
|
291
|
+
|
292
|
+
def vagrantfile(opts=nil)
|
293
|
+
project(:vagrantfile)
|
294
|
+
end
|
295
|
+
|
296
|
+
def provision_script(opts=nil)
|
297
|
+
internal(:vagrant, :provision_script)
|
298
|
+
end
|
299
|
+
|
300
|
+
def mvn_settings(opts=nil)
|
301
|
+
resource(:config, :maven, :settings_file)
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
end
|
306
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "log4r"
|
2
|
+
require "vagrant/plugin/manager"
|
3
|
+
require "vagrant/util/platform"
|
4
|
+
require "vagrant/errors"
|
5
|
+
|
6
|
+
|
7
|
+
module VagrantPlugins
|
8
|
+
module ECSandbox
|
9
|
+
module Errors
|
10
|
+
class Base < Vagrant::Errors::VagrantError
|
11
|
+
def initialize(*args)
|
12
|
+
super(args.first)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class WildflyNotInstalled < Base
|
17
|
+
error_key(:wildfly_not_installed, "ec_sandbox.errors")
|
18
|
+
end
|
19
|
+
|
20
|
+
class WildflyInstallerNotFound < Base
|
21
|
+
error_key(:wildfly_installer_not_found, "ec_sandbox.errors")
|
22
|
+
end
|
23
|
+
|
24
|
+
class DistNotFound < Base
|
25
|
+
error_key(:dist_not_found, "ec_sandbox.errors")
|
26
|
+
end
|
27
|
+
|
28
|
+
class UserNameNotFoundError < Base
|
29
|
+
error_key(:user_name_not_found, "ec_sandbox.errors")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module ECSandbox
|
3
|
+
|
4
|
+
# The source root is the path to the root directory of the Vagrant source.
|
5
|
+
#
|
6
|
+
# @return [Pathname]
|
7
|
+
def self.source_root
|
8
|
+
@source_root ||= Pathname.new(File.expand_path('../../../', __FILE__))
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative "dir_structure"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module ECSandbox
|
5
|
+
class Ec < Vagrant.plugin("2")
|
6
|
+
name 'EC Sandbox'
|
7
|
+
|
8
|
+
command "ec" do
|
9
|
+
require_relative 'command/root'
|
10
|
+
init!
|
11
|
+
Command::Root
|
12
|
+
end
|
13
|
+
|
14
|
+
config "ec" do
|
15
|
+
require_relative "config/sandbox_config"
|
16
|
+
init!
|
17
|
+
Config::SandboxConfig
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.init!
|
21
|
+
return if defined?(@_init)
|
22
|
+
I18n.load_path << File.expand_path("templates/locales/en.yml", VagrantPlugins::ECSandbox.source_root)
|
23
|
+
I18n.reload!
|
24
|
+
|
25
|
+
@_init = true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "vagrant/util/platform"
|
2
|
+
require_relative 'resource_provider'
|
3
|
+
require_relative "../util/host/hg_clone"
|
4
|
+
|
5
|
+
|
6
|
+
module VagrantPlugins
|
7
|
+
module ECSandbox
|
8
|
+
module Resource
|
9
|
+
class HgCloneProvider < ResourceProvider
|
10
|
+
def self.name
|
11
|
+
'hg_clone'
|
12
|
+
end
|
13
|
+
|
14
|
+
def prepare(env)
|
15
|
+
session = env[:sandbox_session]
|
16
|
+
|
17
|
+
artifact = @config.repo || @name
|
18
|
+
artifact = artifact.to_s.strip
|
19
|
+
dist_dir = @config.target || session.dir_structures[:host].resource(:code, artifact)
|
20
|
+
default_branch = @config.default_branch || 'default'
|
21
|
+
default_user = @config.default_user
|
22
|
+
|
23
|
+
raise 'artifact cannot be null or empty' unless artifact && artifact.size > 0
|
24
|
+
|
25
|
+
env[:ui].info("Bitbucket login:")
|
26
|
+
user = env[:ui].ask("User name [#{default_user}]: ")
|
27
|
+
password = env[:ui].ask("Password: ", echo:false)
|
28
|
+
branch = env[:ui].ask("Branch to build [#{default_branch}]: ")
|
29
|
+
|
30
|
+
branch = default_branch if branch.size == 0
|
31
|
+
user = default_user if user.size == 0
|
32
|
+
|
33
|
+
clone_url = "https://#{user}:#{URI.escape(password)}@bitbucket.org/energycomponents/#{artifact}"
|
34
|
+
FileUtils.rm_rf(dist_dir) if File.exist?(dist_dir)
|
35
|
+
FileUtils.mkdir_p(dist_dir)
|
36
|
+
|
37
|
+
env[:ui].info("Cloning #{artifact}...")
|
38
|
+
VagrantPlugins::ECSandbox::Util::Host::HgClone.execute(clone_url, dist_dir, branch, env)
|
39
|
+
env[:ui].success("#{artifact} cloned.")
|
40
|
+
|
41
|
+
dist_dir
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
require_relative 'provider_config'
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module ECSandbox
|
6
|
+
module Resource
|
7
|
+
class HgCloneProviderConfig < ProviderConfig
|
8
|
+
attr_accessor :default_branch
|
9
|
+
attr_accessor :default_user
|
10
|
+
attr_accessor :target # the target dir to clone to, if nil, [:resource/:code/:artifact] will be used
|
11
|
+
attr_accessor :repo # the repo to clone, if nil, the artifict name will be used
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@default_branch = UNSET_VALUE
|
15
|
+
@default_user = UNSET_VALUE
|
16
|
+
@target = UNSET_VALUE
|
17
|
+
@repo = UNSET_VALUE
|
18
|
+
end
|
19
|
+
|
20
|
+
def finalize!
|
21
|
+
@default_branch = nil if @default_branch == UNSET_VALUE
|
22
|
+
@default_user = nil if @default_user == UNSET_VALUE
|
23
|
+
@target = nil if @target == UNSET_VALUE
|
24
|
+
@repo = nil if @repo == UNSET_VALUE
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative 'resource_provider'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module ECSandbox
|
5
|
+
module Resource
|
6
|
+
class LocalProvider < ResourceProvider
|
7
|
+
def self.name
|
8
|
+
'local'
|
9
|
+
end
|
10
|
+
|
11
|
+
def prepare(env)
|
12
|
+
FileUtils.mkdir_p(config.path) unless File.exist?(config.path)
|
13
|
+
|
14
|
+
@config.path
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
require_relative 'provider_config'
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module ECSandbox
|
6
|
+
module Resource
|
7
|
+
class LocalProviderConfig < ProviderConfig
|
8
|
+
attr_accessor :path
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@path = UNSET_VALUE
|
12
|
+
end
|
13
|
+
|
14
|
+
def finalize!
|
15
|
+
@path = nil if @path == UNSET_VALUE
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require_relative 'resource_provider'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module ECSandbox
|
5
|
+
module Resource
|
6
|
+
class MavenProvider < ResourceProvider
|
7
|
+
def self.name
|
8
|
+
'maven_build'
|
9
|
+
end
|
10
|
+
|
11
|
+
def prepare(env)
|
12
|
+
session = env[:sandbox_session]
|
13
|
+
code_name = @config.code || @name
|
14
|
+
code_provider = session.resource_provider(:code, code_name)
|
15
|
+
|
16
|
+
dist_dir = code_provider.prepare(env)
|
17
|
+
|
18
|
+
env[:ui].info("Building #{name}...")
|
19
|
+
artifact = nil
|
20
|
+
version = nil
|
21
|
+
files = []
|
22
|
+
|
23
|
+
VagrantPlugins::ECSandbox::Util::Host::Mvn.install(dist_dir, env) do |status_type, data|
|
24
|
+
case status_type
|
25
|
+
when :downloading
|
26
|
+
uri = URI.parse(data)
|
27
|
+
file_name = File.basename(uri.path)
|
28
|
+
env[:ui].detail("Downloading #{file_name}...")
|
29
|
+
# when :start_build
|
30
|
+
# artifact = data[:artifact]
|
31
|
+
# version = data[:version]
|
32
|
+
when :installing
|
33
|
+
files << data[:repo]
|
34
|
+
when :result
|
35
|
+
case data
|
36
|
+
when :success
|
37
|
+
env[:ui].success("Built.")
|
38
|
+
when :failure
|
39
|
+
env[:ui].error("Build failed.")
|
40
|
+
else
|
41
|
+
env[:ui].error("Unknown build result #{data}.")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
files
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
require_relative 'provider_config'
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module ECSandbox
|
6
|
+
module Resource
|
7
|
+
class MavenProviderConfig < ProviderConfig
|
8
|
+
attr_accessor :code # the name of code set to use, if not given, name of the resource will be used
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@code = UNSET_VALUE
|
12
|
+
end
|
13
|
+
|
14
|
+
def finalize!
|
15
|
+
@code = nil if @code == UNSET_VALUE
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module ECSandbox
|
3
|
+
module Resource
|
4
|
+
class ResourceProvider
|
5
|
+
attr_reader :category
|
6
|
+
attr_reader :name
|
7
|
+
attr_reader :config
|
8
|
+
|
9
|
+
def initialize(category, name, config)
|
10
|
+
@category = category
|
11
|
+
@name = name
|
12
|
+
@config = config
|
13
|
+
end
|
14
|
+
|
15
|
+
def prepare(env)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative '../server'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module ECSandbox
|
5
|
+
module Server
|
6
|
+
module AppServer
|
7
|
+
class AS < VagrantPlugins::ECSandbox::Server::Server
|
8
|
+
def self.name
|
9
|
+
"app_server"
|
10
|
+
end
|
11
|
+
|
12
|
+
def finalize!
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module ECSandbox
|
3
|
+
module Server
|
4
|
+
module AppServer
|
5
|
+
class ASConfig < Vagrant.plugin("2", "config")
|
6
|
+
attr_accessor :smtp_host
|
7
|
+
attr_accessor :smtp_port
|
8
|
+
attr_accessor :datasrc_pw_encryption
|
9
|
+
attr_accessor :developer_mode
|
10
|
+
attr_accessor :wildfly_servers
|
11
|
+
attr_accessor :wildfly_server_group
|
12
|
+
attr_accessor :wildfly_profile
|
13
|
+
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
@smtp_host = UNSET_VALUE
|
17
|
+
@smtp_port = UNSET_VALUE
|
18
|
+
@datasrc_pw_encryption = UNSET_VALUE
|
19
|
+
@developer_mode = UNSET_VALUE
|
20
|
+
@wildfly_servers = UNSET_VALUE
|
21
|
+
@wildfly_server_group = UNSET_VALUE
|
22
|
+
@wildfly_profile = UNSET_VALUE
|
23
|
+
end
|
24
|
+
|
25
|
+
def finalize!
|
26
|
+
@smtp_host = nil if @smtp_host == UNSET_VALUE
|
27
|
+
@smtp_port = nil if @smtp_port == UNSET_VALUE
|
28
|
+
@datasrc_pw_encryption = false if @datasrc_pw_encryption == UNSET_VALUE
|
29
|
+
@developer_mode = true if @developer_mode == UNSET_VALUE
|
30
|
+
@wildfly_servers = ['ec-default-server'] if @wildfly_servers == UNSET_VALUE
|
31
|
+
@wildfly_server_group = 'ec-default-group' if @wildfly_server_group == UNSET_VALUE
|
32
|
+
@wildfly_profile = 'full' if @wildfly_profile == UNSET_VALUE
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|