vagrant-skytap 0.2.8 → 0.2.9
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/vagrant-skytap/action/prepare_nfs_settings.rb +18 -4
- data/lib/vagrant-skytap/action.rb +22 -3
- data/lib/vagrant-skytap/api/client.rb +6 -1
- data/lib/vagrant-skytap/version.rb +1 -1
- data/locales/en.yml +13 -1
- data/spec/unit/actions/prepare_nfs_settings_spec.rb +106 -0
- data/spec/unit/api_client_spec.rb +44 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92ab283292efba6720a6ae941f353a1810e9b9e2
|
4
|
+
data.tar.gz: f4ad9c240aa4a0f6ad2029a9e1db5864b4cd19df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc829f8e0f1b6124da4f00ffc4a5d18b4d3e0a4cad4e0247b4103e76f073129fdd7e4c0515a663b2a45735993397854f4f801193d255518210c4460406b81870
|
7
|
+
data.tar.gz: c7b1d5cc0400d3076c7a03bd78b9e9a4486085917a609edc0c321356355b5d2e99309227f3327ccdf615fa612b46fc27ddaecbc63e6e6c13e2a84b68d165a1a2
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# 0.2.9 (February 26, 2016)
|
2
|
+
|
3
|
+
* Re-add User-Agent string.
|
4
|
+
* Set NFS host/guest IP addresses for synced folders of unspecified type
|
5
|
+
(Vagrant can choose NFS as the default type, which resulted in an
|
6
|
+
error).
|
7
|
+
* Don't allow suspending stopped VMs. Don't allow halting suspended VMs
|
8
|
+
without the --force flag.
|
9
|
+
|
1
10
|
# 0.2.8 (February 24, 2016)
|
2
11
|
|
3
12
|
* Revert change to User-Agent string, which contained a bug.
|
@@ -43,14 +43,25 @@ module VagrantPlugins
|
|
43
43
|
@app.call(env)
|
44
44
|
end
|
45
45
|
|
46
|
+
# Determine whether there are enabled synced folders defined
|
47
|
+
# for this machine which are either of type :nfs, or of the
|
48
|
+
# default type (Vagrant may choose NFS as the default).
|
49
|
+
# https://github.com/mitchellh/vagrant/issues/4192
|
50
|
+
#
|
51
|
+
# @return [Boolean]
|
46
52
|
def using_nfs?
|
47
|
-
|
48
|
-
|
53
|
+
machine.config.vm.synced_folders.any? do |_, opts|
|
54
|
+
(opts[:type] == :nfs || opts[:type].blank?) unless opts[:disabled]
|
55
|
+
end.tap do |ret|
|
56
|
+
@logger.debug("PrepareNFSSettings#using_nfs? returning #{ret}. "\
|
57
|
+
"Synced folders: #{machine.config.vm.synced_folders.inspect}")
|
49
58
|
end
|
50
59
|
end
|
51
60
|
|
52
|
-
# Returns the IP address of the host, preferring one on an interface
|
53
|
-
# the client can route to.
|
61
|
+
# Returns the IP address of the host, preferring one on an interface
|
62
|
+
# which the client can route to.
|
63
|
+
#
|
64
|
+
# @return [String]
|
54
65
|
def read_host_ip
|
55
66
|
UDPSocket.open do |s|
|
56
67
|
s.connect(machine.ssh_info[:host], 1)
|
@@ -60,6 +71,9 @@ module VagrantPlugins
|
|
60
71
|
end
|
61
72
|
end
|
62
73
|
|
74
|
+
# Returns the IP address of the guest VM.
|
75
|
+
#
|
76
|
+
# @return [String]
|
63
77
|
def read_machine_ip
|
64
78
|
machine.ssh_info[:host]
|
65
79
|
end
|
@@ -38,7 +38,20 @@ module VagrantPlugins
|
|
38
38
|
b1.use MessageNotCreated
|
39
39
|
else
|
40
40
|
b1.use ClearForwardedPorts
|
41
|
-
|
41
|
+
# May not halt suspended machines without --force flag
|
42
|
+
b1.use Call, IsSuspended do |env2, b2|
|
43
|
+
if env2[:result]
|
44
|
+
b2.use Call, IsEnvSet, :force_halt do |env3, b3|
|
45
|
+
if env3[:result]
|
46
|
+
b3.use StopVm
|
47
|
+
else
|
48
|
+
b3.use Message, I18n.t("vagrant_skytap.commands.halt.not_allowed_if_suspended")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
else
|
52
|
+
b2.use StopVm
|
53
|
+
end
|
54
|
+
end
|
42
55
|
end
|
43
56
|
end
|
44
57
|
end
|
@@ -53,8 +66,14 @@ module VagrantPlugins
|
|
53
66
|
when :missing_environment, :missing_vm, :no_vms
|
54
67
|
b1.use MessageNotCreated
|
55
68
|
else
|
56
|
-
b1.use
|
57
|
-
|
69
|
+
b1.use Call, IsRunning do |env2, b2|
|
70
|
+
if env2[:result]
|
71
|
+
b2.use ClearForwardedPorts
|
72
|
+
b2.use SuspendVm
|
73
|
+
else
|
74
|
+
b2.use Message, I18n.t("vagrant_skytap.commands.suspend.only_allowed_if_running")
|
75
|
+
end
|
76
|
+
end
|
58
77
|
end
|
59
78
|
end
|
60
79
|
end
|
@@ -21,6 +21,7 @@
|
|
21
21
|
# DEALINGS IN THE SOFTWARE.
|
22
22
|
|
23
23
|
require 'base64'
|
24
|
+
require "vagrant-skytap/version"
|
24
25
|
|
25
26
|
module VagrantPlugins
|
26
27
|
module Skytap
|
@@ -129,12 +130,16 @@ module VagrantPlugins
|
|
129
130
|
|
130
131
|
private
|
131
132
|
|
133
|
+
def user_agent_string
|
134
|
+
"Vagrant-Skytap/#{VagrantPlugins::Skytap::VERSION} Vagrant/#{Vagrant::VERSION}"
|
135
|
+
end
|
132
136
|
|
133
137
|
def default_headers
|
134
138
|
{
|
135
139
|
'Authorization' => auth_header,
|
136
140
|
'Content-Type' => 'application/json',
|
137
|
-
'Accept' => 'application/json'
|
141
|
+
'Accept' => 'application/json',
|
142
|
+
'User-Agent' => user_agent_string,
|
138
143
|
}
|
139
144
|
end
|
140
145
|
|
data/locales/en.yml
CHANGED
@@ -171,4 +171,16 @@ en:
|
|
171
171
|
created through the Skytap UI) have been deleted. Users cannot
|
172
172
|
manage these VMs, or access them through SmartClient, unless they
|
173
173
|
have a Skytap user account with appropriate permissions.
|
174
|
-
|
174
|
+
halt:
|
175
|
+
not_allowed_if_suspended: |-
|
176
|
+
Suspended machines cannot be halted gracefully. Run `vagrant up`
|
177
|
+
or `vagrant resume` to run the machine before halting. Alternately,
|
178
|
+
you may power off the machine with `vagrant halt --force`, but
|
179
|
+
data corruption may occur.
|
180
|
+
suspend:
|
181
|
+
only_allowed_if_running: |-
|
182
|
+
Only running machines may be suspended. Run `vagrant up` before
|
183
|
+
suspending this machine.
|
184
|
+
resume:
|
185
|
+
only_allowed_if_suspended: |-
|
186
|
+
Only suspended machines may be resumed.
|
@@ -0,0 +1,106 @@
|
|
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 File.expand_path("../../base", __FILE__)
|
24
|
+
require "vagrant-skytap/action/prepare_nfs_settings"
|
25
|
+
|
26
|
+
describe VagrantPlugins::Skytap::Action::PrepareNFSSettings do
|
27
|
+
include_context "skytap"
|
28
|
+
|
29
|
+
let(:app) { lambda { |env| } }
|
30
|
+
let(:env) { { machine: machine} }
|
31
|
+
|
32
|
+
let(:machine) { double(:machine, config: config, provider_config: provider_config, ssh_info: {host: guest_ip}) }
|
33
|
+
let(:config) { double(:config, vm: vm_config) }
|
34
|
+
let(:vm_config) { double(:vm_config, synced_folders: synced_folders) }
|
35
|
+
let(:provider_config) { double(:provider_config) }
|
36
|
+
let(:host_ip) { '10.0.0.1' }
|
37
|
+
let(:guest_ip) { '192.168.0.1' }
|
38
|
+
let(:using_nfs) { false }
|
39
|
+
|
40
|
+
let(:default_folder_props) do
|
41
|
+
{guestpath: "/vagrant", hostpath: ".", disabled: false}
|
42
|
+
end
|
43
|
+
let(:synced_folders) { { "/vagrant" => default_folder_props } }
|
44
|
+
|
45
|
+
let(:instance) { described_class.new(app, env) }
|
46
|
+
|
47
|
+
before do
|
48
|
+
allow(instance).to receive(:machine).and_return(machine)
|
49
|
+
allow(subject).to receive(:using_nfs?).and_return(using_nfs)
|
50
|
+
allow(subject).to receive(:read_host_ip).and_return(host_ip)
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "#call" do
|
54
|
+
subject {instance}
|
55
|
+
|
56
|
+
context "when not using nfs" do
|
57
|
+
it "does not set the host and guest ip addresses" do
|
58
|
+
expect(app).to receive(:call).with(env)
|
59
|
+
subject.call(env)
|
60
|
+
expect(env[:nfs_host_ip]).to be nil
|
61
|
+
expect(env[:nfs_machine_ip]).to be nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context "when using nfs" do
|
66
|
+
let(:using_nfs) { true }
|
67
|
+
it "sets the host and guest ip addresses" do
|
68
|
+
expect(app).to receive(:call).with(env)
|
69
|
+
subject.call(env)
|
70
|
+
expect(env[:nfs_host_ip]).to eq host_ip
|
71
|
+
expect(env[:nfs_machine_ip]).to eq guest_ip
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "using_nfs?" do
|
77
|
+
subject {instance.using_nfs?}
|
78
|
+
|
79
|
+
context "when there is only the default folder" do
|
80
|
+
context "when its type is unset" do
|
81
|
+
it {should be true }
|
82
|
+
end
|
83
|
+
|
84
|
+
context "when its type is rsync" do
|
85
|
+
let(:default_folder_props) do
|
86
|
+
{guestpath: "/vagrant", hostpath: ".", disabled: false, type: :rsync}
|
87
|
+
end
|
88
|
+
it {should be false }
|
89
|
+
end
|
90
|
+
|
91
|
+
context "when its type is nfs" do
|
92
|
+
let(:default_folder_props) do
|
93
|
+
{guestpath: "/vagrant", hostpath: ".", disabled: false, type: :nfs}
|
94
|
+
end
|
95
|
+
it {should be true }
|
96
|
+
|
97
|
+
context "when it is disabled" do
|
98
|
+
let(:default_folder_props) do
|
99
|
+
{guestpath: "/vagrant", hostpath: ".", disabled: true, type: :nfs}
|
100
|
+
end
|
101
|
+
it {should be false }
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,44 @@
|
|
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_relative 'base'
|
24
|
+
require "vagrant-skytap/api/client"
|
25
|
+
|
26
|
+
describe VagrantPlugins::Skytap::API::Client do
|
27
|
+
include_context "rest_api"
|
28
|
+
|
29
|
+
let(:provider_config) do
|
30
|
+
double(:provider_config, vm_url: "/vms/1", username: "jsmith", api_token: "123123", base_url: base_url)
|
31
|
+
end
|
32
|
+
let(:instance) { described_class.new(provider_config) }
|
33
|
+
|
34
|
+
before :each do
|
35
|
+
stub_request(:get, /.*/).to_return(body: "{}", status: 200)
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "user_agent_string" do
|
39
|
+
subject do
|
40
|
+
instance.send(:user_agent_string)
|
41
|
+
end
|
42
|
+
it {should match %r{^Vagrant-Skytap/.* Vagrant/.*}}
|
43
|
+
end
|
44
|
+
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.2.
|
4
|
+
version: 0.2.9
|
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-02-
|
12
|
+
date: 2016-02-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json_pure
|
@@ -213,7 +213,9 @@ files:
|
|
213
213
|
- README.md
|
214
214
|
- spec/spec_helper.rb
|
215
215
|
- spec/unit/actions/compose_environment_spec.rb
|
216
|
+
- spec/unit/actions/prepare_nfs_settings_spec.rb
|
216
217
|
- spec/unit/actions/update_hardware_spec.rb
|
218
|
+
- spec/unit/api_client_spec.rb
|
217
219
|
- spec/unit/base.rb
|
218
220
|
- spec/unit/config_spec.rb
|
219
221
|
- spec/unit/credentials_spec.rb
|