From 7c1c082be0e9c9bacfd251fe3fa1de33a0d2864f Mon Sep 17 00:00:00 2001 From: Kristine Bujold Date: Fri, 9 Nov 2018 10:23:56 -0500 Subject: [PATCH] DC fix audit sync failure During the sync Security Group needs to be compared with the tenant names and not tenant ids. The tenant id which is the uuid are different between regions. The compare does not match and an attempt to create the Security Group fails since it already exists. This commit changes the compare to use tenant names. Closes-Bug: 1802397 Change-Id: I9363945868b857802e137dcf05757ec3691230c1 Signed-off-by: Kristine Bujold --- dcorch/engine/sync_services/network.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/dcorch/engine/sync_services/network.py b/dcorch/engine/sync_services/network.py index 8e22d21d1..d04fa4222 100644 --- a/dcorch/engine/sync_services/network.py +++ b/dcorch/engine/sync_services/network.py @@ -22,6 +22,7 @@ from oslo_serialization import jsonutils from dcorch.common import consts from dcorch.common import exceptions +from dcorch.drivers.openstack import sdk from dcorch.engine import quota_manager from dcorch.engine.sync_thread import SyncThread from dcorch.objects import resource @@ -417,14 +418,31 @@ class NetworkSyncThread(SyncThread): self.post_security_group_rule(request, rsrc) def same_security_group(self, qc1, qc2): + # Fetch the tenant name from the project. Tenant ids are different + # between regions. + qc1_tenant_name = sdk.OpenStackDriver().get_project_by_id( + qc1['tenant_id']).name + qc2_tenant_name = sdk.OpenStackDriver( + self.subcloud_engine.subcloud.region_name).get_project_by_id( + qc2['tenant_id']).name + return (qc1['description'] == qc2['description'] and - qc1['tenant_id'] == qc2['tenant_id'] and + qc1_tenant_name == qc2_tenant_name and qc1['name'] == qc2['name']) def same_security_group_rule(self, qc1, qc2): # Ignore id, created_at, updated_at, and revision_number + + # Fetch the tenant name from the project. Tenant id are different + # between regions. + qc1_tenant_name = sdk.OpenStackDriver().get_project_by_id( + qc1['tenant_id']).name + qc2_tenant_name = sdk.OpenStackDriver( + self.subcloud_engine.subcloud.region_name).get_project_by_id( + qc2['tenant_id']).name + return (qc1['description'] == qc2['description'] and - qc1['tenant_id'] == qc2['tenant_id'] and + qc1_tenant_name == qc2_tenant_name and qc1['project_id'] == qc2['project_id'] and qc1['direction'] == qc2['direction'] and qc1['protocol'] == qc2['protocol'] and