소스 검색

Merge branch 'master' of ssh://gogs.mague.com:7022/Shokunin/neo-infra

Chris Mague 6 년 전
부모
커밋
0aa3598440
1개의 변경된 파일16개의 추가작업 그리고 12개의 파일을 삭제
  1. 16 12
      lib/neoinfra/aws.rb

+ 16 - 12
lib/neoinfra/aws.rb

@@ -49,19 +49,23 @@ module NeoInfra
     end
 
     def azs(region)
-      account = @cfg.accounts.first
-      base_conf = {
-        provider: 'AWS',
-        aws_access_key_id: account[:key],
-        aws_secret_access_key: account[:secret],
-        region: region
-      }
-      begin
-        conn = Fog::Compute.new(base_conf)
-        conn.describe_availability_zones.data[:body]['availabilityZoneInfo'].collect { |x| x['zoneName'] }
-      rescue Exception => e
-        puts "Zone couldn't load region #{region}: #{e.message}"
+      azs = []
+      @cfg.accounts.each do |account|
+        next unless Region.where(region: region).empty?
+        base_conf = {
+          provider: 'AWS',
+          aws_access_key_id: account[:key],
+          aws_secret_access_key: account[:secret],
+          region: region
+        }
+        begin
+          conn = Fog::Compute.new(base_conf)
+          azs << conn.describe_availability_zones.data[:body]['availabilityZoneInfo'].collect { |x| x['zoneName'] }
+        rescue Exception => e
+          puts "Zone couldn't load region #{region}: #{e.message}"
+        end
       end
+      azs.uniq
     end
 
     def load_regions