Make private flavor tenant access works
Make private flavor tenant access works. Change-Id: Ibcb82d3518320534e9e0397e9d0651c3b602d439 Closes-Bug: #1719805
This commit is contained in:
parent
4a6aecc5df
commit
13cd27a955
|
@ -167,10 +167,10 @@ class NovaFlavor(resource.Resource):
|
|||
if flavor_keys:
|
||||
flavor.set_keys(flavor_keys)
|
||||
|
||||
if not self.IS_PUBLIC:
|
||||
if not self.properties[self.IS_PUBLIC]:
|
||||
if not tenants:
|
||||
LOG.info('Tenant property is recommended if IS_PUBLIC '
|
||||
'is false.')
|
||||
LOG.info('Tenant property is recommended '
|
||||
'for the private flavors.')
|
||||
tenant = self.stack.context.tenant_id
|
||||
self.client().flavor_access.add_tenant_access(flavor, tenant)
|
||||
else:
|
||||
|
@ -189,7 +189,7 @@ class NovaFlavor(resource.Resource):
|
|||
if new_keys is not None:
|
||||
flavor.set_keys(new_keys)
|
||||
"""Update tenant access list."""
|
||||
if self.TENANTS in prop_diff and not self.IS_PUBLIC:
|
||||
if self.TENANTS in prop_diff and not self.properties[self.IS_PUBLIC]:
|
||||
kwargs = {'flavor': self.resource_id}
|
||||
old_tenants = [
|
||||
x.tenant_id for x in self.client().flavor_access.list(**kwargs)
|
||||
|
|
|
@ -118,7 +118,6 @@ class NovaFlavorTest(common.HeatTestCase):
|
|||
flavor_id = '927202df-1afb-497f-8368-9c2d2f26e5db'
|
||||
value.id = flavor_id
|
||||
value.is_public = False
|
||||
self.my_flavor.IS_PUBLIC = False
|
||||
self.flavors.create.return_value = value
|
||||
self.flavors.get.return_value = value
|
||||
self.my_flavor.handle_create()
|
||||
|
@ -143,12 +142,11 @@ class NovaFlavorTest(common.HeatTestCase):
|
|||
value.set_keys.assert_called_once_with(new_keys)
|
||||
|
||||
def test_flavor_handle_update_add_tenants(self):
|
||||
self.create_flavor()
|
||||
self.create_flavor(is_public=False)
|
||||
value = mock.MagicMock()
|
||||
|
||||
new_tenants = ["new_foo", "new_bar"]
|
||||
prop_diff = {'tenants': new_tenants}
|
||||
self.my_flavor.IS_PUBLIC = False
|
||||
self.flavors.get.return_value = value
|
||||
|
||||
self.my_flavor.handle_update(json_snippet=None,
|
||||
|
@ -165,7 +163,6 @@ class NovaFlavorTest(common.HeatTestCase):
|
|||
|
||||
new_tenants = []
|
||||
prop_diff = {'tenants': new_tenants}
|
||||
self.my_flavor.IS_PUBLIC = False
|
||||
self.flavors.get.return_value = value
|
||||
|
||||
itemFoo = mock.MagicMock()
|
||||
|
|
Loading…
Reference in New Issue