Fix Quota ant SecurityGroup resources refreshing.
The Quota and SecurityGroup resources were not refreshed correctly. Change-Id: I5b0a9efc07bc7ef05673256df5785aca931f64d8
This commit is contained in:
parent
c879ee8cc5
commit
d17505462d
@ -18,8 +18,11 @@ from novaclient import base
|
||||
|
||||
class QuotaSet(base.Resource):
|
||||
|
||||
def get(self):
|
||||
self.manager.get(self)
|
||||
@property
|
||||
def id(self):
|
||||
"""QuotaSet does not have a 'id' attribute but base.Resource needs it
|
||||
to self-refresh and QuotaSet is indexed by tenant_id"""
|
||||
return self.tenant_id
|
||||
|
||||
def update(self, *args, **kwargs):
|
||||
self.manager.update(self.tenant_id, *args, **kwargs)
|
||||
|
@ -27,9 +27,6 @@ class SecurityGroup(base.Resource):
|
||||
def delete(self):
|
||||
self.manager.delete(self)
|
||||
|
||||
def get(self):
|
||||
self.manager.get(self)
|
||||
|
||||
|
||||
class SecurityGroupManager(base.ManagerWithFind):
|
||||
resource_class = SecurityGroup
|
||||
|
@ -36,3 +36,12 @@ class QuotaSetsTest(utils.TestCase):
|
||||
q = cs.quotas.get('test')
|
||||
q.update(volumes=2)
|
||||
cs.assert_called('PUT', '/os-quota-sets/test')
|
||||
|
||||
def test_refresh_quota(self):
|
||||
q = cs.quotas.get('test')
|
||||
q2 = cs.quotas.get('test')
|
||||
self.assertEqual(q.volumes, q2.volumes)
|
||||
q2.volumes = 0
|
||||
self.assertNotEqual(q.volumes, q2.volumes)
|
||||
q2.get()
|
||||
self.assertEqual(q.volumes, q2.volumes)
|
||||
|
@ -31,3 +31,12 @@ class SecurityGroupsTest(utils.TestCase):
|
||||
sg = cs.security_groups.create("foo", "foo barr")
|
||||
cs.assert_called('POST', '/os-security-groups')
|
||||
self.assertTrue(isinstance(sg, security_groups.SecurityGroup))
|
||||
|
||||
def test_refresh_security_group(self):
|
||||
sg = cs.security_groups.get(1)
|
||||
sg2 = cs.security_groups.get(1)
|
||||
self.assertEqual(sg.name, sg2.name)
|
||||
sg2.name = "should be test"
|
||||
self.assertNotEqual(sg.name, sg2.name)
|
||||
sg2.get()
|
||||
self.assertEqual(sg.name, sg2.name)
|
||||
|
Loading…
Reference in New Issue
Block a user