Skip to content

Commit

Permalink
Merge pull request #59 from tumido/fog_google_upgrade
Browse files Browse the repository at this point in the history
Follow up on #54 "Fog google upgrade (to 1.3.3)" code cleanup
  • Loading branch information
agrare committed Jun 4, 2018
2 parents d57070d + 524bc14 commit 466bbd5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ def get_zones
def get_flavors
# Google API returns a duplicate flavor for every zone
# so build a unique list of flavors using the flavor
flavors = @connection.list_aggregated_machine_types.items.values.each_with_object([]) do |zone, arr|
arr.concat(zone.machine_types) if zone.machine_types
end
flavors.uniq!(&:id)
flavors_by_zone = @connection.list_aggregated_machine_types.items
flavors = flavors_by_zone.values.flat_map(&:machine_types).compact.uniq(&:id)

process_collection(flavors, :flavors) { |flavor| parse_flavor(flavor) }
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def get_cloud_networks

def subnetworks
unless @subnetworks
@subnetworks = @connection.list_aggregated_subnetworks.to_h[:items].flat_map { |_, v| v[:subnetworks] }
@subnetworks = @connection.list_aggregated_subnetworks.to_h[:items].values.flat_map { |v| v[:subnetworks] }
# For a backwards compatibility, old GCE networks were created without subnet. It's not possible now, but
# GCE haven't migrated to new format. We will create a fake subnet for each network without subnets.
@subnetworks += @connection.networks.select { |x| x.ipv4_range.present? }.map do |x|
Expand Down

0 comments on commit 466bbd5

Please sign in to comment.