From 0d5da8224caa9bdb687cb052e44b7e5fc36b49e2 Mon Sep 17 00:00:00 2001 From: Gary Kotton Date: Tue, 15 Aug 2017 16:25:27 -0700 Subject: [PATCH] Ensure retry on stale resources for exclude list updates Change-Id: I075243c5a946ba03178f0d1e36c7d6b74819af88 --- vmware_nsxlib/v3/security.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/vmware_nsxlib/v3/security.py b/vmware_nsxlib/v3/security.py index 7fc32bbe..2b690aaf 100644 --- a/vmware_nsxlib/v3/security.py +++ b/vmware_nsxlib/v3/security.py @@ -227,15 +227,27 @@ class NsxLibNsGroup(utils.NsxLibApiBase): class NsxLibFirewallSection(utils.NsxLibApiBase): def add_member_to_fw_exclude_list(self, target_id, target_type): - resource = 'firewall/excludelist?action=add_member' - body = {"target_id": target_id, - "target_type": target_type} - self.client.create(resource, body) + @utils.retry_upon_exception( + exceptions.StaleRevision, + max_attempts=self.nsxlib_config.max_attempts) + def _add_member_to_fw_exclude_list(): + resource = 'firewall/excludelist?action=add_member' + body = {"target_id": target_id, + "target_type": target_type} + self.client.create(resource, body) + + _add_member_to_fw_exclude_list() def remove_member_from_fw_exclude_list(self, target_id, target_type): - resource = ('firewall/excludelist?action=remove_member&object_id=' - + target_id) - self.client.create(resource) + @utils.retry_upon_exception( + exceptions.StaleRevision, + max_attempts=self.nsxlib_config.max_attempts) + def _remove_member_from_fw_exclude_list(): + resource = ('firewall/excludelist?action=remove_member&object_id=' + + target_id) + self.client.create(resource) + + _remove_member_from_fw_exclude_list() def get_excludelist(self): return self.client.list('firewall/excludelist')