knife-elb 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg
data/README.rdoc CHANGED
@@ -44,6 +44,7 @@ Delete an instance to an exitsing elb
44
44
 
45
45
 
46
46
 
47
+ knife elb does not create or delete elbs. or listener configurations.
47
48
  = LICENSE:
48
49
 
49
50
  Author:: Ranjib Dey (<dey.ranjib@gmail.com>)
@@ -40,7 +40,7 @@ class Chef
40
40
  ui.error("No ELB with id #{elb_id} found")
41
41
  exit(1)
42
42
  end
43
-
43
+ ui.confirm("Are you sure you want to add this instance in the ELB?")
44
44
  elbs.first.register_instances(instance)
45
45
  ui.info("Instance added")
46
46
  end
@@ -41,6 +41,7 @@ class Chef
41
41
  exit(1)
42
42
  end
43
43
 
44
+ ui.confirm("Are you sure you want to delete this instance from the ELB?")
44
45
  elbs.first.deregister_instances(instance)
45
46
  ui.info("Instance removed")
46
47
  end
@@ -35,7 +35,8 @@ class Chef
35
35
  elb_list = [
36
36
  ui.color('ELB Id', :bold),
37
37
  ui.color('DNS', :bold),
38
- ui.color('Number of instances', :bold),
38
+ ui.color('Total instances', :bold),
39
+ ui.color('Active instances', :bold),
39
40
  ui.color('Created At', :bold),
40
41
  ui.color('Zones', :bold)
41
42
  ].flatten.compact
@@ -43,16 +44,23 @@ class Chef
43
44
  output_column_count = elb_list.length
44
45
 
45
46
  connection.load_balancers.each do |elb|
47
+
48
+ total_instances = elb.instances.size
49
+ instances_in_service = elb.instances_in_service.size
50
+
46
51
  elb_list << elb.id.to_s
47
52
  elb_list << elb.dns_name
48
- elb_list << begin
49
- count = elb.instances.size
50
- if count == 0
51
- ui.color(count.to_s, :red)
52
- else
53
- ui.color(count.to_s, :green)
54
- end
55
- end
53
+
54
+ elb_list << if total_instances == 0
55
+ ui.color(total_instances.to_s, :red)
56
+ else
57
+ ui.color(total_instances.to_s, :green)
58
+ end
59
+ elb_list << if (instances_in_service != total_instances)
60
+ ui.color(instances_in_service.to_s, :red)
61
+ else
62
+ ui.color(instances_in_service.to_s, :green)
63
+ end
56
64
  elb_list << elb.created_at.to_s
57
65
  elb_list << elb.availability_zones.join(',')
58
66
  end
@@ -19,7 +19,6 @@
19
19
 
20
20
  require 'chef/knife'
21
21
  require 'chef/knife/elb_base'
22
- require 'json'
23
22
 
24
23
  class Chef
25
24
  class Knife
@@ -39,7 +38,7 @@ class Chef
39
38
  ui.error("No load balancer with id #{@name_args.first} found")
40
39
  exit 1
41
40
  end
42
- ui.output(JSON.parse(elbs.first.to_json))
41
+ ui.output(Chef::JSONCompat.from_json(elbs.first.to_json))
43
42
  end
44
43
  end
45
44
  end
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module ELB
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-elb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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-03-09 00:00:00.000000000 Z
12
+ date: 2013-03-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: knife-ec2
@@ -100,13 +100,12 @@ extra_rdoc_files:
100
100
  - README.rdoc
101
101
  - LICENSE
102
102
  files:
103
+ - .gitignore
103
104
  - LICENSE
104
105
  - README.rdoc
105
106
  - Rakefile
106
107
  - knife-elb.gemspec
107
108
  - lib/chef/knife/elb_base.rb
108
- - lib/chef/knife/elb_create.rb
109
- - lib/chef/knife/elb_delete.rb
110
109
  - lib/chef/knife/elb_instance_add.rb
111
110
  - lib/chef/knife/elb_instance_delete.rb
112
111
  - lib/chef/knife/elb_list.rb
@@ -1,36 +0,0 @@
1
-
2
- #
3
- # Author:: Ranjib Dey (<dey.ranjib@gmail.com>)
4
- # Copyright:: Copyright (c) 2013 Ranjib Dey.
5
- # License:: Apache License, Version 2.0
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
- #
19
-
20
- require 'chef/knife'
21
- require 'chef/knife/elb_base'
22
-
23
- class Chef
24
- class Knife
25
- class ElbCreate < Knife
26
-
27
- include Knife::ElbBase
28
-
29
- banner "knife elb create"
30
-
31
- def run
32
- end
33
- end
34
- end
35
- end
36
-
@@ -1,36 +0,0 @@
1
-
2
- #
3
- # Author:: Ranjib Dey (<dey.ranjib@gmail.com>)
4
- # Copyright:: Copyright (c) 2013 Ranjib Dey.
5
- # License:: Apache License, Version 2.0
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
- #
19
-
20
- require 'chef/knife'
21
- require 'chef/knife/elb_base'
22
-
23
- class Chef
24
- class Knife
25
- class ElbDelete < Knife
26
-
27
- include Knife::ElbBase
28
-
29
- banner "knife elb delete"
30
-
31
- def run
32
- end
33
- end
34
- end
35
- end
36
-