vagrant-openstack-cloud-provider 1.1.4
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 +15 -0
- data/.gitignore +23 -0
- data/.travis.yml +11 -0
- data/AUTHORS +5 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +23 -0
- data/README.md +169 -0
- data/Rakefile +21 -0
- data/dummy.box +0 -0
- data/example_box/README.md +13 -0
- data/example_box/metadata.json +3 -0
- data/lib/vagrant-openstack-cloud-provider.rb +53 -0
- data/lib/vagrant-openstack-cloud-provider/action.rb +129 -0
- data/lib/vagrant-openstack-cloud-provider/action/connect_openstack.rb +34 -0
- data/lib/vagrant-openstack-cloud-provider/action/create_server.rb +185 -0
- data/lib/vagrant-openstack-cloud-provider/action/delete_server.rb +26 -0
- data/lib/vagrant-openstack-cloud-provider/action/is_created.rb +16 -0
- data/lib/vagrant-openstack-cloud-provider/action/message_already_created.rb +16 -0
- data/lib/vagrant-openstack-cloud-provider/action/message_not_created.rb +16 -0
- data/lib/vagrant-openstack-cloud-provider/action/read_ssh_info_from_api.rb +46 -0
- data/lib/vagrant-openstack-cloud-provider/action/read_ssh_info_from_cache.rb +53 -0
- data/lib/vagrant-openstack-cloud-provider/action/read_state.rb +38 -0
- data/lib/vagrant-openstack-cloud-provider/action/sync_folders.rb +58 -0
- data/lib/vagrant-openstack-cloud-provider/config.rb +126 -0
- data/lib/vagrant-openstack-cloud-provider/errors.rb +35 -0
- data/lib/vagrant-openstack-cloud-provider/plugin.rb +37 -0
- data/lib/vagrant-openstack-cloud-provider/provider.rb +50 -0
- data/lib/vagrant-openstack-cloud-provider/version.rb +5 -0
- data/locales/en.yml +81 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/vagrant-openstack-cloud-provider/action/create_server_spec.rb +89 -0
- data/spec/vagrant-openstack-cloud-provider/action/read_ssh_info_spec.rb +122 -0
- data/spec/vagrant-openstack-cloud-provider/config_spec.rb +81 -0
- data/vagrant-openstack-cloud-provider.gemspec +25 -0
- metadata +123 -0
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'vagrant-openstack-cloud-provider/action/read_ssh_info_from_api'
|
3
|
+
|
4
|
+
describe VagrantPlugins::OpenStack::Action::ReadSSHInfoFromAPI do
|
5
|
+
describe '#call' do
|
6
|
+
it "passes proper parameters to read_ssh_info and puts them in machine_ssh_info" do
|
7
|
+
app = lambda { |only_one_parameter| }
|
8
|
+
env = {:openstack_compute => :my_compute, :machine => :my_machine}
|
9
|
+
|
10
|
+
subject = described_class.new(app, nil)
|
11
|
+
subject.should_receive(:read_ssh_info).with(:my_compute, :my_machine).and_return(:my_ssh_info)
|
12
|
+
|
13
|
+
subject.call(env)
|
14
|
+
env[:machine_ssh_info].should == :my_ssh_info
|
15
|
+
end
|
16
|
+
|
17
|
+
it "calls app.call with the right env" do
|
18
|
+
app = double()
|
19
|
+
env = {:openstack_compute => nil, :machine => nil}
|
20
|
+
app.should_receive(:call).with(env)
|
21
|
+
|
22
|
+
subject = described_class.new(app, nil)
|
23
|
+
subject.stub(:read_ssh_info)
|
24
|
+
subject.call(env)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#read_ssh_info' do
|
29
|
+
subject {
|
30
|
+
described_class.new(nil, nil)
|
31
|
+
}
|
32
|
+
|
33
|
+
let(:machine) { double }
|
34
|
+
let(:openstack) { double }
|
35
|
+
let(:servers) { double }
|
36
|
+
let(:provider_config) do
|
37
|
+
mock = double
|
38
|
+
mock.stub(:public_network_name => "public")
|
39
|
+
mock.stub(:ssh_username => "username")
|
40
|
+
mock
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should return nil if machine is nil" do
|
44
|
+
machine.stub(:id).and_return(nil)
|
45
|
+
subject.read_ssh_info(nil, machine).should == nil
|
46
|
+
end
|
47
|
+
|
48
|
+
it "assigns machine_id to nil and returns nil if openstack returns nil" do
|
49
|
+
machine.stub(:id => "anything")
|
50
|
+
machine.stub(:id=)
|
51
|
+
|
52
|
+
servers.should_receive(:get).and_return(nil)
|
53
|
+
openstack.should_receive(:servers).and_return(servers)
|
54
|
+
|
55
|
+
subject.read_ssh_info(openstack, machine).should == nil
|
56
|
+
end
|
57
|
+
|
58
|
+
it "returns nil when something bad happens while fetching address" do
|
59
|
+
provider_config.stub(:ssh_username)
|
60
|
+
machine.stub(:id => "anything")
|
61
|
+
machine.stub(:provider_config => provider_config)
|
62
|
+
|
63
|
+
invalid_openstack_server_instance = double()
|
64
|
+
invalid_openstack_server_instance.should_receive(:addresses).and_raise(StandardError)
|
65
|
+
servers.should_receive(:get).and_return(invalid_openstack_server_instance)
|
66
|
+
openstack.should_receive(:servers).and_return(servers)
|
67
|
+
|
68
|
+
result = subject.read_ssh_info(openstack, machine)
|
69
|
+
|
70
|
+
result[:port].should == 22
|
71
|
+
result[:host].should == nil
|
72
|
+
end
|
73
|
+
|
74
|
+
it "returns a proper ssh_info hash" do
|
75
|
+
provider_config.stub(:ssh_username => "root")
|
76
|
+
machine.stub(:id => "anything")
|
77
|
+
machine.stub(:provider_config => provider_config)
|
78
|
+
|
79
|
+
valid_server_addresses = {
|
80
|
+
"public" => [
|
81
|
+
{ "addr" => 'server1.example.org' },
|
82
|
+
{ "addr" => 'server2.example.org' }
|
83
|
+
]
|
84
|
+
}
|
85
|
+
|
86
|
+
openstack_server_instance = double()
|
87
|
+
openstack_server_instance.should_receive(:addresses).and_return(valid_server_addresses)
|
88
|
+
|
89
|
+
servers.should_receive(:get).and_return(openstack_server_instance)
|
90
|
+
openstack.should_receive(:servers).and_return(servers)
|
91
|
+
|
92
|
+
result = subject.read_ssh_info(openstack, machine)
|
93
|
+
|
94
|
+
result[:port].should == 22
|
95
|
+
result[:host].should == "server2.example.org"
|
96
|
+
result[:username].should == "root"
|
97
|
+
end
|
98
|
+
|
99
|
+
it "uses the public network name from the config" do
|
100
|
+
provider_config.stub(:public_network_name => "my_custom_public_network_name")
|
101
|
+
machine.stub(:id => "anything")
|
102
|
+
machine.stub(:provider_config => provider_config)
|
103
|
+
|
104
|
+
valid_server_addresses = {
|
105
|
+
"my_custom_public_network_name" => [
|
106
|
+
{ "addr" => 'server1.example.org' },
|
107
|
+
{ "addr" => 'server2.example.org' }
|
108
|
+
]
|
109
|
+
}
|
110
|
+
|
111
|
+
openstack_server_instance = double()
|
112
|
+
openstack_server_instance.should_receive(:addresses).and_return(valid_server_addresses)
|
113
|
+
|
114
|
+
servers.should_receive(:get).and_return(openstack_server_instance)
|
115
|
+
openstack.should_receive(:servers).and_return(servers)
|
116
|
+
|
117
|
+
result = subject.read_ssh_info(openstack, machine)
|
118
|
+
|
119
|
+
result[:host].should == "server2.example.org"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require "vagrant-openstack-cloud-provider/config"
|
3
|
+
|
4
|
+
describe VagrantPlugins::OpenStack::Config do
|
5
|
+
describe "defaults" do
|
6
|
+
let(:vagrant_public_key) { Vagrant.source_root.join("keys/vagrant.pub") }
|
7
|
+
|
8
|
+
subject do
|
9
|
+
super().tap do |o|
|
10
|
+
o.finalize!
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
its(:api_key) { should be_nil }
|
15
|
+
its(:endpoint) { should be_nil }
|
16
|
+
its(:region) { should be_nil }
|
17
|
+
its(:flavor) { should eq(/m1.tiny/) }
|
18
|
+
its(:image) { should eq(/cirros/) }
|
19
|
+
its(:server_name) { should be_nil }
|
20
|
+
its(:username) { should be_nil }
|
21
|
+
its(:keypair_name) { should be_nil }
|
22
|
+
its(:ssh_username) { should be_nil }
|
23
|
+
its(:user_data) { should eq("") }
|
24
|
+
its(:metadata) { should eq({}) }
|
25
|
+
its(:public_network_name) { should eq("public") }
|
26
|
+
its(:networks) { should eq(["public"]) }
|
27
|
+
its(:tenant) { should be_nil }
|
28
|
+
its(:scheduler_hints) { should eq({}) }
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "overriding defaults" do
|
32
|
+
[:api_key,
|
33
|
+
:endpoint,
|
34
|
+
:region,
|
35
|
+
:flavor,
|
36
|
+
:image,
|
37
|
+
:server_name,
|
38
|
+
:username,
|
39
|
+
:keypair_name,
|
40
|
+
:ssh_username,
|
41
|
+
:metadata,
|
42
|
+
:public_network_name,
|
43
|
+
:networks,
|
44
|
+
:tenant,
|
45
|
+
:scheduler_hints].each do |attribute|
|
46
|
+
it "should not default #{attribute} if overridden" do
|
47
|
+
subject.send("#{attribute}=", "foo")
|
48
|
+
subject.finalize!
|
49
|
+
subject.send(attribute).should == "foo"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "validation" do
|
55
|
+
let(:machine) { double("machine") }
|
56
|
+
|
57
|
+
subject do
|
58
|
+
super().tap do |o|
|
59
|
+
o.finalize!
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context "with good values" do
|
64
|
+
it "should validate"
|
65
|
+
end
|
66
|
+
|
67
|
+
context "the API key" do
|
68
|
+
it "should error if not given"
|
69
|
+
end
|
70
|
+
|
71
|
+
context "the public key path" do
|
72
|
+
it "should have errors if the key doesn't exist"
|
73
|
+
it "should not have errors if the key exists with an absolute path"
|
74
|
+
it "should not have errors if the key exists with a relative path"
|
75
|
+
end
|
76
|
+
|
77
|
+
context "the username" do
|
78
|
+
it "should error if not given"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'vagrant-openstack-cloud-provider/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "vagrant-openstack-cloud-provider"
|
8
|
+
gem.version = VagrantPlugins::OpenStack::VERSION
|
9
|
+
gem.licenses = ['MIT']
|
10
|
+
gem.authors = ["Mathieu Mitchell"]
|
11
|
+
gem.email = ["mat128@gmail.com"]
|
12
|
+
gem.description = "Vagrant provider for OpenStack clouds."
|
13
|
+
gem.summary = "Enables Vagrant to manage machines in OpenStack Cloud."
|
14
|
+
gem.homepage = "http://www.vagrantup.com"
|
15
|
+
|
16
|
+
gem.add_runtime_dependency "fog", "~> 1.22"
|
17
|
+
|
18
|
+
gem.add_development_dependency "rake"
|
19
|
+
gem.add_development_dependency "rspec", "~> 2.13.0"
|
20
|
+
|
21
|
+
gem.files = `git ls-files`.split($/)
|
22
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
23
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
24
|
+
gem.require_paths = ["lib"]
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-openstack-cloud-provider
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mathieu Mitchell
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fog
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.22'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.22'
|
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
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.13.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.13.0
|
55
|
+
description: Vagrant provider for OpenStack clouds.
|
56
|
+
email:
|
57
|
+
- mat128@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- .travis.yml
|
64
|
+
- AUTHORS
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- dummy.box
|
70
|
+
- example_box/README.md
|
71
|
+
- example_box/metadata.json
|
72
|
+
- lib/vagrant-openstack-cloud-provider.rb
|
73
|
+
- lib/vagrant-openstack-cloud-provider/action.rb
|
74
|
+
- lib/vagrant-openstack-cloud-provider/action/connect_openstack.rb
|
75
|
+
- lib/vagrant-openstack-cloud-provider/action/create_server.rb
|
76
|
+
- lib/vagrant-openstack-cloud-provider/action/delete_server.rb
|
77
|
+
- lib/vagrant-openstack-cloud-provider/action/is_created.rb
|
78
|
+
- lib/vagrant-openstack-cloud-provider/action/message_already_created.rb
|
79
|
+
- lib/vagrant-openstack-cloud-provider/action/message_not_created.rb
|
80
|
+
- lib/vagrant-openstack-cloud-provider/action/read_ssh_info_from_api.rb
|
81
|
+
- lib/vagrant-openstack-cloud-provider/action/read_ssh_info_from_cache.rb
|
82
|
+
- lib/vagrant-openstack-cloud-provider/action/read_state.rb
|
83
|
+
- lib/vagrant-openstack-cloud-provider/action/sync_folders.rb
|
84
|
+
- lib/vagrant-openstack-cloud-provider/config.rb
|
85
|
+
- lib/vagrant-openstack-cloud-provider/errors.rb
|
86
|
+
- lib/vagrant-openstack-cloud-provider/plugin.rb
|
87
|
+
- lib/vagrant-openstack-cloud-provider/provider.rb
|
88
|
+
- lib/vagrant-openstack-cloud-provider/version.rb
|
89
|
+
- locales/en.yml
|
90
|
+
- spec/spec_helper.rb
|
91
|
+
- spec/vagrant-openstack-cloud-provider/action/create_server_spec.rb
|
92
|
+
- spec/vagrant-openstack-cloud-provider/action/read_ssh_info_spec.rb
|
93
|
+
- spec/vagrant-openstack-cloud-provider/config_spec.rb
|
94
|
+
- vagrant-openstack-cloud-provider.gemspec
|
95
|
+
homepage: http://www.vagrantup.com
|
96
|
+
licenses:
|
97
|
+
- MIT
|
98
|
+
metadata: {}
|
99
|
+
post_install_message:
|
100
|
+
rdoc_options: []
|
101
|
+
require_paths:
|
102
|
+
- lib
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ! '>='
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ! '>='
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
requirements: []
|
114
|
+
rubyforge_project:
|
115
|
+
rubygems_version: 2.4.5
|
116
|
+
signing_key:
|
117
|
+
specification_version: 4
|
118
|
+
summary: Enables Vagrant to manage machines in OpenStack Cloud.
|
119
|
+
test_files:
|
120
|
+
- spec/spec_helper.rb
|
121
|
+
- spec/vagrant-openstack-cloud-provider/action/create_server_spec.rb
|
122
|
+
- spec/vagrant-openstack-cloud-provider/action/read_ssh_info_spec.rb
|
123
|
+
- spec/vagrant-openstack-cloud-provider/config_spec.rb
|