mappru 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d2863ef4f96c705e0456fed60c95340f14ac98a
4
- data.tar.gz: 782fbb40ac0429950b62978c469818dfbbd67216
3
+ metadata.gz: 4dc8eb3b82ed3ed02195af6fd449f315b525b164
4
+ data.tar.gz: 643e6d69321a42e687cd9fd3704966d849c10ec9
5
5
  SHA512:
6
- metadata.gz: 6d5719b27e17b0b5f079daacf39af19b7659ab68e60a95ab30b7ab0a71d2a1321ee5214c300194af00677968874d7a2b5e2a5efd0aae9730538b3825480fb20a
7
- data.tar.gz: e1118fa5356b82b3fb5f6ebd63a9982bf72865f9f93ec6037459f5806b9835409ca016f25888d2afbb881a0d1d4b3bdb77d6fc278ef44f9458020f17890ace99
6
+ metadata.gz: 88a107a38dc9bf505e63f42808855288c78244f9ae829a1ab3a232c2a8d14d4a101cc528e0b24279915daf1a38c2960060e174660598d327ee09cd78f5413681
7
+ data.tar.gz: 54464a727881e6682f86d151efc3e14ec1bdb285db3811c827753c4779f23550a95d2ba6a07dc7fac011ce48bd343a7293c81ba1c4e3aab193cb440f9ead2241
data/exe/mappru CHANGED
@@ -91,13 +91,14 @@ def run_export(client, options)
91
91
  requires = []
92
92
 
93
93
  exported.each do |vpc_id, rts|
94
- vpc_name = client.vpc_name_by_id(vpc_id) || vpc_id
95
- vpc_dir = File.join(dir, vpc_name)
94
+ vpc_dir_basename = client.vpc_name_by_id(vpc_id) || vpc_id
95
+ vpc_dir_basename.gsub(/\s+/, '_')
96
+ vpc_dir = File.join(dir, vpc_dir_basename)
96
97
  FileUtils.mkdir_p(vpc_dir)
97
98
 
98
99
  rts.each do |rt_name, attrs|
99
- filename = "#{rt_name}.rtbl"
100
- requires << File.join(vpc_name, filename)
100
+ filename = "#{rt_name}.rtbl".gsub(/\s+/, '_')
101
+ requires << File.join(vpc_dir_basename, filename)
101
102
  rt_file = File.join(vpc_dir, filename)
102
103
 
103
104
  logger.info(" write `#{rt_file}`")
data/lib/mappru/driver.rb CHANGED
@@ -70,7 +70,6 @@ class Mappru::Driver
70
70
  log(:info, "Update Route `#{vpc_id}` > `#{rt_name}` > `#{dest_cidr}`", color: :green)
71
71
  log(:info, diff(old_route, route, color: @options[:color]), color: false)
72
72
 
73
-
74
73
  unless @options[:dry_run]
75
74
  rt_id = rt_id_by_vpc_rt_name.fetch(vpc_id).fetch(rt_name)
76
75
  params = route.merge(route_table_id: rt_id, destination_cidr_block: dest_cidr)
@@ -55,7 +55,11 @@ class Mappru::Exporter
55
55
 
56
56
  # route -> (Array<Route>, nil)
57
57
  # http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/RouteTable.html#routes-instance_method
58
- rt.routes.reject(&:nil?).each {|route|
58
+ sorted_routes = rt.routes.reject(&:nil?).sort_by do |route|
59
+ IPAddr.new(route.destination_cidr_block).to_i
60
+ end
61
+
62
+ sorted_routes.each do |route|
59
63
  # Skip "local"
60
64
  next if route.gateway_id == 'local'
61
65
 
@@ -72,7 +76,7 @@ class Mappru::Exporter
72
76
  ].each {|k| hash[k] = route.send(k) }
73
77
 
74
78
  result[:routes] << hash
75
- }
79
+ end
76
80
 
77
81
  result
78
82
  end
@@ -1,3 +1,3 @@
1
1
  module Mappru
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
data/lib/mappru.rb CHANGED
@@ -2,6 +2,7 @@ require 'aws-sdk'
2
2
  require 'diffy'
3
3
  require 'hash_modern_inspect'
4
4
  require 'hashie'
5
+ require 'ipaddr'
5
6
  require 'logger'
6
7
  require 'pp'
7
8
  require 'singleton'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mappru
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - winebarrel