diff --git a/vmware_nsx/nsxlib/mh/lsn.py b/vmware_nsx/nsxlib/mh/lsn.py index a5f6f3e84b..a66a9fb7cb 100644 --- a/vmware_nsx/nsxlib/mh/lsn.py +++ b/vmware_nsx/nsxlib/mh/lsn.py @@ -59,7 +59,7 @@ def lsn_for_network_create(cluster, network_id): } return nsxlib.do_request(HTTP_POST, nsxlib._build_uri_path(LSERVICESNODE_RESOURCE), - jsonutils.dumps(lsn_obj), + jsonutils.dumps(lsn_obj, sort_keys=True), cluster=cluster)["uuid"] @@ -91,7 +91,7 @@ def lsn_port_host_entries_update( parent_resource_id=lsn_id, resource_id=lsn_port_id, extra_action=conf), - jsonutils.dumps(hosts_obj), + jsonutils.dumps(hosts_obj, sort_keys=True), cluster=cluster) @@ -167,7 +167,7 @@ def lsn_port_plug_network(cluster, lsn_id, lsn_port_id, lswitch_port_id): parent_resource_id=lsn_id, resource_id=lsn_port_id, is_attachment=True), - jsonutils.dumps(patch_obj), + jsonutils.dumps(patch_obj, sort_keys=True), cluster=cluster) except api_exc.Conflict: # This restriction might be lifted at some point @@ -187,7 +187,7 @@ def _lsn_configure_action( nsxlib._build_uri_path(LSERVICESNODE_RESOURCE, resource_id=lsn_id, extra_action=action), - jsonutils.dumps(lsn_obj), + jsonutils.dumps(lsn_obj, sort_keys=True), cluster=cluster) @@ -197,14 +197,15 @@ def _lsn_port_configure_action( nsxlib._build_uri_path(LSERVICESNODE_RESOURCE, resource_id=lsn_id, extra_action=action), - jsonutils.dumps({"enabled": is_enabled}), + jsonutils.dumps({"enabled": is_enabled}, + sort_keys=True), cluster=cluster) nsxlib.do_request(HTTP_PUT, nsxlib._build_uri_path(LSERVICESNODEPORT_RESOURCE, parent_resource_id=lsn_id, resource_id=lsn_port_id, extra_action=action), - jsonutils.dumps(obj), + jsonutils.dumps(obj, sort_keys=True), cluster=cluster) @@ -247,7 +248,7 @@ def _lsn_port_host_action( resource_id=lsn_port_id, extra_action=extra_action, filters={"action": action}), - jsonutils.dumps(host_obj), + jsonutils.dumps(host_obj, sort_keys=True), cluster=cluster) diff --git a/vmware_nsx/tests/unit/nsxlib/mh/test_lsn.py b/vmware_nsx/tests/unit/nsxlib/mh/test_lsn.py index 8b16b29ef6..62308ba36d 100644 --- a/vmware_nsx/tests/unit/nsxlib/mh/test_lsn.py +++ b/vmware_nsx/tests/unit/nsxlib/mh/test_lsn.py @@ -69,7 +69,7 @@ class LSNTestCase(base.BaseTestCase): lsnlib.lsn_for_network_create(self.cluster, net_id) self.mock_request.assert_called_once_with( "POST", "/ws.v1/lservices-node", - jsonutils.dumps(obj), cluster=self.cluster) + jsonutils.dumps(obj, sort_keys=True), cluster=self.cluster) def test_lsn_for_network_get(self): net_id = "foo_network_id" @@ -121,7 +121,7 @@ class LSNTestCase(base.BaseTestCase): '/ws.v1/lservices-node/%s/lport/%s/%s' % (lsn_id, lsn_port_id, lsn_type), - jsonutils.dumps({'hosts': hosts_data}), + jsonutils.dumps({'hosts': hosts_data}, sort_keys=True), cluster=self.cluster) def test_lsn_port_dhcp_entries_update(self): @@ -233,7 +233,7 @@ class LSNTestCase(base.BaseTestCase): ("/ws.v1/lservices-node/%s/lport/%s/" "attachment") % (lsn_id, lsn_port_id), jsonutils.dumps({"peer_port_uuid": lswitch_port_id, - "type": "PatchAttachment"}), + "type": "PatchAttachment"}, sort_keys=True), cluster=self.cluster) def test_lsn_port_plug_network_raise_conflict(self): @@ -256,12 +256,13 @@ class LSNTestCase(base.BaseTestCase): ] self.mock_request.assert_has_calls([ mock.call("PUT", "/ws.v1/lservices-node/%s/dhcp" % lsn_id, - jsonutils.dumps({"enabled": is_enabled}), + jsonutils.dumps({"enabled": is_enabled}, + sort_keys=True), cluster=self.cluster), mock.call("PUT", ("/ws.v1/lservices-node/%s/" "lport/%s/dhcp") % (lsn_id, lsn_port_id), - jsonutils.dumps({"options": opt_array}), + jsonutils.dumps({"options": opt_array}, sort_keys=True), cluster=self.cluster) ]) @@ -290,7 +291,7 @@ class LSNTestCase(base.BaseTestCase): self.mock_request.assert_has_calls([ mock.call("PUT", "/ws.v1/lservices-node/%s/metadata-proxy" % lsn_id, - jsonutils.dumps(lsn_obj), + jsonutils.dumps(lsn_obj, sort_keys=True), cluster=self.cluster), ]) @@ -336,7 +337,7 @@ class LSNTestCase(base.BaseTestCase): "POST", ("/ws.v1/lservices-node/%s/lport/" "%s/%s?action=%s") % (lsn_id, lsn_port_id, extra_action, action), - jsonutils.dumps(host), cluster=self.cluster) + jsonutils.dumps(host, sort_keys=True), cluster=self.cluster) def test_lsn_port_dhcp_host_add(self): host = {