sample_data.rake 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # frozen_string_literal: true
  2. require 'yaml'
  3. namespace :sample_data do
  4. sample_data = YAML.load_file(
  5. File.join(File.dirname(File.expand_path(__FILE__)), 'sample_data.yaml')
  6. )
  7. Neo4j::Session.open(:server_db, 'http://localhost:7474')
  8. task :accounts do
  9. puts 'loading accounts'
  10. sample_data['accounts'].each do |account|
  11. next unless AwsAccount.where(name: account[:name]).empty?
  12. acct = AwsAccount.new(
  13. name: account[:name],
  14. account_id: 90000+rand(20),
  15. user_id: account[:name],
  16. key_md5: Digest:: MD5.hexdigest(account[:name]),
  17. secret_md5: Digest:: MD5.hexdigest(account[:name])
  18. )
  19. acct.save
  20. end
  21. end
  22. task :vpcs do
  23. puts 'loading vpcs'
  24. j = NeoInfra::Vpcs.new
  25. end
  26. task :regions do
  27. puts 'loading regions'
  28. j = NeoInfra::Aws.new
  29. end
  30. task :buckets do
  31. puts 'loading buckets'
  32. j = NeoInfra::Aws.new
  33. end
  34. task :nodes do
  35. puts 'loading nodes'
  36. #j = NeoInfra::Nodes.new
  37. end
  38. desc 'Load Sample Data'
  39. task all: %i[accounts regions vpcs buckets nodes]
  40. end