Merge "provider/neutron.rb: fix list_router_ports"

This commit is contained in:
Jenkins 2015-12-30 11:29:57 +00:00 committed by Gerrit Code Review
commit fd0d670c58
2 changed files with 27 additions and 2 deletions

View File

@ -210,8 +210,10 @@ correctly configured.")
self.find_and_parse_json(cmd_output).each do |port|
if port['fixed_ips']
fixed_ips = JSON.parse(port['fixed_ips'])
port['subnet_id'] = fixed_ips['subnet_id']
if !port['fixed_ips'].empty?
fixed_ips = JSON.parse(port['fixed_ips'])
port['subnet_id'] = fixed_ips['subnet_id']
end
port.delete('fixed_ips')
end
results << port

View File

@ -243,6 +243,29 @@ describe Puppet::Provider::Neutron do
expect(result).to eql(expected)
end
it 'should handle empty fixed_ips field' do
output = '''
[
{
"id": "1345e576-a21f-4c2e-b24a-b245639852ab",
"name": "",
"mac_address": "fa:16:3e:e3:e6:38",
"fixed_ips": ""
}
]
'''
expected =
[{ "name"=>"",
"id"=>"1345e576-a21f-4c2e-b24a-b245639852ab",
"mac_address"=>"fa:16:3e:e3:e6:38"}]
klass.expects(:auth_neutron).
with('router-port-list', '--format=json', router).
returns(output)
result = klass.list_router_ports(router)
expect(result).to eql(expected)
end
end
describe 'when parsing creation output' do