vagrant-skytap 0.1.6 → 0.1.7

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.
@@ -78,6 +78,10 @@ module VagrantPlugins
78
78
  super
79
79
  end
80
80
 
81
+ def run!(vm_ids = nil)
82
+ set_runstate :running, vm_ids: vm_ids
83
+ end
84
+
81
85
  def delete
82
86
  retry_while_resource_busy do
83
87
  api_client.delete(url)
@@ -20,12 +20,17 @@ module VagrantPlugins
20
20
  end
21
21
 
22
22
  def poweroff!
23
- set_runstate :halted, :stopped
23
+ set_runstate :halted, completed_runstate: :stopped
24
24
  end
25
25
 
26
- def set_runstate(new_runstate, completed_runstate = nil)
27
- completed_runstate ||= new_runstate
28
- update_with_retry(runstate: new_runstate)
26
+ def set_runstate(new_runstate, opts = {})
27
+ completed_runstate = opts.delete(:completed_runstate) || new_runstate
28
+
29
+ params = {runstate: new_runstate}.tap do |ret|
30
+ ret[:multiselect] = opts[:vm_ids] if opts[:vm_ids]
31
+ end
32
+ update_with_retry(params)
33
+
29
34
  wait_for_runstate(completed_runstate) unless runstate == completed_runstate
30
35
  end
31
36
 
