Browse Source

grab all vpc information

Chris Mague 7 years ago
parent
commit
bc08cc639b
3 changed files with 13 additions and 2 deletions
  1. 2 1
      Rakefile
  2. 9 1
      lib/neoinfra/vpcs.rb
  3. 2 0
      models/vpc.rb

+ 2 - 1
Rakefile

@@ -31,11 +31,12 @@ task :load_accounts do
   j.load
 end
 
-desc 'Load accounts into the neo4j container'
+desc 'Load VPCs into the neo4j container'
 task :load_vpcs do
   j = NeoInfra::Vpcs.new
   j.load
 end
 
+desc 'Load Everything'
 task load_all: %i[load_accounts load_vpcs]
 task full_test: %i[rubocop spec]

+ 9 - 1
lib/neoinfra/vpcs.rb

@@ -27,6 +27,7 @@ module NeoInfra
         aws.regions.each do |region|
           region_conf = {:region => region['regionName'] }
           new_conn = Fog::Compute.new(region_conf.merge(base_conf))
+          # Get VPCs
           new_conn.vpcs.all.each do |vpc|
             if Vpc.where(vpc_id: vpc.id).length < 1
               if vpc.tags.empty?
@@ -38,11 +39,18 @@ module NeoInfra
                   vpc_name = vpc.id
                 end
               end
-              vpc_id = Vpc.new(:vpc_id => vpc.id, :name => vpc_name, :cidr => vpc.cidr_block)
+              vpc_id = Vpc.new(
+                :vpc_id => vpc.id,
+                :name => vpc_name,
+                :cidr => vpc.cidr_block,
+                :state => vpc.state,
+                :default => vpc.is_default.to_s
+              )
               vpc_id.save
               AccountVpc.create(from_node: vpc_id, to_node: AwsAccount.where(name: account[:name]).first )
             end
           end
+        # Get all Subnets
         end
       end
     end

+ 2 - 0
models/vpc.rb

@@ -8,6 +8,8 @@ class Vpc
   property :vpc_id, constraint: :unique
   property :name
   property :cidr
+  property :default
+  property :state
   has_one :out, :region, rel_class: :VpcRegion
   has_one :out, :owned, rel_class: :AccountVpc
   has_many :out, :az, rel_class: :VpcAz