vagrant-rackspace 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +5 -0
- data/CHANGELOG.md +9 -1
- data/Gemfile +1 -0
- data/README.md +12 -0
- data/lib/vagrant-rackspace/action/create_server.rb +2 -0
- data/lib/vagrant-rackspace/config.rb +45 -0
- data/lib/vagrant-rackspace/version.rb +1 -1
- data/locales/en.yml +2 -0
- data/spec/vagrant-rackspace/config_spec.rb +79 -6
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODA5MmJhZGMzMzRlYmE2NTJmMGVmMWRkNTM2Y2ZjNzA4MWRmNzZkNg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OWFkY2M1MTVlYTRhY2QyMDJkNzMyZmM1NGE3ODNjNjdjMTc4ZWYyNg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YzE1YjAwOGYwNTc1MjQxNzY0NmU5MjM1MmQzMTZjNGQ4ZTUwYjhmOGRmMzU1
|
10
|
+
NDM3OTU0NzVjZWQ0M2EzMWRjMzExZmEyYWFhZjNiMWQ3MmRiNTE5ZmMwNmZm
|
11
|
+
ZjRmOGJhNjJkOTc0YTMxYjI2MjZiNWYzNGE5N2I4M2QwNmIwMDE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTllOWVkZTNiMGQ4ZWJkMTFiM2YzNzZkMmZkNjdlZjRlNzliZjhmNTlhYjVl
|
14
|
+
N2M2YmIzYmJhNThmYzFmY2ZmZDVmMTI3ODc3MjY5MTNjYWMyODZkNjRiOGIx
|
15
|
+
YWVjYjE0NDM2N2M5Mzk2YTZmMTcwZGI0NDg3YTNlN2Y4MTM0OTQ=
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
|
-
# 0.1.
|
1
|
+
# 0.1.4 (October 15, 2013)
|
2
|
+
|
3
|
+
IMPROVEMENTS:
|
2
4
|
|
5
|
+
- Adds endpoint validation (rackspace_compute_url, rackspace_auth_url) [GH-39]
|
6
|
+
|
7
|
+
FEATURES:
|
8
|
+
- Adds ability to configure networks [GH-37]
|
9
|
+
|
10
|
+
# 0.1.3 (September 6, 2013)
|
3
11
|
|
4
12
|
IMPROVEMENTS:
|
5
13
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -125,6 +125,18 @@ supported with `vagrant-rackspace`, currently. If any of these are
|
|
125
125
|
specified, Vagrant will emit a warning, but will otherwise boot
|
126
126
|
the Rackspace server.
|
127
127
|
|
128
|
+
However, you may attach a VM to an isolated [Cloud Network](http://www.rackspace.com/knowledge_center/article/getting-started-with-cloud-networks) (or Networks) using the `network` configuration option. Here's an example which adds two Cloud Networks and disables ServiceNet with the `:attach => false` option:
|
129
|
+
|
130
|
+
```ruby
|
131
|
+
config.vm.provider :rackspace do |rs|
|
132
|
+
rs.username = "mitchellh"
|
133
|
+
rs.api_key = "foobarbaz"
|
134
|
+
rs.network '443aff42-be57-effb-ad30-c097c1e4503f'
|
135
|
+
rs.network '5e738e11-def2-4a75-ad1e-05bbe3b49efe'
|
136
|
+
rs.network :service_net, :attached => false
|
137
|
+
end
|
138
|
+
```
|
139
|
+
|
128
140
|
## Synced Folders
|
129
141
|
|
130
142
|
There is minimal support for synced folders. Upon `vagrant up`,
|
@@ -45,6 +45,7 @@ module VagrantPlugins
|
|
45
45
|
env[:ui].info(" -- Flavor: #{flavor.name}")
|
46
46
|
env[:ui].info(" -- Image: #{image.name}")
|
47
47
|
env[:ui].info(" -- Disk Config: #{config.disk_config}") if config.disk_config
|
48
|
+
env[:ui].info(" -- Networks: #{config.networks}") if config.networks
|
48
49
|
env[:ui].info(" -- Name: #{server_name}")
|
49
50
|
|
50
51
|
# Build the options for launching...
|
@@ -60,6 +61,7 @@ module VagrantPlugins
|
|
60
61
|
]
|
61
62
|
}
|
62
63
|
options[:disk_config] = config.disk_config if config.disk_config
|
64
|
+
options[:networks] = config.networks if config.networks
|
63
65
|
|
64
66
|
# Create the server
|
65
67
|
server = env[:rackspace_compute].servers.create(options)
|
@@ -81,6 +81,15 @@ module VagrantPlugins
|
|
81
81
|
# This defaults to MANUAL
|
82
82
|
attr_accessor :disk_config
|
83
83
|
|
84
|
+
# Cloud Networks to attach to the server
|
85
|
+
#
|
86
|
+
# @return [Array]
|
87
|
+
attr_accessor :networks
|
88
|
+
|
89
|
+
# Default Rackspace Cloud Network IDs
|
90
|
+
SERVICE_NET_ID = '11111111-1111-1111-1111-111111111111'
|
91
|
+
PUBLIC_NET_ID = '00000000-0000-0000-0000-000000000000'
|
92
|
+
|
84
93
|
def initialize
|
85
94
|
@api_key = UNSET_VALUE
|
86
95
|
@rackspace_region = UNSET_VALUE
|
@@ -93,6 +102,7 @@ module VagrantPlugins
|
|
93
102
|
@server_name = UNSET_VALUE
|
94
103
|
@username = UNSET_VALUE
|
95
104
|
@disk_config = UNSET_VALUE
|
105
|
+
@networks = []
|
96
106
|
end
|
97
107
|
|
98
108
|
def finalize!
|
@@ -106,6 +116,7 @@ module VagrantPlugins
|
|
106
116
|
@server_name = nil if @server_name == UNSET_VALUE
|
107
117
|
@username = nil if @username == UNSET_VALUE
|
108
118
|
@disk_config = nil if @disk_config == UNSET_VALUE
|
119
|
+
@networks = nil if @networks.empty?
|
109
120
|
|
110
121
|
if @public_key_path == UNSET_VALUE
|
111
122
|
@public_key_path = Vagrant.source_root.join("keys/vagrant.pub")
|
@@ -122,12 +133,39 @@ module VagrantPlugins
|
|
122
133
|
end
|
123
134
|
end
|
124
135
|
|
136
|
+
def network(net_id, options={})
|
137
|
+
# Eventually, this should accept options for network configuration,
|
138
|
+
# primarily the IP address, but at the time of writing these
|
139
|
+
# options are unsupported by Cloud Networks.
|
140
|
+
options = {:attached => true}.merge(options)
|
141
|
+
|
142
|
+
# Add the default Public and ServiceNet networks
|
143
|
+
if @networks.empty?
|
144
|
+
@networks = [PUBLIC_NET_ID, SERVICE_NET_ID]
|
145
|
+
end
|
146
|
+
|
147
|
+
net_id = SERVICE_NET_ID if net_id == :service_net
|
148
|
+
|
149
|
+
if options[:attached]
|
150
|
+
@networks << net_id unless @networks.include? net_id
|
151
|
+
else
|
152
|
+
@networks.delete net_id
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
125
156
|
def validate(machine)
|
126
157
|
errors = []
|
127
158
|
|
128
159
|
errors << I18n.t("vagrant_rackspace.config.api_key_required") if !@api_key
|
129
160
|
errors << I18n.t("vagrant_rackspace.config.username_required") if !@username
|
130
161
|
|
162
|
+
{
|
163
|
+
:rackspace_compute_url => @rackspace_compute_url,
|
164
|
+
:rackspace_auth_url => @rackspace_auth_url
|
165
|
+
}.each_pair do |key, value|
|
166
|
+
errors << I18n.t("vagrant_rackspace.config.invalid_uri", :key => key, :uri => value) unless value.nil? || valid_uri?(value)
|
167
|
+
end
|
168
|
+
|
131
169
|
public_key_path = File.expand_path(@public_key_path, machine.env.root_path)
|
132
170
|
if !File.file?(public_key_path)
|
133
171
|
errors << I18n.t("vagrant_rackspace.config.public_key_not_found")
|
@@ -141,6 +179,13 @@ module VagrantPlugins
|
|
141
179
|
def lon_region?
|
142
180
|
rackspace_region && rackspace_region != UNSET_VALUE && rackspace_region.to_sym == :lon
|
143
181
|
end
|
182
|
+
|
183
|
+
private
|
184
|
+
|
185
|
+
def valid_uri? value
|
186
|
+
uri = URI.parse value
|
187
|
+
uri.kind_of?(URI::HTTP)
|
188
|
+
end
|
144
189
|
end
|
145
190
|
end
|
146
191
|
end
|
data/locales/en.yml
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
if ENV['COVERAGE'] != 'false'
|
2
|
+
require 'simplecov'
|
3
|
+
require 'coveralls'
|
4
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
5
|
+
SimpleCov::Formatter::HTMLFormatter,
|
6
|
+
Coveralls::SimpleCov::Formatter
|
7
|
+
]
|
8
|
+
SimpleCov.start
|
9
|
+
end
|
10
|
+
|
1
11
|
require "vagrant-rackspace/config"
|
2
12
|
require 'fog'
|
3
13
|
|
@@ -22,6 +32,7 @@ describe VagrantPlugins::Rackspace::Config do
|
|
22
32
|
its(:server_name) { should be_nil }
|
23
33
|
its(:username) { should be_nil }
|
24
34
|
its(:disk_config) { should be_nil }
|
35
|
+
its(:networks) { should be_nil }
|
25
36
|
end
|
26
37
|
|
27
38
|
describe "overriding defaults" do
|
@@ -42,10 +53,27 @@ describe VagrantPlugins::Rackspace::Config do
|
|
42
53
|
subject.send(attribute).should == "foo"
|
43
54
|
end
|
44
55
|
end
|
56
|
+
|
57
|
+
it "should not default networks if overridden" do
|
58
|
+
net_id = "deadbeef-0000-0000-0000-000000000000"
|
59
|
+
subject.send(:network, net_id)
|
60
|
+
subject.finalize!
|
61
|
+
subject.send(:networks).should include(net_id)
|
62
|
+
subject.send(:networks).should include(VagrantPlugins::Rackspace::Config::PUBLIC_NET_ID)
|
63
|
+
subject.send(:networks).should include(VagrantPlugins::Rackspace::Config::SERVICE_NET_ID)
|
64
|
+
end
|
45
65
|
end
|
46
66
|
|
47
67
|
describe "validation" do
|
48
68
|
let(:machine) { double("machine") }
|
69
|
+
let(:validation_errors) { subject.validate(machine)['RackSpace Provider'] }
|
70
|
+
let(:error_message) { double("error message") }
|
71
|
+
|
72
|
+
before(:each) do
|
73
|
+
machine.stub_chain(:env, :root_path).and_return '/'
|
74
|
+
subject.username = 'foo'
|
75
|
+
subject.api_key = 'bar'
|
76
|
+
end
|
49
77
|
|
50
78
|
subject do
|
51
79
|
super().tap do |o|
|
@@ -54,21 +82,52 @@ describe VagrantPlugins::Rackspace::Config do
|
|
54
82
|
end
|
55
83
|
|
56
84
|
context "with good values" do
|
57
|
-
it "should validate"
|
85
|
+
it "should validate" do
|
86
|
+
validation_errors.should be_empty
|
87
|
+
end
|
58
88
|
end
|
59
89
|
|
60
90
|
context "the API key" do
|
61
|
-
it "should error if not given"
|
91
|
+
it "should error if not given" do
|
92
|
+
subject.api_key = nil
|
93
|
+
I18n.should_receive(:t).with('vagrant_rackspace.config.api_key_required').and_return error_message
|
94
|
+
validation_errors.first.should == error_message
|
95
|
+
end
|
62
96
|
end
|
63
97
|
|
64
98
|
context "the public key path" do
|
65
|
-
it "should have errors if the key doesn't exist"
|
66
|
-
|
67
|
-
|
99
|
+
it "should have errors if the key doesn't exist" do
|
100
|
+
subject.public_key_path = 'missing'
|
101
|
+
I18n.should_receive(:t).with('vagrant_rackspace.config.public_key_not_found').and_return error_message
|
102
|
+
validation_errors.first.should == error_message
|
103
|
+
end
|
104
|
+
it "should not have errors if the key exists with an absolute path" do
|
105
|
+
subject.public_key_path = File.expand_path 'locales/en.yml', Dir.pwd
|
106
|
+
validation_errors.should be_empty
|
107
|
+
end
|
108
|
+
it "should not have errors if the key exists with a relative path" do
|
109
|
+
machine.stub_chain(:env, :root_path).and_return '.'
|
110
|
+
subject.public_key_path = 'locales/en.yml'
|
111
|
+
validation_errors.should be_empty
|
112
|
+
end
|
68
113
|
end
|
69
114
|
|
70
115
|
context "the username" do
|
71
|
-
it "should error if not given"
|
116
|
+
it "should error if not given" do
|
117
|
+
subject.username = nil
|
118
|
+
I18n.should_receive(:t).with('vagrant_rackspace.config.username_required').and_return error_message
|
119
|
+
validation_errors.first.should == error_message
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
[:rackspace_compute_url, :rackspace_auth_url].each do |url|
|
124
|
+
context "the #{url}" do
|
125
|
+
it "should not validate if the URL is invalid" do
|
126
|
+
subject.send "#{url}=", 'baz'
|
127
|
+
I18n.should_receive(:t).with('vagrant_rackspace.config.invalid_uri', {:key => url, :uri => 'baz'}).and_return error_message
|
128
|
+
validation_errors.first.should == error_message
|
129
|
+
end
|
130
|
+
end
|
72
131
|
end
|
73
132
|
end
|
74
133
|
|
@@ -120,4 +179,18 @@ describe VagrantPlugins::Rackspace::Config do
|
|
120
179
|
subject.send(:lon_region?).should be_true
|
121
180
|
end
|
122
181
|
end
|
182
|
+
|
183
|
+
describe "network" do
|
184
|
+
it "should remove SERVICE_NET_ID if :service_net is detached" do
|
185
|
+
subject.send(:network, :service_net, :attached => false)
|
186
|
+
subject.send(:networks).should_not include(VagrantPlugins::Rackspace::Config::SERVICE_NET_ID)
|
187
|
+
end
|
188
|
+
|
189
|
+
it "should not allow duplicate networks" do
|
190
|
+
net_id = "deadbeef-0000-0000-0000-000000000000"
|
191
|
+
subject.send(:network, net_id)
|
192
|
+
subject.send(:network, net_id)
|
193
|
+
subject.send(:networks).count(net_id).should == 1
|
194
|
+
end
|
195
|
+
end
|
123
196
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-rackspace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mitchell Hashimoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog
|
@@ -74,6 +74,7 @@ extensions: []
|
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
76
|
- .gitignore
|
77
|
+
- .travis.yml
|
77
78
|
- CHANGELOG.md
|
78
79
|
- Gemfile
|
79
80
|
- LICENSE.txt
|