binding.vnic_type = vnic_type
changes = True
- # CLI can't send {}, so treat None as {}.
- profile = attrs and attrs.get(portbindings.PROFILE) or {}
- if (profile is not attributes.ATTR_NOT_SPECIFIED and
- self._get_profile(binding) != profile):
+ # treat None as clear of profile.
+ profile = None
+ if attrs and portbindings.PROFILE in attrs:
+ profile = attrs.get(portbindings.PROFILE) or {}
+
+ if profile not in (None, attributes.ATTR_NOT_SPECIFIED,
+ self._get_profile(binding)):
binding.profile = jsonutils.dumps(profile)
if len(binding.profile) > models.BINDING_PROFILE_LEN:
msg = _("binding:profile value too large")
# should have returned before calling _make_port_dict
self.assertFalse(mpd_mock.mock_calls)
+ def test_port_binding_profile_not_changed(self):
+ profile = {'e': 5}
+ profile_arg = {portbindings.PROFILE: profile}
+ with self.port(arg_list=(portbindings.PROFILE,),
+ **profile_arg) as port:
+ self._check_port_binding_profile(port['port'], profile)
+ port_id = port['port']['id']
+ state_arg = {'admin_state_up': True}
+ port = self._update('ports', port_id,
+ {'port': state_arg})['port']
+ self._check_port_binding_profile(port, profile)
+ port = self._show('ports', port_id)['port']
+ self._check_port_binding_profile(port, profile)
+
class TestMl2PortBindingNoSG(TestMl2PortBinding):
HAS_PORT_FILTER = False