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:
@@ -68,7 +68,8 @@ class BaseProxy(object):
|
|||||||
is attempted to be deleted.
|
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:
|
try:
|
||||||
rv = res.delete(self.session)
|
rv = res.delete(self.session)
|
||||||
@@ -99,7 +100,8 @@ class BaseProxy(object):
|
|||||||
:returns: The result of the ``update``
|
:returns: The result of the ``update``
|
||||||
:rtype: :class:`~openstack.resource.Resource`
|
: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)
|
res.update_attrs(attrs)
|
||||||
return res.update(self.session)
|
return res.update(self.session)
|
||||||
|
|
||||||
@@ -132,7 +134,8 @@ class BaseProxy(object):
|
|||||||
:rtype: :class:`~openstack.resource.Resource`
|
: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:
|
try:
|
||||||
return res.get(self.session)
|
return res.get(self.session)
|
||||||
except exceptions.NotFoundException as exc:
|
except exceptions.NotFoundException as exc:
|
||||||
@@ -176,7 +179,9 @@ class BaseProxy(object):
|
|||||||
:rtype: :class:`~openstack.resource.Resource`
|
:rtype: :class:`~openstack.resource.Resource`
|
||||||
"""
|
"""
|
||||||
if value is not None:
|
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:
|
else:
|
||||||
res = resource_type()
|
res = resource_type()
|
||||||
|
|
||||||
|
@@ -38,11 +38,11 @@ class TestKeypair(base.BaseFunctionalTest):
|
|||||||
sot = self.conn.compute.find_keypair(self.NAME)
|
sot = self.conn.compute.find_keypair(self.NAME)
|
||||||
self.assertEqual(self.ID, sot.id)
|
self.assertEqual(self.ID, sot.id)
|
||||||
|
|
||||||
# def test_get(self):
|
def test_get(self):
|
||||||
# sot = self.conn.compute.get_keypair(self.NAME)
|
sot = self.conn.compute.get_keypair(self.NAME)
|
||||||
# self.assertEqual(self.NAME, sot.name)
|
self.assertEqual(self.NAME, sot.name)
|
||||||
# self.assertEqual(self.ID, sot.id)
|
self.assertEqual(self.ID, sot.id)
|
||||||
#
|
|
||||||
def test_list(self):
|
def test_list(self):
|
||||||
names = [o.name for o in self.conn.compute.keypairs()]
|
names = [o.name for o in self.conn.compute.keypairs()]
|
||||||
self.assertIn(self.NAME, names)
|
self.assertIn(self.NAME, names)
|
||||||
|
Reference in New Issue
Block a user