piculet 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # Piculet
2
2
 
3
- Piculet is a tool to manage Security Group.
3
+ Piculet is a tool to manage EC2 Security Group.
4
4
 
5
- It defines the state of Security Group using DSL, and updates Security Group according to DSL.
5
+ It defines the state of EC2 Security Group using DSL, and updates EC2 Security Group according to DSL.
6
+
7
+ [![Build Status](https://drone.io/bitbucket.org/winebarrel/piculet/status.png)](https://drone.io/bitbucket.org/winebarrel/piculet/latest)
6
8
 
7
9
  ## Installation
8
10
 
@@ -20,17 +22,18 @@ Or install it yourself as:
20
22
 
21
23
  ## Usage
22
24
 
23
- ```
24
- shell> export AWS_ACCESS_KEY_ID='...'
25
- shell> export AWS_SECRET_ACCESS_KEY='...'
26
- shell> export AWS_REGION='ap-northeast-1'
27
- shell> piculet -e -o Groupfile
28
- shell> vi Groupfile
29
- shell> piculet -a --dry-run
30
- shell> piculet -a
25
+ ```sh
26
+ export AWS_ACCESS_KEY_ID='...'
27
+ export AWS_SECRET_ACCESS_KEY='...'
28
+ export AWS_REGION='ap-northeast-1'
29
+ #export AWS_OWNER_ID='123456789012'
30
+ piculet -e -o Groupfile
31
+ vi Groupfile
32
+ piculet -a --dry-run
33
+ piculet -a
31
34
  ```
32
35
 
33
- ## Routefile example
36
+ ## Groupfile example
34
37
 
35
38
  ```ruby
36
39
  require 'other/groupfile'
data/bin/piculet CHANGED
@@ -19,9 +19,11 @@ ARGV.options do |opt|
19
19
  begin
20
20
  access_key = nil
21
21
  secret_key = nil
22
+ region = nil
22
23
 
23
24
  opt.on('-k', '--access-key ACCESS_KEY') {|v| access_key = v }
24
25
  opt.on('-s', '--secret-key SECRET_KEY') {|v| secret_key = v }
26
+ opt.on('-r', '--region REGION') {|v| region = v }
25
27
  opt.on('-a', '--apply') {|v| mode = :apply }
26
28
  opt.on('-f', '--file FILE') {|v| file = v }
27
29
  opt.on('', '--dry-run') {|v| options[:dry_run] = true }
@@ -34,10 +36,12 @@ ARGV.options do |opt|
34
36
  opt.parse!
35
37
 
36
38
  if access_key and secret_key
37
- AWS.config({
39
+ aws_opts = {
38
40
  :access_key_id => access_key,
39
41
  :secret_access_key => secret_key,
40
- })
42
+ }
43
+ aws_opts[:region] = region if region
44
+ AWS.config(aws_opts)
41
45
  elsif (access_key and !secret_key) or (!access_key and secret_key) or mode.nil?
42
46
  puts opt.help
43
47
  exit 1
@@ -39,39 +39,32 @@ module AWS
39
39
 
40
40
  def random_security_group_owner_id(security_group)
41
41
  owner_id = nil
42
- exception = nil
43
42
 
44
- DESC_OWNER_ID_RETRY_TIMES.times do
43
+ (1..DESC_OWNER_ID_RETRY_TIMES).each do |i|
45
44
  begin
46
45
  owner_id = security_group.owner_id
47
46
  break
48
47
  rescue => e
49
- exception = e
48
+ raise e unless i < DESC_OWNER_ID_RETRY_TIMES
50
49
  end
51
50
 
52
51
  sleep DESC_OWNER_ID_RETRY_WAIT
53
52
  end
54
53
 
55
- raise exception if exception
56
-
57
54
  return owner_id
58
55
  end
59
56
 
60
57
  def delete_random_security_group(security_group)
61
- exception = nil
62
-
63
- DESC_OWNER_ID_RETRY_TIMES.times do
58
+ (1..DESC_OWNER_ID_RETRY_TIMES).each do |i|
64
59
  begin
65
60
  security_group.delete
66
61
  break
67
62
  rescue => e
68
- exception = e
63
+ raise e unless i < DESC_OWNER_ID_RETRY_TIMES
69
64
  end
70
65
 
71
66
  sleep DESC_OWNER_ID_RETRY_WAIT
72
67
  end
73
-
74
- raise exception if exception
75
68
  end
76
69
 
77
70
  def random_security_group_name
@@ -25,7 +25,7 @@ module Piculet
25
25
  message = "[#{level.to_s.upcase}] #{message}" unless level == :info
26
26
  message << ": #{log_id}" if log_id
27
27
  message << ' (dry-run)' if @options && @options.dry_run
28
- logger = Piculet::Logger.instance
28
+ logger = (@options && @options.logger) || Piculet::Logger.instance
29
29
  logger.send(level, message.send(color))
30
30
  end
31
31
  end # ClientHelper
@@ -1,5 +1,5 @@
1
1
  module Piculet
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
4
4
 
5
5
  Version = Piculet::VERSION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: piculet
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-09-29 00:00:00.000000000 Z
12
+ date: 2013-09-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk
@@ -76,23 +76,23 @@ dependencies:
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  - !ruby/object:Gem::Dependency
79
- name: pry
79
+ name: rspec
80
80
  requirement: !ruby/object:Gem::Requirement
81
81
  none: false
82
82
  requirements:
83
- - - ! '>='
83
+ - - ~>
84
84
  - !ruby/object:Gem::Version
85
- version: '0'
85
+ version: 2.14.1
86
86
  type: :development
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
89
89
  none: false
90
90
  requirements:
91
- - - ! '>='
91
+ - - ~>
92
92
  - !ruby/object:Gem::Version
93
- version: '0'
94
- description: Piculet is a tool to manage Security Group. It defines the state of Security
95
- Group using DSL, and updates Security Group according to DSL.
93
+ version: 2.14.1
94
+ description: Piculet is a tool to manage EC2 Security Group. It defines the state
95
+ of EC2 Security Group using DSL, and updates EC2 Security Group according to DSL.
96
96
  email:
97
97
  - sgwr_dts@yahoo.co.jp
98
98
  executables:
@@ -134,16 +134,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
134
  - - ! '>='
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0'
137
+ segments:
138
+ - 0
139
+ hash: 535241775
137
140
  required_rubygems_version: !ruby/object:Gem::Requirement
138
141
  none: false
139
142
  requirements:
140
143
  - - ! '>='
141
144
  - !ruby/object:Gem::Version
142
145
  version: '0'
146
+ segments:
147
+ - 0
148
+ hash: 535241775
143
149
  requirements: []
144
150
  rubyforge_project:
145
151
  rubygems_version: 1.8.23
146
152
  signing_key:
147
153
  specification_version: 3
148
- summary: Piculet is a tool to manage Security Group.
154
+ summary: Piculet is a tool to manage EC2 Security Group.
149
155
  test_files: []