knife-cloud 1.2.1 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE +1 -1
- data/lib/chef/knife/cloud/chefbootstrap/bootstrap_distribution.rb +2 -2
- data/lib/chef/knife/cloud/chefbootstrap/bootstrap_options.rb +115 -133
- data/lib/chef/knife/cloud/chefbootstrap/bootstrap_protocol.rb +6 -6
- data/lib/chef/knife/cloud/chefbootstrap/bootstrapper.rb +11 -12
- data/lib/chef/knife/cloud/chefbootstrap/ssh_bootstrap_protocol.rb +49 -54
- data/lib/chef/knife/cloud/chefbootstrap/unix_distribution.rb +3 -3
- data/lib/chef/knife/cloud/chefbootstrap/windows_distribution.rb +3 -3
- data/lib/chef/knife/cloud/chefbootstrap/winrm_bootstrap_protocol.rb +11 -12
- data/lib/chef/knife/cloud/command.rb +24 -27
- data/lib/chef/knife/cloud/exceptions.rb +1 -2
- data/lib/chef/knife/cloud/fog/options.rb +8 -8
- data/lib/chef/knife/cloud/fog/service.rb +54 -60
- data/lib/chef/knife/cloud/helpers.rb +2 -3
- data/lib/chef/knife/cloud/list_resource_command.rb +6 -7
- data/lib/chef/knife/cloud/list_resource_options.rb +5 -5
- data/lib/chef/knife/cloud/server/create_command.rb +30 -35
- data/lib/chef/knife/cloud/server/create_options.rb +33 -34
- data/lib/chef/knife/cloud/server/delete_command.rb +12 -15
- data/lib/chef/knife/cloud/server/delete_options.rb +7 -8
- data/lib/chef/knife/cloud/server/list_command.rb +22 -22
- data/lib/chef/knife/cloud/server/list_options.rb +9 -10
- data/lib/chef/knife/cloud/server/options.rb +7 -7
- data/lib/chef/knife/cloud/server/show_command.rb +5 -5
- data/lib/chef/knife/cloud/server/show_options.rb +5 -6
- data/lib/chef/knife/cloud/service.rb +12 -13
- data/lib/knife-cloud/version.rb +2 -2
- data/lib/test/fixtures/knife.rb +3 -3
- data/lib/test/fixtures/validation.pem +27 -0
- data/lib/test/knife-utils/helper.rb +11 -11
- data/lib/test/knife-utils/knife_test_utils.rb +4 -4
- data/lib/test/knife-utils/matchers.rb +3 -3
- data/lib/test/knife-utils/test_bed.rb +38 -38
- data/lib/test/templates/windows-chef-client-msi.erb +3 -4
- data/lib/test/templates/windows-shell.erb +2 -2
- metadata +12 -152
- data/.gitignore +0 -33
- data/.travis.yml +0 -6
- data/CHANGELOG.md +0 -133
- data/CONTRIBUTING.md +0 -5
- data/Gemfile +0 -9
- data/README.md +0 -421
- data/Rakefile +0 -35
- data/ci.gemfile +0 -18
- data/knife-cloud.gemspec +0 -26
- data/spec/resource_spec_helper.rb +0 -49
- data/spec/server_command_common_spec_helper.rb +0 -48
- data/spec/spec_helper.rb +0 -25
- data/spec/support/shared_examples_for_command.rb +0 -35
- data/spec/support/shared_examples_for_servercreatecommand.rb +0 -144
- data/spec/support/shared_examples_for_serverdeletecommand.rb +0 -77
- data/spec/support/shared_examples_for_service.rb +0 -85
- data/spec/unit/bootstrap_protocol_spec.rb +0 -98
- data/spec/unit/bootstrapper_spec.rb +0 -171
- data/spec/unit/cloud_command_spec.rb +0 -35
- data/spec/unit/command_spec.rb +0 -49
- data/spec/unit/fog_service_spec.rb +0 -163
- data/spec/unit/list_resource_command_spec.rb +0 -140
- data/spec/unit/server_create_command_spec.rb +0 -198
- data/spec/unit/server_delete_command_spec.rb +0 -25
- data/spec/unit/server_list_command_spec.rb +0 -119
- data/spec/unit/server_show_command_spec.rb +0 -64
- data/spec/unit/service_spec.rb +0 -46
- data/spec/unit/ssh_bootstrap_protocol_spec.rb +0 -116
- data/spec/unit/unix_distribution_spec.rb +0 -37
- data/spec/unit/windows_distribution_spec.rb +0 -37
- data/spec/unit/winrm_bootstrap_protocol_spec.rb +0 -108
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright:: Copyright (c) 2013
|
2
|
+
# Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
|
3
3
|
# License:: Apache License, Version 2.0
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -21,7 +21,7 @@ class Chef
|
|
21
21
|
module Helpers
|
22
22
|
|
23
23
|
# Additional helpers
|
24
|
-
def msg_pair(label, value, color
|
24
|
+
def msg_pair(label, value, color = :cyan)
|
25
25
|
if value && !value.to_s.empty?
|
26
26
|
puts "#{ui.color(label, color)}: #{value}"
|
27
27
|
end
|
@@ -36,4 +36,3 @@ class Chef
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
39
|
-
|
@@ -16,14 +16,14 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require
|
19
|
+
require "chef/knife/cloud/command"
|
20
20
|
|
21
21
|
class Chef
|
22
22
|
class Knife
|
23
23
|
class Cloud
|
24
24
|
class ResourceListCommand < Command
|
25
25
|
|
26
|
-
def initialize(argv=[])
|
26
|
+
def initialize(argv = [])
|
27
27
|
super argv
|
28
28
|
# columns_with_info is array of hash with label, key and attribute extraction callback, ex [{:label => "Label text", :key => 'key', value_callback => callback_method to extract/format the required value}, ...]
|
29
29
|
@columns_with_info = []
|
@@ -40,14 +40,14 @@ class Chef
|
|
40
40
|
|
41
41
|
def query_resource
|
42
42
|
# specific resource type must override this.
|
43
|
-
raise Chef::Exceptions::Override, "You must override query_resource in #{self
|
43
|
+
raise Chef::Exceptions::Override, "You must override query_resource in #{self} to return resources."
|
44
44
|
end
|
45
45
|
|
46
46
|
def is_resource_filtered?(attribute, value)
|
47
47
|
# resource_filters is array of filters in form {:attribute => attribute-name, :regex => 'filter regex value'}
|
48
48
|
return false if @resource_filters.nil?
|
49
49
|
@resource_filters.each do |filter|
|
50
|
-
if attribute == filter[:attribute]
|
50
|
+
if attribute == filter[:attribute] && value =~ filter[:regex]
|
51
51
|
return true
|
52
52
|
end
|
53
53
|
end
|
@@ -70,11 +70,11 @@ class Chef
|
|
70
70
|
|
71
71
|
# When @columns_with_info is nil display all
|
72
72
|
def list(resources)
|
73
|
-
if
|
73
|
+
if config[:format] == "summary"
|
74
74
|
# display column wise only if @columns_with_info is specified, else as a json for readable display.
|
75
75
|
begin
|
76
76
|
resource_list = @columns_with_info.map { |col_info| ui.color(col_info[:label], :bold) } if @columns_with_info.length > 0
|
77
|
-
resources.sort_by{|x| x.send(@sort_by_field).downcase }.each do |resource|
|
77
|
+
resources.sort_by { |x| x.send(@sort_by_field).downcase }.each do |resource|
|
78
78
|
if @columns_with_info.length > 0
|
79
79
|
list = get_resource_col_val(resource)
|
80
80
|
resource_list.concat(list) unless list.nil?
|
@@ -99,4 +99,3 @@ class Chef
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
end
|
102
|
-
|
@@ -8,14 +8,14 @@ class Chef
|
|
8
8
|
includer.class_eval do
|
9
9
|
|
10
10
|
option :disable_filter,
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
11
|
+
long: "--disable-filter",
|
12
|
+
description: "Disable filtering of the current resource listing.",
|
13
|
+
boolean: true,
|
14
|
+
default: false
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
21
|
-
end
|
21
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright:: Copyright (c) 2013
|
2
|
+
# Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
|
3
3
|
# License:: Apache License, Version 2.0
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -14,9 +14,9 @@
|
|
14
14
|
# See the License for the specific language governing permissions and
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
17
|
+
require "chef/knife/cloud/command"
|
18
|
+
require "chef/knife/cloud/exceptions"
|
19
|
+
require "chef/knife/cloud/chefbootstrap/bootstrapper"
|
20
20
|
|
21
21
|
class Chef
|
22
22
|
class Knife
|
@@ -24,7 +24,7 @@ class Chef
|
|
24
24
|
class ServerCreateCommand < Command
|
25
25
|
attr_accessor :server, :create_options
|
26
26
|
|
27
|
-
def initialize(argv=[])
|
27
|
+
def initialize(argv = [])
|
28
28
|
super argv
|
29
29
|
# columns_with_info is array of hash with label, key and attribute extraction callback, ex [{:label => "Label text", :key => 'key', value_callback => callback_method to extract/format the required value}, ...]
|
30
30
|
@columns_with_info = []
|
@@ -37,11 +37,11 @@ class Chef
|
|
37
37
|
# validate ssh_user, ssh_password, identity_file for ssh bootstrap protocol and winrm_password for winrm bootstrap protocol
|
38
38
|
errors = []
|
39
39
|
|
40
|
-
if locate_config_value(:bootstrap_protocol) ==
|
40
|
+
if locate_config_value(:bootstrap_protocol) == "ssh"
|
41
41
|
if locate_config_value(:identity_file).nil? && locate_config_value(:ssh_password).nil?
|
42
42
|
errors << "You must provide either Identity file or SSH Password."
|
43
43
|
end
|
44
|
-
elsif locate_config_value(:bootstrap_protocol) ==
|
44
|
+
elsif locate_config_value(:bootstrap_protocol) == "winrm"
|
45
45
|
if locate_config_value(:winrm_password).nil?
|
46
46
|
errors << "You must provide Winrm Password."
|
47
47
|
end
|
@@ -49,18 +49,16 @@ class Chef
|
|
49
49
|
errors << "You must provide a valid bootstrap protocol. options [ssh/winrm]. For linux type images, options [ssh]"
|
50
50
|
end
|
51
51
|
error_message = ""
|
52
|
-
raise CloudExceptions::ValidationError, error_message if errors.each{|e| ui.error(e); error_message = "#{error_message} #{e}."}.any?
|
52
|
+
raise CloudExceptions::ValidationError, error_message if errors.each { |e| ui.error(e); error_message = "#{error_message} #{e}." }.any?
|
53
53
|
end
|
54
54
|
|
55
55
|
def before_exec_command
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
raise e
|
63
|
-
end
|
56
|
+
post_connection_validations
|
57
|
+
service.create_server_dependencies
|
58
|
+
rescue CloudExceptions::ServerCreateDependenciesError => e
|
59
|
+
ui.fatal(e.message)
|
60
|
+
service.delete_server_dependencies
|
61
|
+
raise e
|
64
62
|
end
|
65
63
|
|
66
64
|
def execute_command
|
@@ -77,19 +75,17 @@ class Chef
|
|
77
75
|
|
78
76
|
# Derived classes can override after_exec_command and also call cleanup_on_failure if any exception occured.
|
79
77
|
def after_exec_command
|
80
|
-
begin
|
81
78
|
# bootstrap the server
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
end
|
79
|
+
bootstrap
|
80
|
+
rescue CloudExceptions::BootstrapError => e
|
81
|
+
ui.fatal(e.message)
|
82
|
+
cleanup_on_failure
|
83
|
+
raise e
|
84
|
+
rescue => e
|
85
|
+
error_message = "Check if --bootstrap-protocol and --image-os-type is correct. #{e.message}"
|
86
|
+
ui.fatal(error_message)
|
87
|
+
cleanup_on_failure
|
88
|
+
raise e, error_message
|
93
89
|
end
|
94
90
|
|
95
91
|
def cleanup_on_failure
|
@@ -111,7 +107,7 @@ class Chef
|
|
111
107
|
|
112
108
|
# any cloud specific initializations/cleanup we want to do around bootstrap.
|
113
109
|
def before_bootstrap
|
114
|
-
ssh_override_winrm if locate_config_value(:bootstrap_protocol) ==
|
110
|
+
ssh_override_winrm if locate_config_value(:bootstrap_protocol) == "ssh"
|
115
111
|
end
|
116
112
|
|
117
113
|
def after_bootstrap
|
@@ -120,14 +116,14 @@ class Chef
|
|
120
116
|
|
121
117
|
# knife-plugin can override set_default_config to set default config by using their own mechanism.
|
122
118
|
def set_default_config
|
123
|
-
config[:image_os_type] =
|
119
|
+
config[:image_os_type] = "windows" if config[:bootstrap_protocol] == "winrm"
|
124
120
|
end
|
125
121
|
|
126
|
-
#generate a random name if chef_node_name is empty
|
122
|
+
# generate a random name if chef_node_name is empty
|
127
123
|
def get_node_name(chef_node_name, prefix)
|
128
124
|
return chef_node_name unless chef_node_name.nil?
|
129
|
-
#lazy uuids, 15 chars cause windows has limits
|
130
|
-
|
125
|
+
# lazy uuids, 15 chars cause windows has limits
|
126
|
+
("#{prefix}-" + rand.to_s.split(".")[1]).slice(0, 14)
|
131
127
|
end
|
132
128
|
|
133
129
|
def post_connection_validations
|
@@ -156,10 +152,9 @@ class Chef
|
|
156
152
|
if locate_config_value(:identity_file).nil? &&
|
157
153
|
!locate_config_value(:kerberos_keytab_file).nil?
|
158
154
|
config[:identity_file] = locate_config_value(:kerberos_keytab_file)
|
159
|
-
end
|
155
|
+
end
|
160
156
|
end
|
161
157
|
end # class ServerCreateCommand
|
162
158
|
end
|
163
159
|
end
|
164
160
|
end
|
165
|
-
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright:: Copyright (c) 2013
|
2
|
+
# Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
|
3
3
|
# License:: Apache License, Version 2.0
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -15,8 +15,8 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
18
|
+
require "chef/knife/cloud/chefbootstrap/bootstrap_options"
|
19
|
+
require "chef/knife/cloud/server/options"
|
20
20
|
|
21
21
|
class Chef
|
22
22
|
class Knife
|
@@ -28,47 +28,47 @@ class Chef
|
|
28
28
|
include ServerOptions
|
29
29
|
include BootstrapOptions
|
30
30
|
option :image,
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
31
|
+
short: "-I IMAGE",
|
32
|
+
long: "--image IMAGE",
|
33
|
+
description: "A regexp matching an image name or an image ID for the server",
|
34
|
+
proc: Proc.new { |i| Chef::Config[:knife][:image] = i }
|
35
35
|
|
36
36
|
option :image_os_type,
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
37
|
+
short: "-T IMAGE_OS_TYPE",
|
38
|
+
long: "--image-os-type IMAGE_OS_TYPE",
|
39
|
+
description: "The image os type. options [windows/linux]. Only required when cloud does not provide a way to identify image os",
|
40
|
+
default: "linux",
|
41
|
+
proc: Proc.new { |i| Chef::Config[:knife][:image_os_type] = i }
|
42
42
|
|
43
43
|
option :flavor,
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
44
|
+
short: "-f FLAVOR_ID",
|
45
|
+
long: "--flavor FLAVOR_ID",
|
46
|
+
description: "The flavor name or ID of server",
|
47
|
+
proc: Proc.new { |f| Chef::Config[:knife][:flavor] = f }
|
48
48
|
|
49
49
|
option :bootstrap_protocol,
|
50
|
-
:
|
51
|
-
:
|
52
|
-
:
|
53
|
-
:
|
50
|
+
long: "--bootstrap-protocol protocol",
|
51
|
+
description: "Protocol to bootstrap servers. options: winrm/ssh. For linux servers always use ssh.",
|
52
|
+
default: "ssh",
|
53
|
+
proc: Proc.new { |b| Chef::Config[:knife][:bootstrap_protocol] = b }
|
54
54
|
|
55
55
|
option :server_create_timeout,
|
56
|
-
:
|
57
|
-
:
|
58
|
-
:
|
59
|
-
:
|
60
|
-
|
56
|
+
long: "--server-create-timeout timeout",
|
57
|
+
description: "How long to wait until the server is ready; default is 600 seconds",
|
58
|
+
default: 600,
|
59
|
+
proc: Proc.new { |v| Chef::Config[:knife][:server_create_timeout] = v }
|
60
|
+
|
61
61
|
option :delete_server_on_failure,
|
62
|
-
:
|
63
|
-
:
|
64
|
-
:
|
65
|
-
:
|
62
|
+
long: "--delete-server-on-failure",
|
63
|
+
boolean: true,
|
64
|
+
default: false,
|
65
|
+
description: "Destroy corresponding server in case of failure"
|
66
66
|
|
67
67
|
option :chef_node_name_prefix,
|
68
|
-
:
|
69
|
-
:
|
70
|
-
:
|
71
|
-
:
|
68
|
+
long: "--chef-node-name-prefix PREFIX_FOR_NODE_NAME",
|
69
|
+
description: "The prefix for chef node name",
|
70
|
+
default: includer.snake_case_name.split("_").first,
|
71
|
+
proc: Proc.new { |key| Chef::Config[:knife][:chef_node_name_prefix] = key }
|
72
72
|
|
73
73
|
end
|
74
74
|
end
|
@@ -77,4 +77,3 @@ class Chef
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
80
|
-
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>)
|
3
|
-
# Copyright:: Copyright (c) 2013
|
3
|
+
# Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -16,10 +16,10 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require
|
19
|
+
require "chef/knife/cloud/command"
|
20
20
|
# These two are needed for the '--purge' deletion case
|
21
|
-
require
|
22
|
-
require
|
21
|
+
require "chef/node"
|
22
|
+
require "chef/api_client"
|
23
23
|
|
24
24
|
class Chef
|
25
25
|
class Knife
|
@@ -41,7 +41,7 @@ class Chef
|
|
41
41
|
destroy_item(Chef::ApiClient, thing_to_delete, "client")
|
42
42
|
else
|
43
43
|
ui.warn("Corresponding node and client for the #{server_name} server were not deleted and remain registered with the Chef Server")
|
44
|
-
|
44
|
+
end
|
45
45
|
end
|
46
46
|
|
47
47
|
# Extracted from Chef::Knife.delete_object, because it has a
|
@@ -50,19 +50,16 @@ class Chef
|
|
50
50
|
# the user is already making their intent known. It is not
|
51
51
|
# necessary to make them confirm two more times.
|
52
52
|
def destroy_item(klass, name, type_name)
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
raise CloudExceptions::ServerDeleteError, error_message
|
61
|
-
end
|
53
|
+
object = klass.load(name)
|
54
|
+
object.destroy
|
55
|
+
ui.warn("Deleted #{type_name} #{name}")
|
56
|
+
rescue Net::HTTPServerException => e
|
57
|
+
error_message = "#{e.message}. Could not find a #{type_name} named #{name} to delete!"
|
58
|
+
ui.warn(error_message)
|
59
|
+
raise CloudExceptions::ServerDeleteError, error_message
|
62
60
|
end
|
63
61
|
|
64
62
|
end # class ServerDeleteCommand
|
65
63
|
end
|
66
64
|
end
|
67
65
|
end
|
68
|
-
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>)
|
3
|
-
# Copyright:: Copyright (c) 2013
|
3
|
+
# Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -16,7 +16,7 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require
|
19
|
+
require "chef/knife/cloud/server/options"
|
20
20
|
|
21
21
|
class Chef
|
22
22
|
class Knife
|
@@ -27,11 +27,11 @@ class Chef
|
|
27
27
|
include ServerOptions
|
28
28
|
|
29
29
|
option :purge,
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
30
|
+
short: "-P",
|
31
|
+
long: "--purge",
|
32
|
+
boolean: true,
|
33
|
+
default: false,
|
34
|
+
description: "Destroy corresponding node and client on the Chef Server, in addition to destroying the Cloud node itself. Assumes node and client have the same name as the server (if not, add the '--node-name' option)."
|
35
35
|
|
36
36
|
end
|
37
37
|
end
|
@@ -39,4 +39,3 @@ class Chef
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
42
|
-
|
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "chef/knife/cloud/list_resource_command"
|
2
|
+
require "chef/knife/cloud/exceptions"
|
3
3
|
|
4
4
|
class Chef
|
5
5
|
class Knife
|
6
6
|
class Cloud
|
7
7
|
class ServerListCommand < ResourceListCommand
|
8
|
-
|
8
|
+
|
9
9
|
def before_exec_command
|
10
10
|
if config[:chef_data]
|
11
11
|
begin
|
@@ -16,18 +16,18 @@ class Chef
|
|
16
16
|
ui.warn(error_message)
|
17
17
|
raise CloudExceptions::ChefServerError, error_message
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
@chef_data_col_info = [
|
21
|
-
{:
|
22
|
-
{:
|
23
|
-
{:
|
24
|
-
{:
|
25
|
-
{:
|
26
|
-
{:
|
21
|
+
{ label: "Chef Node Name", key: "name" },
|
22
|
+
{ label: "Environment", key: "chef_environment" },
|
23
|
+
{ label: "FQDN", key: "fqdn" },
|
24
|
+
{ label: "Runlist", key: "run_list" },
|
25
|
+
{ label: "Tags", key: "tags" },
|
26
|
+
{ label: "Platform", key: "platform" },
|
27
27
|
]
|
28
28
|
|
29
29
|
if config[:chef_node_attribute]
|
30
|
-
@chef_data_col_info << {:
|
30
|
+
@chef_data_col_info << { label: "#{config[:chef_node_attribute]}", key: "#{config[:chef_node_attribute]}" }
|
31
31
|
end
|
32
32
|
@columns_with_info.concat(@chef_data_col_info)
|
33
33
|
end
|
@@ -40,7 +40,7 @@ class Chef
|
|
40
40
|
if config[:chef_data] && @chef_data_col_info.include?(col_info)
|
41
41
|
server_name = service.get_server_name(server)
|
42
42
|
if @node_list.include?(server_name)
|
43
|
-
node =
|
43
|
+
node = @node_list[server_name]
|
44
44
|
# Raise serverlisting error on invalid chef_node_attribute.
|
45
45
|
if col_info[:key] == config[:chef_node_attribute] && ! node.attribute?(col_info[:key])
|
46
46
|
error_message = "The Node does not have a #{col_info[:key]} attribute."
|
@@ -66,16 +66,16 @@ class Chef
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def format_server_state(state)
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
69
|
+
state = state.to_s.downcase
|
70
|
+
state_color = case state
|
71
|
+
when "shutting-down", "terminated", "stopping", "stopped", "error", "shutoff"
|
72
|
+
:red
|
73
|
+
when "pending", "build", "paused", "suspended", "hard_reboot"
|
74
|
+
:yellow
|
75
|
+
else
|
76
|
+
:green
|
77
|
+
end
|
78
|
+
ui.color(state, state_color)
|
79
79
|
end
|
80
80
|
|
81
81
|
end # class ServerListCommand
|