vagrant-skytap 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/vagrant-skytap/action.rb +1 -1
- data/lib/vagrant-skytap/action/set_hostname.rb +1 -1
- data/lib/vagrant-skytap/action/update_hardware.rb +1 -1
- data/lib/vagrant-skytap/api/client.rb +39 -25
- data/lib/vagrant-skytap/api/environment.rb +1 -8
- data/lib/vagrant-skytap/api/interface.rb +0 -3
- data/lib/vagrant-skytap/api/publish_set.rb +0 -4
- data/lib/vagrant-skytap/api/resource.rb +27 -1
- data/lib/vagrant-skytap/api/runstate_operations.rb +12 -6
- data/lib/vagrant-skytap/api/vm.rb +0 -11
- data/lib/vagrant-skytap/api/vpn_attachment.rb +1 -4
- data/lib/vagrant-skytap/version.rb +1 -1
- data/spec/unit/actions/update_hardware_spec.rb +1 -1
- metadata +2 -3
- data/lib/vagrant-skytap/api/busyable.rb +0 -59
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ad66d0732292fb4e3eade24cdcc614b00b18869
|
4
|
+
data.tar.gz: 193d5678f30a527277f1bd04816c41d6857a2e2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27195d6fe141492a6979a4995ea2ba7aa20f0245a4e3409786f9bb65a58b3e1620cf9ef085221a2d00d13af7bf327d1f65bcdda13e831a15440adf45e07b39d2
|
7
|
+
data.tar.gz: d05d051aaf236112118c65d4ffeef8193ce29ec2fc2e2508622a0f8014ded4718d4be620abb5bf1224a01b2ae2f71641866bec76ecb72544b4c73a1aaa436b70
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
+
# 0.3.2 (April 19, 2016)
|
2
|
+
|
3
|
+
* Retry all operations on 423 response (previously this was not happening when attaching to a VPN).
|
4
|
+
|
1
5
|
# 0.3.1 (April 15, 2016)
|
2
6
|
|
3
7
|
* Add support for running in a Skytap VM when the VM's network is using a custom DNS.
|
8
|
+
* Clean up SSH tunnels on `vagrant destroy` (port forwarding bug).
|
4
9
|
|
5
10
|
# 0.3.0 (April 13, 2016)
|
6
11
|
|
@@ -97,6 +97,7 @@ module VagrantPlugins
|
|
97
97
|
end
|
98
98
|
b1.use Call, DestroyConfirm do |env2, b2|
|
99
99
|
if env2[:result]
|
100
|
+
b2.use ClearForwardedPorts
|
100
101
|
case existence_state
|
101
102
|
when :one_of_many_vms
|
102
103
|
b2.use DeleteVm
|
@@ -109,7 +110,6 @@ module VagrantPlugins
|
|
109
110
|
end
|
110
111
|
end
|
111
112
|
end
|
112
|
-
b.use ClearForwardedPorts
|
113
113
|
b.use PrepareNFSValidIds
|
114
114
|
b.use SyncedFolderCleanup
|
115
115
|
end
|
@@ -22,6 +22,7 @@
|
|
22
22
|
|
23
23
|
require 'base64'
|
24
24
|
require "vagrant-skytap/version"
|
25
|
+
require 'timeout'
|
25
26
|
|
26
27
|
module VagrantPlugins
|
27
28
|
module Skytap
|
@@ -29,8 +30,9 @@ module VagrantPlugins
|
|
29
30
|
class Client
|
30
31
|
attr_reader :config, :http
|
31
32
|
|
33
|
+
DEFAULT_TIMEOUT = 120
|
32
34
|
MAX_RATE_LIMIT_RETRIES = 3
|
33
|
-
DEFAULT_RETRY_AFTER_SECONDS =
|
35
|
+
DEFAULT_RETRY_AFTER_SECONDS = 5
|
34
36
|
|
35
37
|
def initialize(config)
|
36
38
|
@logger = Log4r::Logger.new("vagrant_skytap::api_client")
|
@@ -83,35 +85,47 @@ module VagrantPlugins
|
|
83
85
|
end
|
84
86
|
|
85
87
|
headers = default_headers.merge(options[:extra_headers] || {})
|
86
|
-
tries = 0
|
87
88
|
retry_after = DEFAULT_RETRY_AFTER_SECONDS
|
89
|
+
most_recent_exception = nil
|
90
|
+
|
88
91
|
begin
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
92
|
+
Timeout.timeout(options[:timeout] || DEFAULT_TIMEOUT) do
|
93
|
+
begin
|
94
|
+
http.send_request(method, URI.encode(path), body, headers).tap do |ret|
|
95
|
+
@logger.debug("REST API response: #{ret.body}")
|
96
|
+
unless ret.code =~ /^2\d\d/
|
97
|
+
raise Errors::DoesNotExist, object_name: "Object '#{path}'" if ret.code == '404'
|
98
|
+
error_class = case ret.code
|
99
|
+
when '403'
|
100
|
+
Errors::Unauthorized
|
101
|
+
when '422'
|
102
|
+
Errors::UnprocessableEntity
|
103
|
+
when '423'
|
104
|
+
Errors::ResourceBusy
|
105
|
+
when '429'
|
106
|
+
retry_after = ret['Retry-After'] || DEFAULT_RETRY_AFTER_SECONDS
|
107
|
+
Errors::RateLimited
|
108
|
+
else
|
109
|
+
Errors::OperationFailed
|
110
|
+
end
|
111
|
+
raise error_class, err: error_string_from_body(ret)
|
112
|
+
end
|
106
113
|
end
|
107
|
-
|
114
|
+
rescue Errors::RateLimited => ex
|
115
|
+
most_recent_exception = ex
|
116
|
+
@logger.info("Rate limited, wil retry in #{retry_after} seconds")
|
117
|
+
sleep retry_after.to_f + 0.1
|
118
|
+
retry
|
119
|
+
rescue Errors::ResourceBusy => ex
|
120
|
+
most_recent_exception = ex
|
121
|
+
@logger.debug("Resource busy, retrying")
|
122
|
+
sleep DEFAULT_RETRY_AFTER_SECONDS
|
123
|
+
retry
|
108
124
|
end
|
109
125
|
end
|
110
|
-
rescue
|
111
|
-
raise if
|
112
|
-
|
113
|
-
sleep retry_after.to_f + 0.1
|
114
|
-
retry
|
126
|
+
rescue Timeout::Error => ex
|
127
|
+
raise most_recent_exception if most_recent_exception
|
128
|
+
raise Errors::OperationFailed, "Timeout exceeded"
|
115
129
|
end
|
116
130
|
end
|
117
131
|
|
@@ -144,13 +144,6 @@ module VagrantPlugins
|
|
144
144
|
set_runstate :running, vm_ids: vm_ids
|
145
145
|
end
|
146
146
|
|
147
|
-
def delete
|
148
|
-
retry_while_resource_busy do
|
149
|
-
api_client.delete(url)
|
150
|
-
break
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
147
|
# Makes the REST call to add VMs to this environment, using
|
155
148
|
# the provided VMs as sources.
|
156
149
|
#
|
@@ -169,7 +162,7 @@ module VagrantPlugins
|
|
169
162
|
end
|
170
163
|
|
171
164
|
existing_vm_ids = self.vms.collect(&:id)
|
172
|
-
|
165
|
+
update(args)
|
173
166
|
get_vms_by_id(self.vms.collect(&:id) - existing_vm_ids)
|
174
167
|
end
|
175
168
|
|
@@ -23,14 +23,11 @@
|
|
23
23
|
require 'vagrant-skytap/api/resource'
|
24
24
|
require 'vagrant-skytap/api/public_ip'
|
25
25
|
require 'vagrant-skytap/api/published_service'
|
26
|
-
require_relative 'busyable'
|
27
26
|
|
28
27
|
module VagrantPlugins
|
29
28
|
module Skytap
|
30
29
|
module API
|
31
30
|
class Interface < Resource
|
32
|
-
include Busyable
|
33
|
-
|
34
31
|
attr_reader :vm
|
35
32
|
|
36
33
|
reads :id, :ip, :nat_addresses, :network_id, :public_ips, :services
|
@@ -33,12 +33,19 @@ module VagrantPlugins
|
|
33
33
|
attr_reader :attrs, :env
|
34
34
|
|
35
35
|
class << self
|
36
|
+
# Last segment of the class name (without the namespace).
|
37
|
+
#
|
38
|
+
# @return [String]
|
39
|
+
def short_name
|
40
|
+
name.split("::").last
|
41
|
+
end
|
42
|
+
|
36
43
|
# Resource name suitable for use in URLs. This should be overridden
|
37
44
|
# for classes with camel-cased names (e.g., VpnAttachment).
|
38
45
|
#
|
39
46
|
# @return [String]
|
40
47
|
def rest_name
|
41
|
-
|
48
|
+
short_name.downcase
|
42
49
|
end
|
43
50
|
end
|
44
51
|
|
@@ -73,6 +80,25 @@ module VagrantPlugins
|
|
73
80
|
self
|
74
81
|
end
|
75
82
|
|
83
|
+
# Sets attributes on the Skytap model, then refreshes this resource
|
84
|
+
# from the response.
|
85
|
+
#
|
86
|
+
# @param [Hash] attrs The attributes to update on the resource.
|
87
|
+
# @param [String] path The path to this resource, if different from
|
88
|
+
# the default.
|
89
|
+
# @return [API::Resource]
|
90
|
+
def update(attrs, path=nil)
|
91
|
+
resp = api_client.put(path || url, JSON.dump(attrs))
|
92
|
+
refresh(JSON.load(resp.body))
|
93
|
+
end
|
94
|
+
|
95
|
+
# Remove this resource from Skytap.
|
96
|
+
#
|
97
|
+
# @return [NilClass]
|
98
|
+
def delete
|
99
|
+
api_client.delete(url)
|
100
|
+
end
|
101
|
+
|
76
102
|
private
|
77
103
|
|
78
104
|
# Return a reference to the API client which was passed in when
|
@@ -21,13 +21,12 @@
|
|
21
21
|
# DEALINGS IN THE SOFTWARE.
|
22
22
|
|
23
23
|
require 'timeout'
|
24
|
-
require_relative 'busyable'
|
25
24
|
|
26
25
|
module VagrantPlugins
|
27
26
|
module Skytap
|
28
27
|
module API
|
29
28
|
module RunstateOperations
|
30
|
-
|
29
|
+
RUNSTATE_RETRY = 5
|
31
30
|
|
32
31
|
def run!
|
33
32
|
set_runstate :running
|
@@ -51,7 +50,7 @@ module VagrantPlugins
|
|
51
50
|
params = {runstate: new_runstate}.tap do |ret|
|
52
51
|
ret[:multiselect] = opts[:vm_ids] if opts[:vm_ids]
|
53
52
|
end
|
54
|
-
|
53
|
+
update(params)
|
55
54
|
|
56
55
|
wait_for_runstate(completed_runstate) unless runstate == completed_runstate
|
57
56
|
end
|
@@ -62,10 +61,17 @@ module VagrantPlugins
|
|
62
61
|
|
63
62
|
def wait_for_runstate(expected_runstate)
|
64
63
|
expected_runstate = expected_runstate.to_s
|
65
|
-
|
66
|
-
|
67
|
-
|
64
|
+
begin
|
65
|
+
Timeout.timeout(provider_config.instance_ready_timeout) do
|
66
|
+
loop do
|
67
|
+
unless reload.busy?
|
68
|
+
break if runstate == expected_runstate || expected_runstate == 'ready'
|
69
|
+
end
|
70
|
+
sleep RUNSTATE_RETRY
|
71
|
+
end
|
68
72
|
end
|
73
|
+
rescue Timeout::Error => ex
|
74
|
+
raise Errors::InstanceReadyTimeout, timeout: provider_config.instance_ready_timeout
|
69
75
|
end
|
70
76
|
end
|
71
77
|
|
@@ -105,17 +105,6 @@ module VagrantPlugins
|
|
105
105
|
def region
|
106
106
|
@region ||= parent.region
|
107
107
|
end
|
108
|
-
|
109
|
-
def delete
|
110
|
-
begin
|
111
|
-
retry_while_resource_busy do
|
112
|
-
api_client.delete(url)
|
113
|
-
break
|
114
|
-
end
|
115
|
-
rescue Errors::OperationFailed => ex
|
116
|
-
raise Errors::OperationFailed, err: 'Failed to delete VM'
|
117
|
-
end
|
118
|
-
end
|
119
108
|
end
|
120
109
|
end
|
121
110
|
end
|
@@ -21,14 +21,11 @@
|
|
21
21
|
# DEALINGS IN THE SOFTWARE.
|
22
22
|
|
23
23
|
require 'vagrant-skytap/api/resource'
|
24
|
-
require_relative 'busyable'
|
25
24
|
|
26
25
|
module VagrantPlugins
|
27
26
|
module Skytap
|
28
27
|
module API
|
29
28
|
class VpnAttachment < Resource
|
30
|
-
include Busyable
|
31
|
-
|
32
29
|
attr_reader :network
|
33
30
|
|
34
31
|
reads :connected, :network, :vpn
|
@@ -65,7 +62,7 @@ module VagrantPlugins
|
|
65
62
|
end
|
66
63
|
|
67
64
|
def connect!
|
68
|
-
|
65
|
+
update(connected: true)
|
69
66
|
raise Errors::VpnConnectionFailed unless connected?
|
70
67
|
end
|
71
68
|
|
@@ -39,7 +39,7 @@ describe VagrantPlugins::Skytap::Action::UpdateHardware do
|
|
39
39
|
describe "#call" do
|
40
40
|
it "filters out unchanged hardware properties" do
|
41
41
|
allow(subject).to receive(:current_vm).and_return(vm)
|
42
|
-
expect(vm).to receive(:
|
42
|
+
expect(vm).to receive(:update).with(hardware: {cpus: 4, cpus_per_socket: 2, guestOS: "linux"})
|
43
43
|
subject.call(env)
|
44
44
|
end
|
45
45
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-skytap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric True
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-04-
|
12
|
+
date: 2016-04-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json_pure
|
@@ -167,7 +167,6 @@ files:
|
|
167
167
|
- lib/vagrant-skytap/action/update_hardware.rb
|
168
168
|
- lib/vagrant-skytap/action/wait_for_communicator.rb
|
169
169
|
- lib/vagrant-skytap/action.rb
|
170
|
-
- lib/vagrant-skytap/api/busyable.rb
|
171
170
|
- lib/vagrant-skytap/api/client.rb
|
172
171
|
- lib/vagrant-skytap/api/connectable.rb
|
173
172
|
- lib/vagrant-skytap/api/credentials.rb
|
@@ -1,59 +0,0 @@
|
|
1
|
-
# Copyright (c) 2014-2016 Skytap, Inc.
|
2
|
-
#
|
3
|
-
# The MIT License (MIT)
|
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
|
20
|
-
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
21
|
-
# DEALINGS IN THE SOFTWARE.
|
22
|
-
|
23
|
-
require 'timeout'
|
24
|
-
|
25
|
-
module VagrantPlugins
|
26
|
-
module Skytap
|
27
|
-
module API
|
28
|
-
module Busyable
|
29
|
-
WAIT_TIMEOUT = 300
|
30
|
-
WAIT_ITERATION_PERIOD = 2
|
31
|
-
|
32
|
-
def update_with_retry(attrs, path=nil)
|
33
|
-
retry_while_resource_busy do
|
34
|
-
resp = api_client.put(path || url, JSON.dump(attrs))
|
35
|
-
refresh(JSON.load(resp.body))
|
36
|
-
break
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def retry_while_resource_busy(timeout=WAIT_TIMEOUT, &block)
|
41
|
-
begin
|
42
|
-
Timeout.timeout(timeout) do
|
43
|
-
loop do
|
44
|
-
break if env[:interrupted]
|
45
|
-
begin
|
46
|
-
yield
|
47
|
-
rescue Errors::ResourceBusy
|
48
|
-
end
|
49
|
-
sleep WAIT_ITERATION_PERIOD
|
50
|
-
end
|
51
|
-
end
|
52
|
-
rescue Timeout::Error => ex
|
53
|
-
raise Errors::InstanceReadyTimeout, timeout: timeout
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|