knife-elb 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7de8c25e41cf759a2252525c364484b6cf46a3aa
4
+ data.tar.gz: b0c0000b6f60335eabe44573774f3fe44493444f
5
+ SHA512:
6
+ metadata.gz: d20e94d27823bee0e23eb5e207602444e156d1ac6cdb9a1a617347155895afe576fb77385a5de6c898a0423bed5372b11926aa689312cbe9e2bceee9897be110
7
+ data.tar.gz: 38cb6b88076306cbf298735aa14a15c64c9d8882f70adc97250b77f2eabf9457d6891835e5a69a2ea76b5c3eb8c32e339cd488fade6b267579e30dd8a646594a
@@ -6,20 +6,23 @@ A knife plugin for managing instances under ELB
6
6
 
7
7
  = INSTALLATION:
8
8
 
9
- This plugin depends upon the knife-ec2 plugin
10
-
11
9
  Be sure you are running the latest version Chef. Versions earlier than 0.10.0 don't support plugins:
12
10
 
13
11
  gem install chef
14
12
 
13
+ This plugin depends upon the knife-ec2 plugin
14
+
15
+ gem install knife-ec2
16
+
15
17
  This plugin is distributed as a Ruby Gem. To install it, run:
16
18
 
17
19
  gem install knife-elb
18
20
 
19
- Depending on your system's configuration, you may need to run this command with root privileges.
21
+ Note: Depending on your system's configuration, you may need to run this command with root/ sudo privileges.
20
22
 
21
23
  = CONFIGURATION:
22
24
  Ditto as knife-ec2 configuration. i.e. put you aws credentials in knife.rb or pass them as command line arguments
