Skip to content

Commit

Permalink
Revert "Unify network ID attribute"
Browse files Browse the repository at this point in the history
This reverts commit 9b88e63.
  • Loading branch information
chris1984 committed Jun 22, 2023
1 parent ca07a0d commit daa5838
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions lib/fog/vsphere/requests/compute/get_network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@ def choose_finder(ref_or_name, distributedswitch)
# only the one will do
proc do |n|
n._ref == ref_or_name || (
n.is_a?(RbVmomi::VIM::DistributedVirtualPortgroup) && (n.name == ref_or_name) &&
n.is_a?(RbVmomi::VIM::DistributedVirtualPortgroup) && (n.name == ref_or_name || n.key == ref_or_name) &&
(n.config.distributedVirtualSwitch.name == distributedswitch)
)
end
when :dvs
# the first distributed virtual switch will do - selected by network - gives control to vsphere
proc do |n|
n._ref == ref_or_name || (
n.is_a?(RbVmomi::VIM::DistributedVirtualPortgroup) && (n.name == ref_or_name)
n.is_a?(RbVmomi::VIM::DistributedVirtualPortgroup) && (n.name == ref_or_name || n.key == ref_or_name)
)
end
else
# the first matching network will do, seems like the non-distributed networks come first
proc { |n| n._ref == ref_or_name || n.name == ref_or_name }
proc { |n| n._ref == ref_or_name || n.name == ref_or_name || (n.is_a?(RbVmomi::VIM::DistributedVirtualPortgroup) && n.key == ref_or_name) }
end
end
end
Expand Down
14 changes: 8 additions & 6 deletions lib/fog/vsphere/requests/compute/list_networks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,17 @@ def list_networks(filters = {})
virtualswitch: dvswitches[network['config.distributedVirtualSwitch']._ref]
)
elsif network.obj.is_a?(RbVmomi::VIM::OpaqueNetwork)
map_attrs_to_hash(network, network_attribute_mapping).merge(
map_attrs_to_hash(network, network_dvportgroup_attribute_mapping).merge(
id: network.obj._ref,
opaqueNetworkId: network.obj.summary.opaqueNetworkId
)
else
map_attrs_to_hash(network, network_attribute_mapping)
map_attrs_to_hash(network, network_attribute_mapping).merge(
id: network.obj._ref
)
end.merge(
_ref: network.obj._ref,
id: managed_obj_id(network.obj),
datacenter: datacenter_name
datacenter: datacenter_name,
_ref: network.obj._ref
)
end.compact
end
Expand All @@ -54,7 +56,7 @@ def network_attribute_mapping

def network_dvportgroup_attribute_mapping
network_attribute_mapping.merge(
dvp_uuid: 'config.key'
id: 'config.key'
)
end

Expand Down

0 comments on commit daa5838

Please sign in to comment.