Merge "Remove redundant method handle_get_attributes"
This commit is contained in:
commit
5387ab44dc
@ -101,19 +101,6 @@ class NeutronResource(resource.Resource):
|
||||
self.physical_resource_name())
|
||||
return props
|
||||
|
||||
@staticmethod
|
||||
def handle_get_attributes(name, key, attributes):
|
||||
'''
|
||||
Support method for responding to FnGetAtt
|
||||
'''
|
||||
if key == 'show':
|
||||
return attributes
|
||||
|
||||
if key in attributes.keys():
|
||||
return attributes[key]
|
||||
|
||||
raise exception.InvalidTemplateAttribute(resource=name, key=key)
|
||||
|
||||
@staticmethod
|
||||
def is_built(attributes):
|
||||
if attributes['status'] == 'BUILD':
|
||||
@ -132,7 +119,10 @@ class NeutronResource(resource.Resource):
|
||||
except NeutronClientException as ex:
|
||||
LOG.warn(_("failed to fetch resource attributes: %s") % ex)
|
||||
return None
|
||||
return self.handle_get_attributes(self.name, name, attributes)
|
||||
if name == 'show':
|
||||
return attributes
|
||||
|
||||
return attributes[name]
|
||||
|
||||
def _confirm_delete(self):
|
||||
while True:
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
import copy
|
||||
|
||||
import mock
|
||||
import mox
|
||||
from neutronclient.common import exceptions as qe
|
||||
from neutronclient.v2_0 import client as neutronclient
|
||||
@ -514,6 +515,27 @@ class NeutronTest(HeatTestCase):
|
||||
'status': 'FROBULATING'
|
||||
})
|
||||
|
||||
def test_resolve_attribute(self):
|
||||
class SomeNeutronResource(qr):
|
||||
properties_schema = {}
|
||||
|
||||
tmpl = rsrc_defn.ResourceDefinition('test_res', 'Foo')
|
||||
stack = mock.MagicMock()
|
||||
res = SomeNeutronResource('aresource', tmpl, stack)
|
||||
|
||||
mock_show_resource = mock.MagicMock()
|
||||
mock_show_resource.side_effect = [{'attr1': 'val1', 'attr2': 'val2'},
|
||||
{'attr1': 'val1', 'attr2': 'val2'},
|
||||
{'attr1': 'val1', 'attr2': 'val2'},
|
||||
qe.NeutronClientException]
|
||||
res._show_resource = mock_show_resource
|
||||
|
||||
self.assertEqual({'attr1': 'val1', 'attr2': 'val2'},
|
||||
res._resolve_attribute('show'))
|
||||
self.assertEqual('val2', res._resolve_attribute('attr2'))
|
||||
self.assertRaises(KeyError, res._resolve_attribute, 'attr3')
|
||||
self.assertIsNone(res._resolve_attribute('attr2'))
|
||||
|
||||
|
||||
class NeutronNetTest(HeatTestCase):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user