vagrant-skytap 0.1.1a

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/.hgignore +22 -0
  4. data/.project +11 -0
  5. data/.rspec +1 -0
  6. data/CHANGELOG.md +85 -0
  7. data/Gemfile +29 -0
  8. data/LICENSE +8 -0
  9. data/README.md +292 -0
  10. data/Rakefile +31 -0
  11. data/Vagrantfile.orig +34 -0
  12. data/bar/checksums.yaml +7 -0
  13. data/bar/data.tar +0 -0
  14. data/bar/metadata +242 -0
  15. data/dummy.box +0 -0
  16. data/example_box/README.md +13 -0
  17. data/example_box/metadata.json +3 -0
  18. data/lib/vagrant-skytap/action/add_vm_to_environment.rb +35 -0
  19. data/lib/vagrant-skytap/action/create_environment.rb +44 -0
  20. data/lib/vagrant-skytap/action/delete_environment.rb +26 -0
  21. data/lib/vagrant-skytap/action/delete_vm.rb +27 -0
  22. data/lib/vagrant-skytap/action/existence_check.rb +35 -0
  23. data/lib/vagrant-skytap/action/fetch_environment.rb +32 -0
  24. data/lib/vagrant-skytap/action/initialize_api_client.rb +28 -0
  25. data/lib/vagrant-skytap/action/is_running.rb +19 -0
  26. data/lib/vagrant-skytap/action/is_stopped.rb +19 -0
  27. data/lib/vagrant-skytap/action/is_suspended.rb +19 -0
  28. data/lib/vagrant-skytap/action/message_already_created.rb +16 -0
  29. data/lib/vagrant-skytap/action/message_already_running.rb +16 -0
  30. data/lib/vagrant-skytap/action/message_environment_url.rb +16 -0
  31. data/lib/vagrant-skytap/action/message_not_created.rb +16 -0
  32. data/lib/vagrant-skytap/action/message_will_not_destroy.rb +16 -0
  33. data/lib/vagrant-skytap/action/mixin_machine_index.rb +22 -0
  34. data/lib/vagrant-skytap/action/prepare_nfs_settings.rb +46 -0
  35. data/lib/vagrant-skytap/action/prepare_nfs_valid_ids.rb +28 -0
  36. data/lib/vagrant-skytap/action/read_ssh_info.rb +23 -0
  37. data/lib/vagrant-skytap/action/read_state.rb +42 -0
  38. data/lib/vagrant-skytap/action/run_environment.rb +53 -0
  39. data/lib/vagrant-skytap/action/run_vm.rb +51 -0
  40. data/lib/vagrant-skytap/action/set_hostname.rb +31 -0
  41. data/lib/vagrant-skytap/action/set_up_vm.rb +21 -0
  42. data/lib/vagrant-skytap/action/stop_environment.rb +43 -0
  43. data/lib/vagrant-skytap/action/stop_vm.rb +43 -0
  44. data/lib/vagrant-skytap/action/store_extra_data.rb +35 -0
  45. data/lib/vagrant-skytap/action/suspend_environment.rb +32 -0
  46. data/lib/vagrant-skytap/action/suspend_vm.rb +32 -0
  47. data/lib/vagrant-skytap/action/timed_provision.rb +21 -0
  48. data/lib/vagrant-skytap/action/update_hardware.rb +37 -0
  49. data/lib/vagrant-skytap/action.rb +272 -0
  50. data/lib/vagrant-skytap/api/busyable.rb +37 -0
  51. data/lib/vagrant-skytap/api/client.rb +127 -0
  52. data/lib/vagrant-skytap/api/credentials.rb +41 -0
  53. data/lib/vagrant-skytap/api/environment.rb +99 -0
  54. data/lib/vagrant-skytap/api/interface.rb +123 -0
  55. data/lib/vagrant-skytap/api/network.rb +40 -0
  56. data/lib/vagrant-skytap/api/public_ip.rb +103 -0
  57. data/lib/vagrant-skytap/api/published_service.rb +90 -0
  58. data/lib/vagrant-skytap/api/resource.rb +44 -0
  59. data/lib/vagrant-skytap/api/runstate_operations.rb +63 -0
  60. data/lib/vagrant-skytap/api/specified_attributes.rb +27 -0
  61. data/lib/vagrant-skytap/api/vm.rb +88 -0
  62. data/lib/vagrant-skytap/api/vpn.rb +146 -0
  63. data/lib/vagrant-skytap/api/vpn_attachment.rb +57 -0
  64. data/lib/vagrant-skytap/config.rb +106 -0
  65. data/lib/vagrant-skytap/core_ext/object/blank.rb +82 -0
  66. data/lib/vagrant-skytap/core_ext/object/tap.rb +8 -0
  67. data/lib/vagrant-skytap/core_ext/try.rb +42 -0
  68. data/lib/vagrant-skytap/environment_properties.rb +11 -0
  69. data/lib/vagrant-skytap/errors.rb +59 -0
  70. data/lib/vagrant-skytap/plugin.rb +73 -0
  71. data/lib/vagrant-skytap/properties.rb +42 -0
  72. data/lib/vagrant-skytap/provider.rb +50 -0
  73. data/lib/vagrant-skytap/setup_helper.rb +193 -0
  74. data/lib/vagrant-skytap/util/ip_address.rb +69 -0
  75. data/lib/vagrant-skytap/util/subnet.rb +97 -0
  76. data/lib/vagrant-skytap/util/timer.rb +17 -0
  77. data/lib/vagrant-skytap/version.rb +5 -0
  78. data/lib/vagrant-skytap/version.rb.orig +5 -0
  79. data/lib/vagrant-skytap/vm_properties.rb +22 -0
  80. data/lib/vagrant-skytap.rb +23 -0
  81. data/locales/en.yml +127 -0
  82. data/skytap-dummy.box +0 -0
  83. data/spec/acceptance/base.rb +2 -0
  84. data/spec/acceptance/provider/halt_spec.rb +3 -0
  85. data/spec/acceptance/shared/context_skytap.rb +3 -0
  86. data/spec/spec_helper.rb +1 -0
  87. data/spec/support/isolated_environment.rb +45 -0
  88. data/spec/unit/base.rb +57 -0
  89. data/spec/unit/config_spec.rb +73 -0
  90. data/spec/unit/environment_spec.rb +144 -0
  91. data/spec/unit/skeletons/empty_environment.json +19 -0
  92. data/spec/unit/skeletons/network1.json +36 -0
  93. data/spec/unit/skeletons/vm1.json +85 -0
  94. data/spec/unit/support/dummy_communicator.rb +83 -0
  95. data/spec/unit/support/dummy_provider.rb +41 -0
  96. data/spec/unit/support/isolated_environment.rb +217 -0
  97. data/spec/unit/support/shared/action_synced_folders_context.rb +15 -0
  98. data/spec/unit/support/shared/base_context.rb +116 -0
  99. data/spec/unit/support/shared/capability_helpers_context.rb +29 -0
  100. data/spec/unit/support/shared/plugin_command_context.rb +12 -0
  101. data/spec/unit/support/shared/skytap_context.rb +3 -0
  102. data/spec/unit/vm_spec.rb +118 -0
  103. data/tasks/acceptance.rake +22 -0
  104. data/tasks/bundler.rake +3 -0
  105. data/tasks/test.rake +14 -0
  106. data/vagrant-skytap.gemspec +62 -0
  107. data/vagrant-spec.config.rb +10 -0
  108. metadata +247 -0
