vagrant-ec-sandbox 0.1.0.Preview

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.
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,79 @@
1
+ require_relative "../util/sandbox/get_user_processes"
2
+ require_relative "../dir_structure"
3
+
4
+
5
+ module VagrantPlugins
6
+ module ECSandbox
7
+ module Action
8
+ module Wildfly
9
+ def self.logger(class_name)
10
+ Log4r::Logger.new("vagrantplugins::ecsandbox::action::wildfly::#{class_name}")
11
+ end
12
+
13
+ def self.wildfly_home_path(session)
14
+ session.dir_structures[:sandbox].internal(:app, :as, "wildfly-8.1.0.Final")
15
+ end
16
+
17
+ def self.wait_host(env)
18
+ found = false
19
+ env[:ui].output("Waiting for Host Controller...")
20
+
21
+ until found
22
+ processes = Util::Sandbox::GetUserProcesses.new("wildfly").execute(env)
23
+ for proc in processes
24
+ found = (proc[:info][:type] == :wildfly_host_controller)
25
+ break if found
26
+ end
27
+
28
+ sleep 5
29
+ end
30
+ env[:ui].success("Host Controller started.")
31
+ end
32
+
33
+ def self.wait_server(env, server_names, opts=nil)
34
+ opts = {
35
+ wait_for_any:false
36
+ }.merge(opts || {})
37
+ server_names = server_names || []
38
+ wait_for_any = opts[:wait_for_any] || false
39
+
40
+ if wait_for_any
41
+ env[:ui].output("Waiting for one of the servers " << server_names.join(", ") << "...")
42
+ else
43
+ env[:ui].output("Waiting for servers " << server_names.join(", ") << "...")
44
+ end
45
+
46
+ pending = server_names.clone
47
+ last_started_server = nil
48
+
49
+ while !pending.empty?
50
+ processes = Util::Sandbox::GetUserProcesses.new("wildfly").execute(env)
51
+
52
+ for proc in processes
53
+ if proc[:info][:type] == :wildfly_server
54
+ if pending.include?(proc[:info][:server_name])
55
+ last_started_server = proc[:info][:server_name]
56
+ env[:ui].detail("Server #{last_started_server} started.")
57
+ pending.delete(last_started_server)
58
+ end
59
+ end
60
+ end
61
+
62
+ if wait_for_any && last_started_server
63
+ break
64
+ end
65
+
66
+ sleep 5
67
+ end
68
+
69
+ if wait_for_any
70
+ env[:ui].output("One or all servers started.")
71
+ else
72
+ env[:ui].success("All servers started.")
73
+ end
74
+ end
75
+
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,129 @@
1
+ require "pathname"
2
+ require "vagrant/action/builder"
3
+ require "vagrant/action/builtin/call"
4
+ require_relative "communicator_extender"
5
+ require_relative "action/wildfly"
6
+ require_relative "action/dist"
7
+ require_relative "action/code"
8
+ require_relative "action/init"
9
+
10
+
11
+ module VagrantPlugins
12
+ module ECSandbox
13
+ module Action
14
+ autoload :SelectDb, File.expand_path("../action/select_db", __FILE__)
15
+ autoload :UseAppServer, File.expand_path("../action/use_app_server", __FILE__)
16
+ Init.autoload :InitVagrant, File.expand_path("../action/init/init_vagrant", __FILE__)
17
+ Init.autoload :EnvConfigConfirm, File.expand_path("../action/init/env_config_confirm", __FILE__)
18
+ Init.autoload :InitDir, File.expand_path("../action/init/init_dir", __FILE__)
19
+ Code.autoload :PrepareDist, File.expand_path("../action/code/prepare_dist", __FILE__)
20
+ Dist.autoload :GetViaBuild, File.expand_path("../action/dist/get_vbuild", __FILE__)
21
+ Dist.autoload :CheckArtifact, File.expand_path("../action/dist/check_artifact", __FILE__)
22
+ Dist.autoload :MakeContents, File.expand_path("../action/dist/make_contents", __FILE__)
23
+ Dist.autoload :ClearContents, File.expand_path("../action/dist/clear_contents", __FILE__)
24
+ Dist.autoload :GetViaNexus, File.expand_path("../action/dist/get_vnexus", __FILE__)
25
+ Dist.autoload :CheckWildflyInstaller, File.expand_path("../action/dist/check_wildfly_installer", __FILE__)
26
+ Dist.autoload :InstallWildfly, File.expand_path("../action/dist/install_wildfly", __FILE__)
27
+ Dist.autoload :ConfigEC, File.expand_path("../action/dist/config_ec", __FILE__)
28
+ Dist.autoload :DeployEcApp, File.expand_path("../action/dist/deploy_ecapp", __FILE__)
29
+ Wildfly.autoload :Remove, File.expand_path("../action/wildfly/remove", __FILE__)
30
+ Wildfly.autoload :GetIsInstalled, File.expand_path("../action/wildfly/get_isinstalled", __FILE__)
31
+ Wildfly.autoload :Start, File.expand_path("../action/wildfly/start", __FILE__)
32
+ Wildfly.autoload :StartAdmin, File.expand_path("../action/wildfly/start_admin", __FILE__)
33
+ Wildfly.autoload :Stop, File.expand_path("../action/wildfly/stop", __FILE__)
34
+ Wildfly.autoload :Status, File.expand_path("../action/wildfly/status", __FILE__)
35
+ Wildfly.autoload :Reload, File.expand_path("../action/wildfly/reload", __FILE__)
36
+ Wildfly.autoload :ReloadAdmin, File.expand_path("../action/wildfly/reload_admin", __FILE__)
37
+ Wildfly.autoload :RedirectDirs, File.expand_path("../action/wildfly/redirect_dirs", __FILE__)
38
+ Wildfly.autoload :SwitchDb, File.expand_path("../action/wildfly/switch_db", __FILE__)
39
+
40
+
41
+ include Vagrant::Action::Builtin
42
+
43
+
44
+ # This middleware sequence will install wildfly from distribution dir.
45
+ def self.action_install_wildfly
46
+ Vagrant::Action::Builder.new.tap do |b|
47
+ b.use SelectDb
48
+ b.use UseAppServer
49
+ b.use Code::PrepareDist
50
+ b.use Dist::GetViaBuild
51
+ b.use Dist::CheckArtifact
52
+ b.use Call, Wildfly::GetIsInstalled do |env1, b2|
53
+ if env1[:result]
54
+ b2.use Wildfly::Stop
55
+ b2.use Wildfly::Remove
56
+ end
57
+ end
58
+ b.use Dist::ClearContents
59
+ b.use Dist::MakeContents
60
+ b.use Dist::CheckWildflyInstaller
61
+ b.use Dist::InstallWildfly
62
+ b.use Wildfly::StartAdmin
63
+ b.use Dist::ConfigEC
64
+ b.use Wildfly::ReloadAdmin
65
+ b.use Wildfly::RedirectDirs
66
+ b.use Dist::DeployEcApp
67
+ b.use Dist::ClearContents
68
+ b.use Wildfly::Reload
69
+ end
70
+ end
71
+
72
+ ## TEST ##
73
+ def self.action_test
74
+ Vagrant::Action::Builder.new.tap do |b|
75
+ b.use UseAppServer
76
+ b.use Code::PrepareDist
77
+ end
78
+ end
79
+
80
+
81
+ def self.action_wildfly_status
82
+ Vagrant::Action::Builder.new.tap do |b|
83
+ b.use Wildfly::Status
84
+ end
85
+ end
86
+
87
+ def self.action_stop_wildfly
88
+ Vagrant::Action::Builder.new.tap do |b|
89
+ b.use UseAppServer
90
+ b.use Wildfly::Stop
91
+ end
92
+ end
93
+
94
+ def self.action_start_wildfly
95
+ Vagrant::Action::Builder.new.tap do |b|
96
+ b.use UseAppServer
97
+ b.use Wildfly::Start
98
+ end
99
+ end
100
+
101
+ def self.action_restart_wildfly
102
+ Vagrant::Action::Builder.new.tap do |b|
103
+ b.use UseAppServer
104
+ b.use Wildfly::Stop
105
+ b.use Wildfly::Start
106
+ end
107
+ end
108
+
109
+ def self.action_config_db
110
+ Vagrant::Action::Builder.new.tap do |b|
111
+ b.use UseAppServer
112
+ b.use SelectDb
113
+ b.use Wildfly::Stop
114
+ b.use Wildfly::StartAdmin
115
+ b.use Wildfly::SwitchDb
116
+ b.use Wildfly::Reload
117
+ end
118
+ end
119
+
120
+ def self.action_init
121
+ Vagrant::Action::Builder.new.tap do |b|
122
+ # b.use Init::EnvConfigConfirm
123
+ b.use Init::InitDir
124
+ b.use Init::InitVagrant
125
+ end
126
+ end
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,34 @@
1
+ require 'optparse'
2
+
3
+ require_relative "../base"
4
+ require_relative "../../action"
5
+ require_relative "../../communicator_extender"
6
+
7
+
8
+ module VagrantPlugins
9
+ module ECSandbox
10
+ module Command
11
+ module AS
12
+ class ConfigDb < Base
13
+ def execute
14
+ opts = OptionParser.new do |o|
15
+ o.banner = "Usage: vagrant ec config_db [-h]"
16
+ end
17
+
18
+ # Parse the options
19
+ argv = parse_options(opts)
20
+ return if !argv
21
+ raise Vagrant::Errors::CLIInvalidUsage, help: opts.help.chomp if argv.length > 0
22
+
23
+ action_machine(Action.action_config_db,
24
+ use_default_db_selector: false,
25
+ auto_start_machine: true)
26
+
27
+ # Success, exit status 0
28
+ 0
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,34 @@
1
+ require 'optparse'
2
+
3
+ require_relative "../base"
4
+ require_relative "../../action"
5
+ require_relative "../../communicator_extender"
6
+
7
+
8
+ module VagrantPlugins
9
+ module ECSandbox
10
+ module Command
11
+ module AS
12
+ class Install < Base
13
+ def execute
14
+ opts = OptionParser.new do |o|
15
+ o.banner = "Usage: vagrant ec update [-h]"
16
+ end
17
+
18
+ # Parse the options
19
+ argv = parse_options(opts)
20
+ return if !argv
21
+ raise Vagrant::Errors::CLIInvalidUsage, help: opts.help.chomp if argv.length > 0
22
+
23
+ action_machine(Action.action_install_wildfly,
24
+ use_default_db_selector: true,
25
+ auto_start_machine: true)
26
+
27
+ # Success, exit status 0
28
+ 0
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,33 @@
1
+ require 'optparse'
2
+
3
+ require_relative "../base"
4
+ require_relative "../../action"
5
+ require_relative "../../communicator_extender"
6
+
7
+
8
+ module VagrantPlugins
9
+ module ECSandbox
10
+ module Command
11
+ module AS
12
+ class Restart < Base
13
+ def execute
14
+ opts = OptionParser.new do |o|
15
+ o.banner = "Usage: vagrant ec restart [-h]"
16
+ end
17
+
18
+ # Parse the options
19
+ argv = parse_options(opts)
20
+ return if !argv
21
+ raise Vagrant::Errors::CLIInvalidUsage, help: opts.help.chomp if argv.length > 0
22
+
23
+ action_machine(Action.action_restart_wildfly,
24
+ auto_start_machine: true)
25
+
26
+ # Success, exit status 0
27
+ 0
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,32 @@
1
+ require 'optparse'
2
+
3
+ require_relative "../base"
4
+ require_relative "../../action"
5
+ require_relative "../../communicator_extender"
6
+
7
+
8
+ module VagrantPlugins
9
+ module ECSandbox
10
+ module Command
11
+ module AS
12
+ class ShowStatus < Base
13
+ def execute
14
+ opts = OptionParser.new do |o|
15
+ o.banner = "Usage: vagrant ec status [-h]"
16
+ end
17
+
18
+ # Parse the options
19
+ argv = parse_options(opts)
20
+ return if !argv
21
+ raise Vagrant::Errors::CLIInvalidUsage, help: opts.help.chomp if argv.length > 0
22
+
23
+ action_machine(Action.action_wildfly_status)
24
+
25
+ # Success, exit status 0
26
+ 0
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,33 @@
1
+ require 'optparse'
2
+
3
+ require_relative "../base"
4
+ require_relative "../../action"
5
+ require_relative "../../communicator_extender"
6
+
7
+
8
+ module VagrantPlugins
9
+ module ECSandbox
10
+ module Command
11
+ module AS
12
+ class Start < Base
13
+ def execute
14
+ opts = OptionParser.new do |o|
15
+ o.banner = "Usage: vagrant ec start [-h]"
16
+ end
17
+
18
+ # Parse the options
19
+ argv = parse_options(opts)
20
+ return if !argv
21
+ raise Vagrant::Errors::CLIInvalidUsage, help: opts.help.chomp if argv.length > 0
22
+
23
+ action_machine(Action.action_start_wildfly,
24
+ auto_start_machine: true)
25
+
26
+ # Success, exit status 0
27
+ 0
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,32 @@
1
+ require 'optparse'
2
+
3
+ require_relative "../base"
4
+ require_relative "../../action"
5
+ require_relative "../../communicator_extender"
6
+
7
+
8
+ module VagrantPlugins
9
+ module ECSandbox
10
+ module Command
11
+ module AS
12
+ class Stop < Base
13
+ def execute
14
+ opts = OptionParser.new do |o|
15
+ o.banner = "Usage: vagrant ec stop [-h]"
16
+ end
17
+
18
+ # Parse the options
19
+ argv = parse_options(opts)
20
+ return if !argv
21
+ raise Vagrant::Errors::CLIInvalidUsage, help: opts.help.chomp if argv.length > 0
22
+
23
+ action_machine(Action.action_stop_wildfly)
24
+
25
+ # Success, exit status 0
26
+ 0
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ require 'optparse'
2
+
3
+ require_relative "../base"
4
+ require_relative "../../action"
5
+ require_relative "../../communicator_extender"
6
+
7
+
8
+ module VagrantPlugins
9
+ module ECSandbox
10
+ module Command
11
+ module AS
12
+ class Test < Base
13
+ def execute
14
+ opts = OptionParser.new do |o|
15
+ o.banner = "Usage: vagrant ec update [-h]"
16
+ end
17
+
18
+ # Parse the options
19
+ argv = parse_options(opts)
20
+ return if !argv
21
+ raise Vagrant::Errors::CLIInvalidUsage, help: opts.help.chomp if argv.length > 0
22
+
23
+ action_machine(Action.action_test)
24
+
25
+ # Success, exit status 0
26
+ 0
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,52 @@
1
+ require "vagrant/plugin/state_file"
2
+ require "vagrant/registry"
3
+ require_relative "../session"
4
+
5
+ module VagrantPlugins
6
+ module ECSandbox
7
+ module Command
8
+ class Base < Vagrant.plugin("2", :command)
9
+ # This is a helper for executing an action sequence with the proper
10
+ # environment hash setup so that the plugin specific helpers are
11
+ # in.
12
+ #
13
+ # @param [Object] callable the Middleware callable
14
+ # @param [Hash] env Extra environment hash that is merged in.
15
+ def action(callable, env=nil)
16
+ merged_env = {
17
+ sandbox_session: VagrantPlugins::ECSandbox::Session.default
18
+ }.merge(env || {})
19
+
20
+ @env.action_runner.run(callable, merged_env)
21
+ end
22
+
23
+ def action_machine(callable, env=nil)
24
+ with_target_vms(@argv) do |machine|
25
+ if machine.state.id != :running
26
+ if env[:auto_start_machine] == true
27
+ @env.cli("up", machine.name.to_s)
28
+ else
29
+ @env.ui.info("#{machine.name} is not running, use command 'vagrant up' to start the virtual machine .")
30
+ next
31
+ end
32
+ end
33
+
34
+ merged_env = {
35
+ machine: machine,
36
+ sandbox_session: VagrantPlugins::ECSandbox::Session.create_machine(machine)
37
+ }.merge(env || {})
38
+
39
+ @env.action_runner.run(callable, merged_env)
40
+ end
41
+ end
42
+
43
+ def initialize(argv, env)
44
+ super(argv, env)
45
+
46
+ # Init session
47
+ VagrantPlugins::ECSandbox::Session.init_default(env)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,29 @@
1
+ require 'optparse'
2
+
3
+ require_relative "base"
4
+ require_relative "../action"
5
+
6
+
7
+ module VagrantPlugins
8
+ module ECSandbox
9
+ module Command
10
+ class Init < Base
11
+ def execute
12
+ opts = OptionParser.new do |o|
13
+ o.banner = "Usage: vagrant ec init [-h]"
14
+ end
15
+
16
+ # Parse the options
17
+ argv = parse_options(opts)
18
+ return if !argv
19
+ raise Vagrant::Errors::CLIInvalidUsage, help: opts.help.chomp if argv.length > 0
20
+
21
+ action(Action.action_init)
22
+
23
+ # Success, exit status 0
24
+ 0
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,101 @@
1
+ require 'optparse'
2
+
3
+ module VagrantPlugins
4
+ module ECSandbox
5
+ module Command
6
+ class Root < Vagrant.plugin("2", :command)
7
+ def self.synopsis
8
+ "manages ec sandboxes: init, update, destroy."
9
+ end
10
+
11
+ def initialize(argv, env)
12
+ super
13
+
14
+ @main_args, @sub_command, @sub_args = split_main_and_subcommand(argv)
15
+
16
+ @subcommands = Vagrant::Registry.new
17
+ @subcommands.register(:init) do
18
+ require_relative "init"
19
+ Init
20
+ end
21
+
22
+ @subcommands.register(:install) do
23
+ require_relative "as/install"
24
+ AS::Install
25
+ end
26
+
27
+ @subcommands.register(:status) do
28
+ require_relative "as/show_status"
29
+ AS::ShowStatus
30
+ end
31
+
32
+ @subcommands.register(:stop) do
33
+ require_relative "as/stop"
34
+ AS::Stop
35
+ end
36
+
37
+ @subcommands.register(:start) do
38
+ require_relative "as/start"
39
+ AS::Start
40
+ end
41
+
42
+ @subcommands.register(:restart) do
43
+ require_relative "as/restart"
44
+ AS::Restart
45
+ end
46
+
47
+ # @subcommands.register(:test) do
48
+ # require_relative "as/test"
49
+ # AS::Test
50
+ # end
51
+
52
+ @subcommands.register(:config_db) do
53
+ require_relative "as/config_db"
54
+ AS::ConfigDb
55
+ end
56
+
57
+
58
+ end
59
+
60
+ def execute
61
+ if @main_args.include?("-h") || @main_args.include?("--help")
62
+ # Print the help for all the sub-commands.
63
+ return help
64
+ end
65
+
66
+ # If we reached this far then we must have a subcommand. If not,
67
+ # then we also just print the help and exit.
68
+ command_class = @subcommands.get(@sub_command.to_sym) if @sub_command
69
+ return help if !command_class || !@sub_command
70
+ @logger.debug("Invoking command class: #{command_class} #{@sub_args.inspect}")
71
+
72
+ # Initialize and execute the command class
73
+ command_class.new(@sub_args, @env).execute
74
+ end
75
+
76
+ # Prints the help out for this command
77
+ def help
78
+ opts = OptionParser.new do |o|
79
+ o.banner = "Usage: vagrant ec <command> [<args>]"
80
+ o.separator ""
81
+ o.separator "Available subcommands:"
82
+
83
+ # Add the available subcommands as separators in order to print them
84
+ # out as well.
85
+ keys = []
86
+ @subcommands.each { |key, value| keys << key.to_s }
87
+
88
+ keys.sort.each do |key|
89
+ o.separator " #{key}"
90
+ end
91
+
92
+ o.separator ""
93
+ o.separator "For help on any individual command run `vagrant ec COMMAND -h`"
94
+ end
95
+
96
+ @env.ui.info(opts.help, prefix: false)
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,45 @@
1
+ require "log4r"
2
+ require "vagrant/plugin/manager"
3
+ require "vagrant/util/platform"
4
+ require_relative "util/name"
5
+ require_relative "dir_structure"
6
+
7
+
8
+ module Vagrant
9
+ module Plugin
10
+ module V2
11
+ class Communicator
12
+ def sh(session, contents, opts=nil, &block)
13
+ new_opts = {
14
+ file_name_base:nil,
15
+ category:nil,
16
+ sudo:nil
17
+ }.merge(opts || {})
18
+
19
+ session.dir_structures[:sandbox].using(
20
+ contents,
21
+ file_name_base:new_opts[:file_name_base],
22
+ category:new_opts[:category],
23
+ use_unit_line_ending:true,
24
+ communicator:self,
25
+ permissions:"755",
26
+ host_dir_structure:session.dir_structures[:host]) do |file|
27
+
28
+ sudo = new_opts[:sudo] || false
29
+ command = "sh #{file}";
30
+
31
+ if (sudo)
32
+ self.sudo(command, opts) do |type, data|
33
+ block.call(type, data) if block
34
+ end
35
+ else
36
+ self.execute(command, opts) do |type, data|
37
+ block.call(type, data) if block
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end