Add id_attribute to base proxy calls
If the id attribute was not id, the base proxy was broken. Change-Id: Ib571f5fab8bfb3ea4674b8524a490b98b8d55c2c Closes-Bug: #1457513
This commit is contained in:
parent
f375e3070c
commit
25049be285
@ -68,7 +68,8 @@ class BaseProxy(object):
|
||||
is attempted to be deleted.
|
||||
|
||||
"""
|
||||
res = resource_type.existing(id=resource.Resource.get_id(value))
|
||||
args = {resource_type.id_attribute: resource.Resource.get_id(value)}
|
||||
res = resource_type.existing(**args)
|
||||
|
||||
try:
|
||||
rv = res.delete(self.session)
|
||||
@ -99,7 +100,8 @@ class BaseProxy(object):
|
||||
:returns: The result of the ``update``
|
||||
:rtype: :class:`~openstack.resource.Resource`
|
||||
"""
|
||||
res = resource_type.existing(id=resource.Resource.get_id(value))
|
||||
args = {resource_type.id_attribute: resource.Resource.get_id(value)}
|
||||
res = resource_type.existing(**args)
|
||||
res.update_attrs(attrs)
|
||||
return res.update(self.session)
|
||||
|
||||
@ -132,7 +134,8 @@ class BaseProxy(object):
|
||||
:rtype: :class:`~openstack.resource.Resource`
|
||||
"""
|
||||
|
||||
res = resource_type.existing(id=resource.Resource.get_id(value))
|
||||
args = {resource_type.id_attribute: resource.Resource.get_id(value)}
|
||||
res = resource_type.existing(**args)
|
||||
try:
|
||||
return res.get(self.session)
|
||||
except exceptions.NotFoundException as exc:
|
||||
@ -176,7 +179,9 @@ class BaseProxy(object):
|
||||
:rtype: :class:`~openstack.resource.Resource`
|
||||
"""
|
||||
if value is not None:
|
||||
res = resource_type.existing(id=resource.Resource.get_id(value))
|
||||
args = {
|
||||
resource_type.id_attribute: resource.Resource.get_id(value)}
|
||||
res = resource_type.existing(**args)
|
||||
else:
|
||||
res = resource_type()
|
||||
|
||||
|
@ -38,11 +38,11 @@ class TestKeypair(base.BaseFunctionalTest):
|
||||
sot = self.conn.compute.find_keypair(self.NAME)
|
||||
self.assertEqual(self.ID, sot.id)
|
||||
|
||||
# def test_get(self):
|
||||
# sot = self.conn.compute.get_keypair(self.NAME)
|
||||
# self.assertEqual(self.NAME, sot.name)
|
||||
# self.assertEqual(self.ID, sot.id)
|
||||
#
|
||||
def test_get(self):
|
||||
sot = self.conn.compute.get_keypair(self.NAME)
|
||||
self.assertEqual(self.NAME, sot.name)
|
||||
self.assertEqual(self.ID, sot.id)
|
||||
|
||||
def test_list(self):
|
||||
names = [o.name for o in self.conn.compute.keypairs()]
|
||||
self.assertIn(self.NAME, names)
|
||||
|
Loading…
x
Reference in New Issue
Block a user