@@ -0,0 +1,47 @@
1
+ module VagrantPlugins
2
+ module Skytap
3
+ module Command
4
+ module StartMixins
5
+
6
+ # Would be nice to just extend this, then alias #build_start_options
7
+ # and add default options flag.
8
+ #include VagrantPlugins::CommandUp::StartMixins
9
+
10
+ # This adds the standard `start` command line flags to the given
11
+ # OptionParser, storing the result in the `options` dictionary.
12
+ #
13
+ # @param [OptionParser] parser
14
+ # @param [Hash] options
15
+ def build_start_options(parser, options)
16
+ # Setup the defaults
17
+ options[:provision_types] = nil
18
+
19
+ # Add the options
20
+ parser.on("--[no-]provision", "Enable or disable provisioning") do |p|
21
+ options[:provision_enabled] = p
22
+ options[:provision_ignore_sentinel] = true
23
+ end
24
+
25
+ parser.on("--provision-with x,y,z", Array,
26
+ "Enable only certain provisioners, by type.") do |list|
27
+ options[:provision_types] = list.map { |type| type.to_sym }
28
+ options[:provision_enabled] = true
29
+ options[:provision_ignore_sentinel] = true
30
+ end
31
+ end
32
+
33
+ # This validates the provisioner flags and raises an exception
34
+ # if there are invalid ones.
35
+ def validate_provisioner_flags!(options)
36
+ (options[:provision_types] || []).each do |type|
37
+ klass = Vagrant.plugin("2").manager.provisioners[type]
38
+ if !klass
39
+ raise Vagrant::Errors::ProvisionerFlagInvalid,
40
+ name: type.to_s
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,126 @@
1
+ require 'optparse'
2
+
3
+ require "vagrant"
4
+
5
+ require_relative 'start_mixins'
6
+
7
+ # This is a modified copy of the built-in "up" command, which alters how
8
+ # parallelization is implemented. Instead of making concurrent requests to run
9
+ # individual VMs, we make a single REST call to update the runstates of
10
+ # multiple VMs within the containing Skytap environment.
11
+
12
+ module VagrantPlugins
13
+ module Skytap
14
+ module Command
15
+ class Up < Vagrant.plugin("2", :command)
16
+ include StartMixins
17
+
18
+ def self.synopsis
19
+ "starts and provisions the vagrant environment"
20
+ end
21
+
22
+ def execute
23
+ options = {}
24
+ options[:destroy_on_error] = true
25
+ options[:parallel] = true
26
+ options[:provision_ignore_sentinel] = false
27
+
28
+ opts = OptionParser.new do |o|
29
+ o.banner = "Usage: vagrant up [options] [name]"
30
+ o.separator ""
31
+ o.separator "Options:"
32
+ o.separator ""
33
+
34
+ build_start_options(o, options)
35
+
36
+ o.on("--[no-]destroy-on-error",
37
+ "Destroy machine if any fatal error happens (default to true)") do |destroy|
38
+ options[:destroy_on_error] = destroy
39
+ end
40
+
41
+ o.on("--[no-]parallel",
42
+ "Enable or disable parallelism if provider supports it") do |parallel|
43
+ options[:parallel] = parallel
44
+ end
45
+
46
+ o.on("--provider PROVIDER", String,
47
+ "Back the machine with a specific provider") do |provider|
48
+ options[:provider] = provider
49
+ end
50
+ end
51
+
52
+ # Parse the options
53
+ argv = parse_options(opts)
54
+ return if !argv
55
+
56
+ # Validate the provisioners
57
+ validate_provisioner_flags!(options)
58
+
59
+ # Go over each VM and bring it up
60
+ @logger.debug("'Up' each target VM...")
61
+
62
+ machines = []
63
+ names = argv
64
+ if names.empty?
65
+ autostart = false
66
+ @env.vagrantfile.machine_names_and_options.each do |n, o|
67
+ autostart = true if o.key?(:autostart)
68
+ o[:autostart] = true if !o.key?(:autostart)
69
+ names << n.to_s if o[:autostart]
70
+ end
71
+
72
+ # If we have an autostart key but no names, it means that
73
+ # all machines are autostart: false and we don't start anything.
74
+ names = nil if autostart && names.empty?
75
+ end
76
+
77
+ if names
78
+ with_target_vms(names, provider: options[:provider]) do |machine|
79
+ @env.ui.info(I18n.t(
80
+ "vagrant.commands.up.upping",
81
+ name: machine.name,
82
+ provider: machine.provider_name))
83
+
84
+ machines << machine
85
+ machine.action(:create, options)
86
+ machine.action(:update_hardware, options)
87
+ end
88
+
89
+ initial_states = machines.inject({}) {|acc, m| acc[m.id] = m.state.id ; acc }
90
+
91
+ machines.each_with_index do |machine, i|
92
+ machine.action(:run_vm, options.merge(
93
+ first_machine: i == 0,
94
+ machines: machines,
95
+ initial_states: initial_states
96
+ ))
97
+ end
98
+ end
99
+
100
+ if machines.empty?
101
+ @env.ui.info(I18n.t("vagrant.up_no_machines"))
102
+ return 0
103
+ end
104
+
105
+ # Output the post-up messages that we have, if any
106
+ machines.each do |m|
107
+ next if !m.config.vm.post_up_message
108
+ next if m.config.vm.post_up_message == ""
109
+
110
+ # Add a newline to separate things.
111
+ @env.ui.info("", prefix: false)
112
+
113
+ m.ui.success(I18n.t(
114
+ "vagrant.post_up_message",
115
+ name: m.name.to_s,
116
+ message: m.config.vm.post_up_message))
117
+ end
118
+
119
+ # Success, exit status 0
120
+ 0
121
+ end
122
+ end
123
+ end
124
+ end
125
+ end
126
+
@@ -24,7 +24,7 @@ module VagrantPlugins
24
24
  Config
25
25
  end
26
26
 
27
- provider(:skytap, parallel: false) do
27
+ provider(:skytap, parallel: true) do
28
28
  # Setup logging and i18n
29
29
  setup_logging
30
30
  setup_i18n
@@ -34,6 +34,11 @@ module VagrantPlugins
34
34
  Provider
35
35
  end
36
36
 
37
+ command("up", primary: true) do
38
+ require_relative "command/up"
39
+ Command::Up
40
+ end
41
+
37
42
  # This initializes the internationalization strings.
38
43
  def self.setup_i18n
39
44
  I18n.load_path << File.expand_path("locales/en.yml", Skytap.source_root)
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Skytap
3
- VERSION = "0.1.6"
3
+ VERSION = "0.1.7"
4
4
  end
5
5
  end
data/locales/en.yml CHANGED
@@ -3,8 +3,8 @@ en:
3
3
  already_status: |-
4
4
  The machine is already %{status}.
5
5
 
6
- launching_instance: |-
7
- Launching an instance with the following settings...
6
+ running_environment: |-
7
+ Starting VMs ...
8
8
  launching_vm: |-
