knife-openstack 1.3.2.pre.1 → 1.3.2.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -1
- data/README.md +8 -0
- data/lib/chef/knife/cloud/openstack_service.rb +23 -12
- data/lib/knife-openstack/version.rb +1 -1
- data/spec/functional/server_create_func_spec.rb +2 -2
- data/spec/functional/server_list_func_spec.rb +19 -18
- data/spec/unit/openstack_server_create_spec.rb +1 -1
- data/spec/unit/openstack_service_spec.rb +42 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe9c78127693e0ad68023794392747f8a58926d5
|
4
|
+
data.tar.gz: a97cc8e5edf0422c8bb4912ab209fa6b1684c732
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f69897fb295203d5c971fe69a745b91ae1b904c9474c7f5388e12a510d9dc9810146e2b13a24924c10a99b0024677f1393c238b4691594d4a2cc28984275a32c
|
7
|
+
data.tar.gz: 7132079550ef827e3a68880110d28f4622ecbd910b588b87f93e373826d28acdb877bf9de5695a1db2ee5c0fd668e4ce2cf5f88811b5279494a6e129422ab627
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -31,6 +31,14 @@ In order to communicate with an OpenStack API you will need to tell Knife your O
|
|
31
31
|
knife[:openstack_tenant] = "Your OpenStack tenant name"
|
32
32
|
knife[:openstack_region] = "Your OpenStack Region"
|
33
33
|
|
34
|
+
All of Fog's `openstack` options (`openstack_domain_name`, `openstack_project_name`, ...) are supported. This includes support for the OpenStack Identity v3 API:
|
35
|
+
|
36
|
+
knife[:openstack_auth_url] = "http://cloud.mycompany.com:5000/v3/auth/tokens"
|
37
|
+
knife[:openstack_username] = "Your OpenStack Dashboard username"
|
38
|
+
knife[:openstack_password] = "Your OpenStack Dashboard password"
|
39
|
+
knife[:openstack_project_name] = "Your OpenStack project"
|
40
|
+
knife[:openstack_domain_name] = "Your OpenStack domain"
|
41
|
+
|
34
42
|
If your knife.rb file will be checked into a SCM system (ie readable by others) you may want to read the values from environment variables. For example, using the conventions of [OpenStack's RC file](http://docs.openstack.org/user-guide/content/cli_openrc.html) (note the `openstack_auth_url`):
|
35
43
|
|
36
44
|
knife[:openstack_auth_url] = "#{ENV['OS_AUTH_URL']}/tokens"
|
@@ -18,18 +18,7 @@ class Chef
|
|
18
18
|
Chef::Log.debug("openstack_insecure #{Chef::Config[:knife][:openstack_insecure]}")
|
19
19
|
Chef::Log.debug("openstack_region #{Chef::Config[:knife][:openstack_region]}")
|
20
20
|
|
21
|
-
super(options.merge(auth_params:
|
22
|
-
provider: 'OpenStack',
|
23
|
-
openstack_username: Chef::Config[:knife][:openstack_username],
|
24
|
-
openstack_api_key: Chef::Config[:knife][:openstack_password],
|
25
|
-
openstack_auth_url: Chef::Config[:knife][:openstack_auth_url],
|
26
|
-
openstack_endpoint_type: Chef::Config[:knife][:openstack_endpoint_type],
|
27
|
-
openstack_tenant: Chef::Config[:knife][:openstack_tenant],
|
28
|
-
openstack_region: Chef::Config[:knife][:openstack_region],
|
29
|
-
connection_options: {
|
30
|
-
ssl_verify_peer: !Chef::Config[:knife][:openstack_insecure]
|
31
|
-
}
|
32
|
-
}))
|
21
|
+
super(options.merge(auth_params: get_auth_params))
|
33
22
|
end
|
34
23
|
|
35
24
|
# add alternate user defined api_endpoint value.
|
@@ -54,6 +43,28 @@ class Chef
|
|
54
43
|
rescue Excon::Errors::BadRequest => e
|
55
44
|
handle_excon_exception(CloudExceptions::KnifeCloudError, e)
|
56
45
|
end
|
46
|
+
|
47
|
+
def get_auth_params
|
48
|
+
load_fog_gem
|
49
|
+
params = {
|
50
|
+
provider: 'OpenStack',
|
51
|
+
connection_options: {
|
52
|
+
ssl_verify_peer: !Chef::Config[:knife][:openstack_insecure]
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
(
|
57
|
+
Fog::Compute::OpenStack.requirements +
|
58
|
+
Fog::Compute::OpenStack.recognized -
|
59
|
+
[:openstack_api_key]
|
60
|
+
).each do |k|
|
61
|
+
next unless k.to_s.start_with?('openstack')
|
62
|
+
params[k] = Chef::Config[:knife][k]
|
63
|
+
end
|
64
|
+
params[:openstack_api_key] = Chef::Config[:knife][:openstack_password] || Chef::Config[:knife][:openstack_api_key]
|
65
|
+
|
66
|
+
params
|
67
|
+
end
|
57
68
|
end
|
58
69
|
end
|
59
70
|
end
|
@@ -75,7 +75,7 @@ describe Chef::Knife::Cloud::OpenstackServerCreate do
|
|
75
75
|
|
76
76
|
context 'for Linux' do
|
77
77
|
before do
|
78
|
-
@config = { openstack_floating_ip: '-1', bootstrap_ip_address: '75.101.253.10', ssh_password: 'password' }
|
78
|
+
@config = { openstack_floating_ip: '-1', bootstrap_ip_address: '75.101.253.10', ssh_password: 'password', hints: { "openstack" => {} }}
|
79
79
|
@knife_openstack_create.config[:distro] = 'chef-full'
|
80
80
|
@bootstrapper = Chef::Knife::Cloud::Bootstrapper.new(@config)
|
81
81
|
@ssh_bootstrap_protocol = Chef::Knife::Cloud::SshBootstrapProtocol.new(@config)
|
@@ -95,7 +95,7 @@ describe Chef::Knife::Cloud::OpenstackServerCreate do
|
|
95
95
|
|
96
96
|
context 'for Windows' do
|
97
97
|
before do
|
98
|
-
@config = { openstack_floating_ip: '-1', image_os_type: 'windows', bootstrap_ip_address: '75.101.253.10', bootstrap_protocol: 'winrm', ssh_password: 'password' }
|
98
|
+
@config = { openstack_floating_ip: '-1', image_os_type: 'windows', bootstrap_ip_address: '75.101.253.10', bootstrap_protocol: 'winrm', ssh_password: 'password', hints: { "openstack" => {} } }
|
99
99
|
@knife_openstack_create.config[:image_os_type] = 'windows'
|
100
100
|
@knife_openstack_create.config[:bootstrap_protocol] = 'winrm'
|
101
101
|
@knife_openstack_create.config[:distro] = 'windows-chef-client-msi'
|
@@ -39,9 +39,10 @@ describe Chef::Knife::Cloud::OpenstackServerList do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'lists formatted list of resources' do
|
42
|
-
expect(instance.ui).to receive(:list).with(['Name', 'Instance ID', '
|
43
|
-
'ubuntu01', 'resource-1', '172.31.6.132', '
|
44
|
-
'windows2008', 'resource-2', '172.31.6.132',
|
42
|
+
expect(instance.ui).to receive(:list).with(['Name', 'Instance ID', 'Addresses', 'Flavor', 'Image', 'Keypair', 'State', 'Availability Zone',
|
43
|
+
'ubuntu01', 'resource-1', 'public:IPv4: 172.31.6.132', '1', 'image1', 'keypair', 'ACTIVE', 'test zone',
|
44
|
+
'windows2008', 'resource-2', 'public:IPv4: 172.31.6.132', 'id2', 'image2', 'keypair', 'ACTIVE', 'test zone',
|
45
|
+
'windows2008', 'resource-3-err', '', 'id2', 'image2', 'keypair', 'ERROR', 'test zone'], :uneven_columns_across, 8)
|
45
46
|
instance.run
|
46
47
|
end
|
47
48
|
|
@@ -54,22 +55,22 @@ describe Chef::Knife::Cloud::OpenstackServerList do
|
|
54
55
|
end
|
55
56
|
|
56
57
|
it 'lists formatted list of resources on chef data option set' do
|
57
|
-
expect(instance.ui).to receive(:list).with(['Name', 'Instance ID', '
|
58
|
-
'server-4', 'server-4', '172.31.6.132', '
|
59
|
-
'ubuntu01', 'resource-1', '172.31.6.132', '
|
60
|
-
'windows2008', 'resource-2', '172.31.6.132',
|
61
|
-
'windows2008', 'resource-3-err',
|
58
|
+
expect(instance.ui).to receive(:list).with(['Name', 'Instance ID', 'Addresses', 'Flavor', 'Image', 'Keypair', 'State', 'Availability Zone', 'Chef Node Name', 'Environment', 'FQDN', 'Runlist', 'Tags', 'Platform',
|
59
|
+
'server-4', 'server-4', 'public:IPv4: 172.31.6.132', '1', 'image1', 'keypair', 'ACTIVE', 'test zone', 'server-4', '_default', 'testfqdnnode.us', '[]', '[]', 'ubuntu',
|
60
|
+
'ubuntu01', 'resource-1', 'public:IPv4: 172.31.6.132', '1', 'image1', 'keypair', 'ACTIVE', 'test zone', '', '', '', '', '', '',
|
61
|
+
'windows2008', 'resource-2', 'public:IPv4: 172.31.6.132', 'id2', 'image2', 'keypair', 'ACTIVE', 'test zone', '', '', '', '', '', '',
|
62
|
+
'windows2008', 'resource-3-err', '', 'id2', 'image2', 'keypair', 'ERROR', 'test zone', '', '', '', '', '', ''], :uneven_columns_across, 14)
|
62
63
|
instance.run
|
63
64
|
end
|
64
65
|
|
65
66
|
it 'lists formatted list of resources on chef-data and chef-node-attribute option set' do
|
66
67
|
instance.config[:chef_node_attribute] = 'platform_family'
|
67
68
|
expect(@node).to receive(:attribute?).with('platform_family').and_return(true)
|
68
|
-
expect(instance.ui).to receive(:list).with(['Name', 'Instance ID', '
|
69
|
-
'server-4', 'server-4', '172.31.6.132', '
|
70
|
-
'ubuntu01', 'resource-1', '172.31.6.132', '
|
71
|
-
'windows2008', 'resource-2', '172.31.6.132',
|
72
|
-
'windows2008', 'resource-3-err',
|
69
|
+
expect(instance.ui).to receive(:list).with(['Name', 'Instance ID', 'Addresses', 'Flavor', 'Image', 'Keypair', 'State', 'Availability Zone', 'Chef Node Name', 'Environment', 'FQDN', 'Runlist', 'Tags', 'Platform', 'platform_family',
|
70
|
+
'server-4', 'server-4', 'public:IPv4: 172.31.6.132', '1', 'image1', 'keypair', 'ACTIVE', 'test zone', 'server-4', '_default', 'testfqdnnode.us', '[]', '[]', 'ubuntu', 'debian',
|
71
|
+
'ubuntu01', 'resource-1', 'public:IPv4: 172.31.6.132', '1', 'image1', 'keypair', 'ACTIVE', 'test zone', '', '', '', '', '', '', '',
|
72
|
+
'windows2008', 'resource-2', 'public:IPv4: 172.31.6.132', 'id2', 'image2', 'keypair', 'ACTIVE', 'test zone', '', '', '', '', '', '', '',
|
73
|
+
'windows2008', 'resource-3-err', '', 'id2', 'image2', 'keypair', 'ERROR', 'test zone', '', '', '', '', '', '', ''], :uneven_columns_across, 15)
|
73
74
|
instance.run
|
74
75
|
end
|
75
76
|
|
@@ -84,11 +85,11 @@ describe Chef::Knife::Cloud::OpenstackServerList do
|
|
84
85
|
it 'not display chef-data on chef-node-attribute set but chef-data option missing' do
|
85
86
|
instance.config[:chef_data] = false
|
86
87
|
instance.config[:chef_node_attribute] = 'platform_family'
|
87
|
-
expect(instance.ui).to receive(:list).with(['Name', 'Instance ID', '
|
88
|
-
'server-4', 'server-4', '172.31.6.132', '
|
89
|
-
'ubuntu01', 'resource-1', '172.31.6.132', '
|
90
|
-
'windows2008', 'resource-2', '172.31.6.132',
|
91
|
-
'windows2008', 'resource-3-err',
|
88
|
+
expect(instance.ui).to receive(:list).with(['Name', 'Instance ID', 'Addresses', 'Flavor', 'Image', 'Keypair', 'State', 'Availability Zone',
|
89
|
+
'server-4', 'server-4', 'public:IPv4: 172.31.6.132', '1', 'image1', 'keypair', 'ACTIVE', 'test zone',
|
90
|
+
'ubuntu01', 'resource-1', 'public:IPv4: 172.31.6.132', '1', 'image1', 'keypair', 'ACTIVE', 'test zone',
|
91
|
+
'windows2008', 'resource-2', 'public:IPv4: 172.31.6.132', 'id2', 'image2', 'keypair', 'ACTIVE', 'test zone',
|
92
|
+
'windows2008', 'resource-3-err', '', 'id2', 'image2', 'keypair', 'ERROR', 'test zone'], :uneven_columns_across, 8)
|
92
93
|
instance.run
|
93
94
|
end
|
94
95
|
end
|
@@ -148,7 +148,7 @@ describe Chef::Knife::Cloud::OpenstackServerCreate do
|
|
148
148
|
|
149
149
|
it 'ensures default value for metadata' do
|
150
150
|
options = @instance.options
|
151
|
-
expect(options[:metadata][:default]).to
|
151
|
+
expect(options[:metadata][:default]).to be_nil
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
@@ -33,21 +33,21 @@ describe Chef::Knife::Cloud::OpenstackService do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'sets the api_endpoint in auth params' do
|
36
|
-
expect(@instance.instance_variable_get(:@auth_params)[:openstack_auth_url]).to
|
36
|
+
expect(@instance.instance_variable_get(:@auth_params)[:openstack_auth_url]).to be_nil
|
37
37
|
@instance.add_api_endpoint
|
38
38
|
expect(@instance.instance_variable_get(:@auth_params)[:openstack_auth_url]).to be == @api_endpoint
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'does not set the endpoint when --api-endpoint option is missing' do
|
42
42
|
Chef::Config[:knife][:api_endpoint] = nil
|
43
|
-
expect(@instance.instance_variable_get(:@auth_params)[:openstack_auth_url]).to
|
43
|
+
expect(@instance.instance_variable_get(:@auth_params)[:openstack_auth_url]).to be_nil
|
44
44
|
@instance.add_api_endpoint
|
45
45
|
expect(@instance.instance_variable_get(:@auth_params)[:openstack_auth_url]).to_not be == @api_endpoint
|
46
|
-
expect(@instance.instance_variable_get(:@auth_params)[:openstack_auth_url]).to
|
46
|
+
expect(@instance.instance_variable_get(:@auth_params)[:openstack_auth_url]).to be_nil
|
47
47
|
end
|
48
48
|
|
49
49
|
it "doesn't set an OpenStack endpoint type by default" do
|
50
|
-
expect(Chef::Config[:knife][:openstack_endpoint_type]).to
|
50
|
+
expect(Chef::Config[:knife][:openstack_endpoint_type]).to be_nil
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -86,4 +86,42 @@ describe Chef::Knife::Cloud::OpenstackService do
|
|
86
86
|
end
|
87
87
|
end
|
88
88
|
end
|
89
|
+
|
90
|
+
describe '#get_auth_params' do
|
91
|
+
let(:auth_params) do
|
92
|
+
Chef::Knife::Cloud::OpenstackService.new.instance_variable_get(:@auth_params)
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'sets ssl_verify_peer to false when openstack_insecure is true' do
|
96
|
+
Chef::Config[:knife][:openstack_insecure] = true
|
97
|
+
expect(auth_params[:connection_options][:ssl_verify_peer]).to be false
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'only copies openstack options from Fog' do
|
101
|
+
params = auth_params.keys - [:provider, :connection_options]
|
102
|
+
expect(params.all? { |p| p.to_s.start_with?('openstack') }).to be true
|
103
|
+
end
|
104
|
+
|
105
|
+
context 'when openstack_password is set' do
|
106
|
+
before(:each) do
|
107
|
+
@expected = 'password'
|
108
|
+
Chef::Config[:knife][:openstack_password] = @expected
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'sets openstack_api_key from openstack_password' do
|
112
|
+
expect(auth_params[:openstack_api_key]).to be == @expected
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'prefers openstack_password over openstack_api_key' do
|
116
|
+
Chef::Config[:knife][:openstack_api_key] = 'unexpected'
|
117
|
+
expect(auth_params[:openstack_api_key]).to be == @expected
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'uses openstack_api_key if openstack_password is not set' do
|
122
|
+
@expected = 'password'
|
123
|
+
Chef::Config[:knife][:openstack_api_key] = @expected
|
124
|
+
expect(auth_params[:openstack_api_key]).to be == @expected
|
125
|
+
end
|
126
|
+
end
|
89
127
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-openstack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.2.
|
4
|
+
version: 1.3.2.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JJ Asghar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog
|