Modify cloud.get_aggregate to use proxy.find

Seems that in some cases old cloud layer is not able to find aggregate
properly causing it's deletion to fail. Use the proxy.find method
instead of own listing (anyway a proper approach in the long run).

Change-Id: I04831a3d25db81ac1a37b450faa0da165518a8c2
Required-By: https://review.opendev.org/c/openstack/devstack/+/766622
This commit is contained in:
Artem Goncharov 2020-12-15 16:23:08 +01:00
parent fcffa668a8
commit 4b8f5ff008
2 changed files with 21 additions and 13 deletions

View File

@ -1591,7 +1591,10 @@ class ComputeCloudMixin(_normalize.Normalizer):
found.
"""
return _utils._get_entity(self, 'aggregate', name_or_id, filters)
aggregate = self.compute.find_aggregate(
name_or_id, ignore_missing=True)
if aggregate:
return aggregate._to_munch()
def create_aggregate(self, name, availability_zone=None):
"""Create a new host aggregate.

View File

@ -84,10 +84,15 @@ class TestAggregate(base.TestCase):
dict(
method='GET',
uri=self.get_mock_url(
'compute', 'public', append=['os-aggregates']
'compute', 'public', append=['os-aggregates',
self.aggregate_name]
),
json={'aggregates': [self.fake_aggregate]},
status_code=404,
),
dict(method='GET',
uri=self.get_mock_url(
'compute', 'public', append=['os-aggregates']),
json={'aggregates': [self.fake_aggregate]}),
dict(method='DELETE',
uri=self.get_mock_url(
'compute', 'public', append=['os-aggregates', '1'])),
@ -101,8 +106,8 @@ class TestAggregate(base.TestCase):
self.register_uris([
dict(method='GET',
uri=self.get_mock_url(
'compute', 'public', append=['os-aggregates']),
json={'aggregates': [self.fake_aggregate]}),
'compute', 'public', append=['os-aggregates', '1']),
json=self.fake_aggregate),
dict(method='PUT',
uri=self.get_mock_url(
'compute', 'public', append=['os-aggregates', '1']),
@ -122,8 +127,8 @@ class TestAggregate(base.TestCase):
self.register_uris([
dict(method='GET',
uri=self.get_mock_url(
'compute', 'public', append=['os-aggregates']),
json={'aggregates': [self.fake_aggregate]}),
'compute', 'public', append=['os-aggregates', '1']),
json=self.fake_aggregate),
dict(method='PUT',
uri=self.get_mock_url(
'compute', 'public', append=['os-aggregates', '1']),
@ -144,8 +149,8 @@ class TestAggregate(base.TestCase):
self.register_uris([
dict(method='GET',
uri=self.get_mock_url(
'compute', 'public', append=['os-aggregates']),
json={'aggregates': [self.fake_aggregate]}),
'compute', 'public', append=['os-aggregates', '1']),
json=self.fake_aggregate),
dict(method='POST',
uri=self.get_mock_url(
'compute', 'public',
@ -163,8 +168,8 @@ class TestAggregate(base.TestCase):
self.register_uris([
dict(method='GET',
uri=self.get_mock_url(
'compute', 'public', append=['os-aggregates']),
json={'aggregates': [self.fake_aggregate]}),
'compute', 'public', append=['os-aggregates', '1']),
json=self.fake_aggregate),
dict(method='POST',
uri=self.get_mock_url(
'compute', 'public',
@ -182,8 +187,8 @@ class TestAggregate(base.TestCase):
self.register_uris([
dict(method='GET',
uri=self.get_mock_url(
'compute', 'public', append=['os-aggregates']),
json={'aggregates': [self.fake_aggregate]}),
'compute', 'public', append=['os-aggregates', '1']),
json=self.fake_aggregate),
dict(method='POST',
uri=self.get_mock_url(
'compute', 'public',