9
9
  Launching a VM with the following settings...
10
10
  not_created: |-
@@ -22,6 +22,8 @@ en:
22
22
  Stopping the instance...
23
23
  terminating: |-
24
24
  Terminating the instance...
25
+ resuming: |-
26
+ Resuming the suspended instance ...
25
27
  waiting_for_ready: |-
26
28
  Waiting for instance to become "ready"...
27
29
  waiting_for_ssh: |-
@@ -0,0 +1,40 @@
1
+ # This tests that an instance can be upped correctly
2
+ shared_examples 'provider/up' do |provider, options|
3
+ if !options[:box]
4
+ raise ArgumentError,
5
+ "box option must be specified for provider: #{provider}"
6
+ end
7
+
8
+ include_context 'acceptance'
9
+
10
+ before do
11
+ environment.skeleton('generic')
12
+ #assert_execute('vagrant', 'box', 'add', 'basic', options[:box])
13
+ end
14
+
15
+ after do
16
+ assert_execute('vagrant', 'destroy', '--force')
17
+ end
18
+
19
+ it 'should bring up the machine and halt it' do
20
+ status("Test: machine can be brought up, parallel by default")
21
+ up_result = execute("vagrant", "up")
22
+ expect(up_result).to exit_with(0)
23
+
24
+ status("Test: machine is running after up")
25
+ echo_result = execute("vagrant", "ssh", "-c", "echo foo")
26
+ expect(echo_result).to exit_with(0)
27
+ expect(echo_result.stdout).to match(/foo\n$/)
28
+ end
29
+
30
+ it 'should bring up the machine and halt it' do
31
+ status("Test: machine can be brought up no parallel")
32
+ up_result = execute("vagrant", "up", "--no-parallel")
33
+ expect(up_result).to exit_with(0)
34
+
35
+ status("Test: machine is running after up")
36
+ echo_result = execute("vagrant", "ssh", "-c", "echo foo")
37
+ expect(echo_result).to exit_with(0)
38
+ expect(echo_result.stdout).to match(/foo\n$/)
39
+ end
40
+ end
metadata CHANGED
@@ -1,111 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-skytap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Astete
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-13 00:00:00.000000000 Z
11
+ date: 2015-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json_pure
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec-core
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: 2.14.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: 2.14.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec-expectations
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: 2.14.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: 2.14.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec-mocks
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
75
  version: 2.14.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: 2.14.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: vagrant-spec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ~>
88
88
  - !ruby/object:Gem::Version
89
89
  version: 1.4.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ~>
95
95
  - !ruby/object:Gem::Version
96
96
  version: 1.4.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: webmock
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ~>
102
102
  - !ruby/object:Gem::Version
103
103
  version: '1.20'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ~>
109
109
  - !ruby/object:Gem::Version
110
110
  version: '1.20'
111
111
  description: Enables Vagrant to manage Skytap machines.
@@ -114,28 +114,26 @@ executables: []
114
114
  extensions: []
115
115
  extra_rdoc_files: []
116
116
  files:
117
- - ".gitignore"
118
- - ".hgignore"
119
- - ".project"
120
- - ".rspec"
121
- - CHANGELOG.md
122
- - Gemfile
123
- - LICENSE
124
- - README.md
125
- - Rakefile
126
- - boxes/README.md
117
+ - bar
127
118
  - boxes/empty.box
128
119
  - boxes/metadata.json
120
+ - boxes/README.md
121
+ - CHANGELOG.md
122
+ - eng-10269-cleanup.diff
123
+ - eng-10269-tmp.diff
124
+ - eng-10269.diff
125
+ - eng-10269.diff.1
129
126
  - eng-10369.diff
130
- - lib/vagrant-skytap.rb
131
- - lib/vagrant-skytap/action.rb
127
+ - Gemfile
132
128
  - lib/vagrant-skytap/action/add_vm_to_environment.rb
133
129
  - lib/vagrant-skytap/action/create_environment.rb
134
130
  - lib/vagrant-skytap/action/delete_environment.rb
135
131
  - lib/vagrant-skytap/action/delete_vm.rb
136
132
  - lib/vagrant-skytap/action/existence_check.rb
