diff --git a/lib/puppet/provider/neutron_port/neutron.rb b/lib/puppet/provider/neutron_port/neutron.rb index 67b0a6dff..383cd19c0 100644 --- a/lib/puppet/provider/neutron_port/neutron.rb +++ b/lib/puppet/provider/neutron_port/neutron.rb @@ -51,6 +51,7 @@ Puppet::Type.type(:neutron_port).provide( def create opts = Array.new + dict_opts = Array.new if @resource[:admin_state_up] == "False" opts << "--admin-state-down" @@ -60,14 +61,14 @@ Puppet::Type.type(:neutron_port).provide( # The spec says that multiple ip addresses may be specified, but this # doesn't seem to work yet. opts << "--fixed-ip" - opts << @resource[:ip_address].map{|ip|"ip_address=#{ip}"}.join(',') + opts << resource[:ip_address].map{|ip|"ip_address=#{ip}"}.join(',') end if @resource[:subnet_name] # The spec says that multiple subnets may be specified, but this doesn't # seem to work yet. opts << "--fixed-ip" - opts << @resource[:subnet_name].map{|s|"subnet_id=#{s}"}.join(',') + opts << resource[:subnet_name].map{|s|"subnet_id=#{s}"}.join(',') end if @resource[:tenant_name] @@ -86,7 +87,9 @@ Puppet::Type.type(:neutron_port).provide( if @resource[:binding_profile] binding_profile_opts = @resource[:binding_profile].map{|k,v| "#{k}=#{v}"}.join(' ') - opts << "--binding:profile type=dict #{binding_profile_opts}" + dict_opts << "--binding:profile" + dict_opts << "type=dict" + dict_opts << "#{binding_profile_opts}" end results = auth_neutron( @@ -94,7 +97,8 @@ Puppet::Type.type(:neutron_port).provide( "--format=shell", "--name=#{resource[:name]}", opts, - resource[:network_name] + resource[:network_name], + dict_opts ) attrs = self.class.parse_creation_output(results) diff --git a/releasenotes/notes/fix-neutron-port-creation-50818b9dc7a9cc05.yaml b/releasenotes/notes/fix-neutron-port-creation-50818b9dc7a9cc05.yaml new file mode 100644 index 000000000..590bb38b6 --- /dev/null +++ b/releasenotes/notes/fix-neutron-port-creation-50818b9dc7a9cc05.yaml @@ -0,0 +1,11 @@ +--- +fixes: + - Parameters of type dict must be at the end of the + shell command to not cause conflict with the network name. + Neutron cli picks up the network name as the first parameter + without "--" prefix, thus tresting type=dict as the network + name instead of the real network name because it comes before. + By providing the special dictionary type commands after the + network name the behaviour of the cli is bypassed and neutron + takes the network name and proceeds interpreting parameters + with special format ( not in the form of --= ) \ No newline at end of file diff --git a/spec/unit/provider/neutron_port/neutron_spec.rb b/spec/unit/provider/neutron_port/neutron_spec.rb index 7d88d3ab9..7528d3bfa 100644 --- a/spec/unit/provider/neutron_port/neutron_spec.rb +++ b/spec/unit/provider/neutron_port/neutron_spec.rb @@ -49,7 +49,8 @@ tenant_id="60f9544eb94c42a6b7e8e98c2be981b1"' provider.expects(:auth_neutron).with('port-create', '--format=shell', "--name=#{port_attrs[:name]}", ["--tenant_id=#{port_attrs[:tenant_id]}"], - port_attrs[:network_name]).returns(output) + port_attrs[:network_name], + []).returns(output) provider.create end @@ -98,9 +99,9 @@ binding_profile="{\"interface_name\": \"eth1\"}"' '--format=shell', "--name=#{port_attrs[:name]}", ["--tenant_id=#{port_attrs[:tenant_id]}", "--binding:host_id=#{port_attrs[:binding_host_id]}", - "--binding:profile type=dict interface_name=#{port_attrs[:binding_profile]['interface_name']}", ], - port_attrs[:network_name]).returns(output) + port_attrs[:network_name], + ['--binding:profile','type=dict','interface_name=eth1']).returns(output) provider.create end