24
24
from heat.engine import properties
25
25
from heat.engine import resource
26
26
from heat.engine import resources
27
from heat.engine import scheduler
27
28
from heat.engine.resources import template_resource
29
30
from heat.openstack.common import uuidutils
496
497
self.assertRaises(exception.StackValidationFailed, temp_res.validate)
497
498
self.m.VerifyAll()
500
def create_stack(self, template):
501
t = template_format.parse(template)
502
stack = self.parse_stack(t)
504
self.assertEqual(stack.state, (stack.CREATE, stack.COMPLETE))
507
def parse_stack(self, t):
508
ctx = utils.dummy_context('test_username', 'aaaa', 'password')
509
stack_name = 'test_stack'
510
tmpl = parser.Template(t)
511
stack = parser.Stack(ctx, stack_name, tmpl)
515
def test_template_resource_update(self):
516
# assertion: updating a template resource is never destructive
517
# as it defers to the nested stack to determine if anything
518
# needs to be replaced.
520
utils.setup_dummy_db()
521
resource._register_class('GenericResource',
522
generic_rsrc.GenericResource)
524
templ_resource_name = 'http://server.test/the.yaml'
526
HeatTemplateFormatVersion: '2012-12-12'
532
''' % templ_resource_name
534
self.m.StubOutWithMock(urlfetch, "get")
535
urlfetch.get(templ_resource_name,
536
allowed_schemes=('http',
537
'https')).MultipleTimes().\
539
HeatTemplateFormatVersion: '2012-12-12'
545
Type: GenericResource
553
stack = self.create_stack(test_template)
554
templ_resource = stack['the_nested']
555
self.assertEqual('myname', templ_resource.FnGetAtt('Foo'))
558
"Type": templ_resource_name,
563
# test that update() does NOT raise UpdateReplace.
564
updater = scheduler.TaskRunner(templ_resource.update, update_snippet)
565
self.assertEqual(None, updater())
566
self.assertEqual('yourname', templ_resource.FnGetAtt('Foo'))