137
133
  - lib/vagrant-skytap/action/fetch_environment.rb
134
+ - lib/vagrant-skytap/action/initial_state.rb
138
135
  - lib/vagrant-skytap/action/initialize_api_client.rb
136
+ - lib/vagrant-skytap/action/is_parallelized.rb
139
137
  - lib/vagrant-skytap/action/is_running.rb
140
138
  - lib/vagrant-skytap/action/is_stopped.rb
141
139
  - lib/vagrant-skytap/action/is_suspended.rb
@@ -143,6 +141,7 @@ files:
143
141
  - lib/vagrant-skytap/action/message_already_running.rb
144
142
  - lib/vagrant-skytap/action/message_environment_url.rb
145
143
  - lib/vagrant-skytap/action/message_not_created.rb
144
+ - lib/vagrant-skytap/action/message_resuming.rb
146
145
  - lib/vagrant-skytap/action/message_will_not_destroy.rb
147
146
  - lib/vagrant-skytap/action/mixin_machine_index.rb
148
147
  - lib/vagrant-skytap/action/prepare_nfs_settings.rb
@@ -161,6 +160,7 @@ files:
161
160
  - lib/vagrant-skytap/action/timed_provision.rb
162
161
  - lib/vagrant-skytap/action/update_hardware.rb
163
162
  - lib/vagrant-skytap/action/wait_for_communicator.rb
163
+ - lib/vagrant-skytap/action.rb
164
164
  - lib/vagrant-skytap/api/busyable.rb
165
165
  - lib/vagrant-skytap/api/client.rb
166
166
  - lib/vagrant-skytap/api/credentials.rb
@@ -175,6 +175,8 @@ files:
175
175
  - lib/vagrant-skytap/api/vm.rb
176
176
  - lib/vagrant-skytap/api/vpn.rb
177
177
  - lib/vagrant-skytap/api/vpn_attachment.rb
178
+ - lib/vagrant-skytap/command/start_mixins.rb
179
+ - lib/vagrant-skytap/command/up.rb
178
180
  - lib/vagrant-skytap/config.rb
179
181
  - lib/vagrant-skytap/core_ext/object/blank.rb
180
182
  - lib/vagrant-skytap/core_ext/object/tap.rb
@@ -190,9 +192,14 @@ files:
190
192
  - lib/vagrant-skytap/util/timer.rb
191
193
  - lib/vagrant-skytap/version.rb
192
194
  - lib/vagrant-skytap/vm_properties.rb
195
+ - lib/vagrant-skytap.rb
196
+ - LICENSE
193
197
  - locales/en.yml
198
+ - Rakefile
199
+ - README.md
194
200
  - spec/acceptance/base.rb
195
201
  - spec/acceptance/provider/halt_spec.rb
202
+ - spec/acceptance/provider/up_spec.rb
196
203
  - spec/acceptance/shared/context_skytap.rb
197
204
  - spec/spec_helper.rb
198
205
  - spec/support/isolated_environment.rb
@@ -219,6 +226,11 @@ files:
219
226
  - tasks/test.rake
220
227
  - vagrant-skytap.gemspec
221
228
  - vagrant-spec.config.rb
229
+ - .byebug_history
230
+ - .gitignore
231
+ - .hgignore
232
+ - .project
233
+ - .rspec
222
234
  homepage: http://www.skytap.com
223
235
  licenses:
224
236
  - MIT
@@ -229,17 +241,17 @@ require_paths:
229
241
  - lib
230
242
  required_ruby_version: !ruby/object:Gem::Requirement
231
243
  requirements:
232
- - - ">="
244
+ - - '>='
233
245
  - !ruby/object:Gem::Version
234
246
  version: '0'
235
247
  required_rubygems_version: !ruby/object:Gem::Requirement
236
248
  requirements:
237
- - - ">="
249
+ - - '>='
238
250
  - !ruby/object:Gem::Version
239
251
  version: 1.3.6
240
252
  requirements: []
241
253
  rubyforge_project: vagrant-skytap
242
- rubygems_version: 2.4.5
254
+ rubygems_version: 2.0.14
243
255
  signing_key:
244
256
  specification_version: 4
245
257
  summary: Enables Vagrant to manage Skytap machines.