25
+ {knife-ec2}[https://github.com/opscode/knife-ec2]
23
26
 
24
27
 
25
28
  = SUBCOMMANDS:
@@ -30,25 +33,29 @@ This plugin provides following knife subcommands
30
33
 
31
34
  Lists all the ELBs
32
35
 
33
- == knife elb show
36
+ == knife elb show ELB
34
37
 
35
- Shows the details of a given ELB
38
+ knife elb show infra-staging
39
+ Shows the details of a specified load-balancer e.g. infra-staging
40
+ Where, ELB is exitsing ELB-ID
36
41
 
37
- == knife elb instance add
42
+ == knife elb instance add ELB INSTANCE_ID
38
43
 
39
- Add an instance to an exitsing elb
44
+ knife elb instance add infra-staging i-dg12b7bd
45
+ This will add an instance with INSTANCE_ID (i-dg12b7bd) to an exitsing ELB-ID (infra-staging)
40
46
 
41
47
  == knife elb instance delete
42
48
 
43
- Delete an instance to an exitsing elb
49
+ knife elb instance delete infra-staging i-dg12b7bd
50
+ This will detach instance with INSTANCE_ID (i-dg12b7bd) from an exitsing ELB-ID (infra-staging)
44
51
 
45
52
 
46
53
 
47
- knife elb does not create or delete elbs. or listener configurations.
54
+ Note: knife elb does not create & delete elbs or change listener configurations.
48
55
  = LICENSE:
49
56
 
50
57
  Author:: Ranjib Dey (<dey.ranjib@gmail.com>)
51
- Copyright:: Copyright (c) 20013.
58
+ Copyright:: Copyright (c) 2013.
52
59
  License:: Apache License, Version 2.0
53
60
 
54
61
  Licensed under the Apache License, Version 2.0 (the "License");
@@ -0,0 +1,64 @@
1
+ # Author:: Bernd Ahlers (<bernd@torch.sh>)
2
+ # Copyright:: Copyright (c) 2014 Bernd Ahlers
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require 'chef/knife'
18
+ require 'chef/knife/elb_base'
19
+ require 'chef/knife/elb_listener_base'
20
+
21
+ class Chef
22
+ class Knife
23
+ class ElbCreate < Knife
24
+ include Chef::Knife::ElbBase
25
+ include Chef::Knife::ElbListenerBase
26
+
27
+ banner 'knife elb create ELB (options)'
28
+
29
+ option :availability_zones,
30
+ :long => '--availability-zones eu-west-1a[,eu-west-1b,eu-west-1c]',
31
+ :description => 'The ELB availability zones (default eu-west-1a)',
32
+ :default => ['eu-west-1a'],
33
+ :proc => Proc.new { |i| i.to_s.split(',') }
34
+
35
+ def run
36
+ validate!
37
+
38
+ response = connection.create_load_balancer(
39
+ config[:availability_zones],
40
+ @name_args.first,
41
+ build_listeners(config)
42
+ )
43
+
44
+ ui.output(Chef::JSONCompat.from_json(response.data[:body].to_json))
45
+ end
46
+
47
+ private
48
+
49
+ def validate!
50
+ super
51
+
52
+ unless @name_args.size == 1
53
+ ui.error('Please specify the ELB ID')
54
+ exit 1
55
+ end
56
+
57
+ if config[:availability_zones].empty?
58
+ ui.error("You have not provided a valid availability zone value. (-Z parameter)")
59
+ exit 1
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,47 @@
1
+ # Author:: Bernd Ahlers (<bernd@torch.sh>)
2
+ # Copyright:: Copyright (c) 2014 Bernd Ahlers
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require 'chef/knife'
18
+ require 'chef/knife/elb_base'
19
+
20
+ class Chef
21
+ class Knife
22
+ class ElbDelete < Knife
23
+ include Chef::Knife::ElbBase
24
+
25
+ banner 'knife elb delete ELB'
26
+
27
+ def run
28
+ validate!
29
+
30
+ response = connection.delete_load_balancer(@name_args.first)
31
+
32
+ ui.output(Chef::JSONCompat.from_json(response.data[:body].to_json))
33
+ end
34
+
35
+ private
36
+
37
+ def validate!
38
+ super
39
+
40
+ unless @name_args.size == 1
41
+ ui.error('Please specify the ELB ID')
42
+ exit 1
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,114 @@
1
+ # Author:: Bernd Ahlers (<bernd@torch.sh>)
2
+ # Copyright:: Copyright (c) 2014 Bernd Ahlers
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require 'chef/knife'
18
+ require 'chef/knife/elb_base'
19
+
20
+ class Chef
21
+ class Knife
22
+ class ElbHealthCheck < Knife
23
+ include Chef::Knife::ElbBase
24
+
25
+ PROTOCOLS = %w(HTTP HTTPS TCP SSL)
26
+
27
+ banner 'knife health check ELB (options)'
28
+
29
+ option :healthy_threshold,
30
+ :long => '--healthy-threshold INT',
31
+ :description => 'Number of consecutive health probe successes before moving instance to healthy (default 2)',
32
+ :default => 2,
33
+ :proc => Proc.new { |i| i.to_i }
34
+
35
+ option :unhealthy_threshold,
36
+ :long => '--unhealthy-threshold INT',
37
+ :description => 'Number of consecutive health probe failures before moving instance to unhealthy (default 2)',
38
+ :default => 2,
39
+ :proc => Proc.new { |i| i.to_i }
40
+
41
+ option :check_interval,
42
+ :long => '--check-interval SECONDS',
43
+ :description => 'Health check interval in seconds (default 30)',
44
+ :default => 30,
45
+ :proc => Proc.new { |i| i.to_i }
46
+
47
+ option :check_timeout,
48
+ :long => '--check-timeout SECONDS',
49
+ :description => 'Health check timeout in seconds (default 10)',
50
+ :default => 10,
51
+ :proc => Proc.new { |i| i.to_i }
52
+
53
+ option :check_target,
54
+ :long => '--check-target VALUE',
55
+ :description => 'Health check target specification. (i.e. HTTP:8080/ping, TCP:5555)',
56
+ :proc => Proc.new { |i| i.to_s }
57
+
58
+ def run
59
+ validate!
60
+
61
+ response = connection.configure_health_check(@name_args.first, build_health_check(config))
62
+
63
+ ui.output(Chef::JSONCompat.from_json(response.data[:body].to_json))
64
+ end
65
+
66
+ private
67
+
68
+ def validate!
69
+ super
70
+
71
+ unless @name_args.size == 1
72
+ ui.error('Please specify the ELB ID')
73
+ exit 1
74
+ end
75
+
76
+ if config[:check_target].to_s.empty?
77
+ ui.error('Please specify the check target. (i.e. HTTP:8080/ping, TCP:5555')
78
+ exit 1
79
+ end
80
+
81
+ validate_check_target(config[:check_target])
82
+ end
83
+
84
+ def validate_check_target(target)
85
+ error = false
86
+ proto, port_and_path = target.to_s.split(':', 2)
87
+ port = port_and_path.to_s.split('/', 2).first
88
+
89
+ unless PROTOCOLS.include?(proto.to_s.upcase)
90
+ ui.error("Invalid protocol for check target: #{proto.to_s.inspect} (available: #{PROTOCOLS.join(' ')})")
91
+ error = true
92
+ end
93
+
94
+ unless port =~ /^\d+$/
95
+ ui.error("Invalid port number for check target: #{port.to_s.inspect} (use a number)")
96
+ error = true
97
+ end
98
+
99
+ exit 1 if error
100
+ end
101
+
102
+ def build_health_check(config)
103
+ # See: http://docs.aws.amazon.com/ElasticLoadBalancing/latest/APIReference/API_HealthCheck.html
104
+ {
105
+ 'HealthyThreshold' => config[:healthy_threshold],
106
+ 'UnhealthyThreshold' => config[:unhealthy_threshold],
107
+ 'Interval' => config[:check_interval],
108
+ 'Target' => config[:check_target],
109
+ 'Timeout' => config[:check_timeout]
110
+ }
111
+ end
112
+ end
113
+ end
114
+ end
@@ -29,7 +29,6 @@ class Chef
29
29
  banner "knife elb list"
30
30
 
31
31
  def run
32
- $stdout.sync = true
33
32
  validate!
34
33
 
35
34
  elb_list = [
@@ -0,0 +1,49 @@
1
+ # Author:: Bernd Ahlers (<bernd@torch.sh>)
2
+ # Copyright:: Copyright (c) 2014 Bernd Ahlers
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require 'chef/knife'
18
+ require 'chef/knife/elb_base'
19
+ require 'chef/knife/elb_listener_base'
20
+
21
+ class Chef
22
+ class Knife
23
+ class ElbListenerAdd < Knife
24
+ include Chef::Knife::ElbBase
25
+ include Chef::Knife::ElbListenerBase
26
+
27
+ banner 'knife elb listener add ELB (options)'
28
+
29
+ def run
30
+ validate!
31
+
32
+ response = connection.create_load_balancer_listeners(@name_args.first, build_listeners(config))
33
+
34
+ ui.output(Chef::JSONCompat.from_json(response.data[:body].to_json))
35
+ end
36
+
37
+ private
38
+
39
+ def validate!
40
+ super
41
+
42
+ unless @name_args.size == 1
43
+ ui.error('Please specify the ELB ID')
44
+ exit 1
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,69 @@
1
+ # Author:: Bernd Ahlers (<bernd@torch.sh>)
2
+ # Copyright:: Copyright (c) 2014 Bernd Ahlers
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require 'chef/knife'
18
+
19
+ class Chef
20
+ class Knife
21
+ module ElbListenerBase
22
+ def self.included(includer)
23
+ includer.class_eval do
24
+ option :listener_proto,
25
+ :long => '--listener-protocol HTTP',
26
+ :description => 'Listener protocol (available: HTTP, HTTPS, TCP, SSL) (default HTTP)',
27
+ :default => 'HTTP',
28
+ :proc => Proc.new { |i| i.to_s.upcase }
29
+
30
+ option :listener_instance_proto,
31
+ :long => '--listener-instance-protocol HTTP',
32
+ :description => 'Instance connection protocol (available: HTTP, HTTPS, TCP, SSL) (default HTTP)',
33
+ :default => 'HTTP',
34
+ :proc => Proc.new { |i| i.to_s.upcase }
35
+
36
+ option :listener_lb_port,
37
+ :long => '--listener-lb-port 80',
38
+ :description => 'Listener load balancer port (default 80)',
39
+ :default => 80,
40
+ :proc => Proc.new { |i| i.to_i }
41
+
42
+ option :listener_instance_port,
43
+ :long => '--listener-instance-port 80',
44
+ :description => 'Instance port to forward traffic to (default 80)',
45
+ :default => 80,
46
+ :proc => Proc.new { |i| i.to_i }
47
+
48
+ option :ssl_certificate_id,
49
+ :long => '--ssl-certificate-id SSL-ID',
50
+ :description => 'ARN of the server SSL certificate',
51
+ :proc => Proc.new { |i| i.to_s }
52
+
53
+ def build_listeners(config)
54
+ [
55
+ {
56
+ 'Protocol' => config[:listener_proto],
57
+ 'LoadBalancerPort' => config[:listener_lb_port],
58
+ 'InstancePort' => config[:listener_instance_port],
59
+ 'InstanceProtocol' => config[:listener_instance_proto],
60
+ 'SSLCertificateId' => config[:ssl_certificate_id]
61
+ }
62
+ ]
63
+ end
64
+ end
65
+
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,47 @@
1
+ # Author:: Bernd Ahlers (<bernd@torch.sh>)
2
+ # Copyright:: Copyright (c) 2014 Bernd Ahlers
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require 'chef/knife'
18
+ require 'chef/knife/elb_base'
19
+
20
+ class Chef
21
+ class Knife
22
+ class ElbListenerDelete < Knife
23
+ include Chef::Knife::ElbBase
24
+
25
+ banner 'knife elb listener delete ELB PORT'
26
+
27
+ def run
28
+ validate!
29
+
30
+ response = connection.delete_load_balancer_listeners(@name_args.shift, @name_args)
31
+
32
+ ui.output(Chef::JSONCompat.from_json(response.data[:body].to_json))
33
+ end
34
+
35
+ private
36
+
37
+ def validate!
38
+ super
39
+
40
+ if @name_args.size < 2
41
+ ui.error('Please specify the ELB ID and the listener PORT to remove')
42
+ exit 1
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module ELB
3
- VERSION = "0.0.2"
3
+ VERSION = '0.0.3'
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,94 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-elb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
5
- prerelease:
4
+ version: 0.0.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ranjib Dey
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-10 00:00:00.000000000 Z
11
+ date: 2014-10-20 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: knife-ec2
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec-core
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec-expectations
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rspec-mocks
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rspec_junit_formatter
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - ">="
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - ">="
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  description: ELB Support for Chef's Knife Command
@@ -100,39 +89,45 @@ extra_rdoc_files:
100
89
  - README.rdoc
101
90
  - LICENSE
102
91
  files:
103
- - .gitignore
92
+ - ".gitignore"
104
93
  - LICENSE
105
94
  - README.rdoc
106
95
  - Rakefile
107
96
  - knife-elb.gemspec
108
97
  - lib/chef/knife/elb_base.rb
98
+ - lib/chef/knife/elb_create.rb
99
+ - lib/chef/knife/elb_delete.rb
100
+ - lib/chef/knife/elb_health_check.rb
109
101
  - lib/chef/knife/elb_instance_add.rb
110
102
  - lib/chef/knife/elb_instance_delete.rb
111
103
  - lib/chef/knife/elb_list.rb
104
+ - lib/chef/knife/elb_listener_add.rb
105
+ - lib/chef/knife/elb_listener_base.rb
106
+ - lib/chef/knife/elb_listener_delete.rb
112
107
  - lib/chef/knife/elb_show.rb
113
108
  - lib/knife-elb/version.rb
114
109
  homepage: http://github.com/ranjib/knife-elb
115
110
  licenses: []
111
+ metadata: {}
116
112
  post_install_message:
117
113
  rdoc_options: []
118
114
  require_paths:
119
115
  - lib
120
116
  required_ruby_version: !ruby/object:Gem::Requirement
121
- none: false
122
117
  requirements:
123
- - - ! '>='
118
+ - - ">="
124
119
  - !ruby/object:Gem::Version
125
120
  version: '0'
126
121
  required_rubygems_version: !ruby/object:Gem::Requirement
127
- none: false
128
122
  requirements:
129
- - - ! '>='
123
+ - - ">="
130
124
  - !ruby/object:Gem::Version
131
125
  version: '0'
132
126
  requirements: []
133
127
  rubyforge_project:
134
- rubygems_version: 1.8.23
128
+ rubygems_version: 2.2.2
135
129
  signing_key:
136
- specification_version: 3
130
+ specification_version: 4
137
131
  summary: ELB Support for Chef's Knife Command
138
132
  test_files: []
133
+ has_rdoc: true