From 1e4b227e6fcf5bf3128d012c125760a7f947ec03 Mon Sep 17 00:00:00 2001 From: kgottholm Date: Tue, 23 May 2017 12:40:56 -0400 Subject: [PATCH] Os port fix (#24913) * replace deprecated cmp() with custom conditional cmp is not present in Python3 but several modules use it Reference 24756 --- lib/ansible/modules/cloud/amazon/ec2_vpc_endpoint.py | 2 +- lib/ansible/modules/cloud/openstack/os_port.py | 3 +-- lib/ansible/modules/cloud/vmware/vmware_cluster.py | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_endpoint.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_endpoint.py index a5b60bcbf5..9273bf8497 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_endpoint.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_endpoint.py @@ -235,7 +235,7 @@ def setup_creation(client, module): if endpoint['VpcId'] == vpc_id and endpoint['ServiceName'] == service_name: sorted_endpoint_rt_ids = sorted(endpoint['RouteTableIds']) sorted_route_table_ids = sorted(route_table_ids) - if cmp(sorted_endpoint_rt_ids, sorted_route_table_ids) == 0: + if sorted_endpoint_rt_ids == sorted_route_table_ids: return False, camel_dict_to_snake_dict(endpoint) changed, result = create_vpc_endpoint(client, module) diff --git a/lib/ansible/modules/cloud/openstack/os_port.py b/lib/ansible/modules/cloud/openstack/os_port.py index 04bbcd148c..5fd6a63b98 100644 --- a/lib/ansible/modules/cloud/openstack/os_port.py +++ b/lib/ansible/modules/cloud/openstack/os_port.py @@ -233,8 +233,7 @@ def _needs_update(module, port, cloud): if module.params[key] is not None and module.params[key] != port[key]: return True for key in compare_dict: - if module.params[key] is not None and cmp(module.params[key], - port[key]) != 0: + if module.params[key] is not None and module.params[key] != port[key]: return True for key in compare_list: if module.params[key] is not None and (set(module.params[key]) != diff --git a/lib/ansible/modules/cloud/vmware/vmware_cluster.py b/lib/ansible/modules/cloud/vmware/vmware_cluster.py index e9635897b0..b21e135f06 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_cluster.py +++ b/lib/ansible/modules/cloud/vmware/vmware_cluster.py @@ -223,7 +223,7 @@ class VMwareCluster(object): self.cluster.configurationEx.drsConfig.enabled, self.cluster.configurationEx.vsanConfigInfo.enabled) - if cmp(desired_state, current_state) != 0: + if desired_state != current_state: return 'update' else: return 'present'