data/bar/metadata ADDED
@@ -0,0 +1,242 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-skytap
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
+ platform: ruby
6
+ authors:
7
+ - Nick Astete
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-core
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 2.14.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 2.14.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-expectations
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.14.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.14.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-mocks
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 2.14.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.14.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: vagrant-spec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 1.4.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 1.4.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.20'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.20'
111
+ description: Enables Vagrant to manage Skytap machines.
112
+ email: nastete@skytap.com
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - ".gitignore"
118
+ - ".hgignore"
119
+ - ".project"
120
+ - ".rspec"
121
+ - CHANGELOG.md
122
+ - Gemfile
123
+ - LICENSE
124
+ - README.md
125
+ - Rakefile
126
+ - dummy.box
127
+ - example_box/README.md
128
+ - example_box/metadata.json
129
+ - lib/vagrant-skytap.rb
130
+ - lib/vagrant-skytap/action.rb
131
+ - lib/vagrant-skytap/action/add_vm_to_environment.rb
132
+ - lib/vagrant-skytap/action/create_environment.rb
133
+ - lib/vagrant-skytap/action/delete_environment.rb
134
+ - lib/vagrant-skytap/action/delete_vm.rb
135
+ - lib/vagrant-skytap/action/existence_check.rb
136
+ - lib/vagrant-skytap/action/fetch_environment.rb
137
+ - lib/vagrant-skytap/action/initialize_api_client.rb
138
+ - lib/vagrant-skytap/action/is_running.rb
139
+ - lib/vagrant-skytap/action/is_stopped.rb
140
+ - lib/vagrant-skytap/action/is_suspended.rb
141
+ - lib/vagrant-skytap/action/message_already_created.rb
142
+ - lib/vagrant-skytap/action/message_already_running.rb
143
+ - lib/vagrant-skytap/action/message_environment_url.rb
144
+ - lib/vagrant-skytap/action/message_not_created.rb
145
+ - lib/vagrant-skytap/action/message_will_not_destroy.rb
146
+ - lib/vagrant-skytap/action/mixin_machine_index.rb
147
+ - lib/vagrant-skytap/action/prepare_nfs_settings.rb
148
+ - lib/vagrant-skytap/action/prepare_nfs_valid_ids.rb
149
+ - lib/vagrant-skytap/action/read_ssh_info.rb
150
+ - lib/vagrant-skytap/action/read_state.rb
151
+ - lib/vagrant-skytap/action/run_environment.rb
152
+ - lib/vagrant-skytap/action/run_vm.rb
153
+ - lib/vagrant-skytap/action/set_hostname.rb
154
+ - lib/vagrant-skytap/action/set_up_vm.rb
155
+ - lib/vagrant-skytap/action/stop_environment.rb
156
+ - lib/vagrant-skytap/action/stop_vm.rb
157
+ - lib/vagrant-skytap/action/store_extra_data.rb
158
+ - lib/vagrant-skytap/action/suspend_environment.rb
159
+ - lib/vagrant-skytap/action/suspend_vm.rb
160
+ - lib/vagrant-skytap/action/timed_provision.rb
161
+ - lib/vagrant-skytap/action/update_hardware.rb
162
+ - lib/vagrant-skytap/api/busyable.rb
163
+ - lib/vagrant-skytap/api/client.rb
164
+ - lib/vagrant-skytap/api/credentials.rb
165
+ - lib/vagrant-skytap/api/environment.rb
166
+ - lib/vagrant-skytap/api/interface.rb
167
+ - lib/vagrant-skytap/api/network.rb
168
+ - lib/vagrant-skytap/api/public_ip.rb
169
+ - lib/vagrant-skytap/api/published_service.rb
170
+ - lib/vagrant-skytap/api/resource.rb
171
+ - lib/vagrant-skytap/api/runstate_operations.rb
172
+ - lib/vagrant-skytap/api/specified_attributes.rb
173
+ - lib/vagrant-skytap/api/vm.rb
174
+ - lib/vagrant-skytap/api/vpn.rb
175
+ - lib/vagrant-skytap/api/vpn_attachment.rb
176
+ - lib/vagrant-skytap/config.rb
177
+ - lib/vagrant-skytap/core_ext/object/blank.rb
178
+ - lib/vagrant-skytap/core_ext/object/tap.rb
179
+ - lib/vagrant-skytap/core_ext/try.rb
180
+ - lib/vagrant-skytap/environment_properties.rb
181
+ - lib/vagrant-skytap/errors.rb
182
+ - lib/vagrant-skytap/plugin.rb
183
+ - lib/vagrant-skytap/properties.rb
184
+ - lib/vagrant-skytap/provider.rb
185
+ - lib/vagrant-skytap/setup_helper.rb
186
+ - lib/vagrant-skytap/util/ip_address.rb
187
+ - lib/vagrant-skytap/util/subnet.rb
188
+ - lib/vagrant-skytap/util/timer.rb
189
+ - lib/vagrant-skytap/version.rb
190
+ - lib/vagrant-skytap/vm_properties.rb
191
+ - locales/en.yml
192
+ - skytap-dummy.box
193
+ - spec/acceptance/base.rb
194
+ - spec/acceptance/provider/halt_spec.rb
195
+ - spec/acceptance/shared/context_skytap.rb
196
+ - spec/spec_helper.rb
197
+ - spec/support/isolated_environment.rb
198
+ - spec/unit/base.rb
199
+ - spec/unit/config_spec.rb
200
+ - spec/unit/environment_spec.rb
201
+ - spec/unit/skeletons/empty_environment.json
202
+ - spec/unit/skeletons/network1.json
203
+ - spec/unit/skeletons/vm1.json
204
+ - spec/unit/support/dummy_communicator.rb
205
+ - spec/unit/support/dummy_provider.rb
206
+ - spec/unit/support/isolated_environment.rb
207
+ - spec/unit/support/shared/action_synced_folders_context.rb
208
+ - spec/unit/support/shared/base_context.rb
209
+ - spec/unit/support/shared/capability_helpers_context.rb
210
+ - spec/unit/support/shared/plugin_command_context.rb
211
+ - spec/unit/support/shared/skytap_context.rb
212
+ - spec/unit/vm_spec.rb
213
+ - tasks/acceptance.rake
214
+ - tasks/bundler.rake
215
+ - tasks/test.rake
216
+ - vagrant-skytap.gemspec
217
+ - vagrant-spec.config.rb
218
+ homepage: http://www.skytap.com
219
+ licenses:
220
+ - MIT
221
+ metadata: {}
222
+ post_install_message:
223
+ rdoc_options: []
224
+ require_paths:
225
+ - lib
226
+ required_ruby_version: !ruby/object:Gem::Requirement
227
+ requirements:
228
+ - - ">="
229
+ - !ruby/object:Gem::Version
230
+ version: '0'
231
+ required_rubygems_version: !ruby/object:Gem::Requirement
232
+ requirements:
233
+ - - ">="
234
+ - !ruby/object:Gem::Version
235
+ version: 1.3.6
236
+ requirements: []
237
+ rubyforge_project: vagrant-skytap
238
+ rubygems_version: 2.4.5
239
+ signing_key:
240
+ specification_version: 4
241
+ summary: Enables Vagrant to manage Skytap machines.
242
+ test_files: []
data/dummy.box ADDED
Binary file
@@ -0,0 +1,13 @@
1
+ # Vagrant AWS Example Box
2
+
3
+ Vagrant providers each require a custom provider-specific box format.
4
+ This folder shows the example contents of a box for the `aws` provider.
5
+ To turn this into a box:
6
+
7
+ ```
8
+ $ tar cvzf aws.box ./metadata.json ./Vagrantfile
9
+ ```
10
+
11
+ This box works by using Vagrant's built-in Vagrantfile merging to setup
12
+ defaults for AWS. These defaults can easily be overwritten by higher-level
13
+ Vagrantfiles (such as project root Vagrantfiles).
@@ -0,0 +1,3 @@
1
+ {
2
+ "provider": "aws"
3
+ }
@@ -0,0 +1,35 @@
1
+ require 'log4r'
2
+ require 'json'
3
+ require 'vagrant-skytap/setup_helper'
4
+
5
+
6
+ module VagrantPlugins
7
+ module Skytap
8
+ module Action
9
+ # Adds the specified vm to this Skytap environment, assuming the vm and environment
10
+ # both exist.
11
+ class AddVmToEnvironment
12
+ attr_reader :env
13
+
14
+ def initialize(app, env)
15
+ @app = app
16
+ @env = env
17
+ @logger = Log4r::Logger.new("vagrant_skytap::action::add_vm_to_environment")
18
+ end
19
+
20
+ def call(env)
21
+ environment = env[:environment]
22
+ vm = environment.add_vm(vm_url)
23
+ env[:machine].id = vm.id
24
+ environment.wait_until_ready
25
+
26
+ @app.call(env)
27
+ end
28
+
29
+ def vm_url
30
+ env[:machine].provider_config.vm_url
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,44 @@
1
+ require 'log4r'
2
+ require 'json'
3
+
4
+ require 'vagrant-skytap/setup_helper'
5
+ require 'vagrant-skytap/util/timer'
6
+ require 'vagrant-skytap/api/environment'
7
+
8
+ require 'net/https'
9
+ require 'uri'
10
+ require 'base64'
11
+ require 'json'
12
+ require 'timeout'
13
+
14
+ module VagrantPlugins
15
+ module Skytap
16
+ module Action
17
+ # Creates an environment from the template URL present in the config
18
+ # file. Stores the new environment URL in the environment properties.
19
+ class CreateEnvironment
20
+ attr_reader :env
21
+
22
+ def initialize(app, env)
23
+ @app = app
24
+ @env = env
25
+ @logger = Log4r::Logger.new("vagrant_skytap::action::create_environment")
26
+ end
27
+
28
+ def call(env)
29
+ environment = API::Environment.create!(env, vm_url)
30
+ env[:environment] = environment
31
+ environment.properties.write('url' => environment.url)
32
+ env[:machine].id = environment.vms.first.id
33
+ environment.wait_until_ready
34
+
35
+ @app.call(env)
36
+ end
37
+
38
+ def vm_url
39
+ env[:machine].provider_config.vm_url
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,26 @@
1
+ module VagrantPlugins
2
+ module Skytap
3
+ module Action
4
+ class DeleteEnvironment
5
+ # Deletes Skytap environment, cleans up data files, and removes the
6
+ # remaining VM from the global machine index.
7
+ def initialize(app, env)
8
+ @app = app
9
+ @logger = Log4r::Logger.new("vagrant_skytap::action::delete_environment")
10
+ end
11
+
12
+ def call(env)
13
+ url_file = env[:machine].env.local_data_path.join('environment')
14
+ url_file.delete if url_file.exist?
15
+
16
+ if env[:environment]
17
+ env[:environment].delete
18
+ end
19
+ env[:machine].id = nil
20
+
21
+ @app.call(env)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,27 @@
1
+ require 'log4r'
2
+ require 'vagrant-skytap/api/vm'
3
+
4
+ module VagrantPlugins
5
+ module Skytap
6
+ module Action
7
+ class DeleteVm
8
+ # Deletes Skytap VM and removes it from the global machine index.
9
+ def initialize(app, env)
10
+ @app = app
11
+ @logger = Log4r::Logger.new("vagrant_skytap::action::delete_vm")
12
+ end
13
+
14
+ def call(env)
15
+ environment = env[:environment]
16
+ if vm = environment.current_vm
17
+ vm.delete
18
+ environment.wait_until_ready
19
+ end
20
+ env[:machine].id = nil
21
+
22
+ @app.call(env)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,35 @@
1
+ require 'vagrant-skytap/api/vm'
2
+
3
+ module VagrantPlugins
4
+ module Skytap
5
+ module Action
6
+ # This can be used with "Call" built-in to check if the environment
7
+ # is created and branch in the middleware.
8
+ class ExistenceCheck
9
+ def initialize(app, env)
10
+ @app = app
11
+ @logger = Log4r::Logger.new("vagrant_skytap::action::existence_check")
12
+ end
13
+
14
+ def call(env)
15
+ environment = env[:environment]
16
+ env[:result] = if !environment
17
+ :missing_environment
18
+ elsif environment.vms.count == 0
19
+ :no_vms
20
+ elsif !environment.current_vm
21
+ # Could be confusing. The *current* vm is not present. This response also implies that there are other vms.
22
+ :missing_vm
23
+ elsif environment.vms.count == 1
24
+ :solitary_vm
25
+ else
26
+ :one_of_many_vms
27
+ end
28
+ @logger.debug("ExistenceCheck returning #{env[:result]}")
29
+
30
+ @app.call(env)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,32 @@
1
+ require 'log4r'
2
+ require 'json'
3
+ require 'vagrant-skytap/api/environment'
4
+
5
+ module VagrantPlugins
6
+ module Skytap
7
+ module Action
8
+ # Fetches the environment from the environment URL file, assuming the
9
+ # file exists and the corresponding Skytap environment does too.
10
+ class FetchEnvironment
11
+ def initialize(app, env)
12
+ @app = app
13
+ @logger = Log4r::Logger.new("vagrant_skytap::action::fetch_environment")
14
+ end
15
+
16
+ def call(env)
17
+ unless env[:environment]
18
+ if props = API::Environment.properties(env)
19
+ begin
20
+ env[:environment] = API::Environment.fetch(env, props['url'])
21
+ rescue Errors::DoesNotExist => ex
22
+ @logger.info("Ignoring missing environment '#{props['url']}'.")
23
+ end
24
+ end
25
+ end
26
+
27
+ @app.call(env)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,28 @@
1
+ require "log4r"
2
+ require "vagrant-skytap/api/client"
3
+
4
+ module VagrantPlugins
5
+ module Skytap
6
+ module Action
7
+ # This action initializes the API client, verifies the provided
8
+ # credentials, and stores the API client object in env[:api_client].
9
+ class InitializeAPIClient
10
+ def initialize(app, env)
11
+ @app = app
12
+ @logger = Log4r::Logger.new("vagrant_skytap::action::initialize_api_client")
13
+ end
14
+
15
+ def call(env)
16
+ @logger.info("Connecting to Skytap...")
17
+
18
+ client = API::Client.new(env[:machine].provider_config)
19
+ if client.get('/configurations').code == '200'
20
+ env[:api_client] = client
21
+ end
22
+
23
+ @app.call(env)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,19 @@
1
+ module VagrantPlugins
2
+ module Skytap
3
+ module Action
4
+ # This can be used with "Call" built-in to check if the machine
5
+ # is running and branch in the middleware.
6
+ class IsRunning
7
+ def initialize(app, env)
8
+ @app = app
9
+ @logger = Log4r::Logger.new("vagrant_skytap::action::is_running")
10
+ end
11
+
12
+ def call(env)
13
+ env[:result] = env[:machine].state.id == :running
14
+ @app.call(env)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ module VagrantPlugins
2
+ module Skytap
3
+ module Action
4
+ # This can be used with "Call" built-in to check if the machine
5
+ # is stopped and branch in the middleware.
6
+ class IsStopped
7
+ def initialize(app, env)
8
+ @app = app
9
+ @logger = Log4r::Logger.new("vagrant_skytap::action::is_stopped")
10
+ end
11
+
12
+ def call(env)
13
+ env[:result] = env[:machine].state.id == :stopped
14
+ @app.call(env)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ module VagrantPlugins
2
+ module Skytap
3
+ module Action
4
+ # This can be used with "Call" built-in to check if the machine
5
+ # is suspended and branch in the middleware.
6
+ class IsSuspended
7
+ def initialize(app, env)
8
+ @app = app
9
+ @logger = Log4r::Logger.new("vagrant_skytap::action::is_suspended")
10
+ end
11
+
12
+ def call(env)
13
+ env[:result] = env[:machine].state.id == :suspended
14
+ @app.call(env)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,16 @@
1
+ module VagrantPlugins
2
+ module Skytap
3
+ module Action
4
+ class MessageAlreadyCreated
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ env[:ui].info(I18n.t("vagrant_skytap.already_status", :status => "created"))
11
+ @app.call(env)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module VagrantPlugins
2
+ module Skytap
3
+ module Action
4
+ class MessageAlreadyRunning
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ env[:ui].info(I18n.t("vagrant_skytap.already_status", :status => "running"))
11
+ @app.call(env)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module VagrantPlugins
2
+ module Skytap
3
+ module Action
4
+ class MessageEnvironmentUrl
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ env[:ui].info(I18n.t("vagrant_skytap.environment_url", url: env[:environment].url))
11
+ @app.call(env)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module VagrantPlugins
2
+ module Skytap
3
+ module Action
4
+ class MessageNotCreated
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ env[:ui].info(I18n.t("vagrant_skytap.not_created"))
11
+ @app.call(env)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module VagrantPlugins
2
+ module Skytap
3
+ module Action
4
+ class MessageWillNotDestroy
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ env[:ui].info(I18n.t("vagrant_skytap.will_not_destroy", name: env[:machine].name))
11
+ @app.call(env)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,22 @@
1
+ module VagrantPlugins
2
+ module Skytap
3
+ module Action
4
+ module MixinMachineIndex
5
+ attr_reader :env
6
+
7
+ # The global machine index lives under ~/.vagrant.d by default, and
8
+ # contains a hash of entries for all guest machines on the host.
9
+
10
+ def machine_index
11
+ @machine_index ||= env[:machine].env.machine_index
12
+ end
13
+
14
+ # NOTE: #get locks the machine. Make sure to #release(entry)
15
+ # when finished.
16
+ def machine_index_entry
17
+ entry = machine_index.get(env[:machine].index_uuid)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end