vagrant-cloudstack 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +18 -19
  3. data/.ruby-version +1 -1
  4. data/.travis.yml +19 -19
  5. data/CHANGELOG.md +179 -171
  6. data/Docker/.dockerignore +2 -0
  7. data/Docker/Dockerfile +51 -0
  8. data/Docker/Dockerfile.chefdk_0_17 +49 -0
  9. data/Docker/Dockerfile.latest_dependencies +49 -0
  10. data/Docker/README.md +67 -0
  11. data/Docker/vac.ps1 +29 -0
  12. data/Docker/vac.sh +30 -0
  13. data/Gemfile +20 -20
  14. data/LICENSE +8 -8
  15. data/README.md +416 -416
  16. data/Rakefile +106 -99
  17. data/bootstrap.key +27 -0
  18. data/build_rpm.sh +7 -7
  19. data/functional-tests/basic/Vagrantfile.basic_networking +45 -45
  20. data/functional-tests/basic/basic_spec.rb +21 -21
  21. data/functional-tests/networking/Vagrantfile.advanced_networking +119 -102
  22. data/functional-tests/networking/networking_spec.rb +14 -0
  23. data/functional-tests/rsync/Vagrantfile.advanced_networking +39 -56
  24. data/functional-tests/rsync/rsync_spec.rb +9 -9
  25. data/functional-tests/vmlifecycle/Vagrantfile.advanced_networking +66 -82
  26. data/functional-tests/vmlifecycle/vmlifecycle_spec.rb +13 -13
  27. data/lib/vagrant-cloudstack/action/connect_cloudstack.rb +47 -47
  28. data/lib/vagrant-cloudstack/action/is_created.rb +18 -18
  29. data/lib/vagrant-cloudstack/action/is_stopped.rb +18 -18
  30. data/lib/vagrant-cloudstack/action/message_already_created.rb +16 -16
  31. data/lib/vagrant-cloudstack/action/message_not_created.rb +16 -16
  32. data/lib/vagrant-cloudstack/action/message_will_not_destroy.rb +16 -16
  33. data/lib/vagrant-cloudstack/action/read_rdp_info.rb +76 -76
  34. data/lib/vagrant-cloudstack/action/read_ssh_info.rb +104 -87
  35. data/lib/vagrant-cloudstack/action/read_state.rb +38 -38
  36. data/lib/vagrant-cloudstack/action/read_winrm_info.rb +103 -103
  37. data/lib/vagrant-cloudstack/action/run_instance.rb +798 -703
  38. data/lib/vagrant-cloudstack/action/start_instance.rb +81 -81
  39. data/lib/vagrant-cloudstack/action/stop_instance.rb +28 -28
  40. data/lib/vagrant-cloudstack/action/terminate_instance.rb +269 -224
  41. data/lib/vagrant-cloudstack/action/timed_provision.rb +21 -21
  42. data/lib/vagrant-cloudstack/action/wait_for_state.rb +41 -41
  43. data/lib/vagrant-cloudstack/action/warn_networks.rb +19 -19
  44. data/lib/vagrant-cloudstack/action.rb +210 -210
  45. data/lib/vagrant-cloudstack/capabilities/rdp.rb +12 -12
  46. data/lib/vagrant-cloudstack/capabilities/winrm.rb +12 -12
  47. data/lib/vagrant-cloudstack/config.rb +566 -548
  48. data/lib/vagrant-cloudstack/errors.rb +27 -27
  49. data/lib/vagrant-cloudstack/exceptions/exceptions.rb +10 -10
  50. data/lib/vagrant-cloudstack/model/cloudstack_resource.rb +51 -33
  51. data/lib/vagrant-cloudstack/plugin.rb +82 -82
  52. data/lib/vagrant-cloudstack/provider.rb +58 -58
  53. data/lib/vagrant-cloudstack/service/cloudstack_resource_service.rb +64 -58
  54. data/lib/vagrant-cloudstack/util/timer.rb +17 -17
  55. data/lib/vagrant-cloudstack/version.rb +5 -5
  56. data/lib/vagrant-cloudstack.rb +17 -17
  57. data/locales/en.yml +131 -123
  58. data/spec/spec_helper.rb +8 -6
  59. data/spec/vagrant-cloudstack/action/read_ssh_info_spec.rb +80 -0
  60. data/spec/vagrant-cloudstack/config_spec.rb +355 -355
  61. data/spec/vagrant-cloudstack/model/cloudstack_resource_spec.rb +95 -73
  62. data/spec/vagrant-cloudstack/service/cloudstack_resource_service_spec.rb +43 -43
  63. data/spec/vagrant-cloudstack/support/be_a_resource.rb +6 -0
  64. data/vagrant-cloudstack.gemspec +59 -59
  65. data/vagrant-cloudstack.spec +42 -42
  66. metadata +14 -7
  67. data/dummy.box +0 -0
  68. data/example_box/README.md +0 -13
  69. data/example_box/metadata.json +0 -3
  70. data/functional-tests/networking/rsync_spec.rb +0 -12
