vagrant-openstack-plugin 0.1.2 → 0.1.3
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.
- data/lib/vagrant-openstack-plugin.rb +1 -1
- data/lib/vagrant-openstack-plugin/action/connect_openstack.rb +9 -0
- data/lib/vagrant-openstack-plugin/action/create_server.rb +7 -0
- data/lib/vagrant-openstack-plugin/action/read_ssh_info.rb +5 -1
- data/lib/vagrant-openstack-plugin/action/sync_folders.rb +2 -1
- data/lib/vagrant-openstack-plugin/config.rb +15 -0
- data/lib/vagrant-openstack-plugin/version.rb +1 -1
- data/locales/en.yml +2 -0
- data/spec/vagrant-openstack-plugin/config_spec.rb +2 -0
- data/vagrant-openstack-plugin.gemspec +1 -1
- metadata +5 -5
|
@@ -4,7 +4,7 @@ require "vagrant-openstack-plugin/plugin"
|
|
|
4
4
|
|
|
5
5
|
module VagrantPlugins
|
|
6
6
|
module OpenStack
|
|
7
|
-
lib_path = Pathname.new(File.expand_path("../vagrant-openstack", __FILE__))
|
|
7
|
+
lib_path = Pathname.new(File.expand_path("../vagrant-openstack-plugin", __FILE__))
|
|
8
8
|
autoload :Errors, lib_path.join("errors")
|
|
9
9
|
|
|
10
10
|
# This initializes the i18n load path so that the plugin-specific
|
|
@@ -28,6 +28,15 @@ module VagrantPlugins
|
|
|
28
28
|
:openstack_auth_url => endpoint
|
|
29
29
|
})
|
|
30
30
|
|
|
31
|
+
if config.network
|
|
32
|
+
env[:openstack_network] = Fog::Network.new({
|
|
33
|
+
:provider => :openstack,
|
|
34
|
+
:openstack_username => username,
|
|
35
|
+
:openstack_api_key => api_key,
|
|
36
|
+
:openstack_auth_url => endpoint
|
|
37
|
+
})
|
|
38
|
+
end
|
|
39
|
+
|
|
31
40
|
@app.call(env)
|
|
32
41
|
end
|
|
33
42
|
end
|
|
@@ -44,8 +44,15 @@ module VagrantPlugins
|
|
|
44
44
|
:image_ref => image.id,
|
|
45
45
|
:name => server_name,
|
|
46
46
|
:key_name => config.keypair_name,
|
|
47
|
+
:metadata => config.metadata,
|
|
47
48
|
:user_data_encoded => Base64.encode64(config.user_data)
|
|
48
49
|
}
|
|
50
|
+
|
|
51
|
+
# Find a network if provided
|
|
52
|
+
if config.network
|
|
53
|
+
network = find_matching(env[:openstack_network].networks, config.network)
|
|
54
|
+
options[:nics] = [{"net_id" => network.id}] if network
|
|
55
|
+
end
|
|
49
56
|
|
|
50
57
|
# Create the server
|
|
51
58
|
server = env[:openstack_compute].servers.create(options)
|
|
@@ -31,7 +31,11 @@ module VagrantPlugins
|
|
|
31
31
|
|
|
32
32
|
config = machine.provider_config
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
if config.network
|
|
35
|
+
host = server.addresses[config.network].last['addr'] rescue nil
|
|
36
|
+
else
|
|
37
|
+
host = server.addresses['public'].last['addr'] rescue nil
|
|
38
|
+
end
|
|
35
39
|
# Read the DNS info
|
|
36
40
|
return {
|
|
37
41
|
# Usually there should only be one public IP
|
|
@@ -38,7 +38,8 @@ module VagrantPlugins
|
|
|
38
38
|
# Rsync over to the guest path using the SSH info
|
|
39
39
|
command = [
|
|
40
40
|
"rsync", "--verbose", "--archive", "-z",
|
|
41
|
-
"
|
|
41
|
+
"--exclude", ".vagrant/",
|
|
42
|
+
"-e", "ssh -p #{ssh_info[:port]} -o StrictHostKeyChecking=no -i '#{ssh_info[:private_key_path]}'",
|
|
42
43
|
hostpath,
|
|
43
44
|
"#{ssh_info[:username]}@#{ssh_info[:host]}:#{guestpath}"]
|
|
44
45
|
|
|
@@ -36,6 +36,11 @@ module VagrantPlugins
|
|
|
36
36
|
#
|
|
37
37
|
# @return [String]
|
|
38
38
|
attr_accessor :keypair_name
|
|
39
|
+
|
|
40
|
+
# Network configurations for the instance
|
|
41
|
+
#
|
|
42
|
+
# @return [String]
|
|
43
|
+
attr_accessor :network
|
|
39
44
|
|
|
40
45
|
# The SSH username to use with this OpenStack instance. This overrides
|
|
41
46
|
# the `config.ssh.username` variable.
|
|
@@ -43,6 +48,11 @@ module VagrantPlugins
|
|
|
43
48
|
# @return [String]
|
|
44
49
|
attr_accessor :ssh_username
|
|
45
50
|
|
|
51
|
+
# A Hash of metadata that will be sent to the instance for configuration
|
|
52
|
+
#
|
|
53
|
+
# @return [Hash]
|
|
54
|
+
attr_accessor :metadata
|
|
55
|
+
|
|
46
56
|
# User data to be sent to the newly created OpenStack instance. Use this
|
|
47
57
|
# e.g. to inject a script at boot time.
|
|
48
58
|
#
|
|
@@ -55,8 +65,10 @@ module VagrantPlugins
|
|
|
55
65
|
@flavor = UNSET_VALUE
|
|
56
66
|
@image = UNSET_VALUE
|
|
57
67
|
@server_name = UNSET_VALUE
|
|
68
|
+
@metatdata = UNSET_VALUE
|
|
58
69
|
@username = UNSET_VALUE
|
|
59
70
|
@keypair_name = UNSET_VALUE
|
|
71
|
+
@network = UNSET_VALUE
|
|
60
72
|
@ssh_username = UNSET_VALUE
|
|
61
73
|
@user_data = UNSET_VALUE
|
|
62
74
|
end
|
|
@@ -67,7 +79,9 @@ module VagrantPlugins
|
|
|
67
79
|
@flavor = /m1.tiny/ if @flavor == UNSET_VALUE
|
|
68
80
|
@image = /cirros/ if @image == UNSET_VALUE
|
|
69
81
|
@server_name = nil if @server_name == UNSET_VALUE
|
|
82
|
+
@metadata = {} if @metadata == UNSET_VALUE
|
|
70
83
|
@username = nil if @username == UNSET_VALUE
|
|
84
|
+
@network = nil if @network == UNSET_VALUE
|
|
71
85
|
|
|
72
86
|
# Keypair defaults to nil
|
|
73
87
|
@keypair_name = nil if @keypair_name == UNSET_VALUE
|
|
@@ -84,6 +98,7 @@ module VagrantPlugins
|
|
|
84
98
|
|
|
85
99
|
errors << I18n.t("vagrant_openstack.config.api_key_required") if !@api_key
|
|
86
100
|
errors << I18n.t("vagrant_openstack.config.username_required") if !@username
|
|
101
|
+
errors << I18n.t("vagrant_openstack.config.metadata_must_be_hash") if !@metadata.is_a?(Hash)
|
|
87
102
|
|
|
88
103
|
{ "OpenStack Provider" => errors }
|
|
89
104
|
end
|
data/locales/en.yml
CHANGED
|
@@ -18,6 +18,7 @@ describe VagrantPlugins::OpenStack::Config do
|
|
|
18
18
|
its(:username) { should be_nil }
|
|
19
19
|
its(:keypair_name) { should be_nil }
|
|
20
20
|
its(:ssh_username) { should be_nil }
|
|
21
|
+
its(:network) { should be_nil }
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
describe "overriding defaults" do
|
|
@@ -28,6 +29,7 @@ describe VagrantPlugins::OpenStack::Config do
|
|
|
28
29
|
:server_name,
|
|
29
30
|
:username,
|
|
30
31
|
:keypair_name,
|
|
32
|
+
:network,
|
|
31
33
|
:ssh_username].each do |attribute|
|
|
32
34
|
it "should not default #{attribute} if overridden" do
|
|
33
35
|
subject.send("#{attribute}=".to_sym, "foo")
|
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
|
|
|
12
12
|
gem.summary = "Enables Vagrant to manage machines in OpenStack Cloud."
|
|
13
13
|
gem.homepage = "http://www.vagrantup.com"
|
|
14
14
|
|
|
15
|
-
gem.add_runtime_dependency "fog"
|
|
15
|
+
gem.add_runtime_dependency "fog", ">= 1.10.1"
|
|
16
16
|
|
|
17
17
|
gem.add_development_dependency "rake"
|
|
18
18
|
gem.add_development_dependency "rspec", "~> 2.13.0"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vagrant-openstack-plugin
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -19,7 +19,7 @@ dependencies:
|
|
|
19
19
|
requirements:
|
|
20
20
|
- - ! '>='
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
|
-
version:
|
|
22
|
+
version: 1.10.1
|
|
23
23
|
type: :runtime
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -27,7 +27,7 @@ dependencies:
|
|
|
27
27
|
requirements:
|
|
28
28
|
- - ! '>='
|
|
29
29
|
- !ruby/object:Gem::Version
|
|
30
|
-
version:
|
|
30
|
+
version: 1.10.1
|
|
31
31
|
- !ruby/object:Gem::Dependency
|
|
32
32
|
name: rake
|
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -111,7 +111,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
111
111
|
version: '0'
|
|
112
112
|
segments:
|
|
113
113
|
- 0
|
|
114
|
-
hash: -
|
|
114
|
+
hash: -4139560228461145832
|
|
115
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
none: false
|
|
117
117
|
requirements:
|
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
120
120
|
version: '0'
|
|
121
121
|
segments:
|
|
122
122
|
- 0
|
|
123
|
-
hash: -
|
|
123
|
+
hash: -4139560228461145832
|
|
124
124
|
requirements: []
|
|
125
125
|
rubyforge_project:
|
|
126
126
|
rubygems_version: 1.8.24
|