knife-openstack 1.3.2.pre → 1.3.2.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -1
- data/Rakefile +7 -28
- data/knife-openstack.gemspec +16 -16
- data/lib/chef/knife/cloud/openstack_server_create_options.rb +44 -44
- data/lib/chef/knife/cloud/openstack_service.rb +27 -31
- data/lib/chef/knife/cloud/openstack_service_options.rb +25 -26
- data/lib/chef/knife/openstack_flavor_list.rb +9 -10
- data/lib/chef/knife/openstack_floating_ip_allocate.rb +4 -4
- data/lib/chef/knife/openstack_floating_ip_associate.rb +5 -5
- data/lib/chef/knife/openstack_floating_ip_disassociate.rb +4 -4
- data/lib/chef/knife/openstack_group_list.rb +9 -11
- data/lib/chef/knife/openstack_helpers.rb +14 -2
- data/lib/chef/knife/openstack_image_list.rb +14 -15
- data/lib/chef/knife/openstack_network_list.rb +8 -9
- data/lib/chef/knife/openstack_server_create.rb +81 -84
- data/lib/chef/knife/openstack_server_delete.rb +25 -26
- data/lib/chef/knife/openstack_server_list.rb +13 -19
- data/lib/chef/knife/openstack_server_show.rb +11 -12
- data/lib/chef/knife/openstack_volume_list.rb +10 -12
- data/lib/knife-openstack/version.rb +1 -1
- data/spec/functional/flavor_list_func_spec.rb +11 -11
- data/spec/functional/floating_ip_list_func_spec.rb +11 -11
- data/spec/functional/group_list_func_spec.rb +27 -31
- data/spec/functional/image_list_func_spec.rb +14 -14
- data/spec/functional/network_list_func_spec.rb +10 -10
- data/spec/functional/server_create_func_spec.rb +23 -24
- data/spec/functional/server_delete_func_spec.rb +16 -17
- data/spec/functional/server_list_func_spec.rb +39 -39
- data/spec/functional/server_show_func_spec.rb +4 -5
- data/spec/functional/volume_list_func_spec.rb +9 -9
- data/spec/integration/cleanup.rb +8 -11
- data/spec/integration/openstack_spec.rb +377 -347
- data/spec/spec_context.rb +10 -10
- data/spec/spec_helper.rb +23 -27
- data/spec/unit/openstack_flavor_list_spec.rb +1 -1
- data/spec/unit/openstack_floating_ip_allocate_spec.rb +2 -3
- data/spec/unit/openstack_floating_ip_associate_spec.rb +2 -2
- data/spec/unit/openstack_floating_ip_disassociate_spec.rb +3 -3
- data/spec/unit/openstack_floating_ip_release_spec.rb +1 -1
- data/spec/unit/openstack_group_list_spec.rb +7 -7
- data/spec/unit/openstack_image_list_spec.rb +2 -2
- data/spec/unit/openstack_network_list_spec.rb +4 -4
- data/spec/unit/openstack_server_create_spec.rb +117 -118
- data/spec/unit/openstack_server_delete_spec.rb +4 -4
- data/spec/unit/openstack_server_list_spec.rb +2 -2
- data/spec/unit/openstack_server_show_spec.rb +6 -6
- data/spec/unit/openstack_service_spec.rb +20 -20
- data/spec/unit/openstack_volume_list_spec.rb +1 -1
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b05331ec3545a48444fc877d7889747529f0d7e3
|
4
|
+
data.tar.gz: 92baa1e81349f00f1e7f58df5b2d297b15a2f51f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2adbd1e48f537165d606ac669515a0d39f26a34e345656a88b4623a4a05ca265d8f5f36f59d1b59bd0f7adbef392286836cae918f07a9da28b9380b1ef89511
|
7
|
+
data.tar.gz: 20d830cb5e373c9ba05020678c41385cb1d87758ca14777bb858b140c743e0ee244de71410194c9119021c4c5f0ce7544d6c569f4caf6f48f9dddad955eddaf0
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -2,34 +2,13 @@
|
|
2
2
|
# Copyright:: Copyright (c) 2013 Chef Software, Inc.
|
3
3
|
|
4
4
|
require 'bundler'
|
5
|
-
|
5
|
+
require 'bundler/setup'
|
6
|
+
require 'bundler/gem_tasks'
|
7
|
+
require 'rubocop/rake_task'
|
8
|
+
require 'rspec/core/rake_task'
|
6
9
|
|
7
|
-
|
8
|
-
require 'rubygems/package_task'
|
10
|
+
RuboCop::RakeTask.new
|
9
11
|
|
10
|
-
|
11
|
-
task :all => [:spec, :uninstall, :install]
|
12
|
+
RSpec::Core::RakeTask.new(:spec)
|
12
13
|
|
13
|
-
|
14
|
-
GEM_NAME = "knife-openstack"
|
15
|
-
require File.dirname(__FILE__) + '/lib/knife-openstack/version'
|
16
|
-
spec = eval(File.read("knife-openstack.gemspec"))
|
17
|
-
Gem::PackageTask.new(spec) do |pkg|
|
18
|
-
pkg.gem_spec = spec
|
19
|
-
end
|
20
|
-
|
21
|
-
desc "uninstall #{GEM_NAME}-#{Knife::OpenStack::VERSION}.gem from system..."
|
22
|
-
task :uninstall do
|
23
|
-
sh %{gem uninstall #{GEM_NAME} -x -v #{Knife::OpenStack::VERSION} }
|
24
|
-
end
|
25
|
-
|
26
|
-
# rspec
|
27
|
-
begin
|
28
|
-
require 'rspec/core/rake_task'
|
29
|
-
desc "Run all specs in spec directory"
|
30
|
-
RSpec::Core::RakeTask.new(:spec) do |t|
|
31
|
-
t.pattern = 'spec/unit/**/*_spec.rb'
|
32
|
-
end
|
33
|
-
rescue LoadError
|
34
|
-
STDERR.puts "\n*** RSpec not available. (sudo) gem install rspec to run unit tests. ***\n\n"
|
35
|
-
end
|
14
|
+
task default: [:rubocop, :spec]
|
data/knife-openstack.gemspec
CHANGED
@@ -1,28 +1,28 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require
|
2
|
+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'knife-openstack/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
-
s.name =
|
6
|
+
s.name = 'knife-openstack'
|
7
7
|
s.version = Knife::OpenStack::VERSION
|
8
8
|
s.version = "#{s.version}-alpha-#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV['TRAVIS']
|
9
|
-
s.platform
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
10
|
s.has_rdoc = true
|
11
|
-
s.extra_rdoc_files = [
|
12
|
-
s.authors = [
|
13
|
-
s.email = [
|
14
|
-
s.homepage =
|
15
|
-
s.summary =
|
16
|
-
s.description =
|
11
|
+
s.extra_rdoc_files = ['README.md', 'LICENSE']
|
12
|
+
s.authors = ['JJ Asghar']
|
13
|
+
s.email = ['jj@chef.io']
|
14
|
+
s.homepage = 'https://github.com/chef/knife-openstack'
|
15
|
+
s.summary = 'A Chef knife plugin for OpenStack clouds.'
|
16
|
+
s.description = 'A Chef knife plugin for OpenStack clouds.'
|
17
17
|
|
18
18
|
s.files = `git ls-files`.split("\n")
|
19
19
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
-
s.require_paths = [
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
21
|
+
s.require_paths = ['lib']
|
22
22
|
|
23
|
-
s.add_dependency
|
24
|
-
s.add_dependency
|
25
|
-
s.add_dependency
|
23
|
+
s.add_dependency 'fog', '~> 1.23'
|
24
|
+
s.add_dependency 'chef', '>= 11'
|
25
|
+
s.add_dependency 'knife-cloud', '~> 1.2.0'
|
26
26
|
|
27
|
-
%w(rake rspec-core rspec-expectations rspec-mocks rspec_junit_formatter).each { |gem| s.add_development_dependency gem }
|
27
|
+
%w(bundler rubocop rake rspec-core rspec-expectations rspec-mocks rspec_junit_formatter).each { |gem| s.add_development_dependency gem }
|
28
28
|
end
|
@@ -11,72 +11,72 @@ class Chef
|
|
11
11
|
|
12
12
|
# Openstack Server create params.
|
13
13
|
option :private_network,
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
long: '--openstack-private-network',
|
15
|
+
description: 'Use the private IP for bootstrapping rather than the public IP',
|
16
|
+
boolean: true,
|
17
|
+
default: false
|
18
18
|
|
19
19
|
option :openstack_floating_ip,
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
short: '-a [IP]',
|
21
|
+
long: '--openstack-floating-ip [IP]',
|
22
|
+
default: '-1',
|
23
|
+
description: 'Request to associate a floating IP address to the new OpenStack node. Assumes IPs have been allocated to the project. Specific IP is optional.'
|
24
24
|
|
25
25
|
option :openstack_volumes,
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
long: '--openstack-volumes VOLUME1,VOLUME2,VOLUME3',
|
27
|
+
description: 'Comma separated list of the UUID(s) of the volume(s) to attach to the server',
|
28
|
+
proc: proc { |volumes| volumes.split(',') }
|
29
29
|
|
30
30
|
option :openstack_scheduler_hints,
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
long: '--scheduler-hints HINTS',
|
32
|
+
description: 'A scheduler group hint to OpenStack',
|
33
|
+
proc: proc { |i| Chef::Config[:knife][:openstack_scheduler_hints] = i }
|
34
34
|
|
35
35
|
option :openstack_security_groups,
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
short: '-G X,Y,Z',
|
37
|
+
long: '--openstack-groups X,Y,Z',
|
38
|
+
description: 'The security groups for this server',
|
39
|
+
default: ['default'],
|
40
|
+
proc: proc { |groups| groups.split(',') }
|
41
41
|
|
42
42
|
option :openstack_ssh_key_id,
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
short: '-S KEY',
|
44
|
+
long: '--openstack-ssh-key-id KEY',
|
45
|
+
description: 'The OpenStack SSH keypair id',
|
46
|
+
proc: proc { |key| Chef::Config[:knife][:openstack_ssh_key_id] = key }
|
47
47
|
|
48
48
|
option :user_data,
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
long: '--user-data USER_DATA',
|
50
|
+
description: 'The file path containing user data information for this server',
|
51
|
+
proc: proc { |user_data| open(user_data, &:read) }
|
52
52
|
|
53
53
|
option :bootstrap_network,
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
long: '--bootstrap-network NAME',
|
55
|
+
default: 'public',
|
56
|
+
description: "Specify network for bootstrapping. Default is 'public'."
|
57
57
|
|
58
58
|
option :network,
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
59
|
+
long: '--no-network',
|
60
|
+
boolean: true,
|
61
|
+
default: true,
|
62
|
+
description: "Use first available network for bootstrapping if 'public' and 'private' are unavailable."
|
63
63
|
|
64
64
|
option :network_ids,
|
65
|
-
|
66
|
-
|
67
|
-
|
65
|
+
long: '--network-ids NETWORK_ID_1,NETWORK_ID_2,NETWORK_ID_3',
|
66
|
+
description: 'Comma separated list of the UUID(s) of the network(s) for the server to attach',
|
67
|
+
proc: proc { |networks| networks.split(',') }
|
68
68
|
|
69
69
|
option :availability_zone,
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
70
|
+
short: '-Z ZONE_NAME',
|
71
|
+
long: '--availability-zone ZONE_NAME',
|
72
|
+
description: 'The availability zone for this server',
|
73
|
+
proc: proc { |z| Chef::Config[:knife][:availability_zone] = z }
|
74
74
|
|
75
75
|
option :metadata,
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
76
|
+
short: '-M X=1',
|
77
|
+
long: '--metadata X=1',
|
78
|
+
description: 'Metadata information for this server (may pass multiple times)',
|
79
|
+
proc: proc { |data| Chef::Config[:knife][:metadata] ||= {}; Chef::Config[:knife][:metadata].merge!(data.split('=')[0] => data.split('=')[1]) }
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
@@ -10,53 +10,49 @@ class Chef
|
|
10
10
|
class Knife
|
11
11
|
class Cloud
|
12
12
|
class OpenstackService < FogService
|
13
|
-
|
14
13
|
def initialize(options = {})
|
15
14
|
Chef::Log.debug("openstack_username #{Chef::Config[:knife][:openstack_username]}")
|
16
15
|
Chef::Log.debug("openstack_auth_url #{Chef::Config[:knife][:openstack_auth_url]}")
|
17
16
|
Chef::Log.debug("openstack_tenant #{Chef::Config[:knife][:openstack_tenant]}")
|
18
|
-
Chef::Log.debug("openstack_endpoint_type #{Chef::Config[:knife][:openstack_endpoint_type] || 'publicURL'
|
19
|
-
Chef::Log.debug("openstack_insecure #{Chef::Config[:knife][:openstack_insecure]
|
20
|
-
Chef::Log.debug("openstack_region #{Chef::Config[:knife][:openstack_region]
|
17
|
+
Chef::Log.debug("openstack_endpoint_type #{Chef::Config[:knife][:openstack_endpoint_type] || 'publicURL'}")
|
18
|
+
Chef::Log.debug("openstack_insecure #{Chef::Config[:knife][:openstack_insecure]}")
|
19
|
+
Chef::Log.debug("openstack_region #{Chef::Config[:knife][:openstack_region]}")
|
21
20
|
|
22
|
-
super(options.merge({
|
23
|
-
|
24
|
-
:
|
25
|
-
:
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
|
32
|
-
:ssl_verify_peer => !Chef::Config[:knife][:openstack_insecure]
|
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]
|
33
31
|
}
|
34
|
-
|
32
|
+
}))
|
35
33
|
end
|
36
34
|
|
37
35
|
# add alternate user defined api_endpoint value.
|
38
36
|
def add_api_endpoint
|
39
|
-
@auth_params.merge!(
|
37
|
+
@auth_params.merge!(openstack_auth_url: Chef::Config[:knife][:api_endpoint]) unless Chef::Config[:knife][:api_endpoint].nil?
|
40
38
|
end
|
41
39
|
|
42
40
|
def get_server(search_term)
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
41
|
+
if server = connection.servers.get(search_term)
|
42
|
+
return server
|
43
|
+
end
|
47
44
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
45
|
+
if servers = connection.servers.all(name: search_term)
|
46
|
+
if servers.length > 1
|
47
|
+
error_message = "Multiple server matches found for '#{search_term}', use an instance_id to be more specific."
|
48
|
+
ui.fatal(error_message)
|
49
|
+
fail CloudExceptions::ValidationError, error_message
|
50
|
+
else
|
51
|
+
servers.first
|
56
52
|
end
|
57
|
-
rescue Excon::Errors::BadRequest => e
|
58
|
-
handle_excon_exception(CloudExceptions::KnifeCloudError, e)
|
59
53
|
end
|
54
|
+
rescue Excon::Errors::BadRequest => e
|
55
|
+
handle_excon_exception(CloudExceptions::KnifeCloudError, e)
|
60
56
|
end
|
61
57
|
end
|
62
58
|
end
|
@@ -3,47 +3,46 @@ class Chef
|
|
3
3
|
class Knife
|
4
4
|
class Cloud
|
5
5
|
module OpenstackServiceOptions
|
6
|
-
|
7
|
-
def self.included(includer)
|
6
|
+
def self.included(includer)
|
8
7
|
includer.class_eval do
|
9
8
|
include FogOptions
|
10
9
|
# Openstack Connection params.
|
11
10
|
option :openstack_username,
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
short: '-A USERNAME',
|
12
|
+
long: '--openstack-username KEY',
|
13
|
+
description: 'Your OpenStack Username',
|
14
|
+
proc: proc { |key| Chef::Config[:knife][:openstack_username] = key }
|
16
15
|
|
17
16
|
option :openstack_password,
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
short: '-K SECRET',
|
18
|
+
long: '--openstack-password SECRET',
|
19
|
+
description: 'Your OpenStack Password',
|
20
|
+
proc: proc { |key| Chef::Config[:knife][:openstack_password] = key }
|
22
21
|
|
23
22
|
option :openstack_tenant,
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
short: '-T NAME',
|
24
|
+
long: '--openstack-tenant NAME',
|
25
|
+
description: 'Your OpenStack Tenant NAME',
|
26
|
+
proc: proc { |key| Chef::Config[:knife][:openstack_tenant] = key }
|
28
27
|
|
29
28
|
option :openstack_auth_url,
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
long: '--openstack-api-endpoint ENDPOINT',
|
30
|
+
description: 'Your OpenStack API endpoint',
|
31
|
+
proc: proc { |endpoint| Chef::Config[:knife][:openstack_auth_url] = endpoint }
|
33
32
|
|
34
33
|
option :openstack_endpoint_type,
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
long: '--openstack-endpoint-type ENDPOINT_TYPE',
|
35
|
+
description: 'OpenStack endpoint type to use (publicURL, internalURL, adminURL)',
|
36
|
+
proc: proc { |type| Chef::Config[:knife][:openstack_endpoint_type] = type }
|
38
37
|
|
39
38
|
option :openstack_insecure,
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
long: '--insecure',
|
40
|
+
description: 'Ignore SSL certificate on the Auth URL',
|
41
|
+
boolean: true,
|
42
|
+
default: false,
|
43
|
+
proc: proc { |key| Chef::Config[:knife][:openstack_insecure] = key }
|
45
44
|
end
|
46
|
-
|
45
|
+
end
|
47
46
|
end
|
48
47
|
end
|
49
48
|
end
|
@@ -12,18 +12,18 @@ class Chef
|
|
12
12
|
include OpenstackHelpers
|
13
13
|
include OpenstackServiceOptions
|
14
14
|
|
15
|
-
banner
|
15
|
+
banner 'knife openstack flavor list (options)'
|
16
16
|
|
17
17
|
def before_exec_command
|
18
|
-
#set columns_with_info map
|
18
|
+
# set columns_with_info map
|
19
19
|
@columns_with_info = [
|
20
|
-
{:
|
21
|
-
{:
|
22
|
-
{:
|
23
|
-
{:
|
24
|
-
{:
|
20
|
+
{ label: 'Name', key: 'name' },
|
21
|
+
{ label: 'ID', key: 'id' },
|
22
|
+
{ label: 'Virtual CPUs', key: 'vcpus' },
|
23
|
+
{ label: 'RAM', key: 'ram', value_callback: method(:ram_in_mb) },
|
24
|
+
{ label: 'Disk', key: 'disk', value_callback: method(:disk_in_gb) }
|
25
25
|
]
|
26
|
-
@sort_by_field =
|
26
|
+
@sort_by_field = 'name'
|
27
27
|
end
|
28
28
|
|
29
29
|
def query_resource
|
@@ -37,8 +37,7 @@ class Chef
|
|
37
37
|
def disk_in_gb(disk)
|
38
38
|
"#{disk} GB"
|
39
39
|
end
|
40
|
-
|
41
40
|
end
|
42
41
|
end
|
43
42
|
end
|
44
|
-
end
|
43
|
+
end
|
@@ -15,10 +15,10 @@ class Chef
|
|
15
15
|
banner 'knife openstack floating_ip allocate (options)'
|
16
16
|
|
17
17
|
option :pool,
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
short: '-p POOL',
|
19
|
+
long: '--pool POOL',
|
20
|
+
description: 'Floating IP pool to allocate from.',
|
21
|
+
proc: proc { |key| Chef::Config[:knife][:pool] = key }
|
22
22
|
|
23
23
|
def execute_command
|
24
24
|
@resource = @service.allocate_address(locate_config_value(:pool))
|
@@ -16,16 +16,16 @@ class Chef
|
|
16
16
|
banner 'knife openstack floating_ip associate IP (options)'
|
17
17
|
|
18
18
|
option :instance_id,
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
long: '--instance-id ID',
|
20
|
+
description: 'Instance id to associate it with.',
|
21
|
+
proc: proc { |key| Chef::Config[:knife][:instance_id] = key },
|
22
|
+
required: true
|
23
23
|
|
24
24
|
def execute_command
|
25
25
|
if @name_args[0]
|
26
26
|
floating_ip = @name_args[0]
|
27
27
|
else
|
28
|
-
ui.error
|
28
|
+
ui.error 'Please provide Floating IP to associate with.'
|
29
29
|
exit 1
|
30
30
|
end
|
31
31
|
|