knife-cfn 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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 <stack name>"
31
-
32
- def run
33
- $stdout.sync = true
34
-
35
- validate!
36
-
37
- stack_name = @name_args[0]
38
-
39
- if stack_name.nil?
40
- show_usage
41
- ui.error("You must specify a stack name")
42
- exit 1
43
- end
44
-
45
- stack_list = [
46
- ui.color('Stack ID', :bold),
47
- ui.color('Status', :bold),
48
- ui.color('Creation Time', :bold),
49
- ui.color('Disable Rollback', :bold)
50
- ]
51
-
52
- @name_args.each do |stack_name|
53
- options = {}
54
- data = Array.new
55
- options['StackName'] = stack_name
56
- begin
57
- response = connection.describe_stacks(options)
58
- data = response.body['Stacks']
59
- rescue Excon::Errors::BadRequest => e
60
- i= e.response.body.index("<Message>")
61
- j = e.response.body.index("</Message>")
62
- if !i.nil? and !j.nil?
63
- ui.error(e.response.body[i+9,j-i-9])
64
- else
65
- print "\n#{e.response.body}"
66
- end
67
- exit 1
68
- else
69
- data.each do |stack|
70
- stack_list << stack['StackId']
71
- stack_list << stack['StackStatus']
72
- stack_list << stack['CreationTime'].to_s
73
- stack_list << stack['DisableRollback'].to_s
74
- end
75
- puts ui.list(stack_list, :uneven_columns_across, 4)
76
- end
77
- end
78
- end
79
- end
80
- end
81
- #end
82
- end
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
@@ -1,3 +1,3 @@
1
1
  module KnifeCfn
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
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.5
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-04-08 00:00:00.000000000 Z
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: '10'
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: '10'
45
+ version: '11'
46
46
  description: CloudFormation Support for Chef's Knife Command
47
47
  email: neillwturner@gmail.com
48
48
  executables: []