Skip to content

Commit

Permalink
Merge pull request #64 from tumido/fog-1.5.0
Browse files Browse the repository at this point in the history
Upgrade to fog-google 1.5.0
(cherry picked from commit ba0968c)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1592504
  • Loading branch information
Bronagh Sorota authored and simaishi committed Jun 18, 2018
1 parent 776f7c1 commit 622fbf2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3,022 deletions.
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.subnetworks.all
# 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 All @@ -193,22 +193,23 @@ def subnetworks
:self_link => x.self_link,
:description => "Subnetwork placeholder for GCE legacy networks without subnetworks",
:creation_timestamp => x.creation_timestamp,
:kind => x.kind)
:kind => x.kind
)
end
end

@subnetworks
end

def subnets_by_link(subnet)
@subnets_by_link ||= subnetworks.each_with_object({}) { |x, subnets| subnets[x[:self_link]] = x }
@subnets_by_link ||= subnetworks.each_with_object({}) { |x, subnets| subnets[x.self_link] = x }

# For legacy GCE networks without subnets, we also try a network link
@subnets_by_link[subnet[:subnetwork]] || @subnets_by_link[subnet[:network]]
end

def subnets_by_network_link(network_link)
@subnets_by_network_link ||= subnetworks.each_with_object({}) { |x, subnets| (subnets[x[:network]] ||= []) << x }
@subnets_by_network_link ||= subnetworks.each_with_object({}) { |x, subnets| (subnets[x.network] ||= []) << x }

@subnets_by_network_link[network_link]
end
Expand Down Expand Up @@ -432,7 +433,7 @@ def parse_load_balancer_health_check_members(target_pool)
# "OutOfService" if we can't find a mapping.
status = "OutOfService"
unless instance_health.nil?
gcp_status = instance_health[0]["healthState"]
gcp_status = instance_health[0][:health_state]

if GCP_HEALTH_STATUS_MAP.include?(gcp_status)
status = GCP_HEALTH_STATUS_MAP[gcp_status]
Expand All @@ -458,7 +459,7 @@ def parse_cloud_network(network)

subnets = subnets_by_network_link(network.self_link) || []
get_cloud_subnets(subnets)
cloud_subnets = subnets.collect { |s| @data_index.fetch_path(:cloud_subnets, s[:id].to_s) }
cloud_subnets = subnets.collect { |s| @data_index.fetch_path(:cloud_subnets, s.id.to_s) }

new_result = {
:ems_ref => uid,
Expand All @@ -474,17 +475,17 @@ def parse_cloud_network(network)
end

def parse_cloud_subnet(subnet)
uid = subnet[:id].to_s
uid = subnet.id.to_s

name = subnet[:name] || uid
name = subnet.name || uid

new_result = {
:type => self.class.cloud_subnet_type,
:ems_ref => uid,
:name => name,
:status => "active",
:cidr => subnet[:ip_cidr_range],
:gateway => subnet[:gateway_address],
:cidr => subnet.ip_cidr_range,
:gateway => subnet.gateway_address,
}

return uid, new_result
Expand Down Expand Up @@ -578,7 +579,7 @@ def parse_cloud_subnet_network_port(cloud_subnet_network_port, subnet_id)
def parse_network_port(network_port)
uid = network_port[:network_ip]
cloud_subnet_network_ports = [
parse_cloud_subnet_network_port(network_port, subnets_by_link(network_port).try(:[], :id))
parse_cloud_subnet_network_port(network_port, subnets_by_link(network_port).try(:id))
]
device = parent_manager_fetch_path(:vms, network_port[:device_id].to_s)
security_groups = [
Expand Down
2 changes: 1 addition & 1 deletion manageiq-providers-google.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Gem::Specification.new do |s|

s.files = Dir["{app,config,lib}/**/*"]

s.add_dependency "fog-google", ">=1.3.3"
s.add_dependency "fog-google", ">=1.5.0"

s.add_development_dependency "codeclimate-test-reporter", "~> 1.0.0"
s.add_development_dependency "simplecov"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ def expected_table_counts
:load_balancer_listener_pool => 4,
:load_balancer_pool_member => 3,
:load_balancer_pool_member_pool => 4,
:miq_template => 1631,
:miq_template => 1511,
:network => 0,
:network_port => 15,
:network_router => 0,
:operating_system => 1643,
:operating_system => 1523,
:orchestration_stack => 0,
:orchestration_stack_output => 0,
:orchestration_stack_parameter => 0,
Expand All @@ -96,7 +96,7 @@ def expected_table_counts
:resource_group => 0,
:security_group => 3,
:vm => 15,
:vm_or_template => 1646,
:vm_or_template => 1526,
}
end

Expand Down
Loading

0 comments on commit 622fbf2

Please sign in to comment.