diff --git a/vmware_nsxlib/tests/unit/v3/policy/test_resources.py b/vmware_nsxlib/tests/unit/v3/policy/test_resources.py index 36a56c46..300d38d7 100644 --- a/vmware_nsxlib/tests/unit/v3/policy/test_resources.py +++ b/vmware_nsxlib/tests/unit/v3/policy/test_resources.py @@ -7508,9 +7508,11 @@ class TestPolicyShare(NsxPolicyLibTestCase): share_id, description=description, tenant=TEST_TENANT) - expected_def = core_defs.ShareDef(share_id=share_id, - description=description, - tenant=TEST_TENANT) + expected_def = core_defs.ShareDef( + share_id=share_id, + description=description, + tenant=TEST_TENANT, + sharing_strategy=constants.DEFAULT_SHARING_STRATEGY) self.assert_called_with_def(api_call, expected_def) self.assertEqual(share_id, result) @@ -7525,10 +7527,12 @@ class TestPolicyShare(NsxPolicyLibTestCase): shared_with=shared_with, description=description, tenant=TEST_TENANT) - expected_def = core_defs.ShareDef(share_id=share_id, - shared_with=shared_with, - description=description, - tenant=TEST_TENANT) + expected_def = core_defs.ShareDef( + share_id=share_id, + shared_with=shared_with, + description=description, + sharing_strategy=constants.DEFAULT_SHARING_STRATEGY, + tenant=TEST_TENANT) self.assert_called_with_def(api_call, expected_def) self.assertIsNotNone(result) @@ -7567,9 +7571,11 @@ class TestPolicyShare(NsxPolicyLibTestCase): self.resourceApi.update(share_id, description=description, tenant=TEST_TENANT) - expected_def = core_defs.ShareDef(share_id=share_id, - description=description, - tenant=TEST_TENANT) + expected_def = core_defs.ShareDef( + share_id=share_id, + description=description, + sharing_strategy=constants.DEFAULT_SHARING_STRATEGY, + tenant=TEST_TENANT) self.assert_called_with_def(update_call, expected_def) diff --git a/vmware_nsxlib/v3/policy/constants.py b/vmware_nsxlib/v3/policy/constants.py index ea7521f0..d0692273 100644 --- a/vmware_nsxlib/v3/policy/constants.py +++ b/vmware_nsxlib/v3/policy/constants.py @@ -112,3 +112,5 @@ ADV_RULE_TIER1_IPSEC_LOCAL_ENDPOINT = 'TIER1_IPSEC_LOCAL_ENDPOINT' IPSEC_VPN_RULE_PROTECT = 'PROTECT' IPSEC_VPN_RULE_BYPASS = 'BYPASS' + +DEFAULT_SHARING_STRATEGY = 'ALL_DESCENDANTS' diff --git a/vmware_nsxlib/v3/policy/core_defs.py b/vmware_nsxlib/v3/policy/core_defs.py index 62bc46a2..33776242 100644 --- a/vmware_nsxlib/v3/policy/core_defs.py +++ b/vmware_nsxlib/v3/policy/core_defs.py @@ -383,7 +383,9 @@ class ShareDef(ResourceDef): body, 'shared_with', body_attr='sharedWith') - self._set_attrs_if_specified(body, ['description', 'tags']) + self._set_attrs_if_specified( + body, + ['description', 'tags', 'sharing_strategy']) return body diff --git a/vmware_nsxlib/v3/policy/core_resources.py b/vmware_nsxlib/v3/policy/core_resources.py index 917b4149..abbf8aa7 100644 --- a/vmware_nsxlib/v3/policy/core_resources.py +++ b/vmware_nsxlib/v3/policy/core_resources.py @@ -5309,20 +5309,23 @@ class NsxPolicyShareApi(NsxPolicyResourceBase): def entry_def(self): return core_defs.ShareDef - def create_or_overwrite(self, share_id, - shared_with=IGNORE, - name=IGNORE, - description=IGNORE, - tags=IGNORE, - tenant=constants.POLICY_INFRA_TENANT): + def create_or_overwrite( + self, + share_id, + shared_with=IGNORE, + name=IGNORE, + description=IGNORE, + tags=IGNORE, + sharing_strategy=constants.DEFAULT_SHARING_STRATEGY, + tenant=constants.POLICY_INFRA_TENANT): share_id = self._init_obj_uuid(share_id) share_def = self._init_def(share_id=share_id, shared_with=shared_with, + sharing_strategy=sharing_strategy, name=name, description=description, tags=tags, tenant=tenant) - self._create_or_store(share_def) return share_id @@ -5344,9 +5347,11 @@ class NsxPolicyShareApi(NsxPolicyResourceBase): name=IGNORE, description=IGNORE, tags=IGNORE, + sharing_strategy=constants.DEFAULT_SHARING_STRATEGY, tenant=constants.POLICY_INFRA_TENANT): self._update(share_id=share_id, shared_with=shared_with, + sharing_strategy=sharing_strategy, name=name, description=description, tags=tags,