sgupdater 0.1.4 → 0.2.0
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.
- checksums.yaml +4 -4
- data/lib/sgupdater/cli.rb +12 -0
- data/lib/sgupdater/client.rb +6 -0
- data/lib/sgupdater/updater.rb +15 -0
- data/lib/sgupdater/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5161be6948e31f29ff7cebfd7ce11ba6050f9c5
|
4
|
+
data.tar.gz: 1cd803164d4b6f0376efd63bd2d88d302f409e61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d5c098f6a98e36711d144bcef9fbcf4e91ed7be285c4052ccc973a95448229ec3eeab127591cbfe0f0feec4f93a8085e368c8213caf37617ec7fe4438ee0b89
|
7
|
+
data.tar.gz: d3d5b03e5ed94132aa1c5c2ce9b6b5ead5bb073c2240151162c8bf49be913a80be2ddd91adf9f38d401d4efa02a7be8dd32f7e2ce4039eca279d77d77c63527a
|
data/lib/sgupdater/cli.rb
CHANGED
@@ -27,6 +27,18 @@ module Sgupdater
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
desc :add, "Add to_cidr address same from_cidr setting"
|
31
|
+
method_option :from_cidr, type: :string, required: true
|
32
|
+
method_option :to_cidr, type: :string, required: true
|
33
|
+
def add
|
34
|
+
added = client.add
|
35
|
+
if added
|
36
|
+
puts "Add success"
|
37
|
+
else
|
38
|
+
puts "No change"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
30
42
|
private
|
31
43
|
def client
|
32
44
|
@client ||= Client.new options, aws_configuration
|
data/lib/sgupdater/client.rb
CHANGED
@@ -24,6 +24,12 @@ module Sgupdater
|
|
24
24
|
updater.update
|
25
25
|
end
|
26
26
|
|
27
|
+
def add
|
28
|
+
updater = Sgupdater::Updater.new(@cli_options)
|
29
|
+
updater.add(@cli_options[:from_cidr], @cli_options[:to_cidr])
|
30
|
+
updater.update
|
31
|
+
end
|
32
|
+
|
27
33
|
def security_groups_with_cidr(cidr)
|
28
34
|
@ec2.security_groups(
|
29
35
|
filters: [
|
data/lib/sgupdater/updater.rb
CHANGED
@@ -29,6 +29,21 @@ module Sgupdater
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
def add(from, to)
|
33
|
+
@exported.each do |vpc, sgs|
|
34
|
+
sgs.each do |sg, props|
|
35
|
+
props[:ingress].each do |ing|
|
36
|
+
ing[:ip_ranges].each do |cidr|
|
37
|
+
if cidr == from
|
38
|
+
ing[:ip_ranges] << to
|
39
|
+
puts [vpc ? vpc : '(classic)', sg, props[:name], ing[:protocol], ing[:port_range], ing[:ip_ranges], ing[:groups]].join("\t")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
32
47
|
def update
|
33
48
|
exported = JSON.pretty_generate(@exported)
|
34
49
|
file = Tempfile.new('exported')
|
data/lib/sgupdater/version.rb
CHANGED