vagrant-openstack-plugin 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +19 -1
- data/lib/vagrant-openstack-plugin/action/connect_openstack.rb +3 -1
- data/lib/vagrant-openstack-plugin/action/create_server.rb +15 -7
- data/lib/vagrant-openstack-plugin/config.rb +19 -4
- data/lib/vagrant-openstack-plugin/version.rb +1 -1
- data/locales/en.yml +2 -0
- data/spec/vagrant-openstack-plugin/config_spec.rb +5 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -53,6 +53,9 @@ require 'vagrant-openstack-plugin'
|
|
53
53
|
Vagrant.configure("2") do |config|
|
54
54
|
config.vm.box = "dummy"
|
55
55
|
|
56
|
+
# Make sure the private key from the key pair is provided
|
57
|
+
config.ssh.private_key_path = "~/.ssh/id_rsa"
|
58
|
+
|
56
59
|
config.vm.provider :openstack do |os| # e.g.
|
57
60
|
os.username = "YOUR USERNAME" # "#{ENV['OS_USERNAME']}"
|
58
61
|
os.api_key = "YOUR API KEY" # "#{ENV['OS_PASSWORD']}"
|
@@ -61,6 +64,12 @@ Vagrant.configure("2") do |config|
|
|
61
64
|
os.endpoint = "KEYSTONE AUTH URL" # "#{ENV['OS_AUTH_URL']}/tokens"
|
62
65
|
os.keypair_name = "YOUR KEYPAIR NAME"
|
63
66
|
os.ssh_username = "SSH USERNAME"
|
67
|
+
|
68
|
+
os.metadata = {"key" => "value"} # Optional
|
69
|
+
os.network = "YOUR NETWORK_NAME" # Optional
|
70
|
+
os.security_groups = ['ssh', 'http'] # Optional
|
71
|
+
os.tenant = "YOUR TENANT_NAME" # Optional
|
72
|
+
|
64
73
|
end
|
65
74
|
end
|
66
75
|
```
|
@@ -103,7 +112,16 @@ This provider exposes quite a few provider-specific configuration options:
|
|
103
112
|
can be overridden with this.
|
104
113
|
* `username` - The username with which to access OpenStack.
|
105
114
|
* `keypair_name` - The name of the keypair to access the machine.
|
106
|
-
* `ssh_username` - The username to access the machine.
|
115
|
+
* `ssh_username` - The username to access the machine. This can also be
|
116
|
+
configured using the standard config.ssh.username configuration value.
|
117
|
+
* `metadata` - A set of key pair values that will be passed to the instance
|
118
|
+
for configuration.
|
119
|
+
* `network` - A name or id that will be used to fetch network configuration
|
120
|
+
data when configuring the instance. NOTE: This is not compliant with the
|
121
|
+
vagrant network configurations.
|
122
|
+
* `security_groups` - List of security groups to be applied to the machine.
|
123
|
+
* `tenant` - Tenant name. You only need to specify this if your OpenStack user has access to multiple tenants.
|
124
|
+
|
107
125
|
|
108
126
|
These can be set like typical provider-specific configuration:
|
109
127
|
|
@@ -19,13 +19,15 @@ module VagrantPlugins
|
|
19
19
|
api_key = config.api_key
|
20
20
|
endpoint = config.endpoint
|
21
21
|
username = config.username
|
22
|
+
tenant = config.tenant
|
22
23
|
|
23
24
|
@logger.info("Connecting to OpenStack...")
|
24
25
|
env[:openstack_compute] = Fog::Compute.new({
|
25
26
|
:provider => :openstack,
|
26
27
|
:openstack_username => username,
|
27
28
|
:openstack_api_key => api_key,
|
28
|
-
:openstack_auth_url => endpoint
|
29
|
+
:openstack_auth_url => endpoint,
|
30
|
+
:openstack_tenant => tenant
|
29
31
|
})
|
30
32
|
|
31
33
|
if config.network
|
@@ -32,12 +32,6 @@ module VagrantPlugins
|
|
32
32
|
# Figure out the name for the server
|
33
33
|
server_name = config.server_name || env[:machine].name
|
34
34
|
|
35
|
-
# Output the settings we're going to use to the user
|
36
|
-
env[:ui].info(I18n.t("vagrant_openstack.launching_server"))
|
37
|
-
env[:ui].info(" -- Flavor: #{flavor.name}")
|
38
|
-
env[:ui].info(" -- Image: #{image.name}")
|
39
|
-
env[:ui].info(" -- Name: #{server_name}")
|
40
|
-
|
41
35
|
# Build the options for launching...
|
42
36
|
options = {
|
43
37
|
:flavor_ref => flavor.id,
|
@@ -45,14 +39,28 @@ module VagrantPlugins
|
|
45
39
|
:name => server_name,
|
46
40
|
:key_name => config.keypair_name,
|
47
41
|
:metadata => config.metadata,
|
48
|
-
:user_data_encoded => Base64.encode64(config.user_data)
|
42
|
+
:user_data_encoded => Base64.encode64(config.user_data),
|
43
|
+
:security_groups => config.security_groups
|
49
44
|
}
|
50
45
|
|
51
46
|
# Find a network if provided
|
52
47
|
if config.network
|
48
|
+
env[:ui].info(I18n.t("vagrant_openstack.finding_network"))
|
53
49
|
network = find_matching(env[:openstack_network].networks, config.network)
|
54
50
|
options[:nics] = [{"net_id" => network.id}] if network
|
55
51
|
end
|
52
|
+
|
53
|
+
# Output the settings we're going to use to the user
|
54
|
+
env[:ui].info(I18n.t("vagrant_openstack.launching_server"))
|
55
|
+
env[:ui].info(" -- Flavor: #{flavor.name}")
|
56
|
+
env[:ui].info(" -- Image: #{image.name}")
|
57
|
+
env[:ui].info(" -- Name: #{server_name}")
|
58
|
+
if network
|
59
|
+
env[:ui].info(" -- Network: #{network.name}")
|
60
|
+
end
|
61
|
+
if config.security_groups
|
62
|
+
env[:ui].info(" -- Security Groups: #{config.security_groups}")
|
63
|
+
end
|
56
64
|
|
57
65
|
# Create the server
|
58
66
|
server = env[:openstack_compute].servers.create(options)
|
@@ -42,6 +42,12 @@ module VagrantPlugins
|
|
42
42
|
# @return [String]
|
43
43
|
attr_accessor :network
|
44
44
|
|
45
|
+
# List of strings representing the security groups to apply.
|
46
|
+
# e.g. ['ssh', 'http']
|
47
|
+
#
|
48
|
+
# @return [Array[String]]
|
49
|
+
attr_accessor :security_groups
|
50
|
+
|
45
51
|
# The SSH username to use with this OpenStack instance. This overrides
|
46
52
|
# the `config.ssh.username` variable.
|
47
53
|
#
|
@@ -53,6 +59,11 @@ module VagrantPlugins
|
|
53
59
|
# @return [Hash]
|
54
60
|
attr_accessor :metadata
|
55
61
|
|
62
|
+
# The tenant to use.
|
63
|
+
#
|
64
|
+
# @return [String]
|
65
|
+
attr_accessor :tenant
|
66
|
+
|
56
67
|
# User data to be sent to the newly created OpenStack instance. Use this
|
57
68
|
# e.g. to inject a script at boot time.
|
58
69
|
#
|
@@ -69,7 +80,9 @@ module VagrantPlugins
|
|
69
80
|
@username = UNSET_VALUE
|
70
81
|
@keypair_name = UNSET_VALUE
|
71
82
|
@network = UNSET_VALUE
|
83
|
+
@security_groups = UNSET_VALUE
|
72
84
|
@ssh_username = UNSET_VALUE
|
85
|
+
@tenant = UNSET_VALUE
|
73
86
|
@user_data = UNSET_VALUE
|
74
87
|
end
|
75
88
|
|
@@ -79,17 +92,20 @@ module VagrantPlugins
|
|
79
92
|
@flavor = /m1.tiny/ if @flavor == UNSET_VALUE
|
80
93
|
@image = /cirros/ if @image == UNSET_VALUE
|
81
94
|
@server_name = nil if @server_name == UNSET_VALUE
|
82
|
-
@metadata =
|
95
|
+
@metadata = nil if @metadata == UNSET_VALUE
|
83
96
|
@username = nil if @username == UNSET_VALUE
|
84
97
|
@network = nil if @network == UNSET_VALUE
|
85
98
|
|
86
99
|
# Keypair defaults to nil
|
87
100
|
@keypair_name = nil if @keypair_name == UNSET_VALUE
|
88
|
-
|
101
|
+
|
102
|
+
@security_groups = nil if @security_groups == UNSET_VALUE
|
103
|
+
|
89
104
|
# The SSH values by default are nil, and the top-level config
|
90
105
|
# `config.ssh` values are used.
|
91
106
|
@ssh_username = nil if @ssh_username == UNSET_VALUE
|
92
|
-
|
107
|
+
|
108
|
+
@tenant = nil if @tenant == UNSET_VALUE
|
93
109
|
@user_data = "" if @user_data == UNSET_VALUE
|
94
110
|
end
|
95
111
|
|
@@ -98,7 +114,6 @@ module VagrantPlugins
|
|
98
114
|
|
99
115
|
errors << I18n.t("vagrant_openstack.config.api_key_required") if !@api_key
|
100
116
|
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)
|
102
117
|
|
103
118
|
{ "OpenStack Provider" => errors }
|
104
119
|
end
|
data/locales/en.yml
CHANGED
@@ -19,6 +19,8 @@ describe VagrantPlugins::OpenStack::Config do
|
|
19
19
|
its(:keypair_name) { should be_nil }
|
20
20
|
its(:ssh_username) { should be_nil }
|
21
21
|
its(:network) { should be_nil }
|
22
|
+
its(:security_groups) { should be_nil }
|
23
|
+
its(:tenant) { should be_nil }
|
22
24
|
end
|
23
25
|
|
24
26
|
describe "overriding defaults" do
|
@@ -30,7 +32,9 @@ describe VagrantPlugins::OpenStack::Config do
|
|
30
32
|
:username,
|
31
33
|
:keypair_name,
|
32
34
|
:network,
|
33
|
-
:ssh_username
|
35
|
+
:ssh_username,
|
36
|
+
:security_groups,
|
37
|
+
:tenant].each do |attribute|
|
34
38
|
it "should not default #{attribute} if overridden" do
|
35
39
|
subject.send("#{attribute}=".to_sym, "foo")
|
36
40
|
subject.finalize!
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-05-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: fog
|
@@ -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: -1985565957385980271
|
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: -1985565957385980271
|
124
124
|
requirements: []
|
125
125
|
rubyforge_project:
|
126
126
|
rubygems_version: 1.8.24
|