vagrant-tart 0.0.2
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 +7 -0
- data/LICENSE +21 -0
- data/README.md +36 -0
- data/lib/vagrant-tart/action/create_instance.rb +42 -0
- data/lib/vagrant-tart/action/delete_instance.rb +36 -0
- data/lib/vagrant-tart/action/forward_ports.rb +25 -0
- data/lib/vagrant-tart/action/get_state.rb +32 -0
- data/lib/vagrant-tart/action/login.rb +43 -0
- data/lib/vagrant-tart/action/pull_image.rb +40 -0
- data/lib/vagrant-tart/action/start_instance.rb +44 -0
- data/lib/vagrant-tart/action/stop_instance.rb +35 -0
- data/lib/vagrant-tart/action/suspend_instance.rb +36 -0
- data/lib/vagrant-tart/action.rb +181 -0
- data/lib/vagrant-tart/config.rb +126 -0
- data/lib/vagrant-tart/errors.rb +42 -0
- data/lib/vagrant-tart/model/get_result.rb +52 -0
- data/lib/vagrant-tart/model/list_result.rb +76 -0
- data/lib/vagrant-tart/model/tart_disk.rb +77 -0
- data/lib/vagrant-tart/plugin.rb +47 -0
- data/lib/vagrant-tart/provider.rb +97 -0
- data/lib/vagrant-tart/scripts/login.sh +9 -0
- data/lib/vagrant-tart/scripts/run.sh +17 -0
- data/lib/vagrant-tart/synced_folder.rb +97 -0
- data/lib/vagrant-tart/util/driver.rb +185 -0
- data/lib/vagrant-tart/version.rb +9 -0
- data/lib/vagrant-tart.rb +20 -0
- data/locales/en.yml +74 -0
- metadata +74 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c396d57625272e20fa44038feb071add4d80fc19de6cf17e8339a46bdaef72ea
|
4
|
+
data.tar.gz: ff2b337cb649360c7d451b721fb8c836e75e1e549fe282ca1a79307f7da36471
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0bab80c64715d5292521cba50edbcbdae81c7cbe50ed42bb28bcb4a5e4169660688ddf8d4dfb903f0d65eaf861df47f5af91982ca15b4b348654be97cce4b51a
|
7
|
+
data.tar.gz: 0267bb6950b5eb82c7ec11c0d2c7dedfc4d753353f372189033500709a3f3a8841090b09b9998d761718a04ceaa0b4864218316149dad08d4a96782d947b0702
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 Laurent Etiemble
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# VagrantPlugins::Tart
|
2
|
+
|
3
|
+
Vagrant-tart is a [Vagrant](http://www.vagrantup.com) plugin that adds a
|
4
|
+
[Tart](https://tart.run/) provider to Vagrant, allowing Vagrant to
|
5
|
+
control and provision machines via Tart command line tool.
|
6
|
+
|
7
|
+
## Installation & Usage
|
8
|
+
|
9
|
+
Refer to the [documentation](https://letiemble.github.io/vagrant-tart/) for detailed installation and usage instructions.
|
10
|
+
|
11
|
+
## Development
|
12
|
+
|
13
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
14
|
+
Then, run `bundle exec rake spec` to run the tests.
|
15
|
+
|
16
|
+
To install this gem into your local Vagrant installation, run:
|
17
|
+
|
18
|
+
```bash
|
19
|
+
bundle exec rake build
|
20
|
+
bundle exec vagrant plugin install ./pkg/vagrant-tart-$VERSION.gem
|
21
|
+
bundle exec vagrant plugin list
|
22
|
+
```
|
23
|
+
|
24
|
+
Once the plugin is installed, you can use Vagrant with the Tart provider.
|
25
|
+
|
26
|
+
## Contributing
|
27
|
+
|
28
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/letiemble/vagrant-tart. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/letiemble/vagrant-tart/blob/main/CODE_OF_CONDUCT.md).
|
29
|
+
|
30
|
+
## License
|
31
|
+
|
32
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
33
|
+
|
34
|
+
## Code of Conduct
|
35
|
+
|
36
|
+
Everyone interacting in the VagrantPlugins::Tart project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/letiemble/vagrant-tart/blob/main/CODE_OF_CONDUCT.md).
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "i18n"
|
4
|
+
require "vagrant/util/ansi_escape_code_remover"
|
5
|
+
|
6
|
+
module VagrantPlugins
|
7
|
+
module Tart
|
8
|
+
module Action
|
9
|
+
# Action block to create a virtual machine.
|
10
|
+
class CreateInstance
|
11
|
+
include Vagrant::Util::ANSIEscapeCodeRemover
|
12
|
+
|
13
|
+
def initialize(app, _env)
|
14
|
+
@app = app
|
15
|
+
end
|
16
|
+
|
17
|
+
def call(env)
|
18
|
+
machine = env[:machine]
|
19
|
+
config = machine.provider_config
|
20
|
+
driver = machine.provider.driver
|
21
|
+
image = config.image
|
22
|
+
name = config.name
|
23
|
+
|
24
|
+
list = driver.list
|
25
|
+
return @app.call(env) if list.any?(name)
|
26
|
+
|
27
|
+
env[:ui].output(I18n.t("vagrant_tart.messages.cloning_instance", image: image, name: name))
|
28
|
+
driver.clone(image, name) do |_type, data|
|
29
|
+
data = remove_ansi_escape_codes(data.chomp).chomp
|
30
|
+
env[:ui].detail(data) if data != ""
|
31
|
+
end
|
32
|
+
env[:ui].output(I18n.t("vagrant_tart.messages.instance_cloned", image: image, name: name))
|
33
|
+
|
34
|
+
# Set the ID and name of the virtual machine
|
35
|
+
machine.id = name
|
36
|
+
|
37
|
+
@app.call(env)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "i18n"
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module Tart
|
7
|
+
module Action
|
8
|
+
# Action block to delete a virtual machine.
|
9
|
+
class DeleteInstance
|
10
|
+
def initialize(app, _env)
|
11
|
+
@app = app
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(env)
|
15
|
+
machine = env[:machine]
|
16
|
+
config = machine.provider_config
|
17
|
+
driver = machine.provider.driver
|
18
|
+
name = config.name
|
19
|
+
|
20
|
+
list = driver.list
|
21
|
+
return @app.call(env) unless list.any?(name)
|
22
|
+
|
23
|
+
instance = driver.get(name)
|
24
|
+
if !instance.nil? && instance.vagrant_state == :stopped
|
25
|
+
env[:ui].output(I18n.t("vagrant_tart.messages.deleting_instance", name: name))
|
26
|
+
driver.delete(name)
|
27
|
+
machine.id = nil
|
28
|
+
env[:ui].output(I18n.t("vagrant_tart.messages.instance_deleted", name: name))
|
29
|
+
end
|
30
|
+
|
31
|
+
@app.call(env)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "i18n"
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module Tart
|
7
|
+
module Action
|
8
|
+
# Action block to setup forwarded ports for a virtual machine.
|
9
|
+
class ForwardPorts
|
10
|
+
def initialize(app, _env)
|
11
|
+
@app = app
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(env)
|
15
|
+
machine = env[:machine]
|
16
|
+
config = machine.provider_config
|
17
|
+
machine.provider.driver
|
18
|
+
config.name
|
19
|
+
|
20
|
+
@app.call(env)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Tart
|
5
|
+
module Action
|
6
|
+
# Action block to get the state of a virtual machine.
|
7
|
+
class GetState
|
8
|
+
def initialize(app, _env)
|
9
|
+
@app = app
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(env)
|
13
|
+
machine = env[:machine]
|
14
|
+
config = machine.provider_config
|
15
|
+
driver = machine.provider.driver
|
16
|
+
name = config.name
|
17
|
+
|
18
|
+
list = driver.list
|
19
|
+
instance = list.find(name)
|
20
|
+
|
21
|
+
env[:machine_state_id] = if instance.nil?
|
22
|
+
:not_created
|
23
|
+
else
|
24
|
+
instance.vagrant_state
|
25
|
+
end
|
26
|
+
|
27
|
+
@app.call(env)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "i18n"
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module Tart
|
7
|
+
module Action
|
8
|
+
# Action to check if Tart is present and can be invoked.
|
9
|
+
class Login
|
10
|
+
def initialize(app, _env)
|
11
|
+
@app = app
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(env)
|
15
|
+
machine = env[:machine]
|
16
|
+
config = machine.provider_config
|
17
|
+
driver = machine.provider.driver
|
18
|
+
|
19
|
+
return @app.call(env) unless config.use_registry?
|
20
|
+
|
21
|
+
login(env, config, driver)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def login(env, config, driver)
|
27
|
+
# Login to the registry
|
28
|
+
env[:ui].output(I18n.t("vagrant_tart.messages.logging_in"))
|
29
|
+
driver.login(config.registry, config.username, config.password)
|
30
|
+
env[:ui].output(I18n.t("vagrant_tart.messages.logged_in"))
|
31
|
+
|
32
|
+
# Continue with the middleware stack
|
33
|
+
@app.call(env)
|
34
|
+
|
35
|
+
# Logout from the registry
|
36
|
+
env[:ui].output(I18n.t("vagrant_tart.messages.logging_out"))
|
37
|
+
driver.logout(config.registry)
|
38
|
+
env[:ui].output(I18n.t("vagrant_tart.messages.logged_out"))
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "i18n"
|
4
|
+
require "vagrant/util/ansi_escape_code_remover"
|
5
|
+
|
6
|
+
module VagrantPlugins
|
7
|
+
module Tart
|
8
|
+
module Action
|
9
|
+
# Action to pull a virtual machine image.
|
10
|
+
class PullImage
|
11
|
+
include Vagrant::Util::ANSIEscapeCodeRemover
|
12
|
+
|
13
|
+
def initialize(app, _env)
|
14
|
+
@app = app
|
15
|
+
end
|
16
|
+
|
17
|
+
def call(env)
|
18
|
+
machine = env[:machine]
|
19
|
+
config = machine.provider_config
|
20
|
+
driver = machine.provider.driver
|
21
|
+
image = config.image
|
22
|
+
|
23
|
+
# Check if the virtual machine image is already present
|
24
|
+
list = driver.list
|
25
|
+
return @app.call(env) if list.any?(image)
|
26
|
+
|
27
|
+
env[:ui].output(I18n.t("vagrant_tart.messages.pulling_image", image: image))
|
28
|
+
driver.pull(image) do |_type, data|
|
29
|
+
data = remove_ansi_escape_codes(data.chomp).chomp
|
30
|
+
data = data.gsub("\r", "")
|
31
|
+
env[:ui].detail(data) if data != ""
|
32
|
+
end
|
33
|
+
env[:ui].output(I18n.t("vagrant_tart.messages.image_pulled", image: image))
|
34
|
+
|
35
|
+
@app.call(env)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "i18n"
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module Tart
|
7
|
+
module Action
|
8
|
+
# Action block to start a virtual machine.
|
9
|
+
class StartInstance
|
10
|
+
def initialize(app, _env)
|
11
|
+
@app = app
|
12
|
+
end
|
13
|
+
|
14
|
+
# rubocop:disable Metrics/AbcSize
|
15
|
+
def call(env)
|
16
|
+
machine = env[:machine]
|
17
|
+
config = machine.provider_config
|
18
|
+
driver = machine.provider.driver
|
19
|
+
name = config.name
|
20
|
+
|
21
|
+
list = driver.list
|
22
|
+
return @app.call(env) unless list.any?(name)
|
23
|
+
|
24
|
+
instance = driver.get(name)
|
25
|
+
return @app.call(env) if instance.nil? || instance.vagrant_state == :running
|
26
|
+
|
27
|
+
env[:ui].output(I18n.t("vagrant_tart.messages.configuring_instance", name: name))
|
28
|
+
driver.set(name, "cpu", config.cpu)
|
29
|
+
driver.set(name, "memory", config.memory)
|
30
|
+
driver.set(name, "disk", config.disk)
|
31
|
+
driver.set(name, "display", config.display)
|
32
|
+
env[:ui].output(I18n.t("vagrant_tart.messages.instance_configured", name: name))
|
33
|
+
|
34
|
+
env[:ui].output(I18n.t("vagrant_tart.messages.starting_instance", name: name))
|
35
|
+
driver.run(name, config.gui, config.suspendable?, config.volumes)
|
36
|
+
env[:ui].output(I18n.t("vagrant_tart.messages.instance_started", name: name))
|
37
|
+
|
38
|
+
@app.call(env)
|
39
|
+
end
|
40
|
+
# rubocop:enable Metrics/AbcSize
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "i18n"
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module Tart
|
7
|
+
module Action
|
8
|
+
# Action block to stop a virtual machine.
|
9
|
+
class StopInstance
|
10
|
+
def initialize(app, _env)
|
11
|
+
@app = app
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(env)
|
15
|
+
machine = env[:machine]
|
16
|
+
config = machine.provider_config
|
17
|
+
driver = machine.provider.driver
|
18
|
+
name = config.name
|
19
|
+
|
20
|
+
list = driver.list
|
21
|
+
return @app.call(env) unless list.any?(name)
|
22
|
+
|
23
|
+
instance = driver.get(name)
|
24
|
+
return @app.call(env) if instance.nil? || instance.vagrant_state != :running
|
25
|
+
|
26
|
+
env[:ui].output(I18n.t("vagrant_tart.messages.stopping_instance", name: name))
|
27
|
+
driver.stop(name)
|
28
|
+
env[:ui].output(I18n.t("vagrant_tart.messages.instance_stopped", name: name))
|
29
|
+
|
30
|
+
@app.call(env)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "i18n"
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module Tart
|
7
|
+
module Action
|
8
|
+
# Action block to suspend a virtual machine.
|
9
|
+
class SuspendInstance
|
10
|
+
def initialize(app, _env)
|
11
|
+
@app = app
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(env)
|
15
|
+
machine = env[:machine]
|
16
|
+
config = machine.provider_config
|
17
|
+
driver = machine.provider.driver
|
18
|
+
name = config.name
|
19
|
+
suspendable = config.suspendable?
|
20
|
+
|
21
|
+
list = driver.list
|
22
|
+
return @app.call(env) unless list.any?(name)
|
23
|
+
|
24
|
+
instance = driver.get(name)
|
25
|
+
return @app.call(env) if instance.nil? || !suspendable
|
26
|
+
|
27
|
+
env[:ui].output(I18n.t("vagrant_tart.messages.suspending_instance", name: name))
|
28
|
+
driver.suspend(name)
|
29
|
+
env[:ui].output(I18n.t("vagrant_tart.messages.instance_suspended", name: name))
|
30
|
+
|
31
|
+
@app.call(env)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,181 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "vagrant"
|
4
|
+
require "vagrant/action/builder"
|
5
|
+
|
6
|
+
module VagrantPlugins
|
7
|
+
module Tart
|
8
|
+
# Contains all the supported actions of the Tart provider.
|
9
|
+
module Action
|
10
|
+
# Include the built-in Vagrant action modules
|
11
|
+
include Vagrant::Action::Builtin
|
12
|
+
|
13
|
+
# Autoloading action blocks
|
14
|
+
action_root = Pathname.new(File.expand_path("action", __dir__))
|
15
|
+
autoload :CreateInstance, action_root.join("create_instance")
|
16
|
+
autoload :DeleteInstance, action_root.join("delete_instance")
|
17
|
+
autoload :GetState, action_root.join("get_state")
|
18
|
+
autoload :Login, action_root.join("login")
|
19
|
+
autoload :PullImage, action_root.join("pull_image")
|
20
|
+
autoload :StartInstance, action_root.join("start_instance")
|
21
|
+
autoload :StopInstance, action_root.join("stop_instance")
|
22
|
+
|
23
|
+
# Vargrant action "destroy".
|
24
|
+
def self.action_destroy
|
25
|
+
Vagrant::Action::Builder.new.tap do |b|
|
26
|
+
b.use ConfigValidate
|
27
|
+
|
28
|
+
b.use Call, IsState, :not_created do |env1, b1|
|
29
|
+
raise Errors::InstanceNotCreatedError if env1[:result]
|
30
|
+
|
31
|
+
b1.use Call, DestroyConfirm do |env2, b2|
|
32
|
+
if env2[:result]
|
33
|
+
b2.use ProvisionerCleanup, :before
|
34
|
+
b2.use StopInstance
|
35
|
+
b2.use DeleteInstance
|
36
|
+
b2.use SyncedFolderCleanup
|
37
|
+
else
|
38
|
+
b2.use MessageWillNotDestroy
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# Vagrant action "halt".
|
46
|
+
def self.action_halt
|
47
|
+
Vagrant::Action::Builder.new.tap do |b|
|
48
|
+
b.use ConfigValidate
|
49
|
+
|
50
|
+
b.use Call, IsState, :not_created do |env, b1|
|
51
|
+
raise Errors::InstanceNotCreatedError if env[:result]
|
52
|
+
|
53
|
+
b1.use StopInstance
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# Vagrant action "provision".
|
59
|
+
def self.action_provision
|
60
|
+
Vagrant::Action::Builder.new.tap do |b|
|
61
|
+
b.use ConfigValidate
|
62
|
+
|
63
|
+
b.use Call, IsState, :not_created do |env, b1|
|
64
|
+
raise Errors::InstanceNotCreatedError if env[:result]
|
65
|
+
|
66
|
+
b1.use Provision
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# Vagrant action "reload".
|
72
|
+
def self.action_reload
|
73
|
+
Vagrant::Action::Builder.new.tap do |b|
|
74
|
+
b.use ConfigValidate
|
75
|
+
|
76
|
+
b.use Call, IsState, :not_created do |env, b1|
|
77
|
+
raise Errors::InstanceNotCreatedError if env[:result]
|
78
|
+
|
79
|
+
b1.use action_halt
|
80
|
+
b1.use action_start
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Vagrant action "resume".
|
86
|
+
def self.action_resume
|
87
|
+
Vagrant::Action::Builder.new.tap do |b|
|
88
|
+
b.use ConfigValidate
|
89
|
+
|
90
|
+
b.use Call, IsState, :not_created do |env, b1|
|
91
|
+
raise Errors::InstanceNotCreatedError if env[:result]
|
92
|
+
|
93
|
+
b1.use action_start
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# Vagrant action "ssh".
|
99
|
+
def self.action_ssh
|
100
|
+
Vagrant::Action::Builder.new.tap do |b|
|
101
|
+
b.use ConfigValidate
|
102
|
+
|
103
|
+
b.use Call, IsState, :not_created do |env, b1|
|
104
|
+
raise Errors::InstanceNotCreatedError if env[:result]
|
105
|
+
|
106
|
+
b1.use Call, IsState, :running do |env2, b2|
|
107
|
+
raise Errors::InstanceNotRunningError unless env2[:result]
|
108
|
+
|
109
|
+
b2.use SSHExec
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# Vagrant action "ssh_run".
|
116
|
+
def self.action_ssh_run
|
117
|
+
Vagrant::Action::Builder.new.tap do |b|
|
118
|
+
b.use ConfigValidate
|
119
|
+
|
120
|
+
b.use Call, IsState, :not_created do |env, b1|
|
121
|
+
raise Errors::InstanceNotCreatedError if env[:result]
|
122
|
+
|
123
|
+
b1.use Call, IsState, :running do |env2, b2|
|
124
|
+
raise Errors::InstanceNotRunningError unless env2[:result]
|
125
|
+
|
126
|
+
b2.use SSHRun
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
# Vagrant action "suspend".
|
133
|
+
def self.action_suspend
|
134
|
+
Vagrant::Action::Builder.new.tap do |b|
|
135
|
+
b.use ConfigValidate
|
136
|
+
|
137
|
+
b.use Call, IsState, :not_created do |env, b1|
|
138
|
+
raise Errors::InstanceNotCreatedError if env[:result]
|
139
|
+
|
140
|
+
b1.use Call, IsState, :running do |env2, b2|
|
141
|
+
raise Errors::InstanceNotRunningError unless env2[:result]
|
142
|
+
|
143
|
+
b2.use SuspendInstance
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
# Vagrant action "up".
|
150
|
+
def self.action_up
|
151
|
+
Vagrant::Action::Builder.new.tap do |b|
|
152
|
+
b.use ConfigValidate
|
153
|
+
|
154
|
+
b.use Login
|
155
|
+
b.use PullImage
|
156
|
+
b.use CreateInstance
|
157
|
+
|
158
|
+
b.use action_start
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
# Retrieves the state of the virtual machine.
|
163
|
+
def self.action_get_state
|
164
|
+
Vagrant::Action::Builder.new.tap do |b|
|
165
|
+
b.use GetState
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
# Starts the virtual machine.
|
170
|
+
def self.action_start
|
171
|
+
Vagrant::Action::Builder.new.tap do |b|
|
172
|
+
b.use SyncedFolderCleanup
|
173
|
+
b.use SyncedFolders
|
174
|
+
b.use StartInstance
|
175
|
+
b.use WaitForCommunicator
|
176
|
+
b.use Provision
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|