Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decode the dvSwitch and dvPortgroup name #4

Merged
merged 3 commits into from
Feb 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -447,14 +447,15 @@ def self.host_inv_to_switch_hashes(inv, dvswitch_inv, dvswitch_uid_ems)
dvswitch_inv.to_miq_a.each do |data|
config = data.fetch('config', {})
uid = data['MOR']
name = config['name'] || data.fetch_path('summary', 'name')
security_policy = config.fetch('defaultPortConfig', {}).fetch('securityPolicy', {})
allow_promiscuous = security_policy.fetch_path('allowPromiscuous', 'value')
forged_transmits = security_policy.fetch_path('forgedTransmits', 'value')
mac_changes = security_policy.fetch_path('macChanges', 'value')

dvswitch_uid_ems[uid] || dvswitch_uid_ems[uid] = {
:uid_ems => uid,
:name => config['name'] || data.fetch_path('summary', 'name'),
:name => URI.decode(name),
:ports => config['numPorts'] || 0,

:allow_promiscuous => allow_promiscuous.nil? ? nil : allow_promiscuous.to_s.casecmp('true') == 0,
Expand Down Expand Up @@ -524,7 +525,7 @@ def self.host_inv_to_lan_hashes(inv, switch_uids, dvportgroup_inv, dvportgroup_u
unless dvportgroup_uid_ems.key?(uid)
dvportgroup_uid_ems[uid] = {
:uid_ems => uid,
:name => spec['name'],
:name => URI.decode(spec['name']),
:tag => spec.fetch_path('defaultPortConfig', 'vlan', 'vlanId').to_s,

:allow_promiscuous => security_policy.fetch_path('allowPromiscuous', 'value').to_s.casecmp('true') == 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
assert_specific_storage
assert_specific_storage_cluster
assert_specific_storage_profile
assert_specific_dvportgroup
assert_specific_host
assert_specific_vm
assert_cpu_layout
Expand Down Expand Up @@ -351,6 +352,13 @@ def assert_specific_storage_profile
expect(@storage.storage_profiles).to include(@storage_profile)
end

def assert_specific_dvportgroup
# Check that a dvPortgroup with a slash in the name is decoded from
# %2f to / by the RefreshParser
dvpg = Lan.find_by(:uid_ems => 'dvportgroup-122')
expect(dvpg.name).to eq('DC1 / DVPG1')
end

def assert_specific_host
@host = ManageIQ::Providers::Vmware::InfraManager::Host.find_by(:name => "VI4ESXM1.manageiq.com")
expect(@host).to have_attributes(
Expand Down
4 changes: 2 additions & 2 deletions spec/tools/vim_data/miq_vim_inventory/dvPortgroupsByMor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
xsiType: :SOAP::SOAPString
vimType:
name: !ruby/string:VimString
str: DC1_DVPG1
str: DC1 %2f DVPG1
xsiType: :SOAP::SOAPString
vimType:
ivars:
Expand All @@ -180,7 +180,7 @@
summary: !ruby/hash-with-ivars:VimHash
elements:
name: !ruby/string:VimString
str: DC1_DVPG1
str: DC1 %2f DVPG1
xsiType: :SOAP::SOAPString
vimType:
ivars:
Expand Down