vagrant_filoo 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +61 -0
- data/Gemfile +14 -0
- data/LICENSE +22 -0
- data/README.md +207 -0
- data/Rakefile +5 -0
- data/doc/img_res/filoo_logo.png +0 -0
- data/doc/img_res/filoo_wolke.png +0 -0
- data/example_box/README.md +13 -0
- data/example_box/metadata.json +3 -0
- data/filoo.box +0 -0
- data/lib/vagrant_filoo/action/create_server.rb +51 -0
- data/lib/vagrant_filoo/action/get_images.rb +21 -0
- data/lib/vagrant_filoo/action/is_created.rb +22 -0
- data/lib/vagrant_filoo/action/is_stopped.rb +18 -0
- data/lib/vagrant_filoo/action/message_already_created.rb +16 -0
- data/lib/vagrant_filoo/action/message_not_created.rb +16 -0
- data/lib/vagrant_filoo/action/read_ssh_info.rb +40 -0
- data/lib/vagrant_filoo/action/read_state.rb +65 -0
- data/lib/vagrant_filoo/action/start_instance.rb +48 -0
- data/lib/vagrant_filoo/action/stop_instance.rb +31 -0
- data/lib/vagrant_filoo/action/terminate_instance.rb +24 -0
- data/lib/vagrant_filoo/action/test.rb +2 -0
- data/lib/vagrant_filoo/action.rb +184 -0
- data/lib/vagrant_filoo/cloud_compute.rb +629 -0
- data/lib/vagrant_filoo/config.rb +54 -0
- data/lib/vagrant_filoo/errors.rb +81 -0
- data/lib/vagrant_filoo/plugin.rb +73 -0
- data/lib/vagrant_filoo/provider.rb +52 -0
- data/lib/vagrant_filoo/util/timer.rb +17 -0
- data/lib/vagrant_filoo/version.rb +5 -0
- data/lib/vagrant_filoo.rb +17 -0
- data/locales/en.yml +122 -0
- data/sample_config/Vagrantfile_example +23 -0
- data/spec/spec_helper.rb +0 -0
- data/spec/vagrant_filoo/config_spec.rb +70 -0
- data/templates/metadata.json.erb +3 -0
- data/templates/vagrant-filoo_package_Vagrantfile.erb +5 -0
- data/vagrant_filoo.gemspec +58 -0
- metadata +178 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative "../cloud_compute"
|
2
|
+
module VagrantPlugins
|
3
|
+
module Filoo
|
4
|
+
module Action
|
5
|
+
# This starts a stopped instance.
|
6
|
+
class TerminateInstance
|
7
|
+
include VagrantPlugins::Filoo::CloudCompute
|
8
|
+
DELETE_SERVER_TIMEOUT = 30
|
9
|
+
def initialize(app, env)
|
10
|
+
@app = app
|
11
|
+
@baseUrl = env[:machine].provider_config.filoo_api_entry_point
|
12
|
+
@apiKey = env[:machine].provider_config.filoo_api_key
|
13
|
+
end
|
14
|
+
|
15
|
+
def call(env)
|
16
|
+
vmid = env[:machine].id
|
17
|
+
env[:result] = VagrantPlugins::Filoo::CloudCompute::deleteServer(vmid, @baseUrl, @apiKey)
|
18
|
+
env[:machine].id = nil
|
19
|
+
@app.call(env)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,184 @@
|
|
1
|
+
require "pathname"
|
2
|
+
require "vagrant/action/builder"
|
3
|
+
require_relative "action/create_server"
|
4
|
+
require_relative "action/get_images"
|
5
|
+
require_relative "action/read_state"
|
6
|
+
require_relative "action/stop_instance"
|
7
|
+
require_relative "action/terminate_instance"
|
8
|
+
require_relative "action/read_ssh_info"
|
9
|
+
|
10
|
+
module VagrantPlugins
|
11
|
+
module Filoo
|
12
|
+
module Action
|
13
|
+
|
14
|
+
# This action is called to read the SSH info of the machine. The
|
15
|
+
# resulting state is expected to be put into the `:machine_ssh_info`
|
16
|
+
# key.
|
17
|
+
def self.action_read_ssh_info
|
18
|
+
Vagrant::Action::Builder.new.tap do |b|
|
19
|
+
b.use ConfigValidate
|
20
|
+
b.use ReadSSHInfo
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# This action is called to halt the remote machine.
|
25
|
+
def self.action_halt
|
26
|
+
Vagrant::Action::Builder.new.tap do |b|
|
27
|
+
b.use ConfigValidate
|
28
|
+
b.use Call, IsCreated do |env, b2|
|
29
|
+
unless env[:result]
|
30
|
+
b2.use MessageNotCreated
|
31
|
+
next
|
32
|
+
end
|
33
|
+
b2.use StopInstance
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# This action is called to terminate the remote machine.
|
39
|
+
def self.action_destroy
|
40
|
+
Vagrant::Action::Builder.new.tap do |b|
|
41
|
+
b.use Call, DestroyConfirm do |env, b2|
|
42
|
+
if env[:result]
|
43
|
+
b2.use ConfigValidate
|
44
|
+
b2.use Call, IsCreated do |env2, b3|
|
45
|
+
unless env2[:result]
|
46
|
+
b3.use MessageNotCreated
|
47
|
+
next
|
48
|
+
end
|
49
|
+
b3.use TerminateInstance
|
50
|
+
b3.use ProvisionerCleanup if defined?(ProvisionerCleanup)
|
51
|
+
end
|
52
|
+
else
|
53
|
+
b2.use MessageWillNotDestroy
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# This action is called when `vagrant provision` is called.
|
60
|
+
def self.action_provision
|
61
|
+
Vagrant::Action::Builder.new.tap do |b|
|
62
|
+
b.use ConfigValidate
|
63
|
+
b.use Call, IsCreated do |env, b2|
|
64
|
+
unless env[:result]
|
65
|
+
b2.use MessageNotCreated
|
66
|
+
next
|
67
|
+
end
|
68
|
+
|
69
|
+
b2.use Provision
|
70
|
+
# b2.use SyncedFolders
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
# This action is called to bring the box up from nothing.
|
77
|
+
include Vagrant::Action::Builtin
|
78
|
+
def self.action_up
|
79
|
+
Vagrant::Action::Builder.new.tap do |b|
|
80
|
+
b.use HandleBox
|
81
|
+
b.use ConfigValidate
|
82
|
+
b.use BoxCheckOutdated
|
83
|
+
b.use Call, IsCreated do |env1, b1|
|
84
|
+
if env1[:result]
|
85
|
+
b1.use Call, IsStopped do |env2, b1|
|
86
|
+
if env2[:result]
|
87
|
+
b1.use StartInstance # restart this instance
|
88
|
+
else
|
89
|
+
b1.use MessageAlreadyCreated # TODO: write a better message
|
90
|
+
end
|
91
|
+
end
|
92
|
+
else
|
93
|
+
# b1.use Provision
|
94
|
+
# b1.use SyncedFolders
|
95
|
+
b1.use GetImages
|
96
|
+
b1.use CreateServer do |env2, b2|
|
97
|
+
if env2[:result]["vmstatus"] == "stopped"
|
98
|
+
b2.use StartInstance # launch a new instance
|
99
|
+
elseif env2[:result]["vmstatus"] != "running"
|
100
|
+
raise VagrantPlugins::Filoo::Errors::UnexpectedStateError,
|
101
|
+
resource: "/vserver/status",
|
102
|
+
state: {"vmstatus" => env1[:result]["vmstatus"]},
|
103
|
+
message: "Unexpected vmstatus after create Server done, vmstatus " + env1[:result]["vmstatus"],
|
104
|
+
description: "Server with vmid #{env1[:result]['vmid']} should be running or stopped "
|
105
|
+
end
|
106
|
+
end
|
107
|
+
b1.use WaitForCommunicator
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
# This action is called to SSH into the machine.
|
114
|
+
def self.action_ssh
|
115
|
+
Vagrant::Action::Builder.new.tap do |b|
|
116
|
+
b.use ConfigValidate
|
117
|
+
b.use Call, IsCreated do |env, b2|
|
118
|
+
unless env[:result]
|
119
|
+
b2.use MessageNotCreated
|
120
|
+
next
|
121
|
+
end
|
122
|
+
|
123
|
+
b2.use SSHExec
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
|
129
|
+
def self.action_ssh_run
|
130
|
+
Vagrant::Action::Builder.new.tap do |b|
|
131
|
+
b.use ConfigValidate
|
132
|
+
b.use Call, IsCreated do |env, b2|
|
133
|
+
unless env[:result]
|
134
|
+
b2.use MessageNotCreated
|
135
|
+
next
|
136
|
+
end
|
137
|
+
|
138
|
+
b2.use SSHRun
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
# This action is called to read the state of the machine. The
|
144
|
+
# resulting state is expected to be put into the `:machine_state_id`
|
145
|
+
# key.
|
146
|
+
def self.action_read_state
|
147
|
+
Vagrant::Action::Builder.new.tap do |b|
|
148
|
+
b.use ConfigValidate
|
149
|
+
b.use ReadState
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
|
154
|
+
def self.action_reload
|
155
|
+
Vagrant::Action::Builder.new.tap do |b|
|
156
|
+
b.use ConfigValidate
|
157
|
+
b.use Call, IsCreated do |env, b2|
|
158
|
+
unless env[:result]
|
159
|
+
b2.use MessageNotCreated
|
160
|
+
next
|
161
|
+
end
|
162
|
+
b2.use action_halt
|
163
|
+
b2.use action_up
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
# The autoload farm
|
169
|
+
action_root = Pathname.new(File.expand_path("../action", __FILE__))
|
170
|
+
autoload :IsCreated, action_root.join("is_created")
|
171
|
+
autoload :IsStopped, action_root.join("is_stopped")
|
172
|
+
autoload :MessageAlreadyCreated, action_root.join("message_already_created")
|
173
|
+
autoload :MessageNotCreated, action_root.join("message_not_created")
|
174
|
+
autoload :ReadSSHInfo, action_root.join("read_ssh_info")
|
175
|
+
autoload :ReadState, action_root.join("read_state")
|
176
|
+
autoload :CreateServer, action_root.join("create_server")
|
177
|
+
autoload :GetImages, action_root.join("get_images")
|
178
|
+
autoload :StartInstance, action_root.join("start_instance")
|
179
|
+
autoload :StopInstance, action_root.join("stop_instance")
|
180
|
+
autoload :TerminateInstance, action_root.join("terminate_instance")
|
181
|
+
autoload :Wait, action_root.join("wait")
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|