knife-cfn 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/chef/knife/cfn_describe.rb +90 -84
- data/lib/knife-cnf/version.rb +1 -1
- metadata +4 -4
@@ -1,84 +1,90 @@
|
|
1
|
-
#
|
2
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
3
|
-
# you may not use this file except in compliance with the License.
|
4
|
-
# You may obtain a copy of the License at
|
5
|
-
#
|
6
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
7
|
-
#
|
8
|
-
# Unless required by applicable law or agreed to in writing, software
|
9
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
10
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11
|
-
# See the License for the specific language governing permissions and
|
12
|
-
# limitations under the License.
|
13
|
-
#
|
14
|
-
|
15
|
-
require 'chef/knife'
|
16
|
-
require 'chef/knife/cfn_base'
|
17
|
-
|
18
|
-
class Chef
|
19
|
-
class Knife
|
20
|
-
class CfnDescribe < Chef::Knife::CfnBase
|
21
|
-
|
22
|
-
deps do
|
23
|
-
require 'fog'
|
24
|
-
require 'readline'
|
25
|
-
require 'chef/json_compat'
|
26
|
-
require 'chef/knife/bootstrap'
|
27
|
-
Chef::Knife::Bootstrap.load_deps
|
28
|
-
end
|
29
|
-
|
30
|
-
banner "knife cfn describe
|
31
|
-
|
32
|
-
def run
|
33
|
-
$stdout.sync = true
|
34
|
-
|
35
|
-
validate!
|
36
|
-
|
37
|
-
stack_name = @name_args[0]
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
ui.color(
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
1
|
+
#
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
3
|
+
# you may not use this file except in compliance with the License.
|
4
|
+
# You may obtain a copy of the License at
|
5
|
+
#
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
#
|
8
|
+
# Unless required by applicable law or agreed to in writing, software
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
10
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11
|
+
# See the License for the specific language governing permissions and
|
12
|
+
# limitations under the License.
|
13
|
+
#
|
14
|
+
|
15
|
+
require 'chef/knife'
|
16
|
+
require 'chef/knife/cfn_base'
|
17
|
+
|
18
|
+
class Chef
|
19
|
+
class Knife
|
20
|
+
class CfnDescribe < Chef::Knife::CfnBase
|
21
|
+
|
22
|
+
deps do
|
23
|
+
require 'fog'
|
24
|
+
require 'readline'
|
25
|
+
require 'chef/json_compat'
|
26
|
+
require 'chef/knife/bootstrap'
|
27
|
+
Chef::Knife::Bootstrap.load_deps
|
28
|
+
end
|
29
|
+
|
30
|
+
banner "knife cfn describe [stack name] - lists all stacks if [stack name] is omitted."
|
31
|
+
|
32
|
+
def run
|
33
|
+
$stdout.sync = true
|
34
|
+
|
35
|
+
validate!
|
36
|
+
|
37
|
+
stack_name = @name_args[0]
|
38
|
+
output_mode = "StackId"
|
39
|
+
output_header = "Stack ID"
|
40
|
+
|
41
|
+
|
42
|
+
if stack_name.nil?
|
43
|
+
@name_args[0] = "__ALL__"
|
44
|
+
output_mode = "StackName"
|
45
|
+
output_header = "Stack Name"
|
46
|
+
end
|
47
|
+
|
48
|
+
stack_list = [
|
49
|
+
ui.color(output_header, :bold),
|
50
|
+
ui.color('Status', :bold),
|
51
|
+
ui.color('Creation Time', :bold),
|
52
|
+
ui.color('Disable Rollback', :bold)
|
53
|
+
]
|
54
|
+
|
55
|
+
@name_args.each do |stack_name|
|
56
|
+
options = {}
|
57
|
+
data = Array.new
|
58
|
+
options['StackName'] = stack_name
|
59
|
+
|
60
|
+
begin
|
61
|
+
if stack_name == "__ALL__"
|
62
|
+
response = connection.describe_stacks()
|
63
|
+
else
|
64
|
+
response = connection.describe_stacks(options)
|
65
|
+
end
|
66
|
+
|
67
|
+
data = response.body['Stacks']
|
68
|
+
rescue Excon::Errors::BadRequest => e
|
69
|
+
i= e.response.body.index("<Message>")
|
70
|
+
j = e.response.body.index("</Message>")
|
71
|
+
if !i.nil? and !j.nil?
|
72
|
+
ui.error(e.response.body[i+9,j-i-9])
|
73
|
+
else
|
74
|
+
print "\n#{e.response.body}"
|
75
|
+
end
|
76
|
+
exit 1
|
77
|
+
else
|
78
|
+
data.each do |stack|
|
79
|
+
stack_list << stack[output_mode]
|
80
|
+
stack_list << stack['StackStatus']
|
81
|
+
stack_list << stack['CreationTime'].to_s
|
82
|
+
stack_list << stack['DisableRollback'].to_s
|
83
|
+
end
|
84
|
+
puts ui.list(stack_list, :uneven_columns_across, 4)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
data/lib/knife-cnf/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-cfn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: '
|
37
|
+
version: '11'
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: '
|
45
|
+
version: '11'
|
46
46
|
description: CloudFormation Support for Chef's Knife Command
|
47
47
|
email: neillwturner@gmail.com
|
48
48
|
executables: []
|