@@ -1,21 +1,21 @@
1
- require "vagrant-cloudstack/util/timer"
2
-
3
- module VagrantPlugins
4
- module Cloudstack
5
- module Action
6
- # This is the same as the builtin provision except it times the
7
- # provisioner runs.
8
- class TimedProvision < Vagrant::Action::Builtin::Provision
9
- def run_provisioner(env, pname, p)
10
- timer = Util::Timer.time do
11
- super
12
- end
13
-
14
- env[:metrics] ||= {}
15
- env[:metrics]["provisioner_times"] ||= []
16
- env[:metrics]["provisioner_times"] << [p.class.to_s, timer]
17
- end
18
- end
19
- end
20
- end
21
- end
1
+ require "vagrant-cloudstack/util/timer"
2
+
3
+ module VagrantPlugins
4
+ module Cloudstack
5
+ module Action
6
+ # This is the same as the builtin provision except it times the
7
+ # provisioner runs.
8
+ class TimedProvision < Vagrant::Action::Builtin::Provision
9
+ def run_provisioner(env, pname, p)
10
+ timer = Util::Timer.time do
11
+ super
12
+ end
13
+
14
+ env[:metrics] ||= {}
15
+ env[:metrics]["provisioner_times"] ||= []
16
+ env[:metrics]["provisioner_times"] << [p.class.to_s, timer]
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,41 +1,41 @@
1
- require "log4r"
2
- require "timeout"
3
-
4
- module VagrantPlugins
5
- module Cloudstack
6
- module Action
7
- # This action will wait for a machine to reach a specific state or quit by timeout
8
- class WaitForState
9
- # env[:result] will be false in case of timeout.
10
- # @param [Symbol] state Target machine state.
11
- # @param [Number] timeout Timeout in seconds.
12
- def initialize(app, env, state, timeout)
13
- @app = app
14
- @logger = Log4r::Logger.new("vagrant_cloudstack::action::wait_for_state")
15
- @state = state
16
- @timeout = timeout
17
- end
18
-
19
- def call(env)
20
- env[:result] = true
21
- if env[:machine].state.id == @state
22
- @logger.info(I18n.t("vagrant_cloudstack.already_status", :status => @state))
23
- else
24
- @logger.info("Waiting for machine to reach state #{@state}")
25
- begin
26
- Timeout.timeout(@timeout) do
27
- until env[:machine].state.id == @state
28
- sleep 2
29
- end
30
- end
31
- rescue Timeout::Error
32
- env[:result] = false # couldn't reach state in time
33
- end
34
- end
35
-
36
- @app.call(env)
37
- end
38
- end
39
- end
40
- end
41
- end
1
+ require "log4r"
2
+ require "timeout"
3
+
4
+ module VagrantPlugins
5
+ module Cloudstack
6
+ module Action
7
+ # This action will wait for a machine to reach a specific state or quit by timeout
8
+ class WaitForState
9
+ # env[:result] will be false in case of timeout.
10
+ # @param [Symbol] state Target machine state.
11
+ # @param [Number] timeout Timeout in seconds.
12
+ def initialize(app, env, state, timeout)
13
+ @app = app
14
+ @logger = Log4r::Logger.new("vagrant_cloudstack::action::wait_for_state")
15
+ @state = state
16
+ @timeout = timeout
17
+ end
18
+
19
+ def call(env)
20
+ env[:result] = true
21
+ if env[:machine].state.id == @state
22
+ @logger.info(I18n.t("vagrant_cloudstack.already_status", :status => @state))
23
+ else
24
+ @logger.info("Waiting for machine to reach state #{@state}")
25
+ begin
26
+ Timeout.timeout(@timeout) do
27
+ until env[:machine].state.id == @state
28
+ sleep 2
29
+ end
30
+ end
31
+ rescue Timeout::Error
32
+ env[:result] = false # couldn't reach state in time
33
+ end
34
+ end
35
+
36
+ @app.call(env)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,19 +1,19 @@
1
- module VagrantPlugins
2
- module Cloudstack
3
- module Action
4
- class WarnNetworks
5
- def initialize(app, env)
6
- @app = app
7
- end
8
-
9
- def call(env)
10
- if env[:machine].config.vm.networks.length > 0
11
- env[:ui].warn(I18n.t("vagrant_cloudstack.warn_networks"))
12
- end
13
-
14
- @app.call(env)
15
- end
16
- end
17
- end
18
- end
19
- end
1
+ module VagrantPlugins
2
+ module Cloudstack
3
+ module Action
4
+ class WarnNetworks
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ if env[:machine].config.vm.networks.length > 0
11
+ env[:ui].warn(I18n.t("vagrant_cloudstack.warn_networks"))
12
+ end
13
+
14
+ @app.call(env)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,210 +1,210 @@
1
- require "pathname"
2
- require "vagrant/action/builder"
3
-
4
- module VagrantPlugins
5
- module Cloudstack
6
- module Action
7
- # Include the built-in modules so we can use them as top-level things.
8
- include Vagrant::Action::Builtin
9
-
10
- # This action is called to halt the remote machine.
11
- def self.action_halt
12
- Vagrant::Action::Builder.new.tap do |b|
13
- b.use ConfigValidate
14
- b.use Call, IsCreated do |env, b2|
15
- if !env[:result]
16
- b2.use MessageNotCreated
17
- next
18
- end
19
-
20
- b2.use ConnectCloudstack
21
- b2.use StopInstance
22
- end
23
- end
24
- end
25
-
26
- # This action is called to terminate the remote machine.
27
- def self.action_destroy
28
- Vagrant::Action::Builder.new.tap do |b|
29
- b.use Call, DestroyConfirm do |env, b2|
30
- if env[:result]
31
- b2.use ConfigValidate
32
- b.use Call, IsCreated do |env2, b3|
33
- if !env2[:result]
34
- b3.use MessageNotCreated
35
- next
36
- end
37
- end
38
- b2.use ConnectCloudstack
39
- b2.use TerminateInstance
40
- else
41
- b2.use MessageWillNotDestroy
42
- end
43
- end
44
- end
45
- end
46
-
47
- # This action is called when `vagrant provision` is called.
48
- def self.action_provision
49
- Vagrant::Action::Builder.new.tap do |b|
50
- b.use ConfigValidate
51
- b.use Call, IsCreated do |env, b2|
52
- if !env[:result]
53
- b2.use MessageNotCreated
54
- next
55
- end
56
-
57
- b2.use Provision
58
- b2.use SyncedFolders
59
- end
60
- end
61
- end
62
-
63
- # This action is called to read the WinRM info of the machine. The
64
- # resulting state is expected to be put into the `:machine_winrm_info`
65
- # key.
66
- def self.action_read_rdp_info
67
- Vagrant::Action::Builder.new.tap do |b|
68
- b.use ConfigValidate
69
- b.use ConnectCloudstack
70
- b.use ReadRdpInfo
71
- end
72
- end
73
-
74
- # This action is called to read the WinRM info of the machine. The
75
- # resulting state is expected to be put into the `:machine_winrm_info`
76
- # key.
77
- def self.action_read_winrm_info
78
- Vagrant::Action::Builder.new.tap do |b|
79
- b.use ConfigValidate
80
- b.use ConnectCloudstack
81
- b.use ReadWinrmInfo
82
- end
83
- end
84
-
85
- # This action is called to read the SSH info of the machine. The
86
- # resulting state is expected to be put into the `:machine_ssh_info`
87
- # key.
88
- def self.action_read_ssh_info
89
- Vagrant::Action::Builder.new.tap do |b|
90
- b.use ConfigValidate
91
- b.use ConnectCloudstack
92
- b.use ReadSSHInfo
93
- end
94
- end
95
-
96
- # This action is called to read the state of the machine. The
97
- # resulting state is expected to be put into the `:machine_state_id`
98
- # key.
99
- def self.action_read_state
100
- Vagrant::Action::Builder.new.tap do |b|
101
- b.use ConfigValidate
102
- b.use ConnectCloudstack
103
- b.use ReadState
104
- end
105
- end
106
-
107
- # This action is called to SSH into the machine.
108
- def self.action_ssh
109
- Vagrant::Action::Builder.new.tap do |b|
110
- b.use ConfigValidate
111
- b.use Call, IsCreated do |env, b2|
112
- if !env[:result]
113
- b2.use MessageNotCreated
114
- next
115
- end
116
-
117
- b2.use SSHExec
118
- end
119
- end
120
- end
121
-
122
- def self.action_ssh_run
123
- Vagrant::Action::Builder.new.tap do |b|
124
- b.use ConfigValidate
125
- b.use Call, IsCreated do |env, b2|
126
- if !env[:result]
127
- b2.use MessageNotCreated
128
- next
129
- end
130
-
131
- b2.use SSHRun
132
- end
133
- end
134
- end
135
-
136
- def self.action_prepare_boot
137
- Vagrant::Action::Builder.new.tap do |b|
138
- b.use Provision
139
- b.use SyncedFolders
140
- b.use WarnNetworks
141
- end
142
- end
143
-
144
- # This action is called to bring the box up from nothing.
145
- def self.action_up
146
- Vagrant::Action::Builder.new.tap do |b|
147
- b.use ConfigValidate
148
- b.use ConnectCloudstack
149
- b.use Call, IsCreated do |env1, b1|
150
- if env1[:result]
151
- b1.use Call, IsStopped do |env2, b2|
152
- if env2[:result]
153
- b2.use action_prepare_boot
154
- b2.use StartInstance # restart this instance
155
- else
156
- b2.use MessageAlreadyCreated # TODO write a better message
157
- end
158
- end
159
- else
160
- b1.use action_prepare_boot
161
- b1.use RunInstance # launch a new instance
162
- end
163
- end
164
- end
165
- end
166
-
167
- def self.action_reload
168
- Vagrant::Action::Builder.new.tap do |b|
169
- b.use ConfigValidate
170
- b.use ConnectCloudstack
171
- b.use Call, IsCreated do |env, b2|
172
- if !env[:result]
173
- b2.use MessageNotCreated
174
- next
175
- end
176
-
177
- b2.use action_halt
178
- b2.use Call, WaitForState, :stopped, 120 do |env2, b3|
179
- if env2[:result]
180
- b3.use action_up
181
- else
182
- # TODO we couldn't reach :stopped, what now?
183
- end
184
- end
185
- end
186
- end
187
- end
188
-
189
- # The autoload farm
190
- action_root = Pathname.new(File.expand_path("../action", __FILE__))
191
- autoload :ConnectCloudstack, action_root.join("connect_cloudstack")
192
- autoload :IsCreated, action_root.join("is_created")
193
- autoload :IsStopped, action_root.join("is_stopped")
194
- autoload :MessageAlreadyCreated, action_root.join("message_already_created")
195
- autoload :MessageNotCreated, action_root.join("message_not_created")
196
- autoload :MessageWillNotDestroy, action_root.join("message_will_not_destroy")
197
- autoload :ReadSSHInfo, action_root.join("read_ssh_info")
198
- autoload :ReadWinrmInfo, action_root.join("read_winrm_info")
199
- autoload :ReadRdpInfo, action_root.join("read_rdp_info")
200
- autoload :ReadState, action_root.join("read_state")
201
- autoload :RunInstance, action_root.join("run_instance")
202
- autoload :StartInstance, action_root.join("start_instance")
203
- autoload :StopInstance, action_root.join("stop_instance")
204
- autoload :TimedProvision, action_root.join("timed_provision")
205
- autoload :WaitForState, action_root.join("wait_for_state")
206
- autoload :WarnNetworks, action_root.join("warn_networks")
207
- autoload :TerminateInstance, action_root.join("terminate_instance")
208
- end
209
- end
210
- end
1
+ require "pathname"
2
+ require "vagrant/action/builder"
3
+
4
+ module VagrantPlugins
5
+ module Cloudstack
6
+ module Action
7
+ # Include the built-in modules so we can use them as top-level things.
8
+ include Vagrant::Action::Builtin
9
+
10
+ # This action is called to halt the remote machine.
11
+ def self.action_halt
12
+ Vagrant::Action::Builder.new.tap do |b|
13
+ b.use ConfigValidate
14
+ b.use Call, IsCreated do |env, b2|
15
+ if !env[:result]
16
+ b2.use MessageNotCreated
17
+ next
18
+ end
19
+
20
+ b2.use ConnectCloudstack
21
+ b2.use StopInstance
22
+ end
23
+ end
24
+ end
25
+
26
+ # This action is called to terminate the remote machine.
27
+ def self.action_destroy
28
+ Vagrant::Action::Builder.new.tap do |b|
29
+ b.use Call, DestroyConfirm do |env, b2|
30
+ if env[:result]
31
+ b2.use ConfigValidate
32
+ b.use Call, IsCreated do |env2, b3|
33
+ if !env2[:result]
34
+ b3.use MessageNotCreated
35
+ next
36
+ end
37
+ end
38
+ b2.use ConnectCloudstack
39
+ b2.use TerminateInstance
40
+ else
41
+ b2.use MessageWillNotDestroy
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ # This action is called when `vagrant provision` is called.
48
+ def self.action_provision
49
+ Vagrant::Action::Builder.new.tap do |b|
50
+ b.use ConfigValidate
51
+ b.use Call, IsCreated do |env, b2|
52
+ if !env[:result]
53
+ b2.use MessageNotCreated
54
+ next
55
+ end
56
+
57
+ b2.use Provision
58
+ b2.use SyncedFolders
59
+ end
60
+ end
61
+ end
62
+
63
+ # This action is called to read the WinRM info of the machine. The
64
+ # resulting state is expected to be put into the `:machine_winrm_info`
65
+ # key.
66
+ def self.action_read_rdp_info
67
+ Vagrant::Action::Builder.new.tap do |b|
68
+ b.use ConfigValidate
69
+ b.use ConnectCloudstack
70
+ b.use ReadRdpInfo
71
+ end
72
+ end
73
+
74
+ # This action is called to read the WinRM info of the machine. The
75
+ # resulting state is expected to be put into the `:machine_winrm_info`
76
+ # key.
77
+ def self.action_read_winrm_info
78
+ Vagrant::Action::Builder.new.tap do |b|
79
+ b.use ConfigValidate
80
+ b.use ConnectCloudstack
81
+ b.use ReadWinrmInfo
82
+ end
83
+ end
84
+
85
+ # This action is called to read the SSH info of the machine. The
86
+ # resulting state is expected to be put into the `:machine_ssh_info`
87
+ # key.
88
+ def self.action_read_ssh_info
89
+ Vagrant::Action::Builder.new.tap do |b|
90
+ b.use ConfigValidate
91
+ b.use ConnectCloudstack
92
+ b.use ReadSSHInfo
93
+ end
94
+ end
95
+
96
+ # This action is called to read the state of the machine. The
97
+ # resulting state is expected to be put into the `:machine_state_id`
98
+ # key.
99
+ def self.action_read_state
100
+ Vagrant::Action::Builder.new.tap do |b|
101
+ b.use ConfigValidate
102
+ b.use ConnectCloudstack
103
+ b.use ReadState
104
+ end
105
+ end
106
+
107
+ # This action is called to SSH into the machine.
108
+ def self.action_ssh
109
+ Vagrant::Action::Builder.new.tap do |b|
110
+ b.use ConfigValidate
111
+ b.use Call, IsCreated do |env, b2|
112
+ if !env[:result]
113
+ b2.use MessageNotCreated
114
+ next
115
+ end
116
+
117
+ b2.use SSHExec
118
+ end
119
+ end
120
+ end
121
+
122
+ def self.action_ssh_run
123
+ Vagrant::Action::Builder.new.tap do |b|
124
+ b.use ConfigValidate
125
+ b.use Call, IsCreated do |env, b2|
126
+ if !env[:result]
127
+ b2.use MessageNotCreated
128
+ next
129
+ end
130
+
131
+ b2.use SSHRun
132
+ end
133
+ end
134
+ end
135
+
136
+ def self.action_prepare_boot
137
+ Vagrant::Action::Builder.new.tap do |b|
138
+ b.use Provision
139
+ b.use SyncedFolders
140
+ b.use WarnNetworks
141
+ end
142
+ end
143
+
144
+ # This action is called to bring the box up from nothing.
145
+ def self.action_up
146
+ Vagrant::Action::Builder.new.tap do |b|
147
+ b.use ConfigValidate
148
+ b.use ConnectCloudstack
149
+ b.use Call, IsCreated do |env1, b1|
150
+ if env1[:result]
151
+ b1.use Call, IsStopped do |env2, b2|
152
+ if env2[:result]
153
+ b2.use action_prepare_boot
154
+ b2.use StartInstance # restart this instance
155
+ else
156
+ b2.use MessageAlreadyCreated # TODO write a better message
157
+ end
158
+ end
159
+ else
160
+ b1.use action_prepare_boot
161
+ b1.use RunInstance # launch a new instance
162
+ end
163
+ end
164
+ end
165
+ end
166
+
167
+ def self.action_reload
168
+ Vagrant::Action::Builder.new.tap do |b|
169
+ b.use ConfigValidate
170
+ b.use ConnectCloudstack
171
+ b.use Call, IsCreated do |env, b2|
172
+ if !env[:result]
173
+ b2.use MessageNotCreated
174
+ next
175
+ end
176
+
177
+ b2.use action_halt
178
+ b2.use Call, WaitForState, :stopped, 120 do |env2, b3|
179
+ if env2[:result]
180
+ b3.use action_up
181
+ else
182
+ # TODO we couldn't reach :stopped, what now?
183
+ end
184
+ end
185
+ end
186
+ end
187
+ end
188
+
189
+ # The autoload farm
190
+ action_root = Pathname.new(File.expand_path("../action", __FILE__))
191
+ autoload :ConnectCloudstack, action_root.join("connect_cloudstack")
192
+ autoload :IsCreated, action_root.join("is_created")
193
+ autoload :IsStopped, action_root.join("is_stopped")
194
+ autoload :MessageAlreadyCreated, action_root.join("message_already_created")
195
+ autoload :MessageNotCreated, action_root.join("message_not_created")
196
+ autoload :MessageWillNotDestroy, action_root.join("message_will_not_destroy")
197
+ autoload :ReadSSHInfo, action_root.join("read_ssh_info")
198
+ autoload :ReadWinrmInfo, action_root.join("read_winrm_info")
199
+ autoload :ReadRdpInfo, action_root.join("read_rdp_info")
200
+ autoload :ReadState, action_root.join("read_state")
201
+ autoload :RunInstance, action_root.join("run_instance")
202
+ autoload :StartInstance, action_root.join("start_instance")
203
+ autoload :StopInstance, action_root.join("stop_instance")
204
+ autoload :TimedProvision, action_root.join("timed_provision")
205
+ autoload :WaitForState, action_root.join("wait_for_state")
206
+ autoload :WarnNetworks, action_root.join("warn_networks")
207
+ autoload :TerminateInstance, action_root.join("terminate_instance")
208
+ end
209
+ end
210
+ end