Ejemplo n.º 1
0
    def create_stack(self, stack_name='test_stack', stub=True):
        temp = template_format.parse(test_template_signal)
        template = parser.Template(temp)
        ctx = utils.dummy_context()
        ctx.tenant_id = 'test_tenant'
        stack = parser.Stack(ctx, stack_name, template, disable_rollback=True)

        # Stub out the stack ID so we have a known value
        with utils.UUIDStub(self.stack_id):
            stack.store()

        if stub:
            self.m.StubOutWithMock(stack_user.StackUser, 'keystone')
            stack_user.StackUser.keystone().MultipleTimes().AndReturn(self.fc)

        self.m.ReplayAll()

        return stack
Ejemplo n.º 2
0
def create_stack(template, stack_id=None):
    tmpl = template_format.parse(template)
    template = templatem.Template(tmpl)
    ctx = utils.dummy_context(tenant_id='test_tenant')
    st = stack.Stack(ctx,
                     'test_st',
                     template,
                     environment.Environment(),
                     disable_rollback=True)

    # Stub out the stack ID so we have a known value
    if stack_id is None:
        stack_id = str(uuid.uuid4())
    with utils.UUIDStub(stack_id):
        st.store()
    st.id = stack_id

    return st
Ejemplo n.º 3
0
    def test_handle_delete_not_found(self):
        rsrc = self._user_create(stack_name='user_testdel2',
                                 project_id='aprojectdel2',
                                 user_id='auserdel2')

        self.m.StubOutWithMock(fakes.FakeKeystoneClient,
                               'delete_stack_domain_user')
        fakes.FakeKeystoneClient.delete_stack_domain_user(
            user_id='auserdel2',
            project_id='aprojectdel2').AndRaise(kc_exceptions.NotFound)

        self.m.ReplayAll()

        with utils.UUIDStub(self.resource_id):
            scheduler.TaskRunner(rsrc.create)()
        self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)
        scheduler.TaskRunner(rsrc.delete)()
        self.assertEqual((rsrc.DELETE, rsrc.COMPLETE), rsrc.state)
        self.m.VerifyAll()
    def create_stack(self, temp=None):
        if temp is None:
            temp = test_template_wc_count
        temp_fmt = template_format.parse(temp)
        template = tmpl.Template(temp_fmt)
        ctx = utils.dummy_context(tenant_id='test_tenant')
        stack = parser.Stack(ctx, 'test_stack', template,
                             disable_rollback=True)

        stack_id = str(uuid.uuid4())
        self.stack_id = stack_id
        with utils.UUIDStub(self.stack_id):
            stack.store()

        self.m.StubOutWithMock(aws_wch.WaitConditionHandle, 'get_status')
        aws_wch.WaitConditionHandle.get_status().AndReturn([])
        aws_wch.WaitConditionHandle.get_status().AndReturn(['SUCCESS'])
        aws_wch.WaitConditionHandle.get_status().AndReturn(['SUCCESS',
                                                            'SUCCESS'])
        aws_wch.WaitConditionHandle.get_status().AndReturn(['SUCCESS',
                                                            'SUCCESS',
                                                            'SUCCESS'])

        return stack
Ejemplo n.º 5
0
    def create_stack(self,
                     stack_id=None,
                     template=test_template_heat_waitcondition_count,
                     params={},
                     stub=True,
                     stub_status=True):
        temp = template_format.parse(template)
        template = parser.Template(temp)
        ctx = utils.dummy_context(tenant_id=self.tenant_id)
        stack = parser.Stack(ctx,
                             'test_stack',
                             template,
                             environment.Environment(params),
                             disable_rollback=True)

        # Stub out the stack ID so we have a known value
        if stack_id is None:
            stack_id = str(uuid.uuid4())

        self.stack_id = stack_id
        with utils.UUIDStub(self.stack_id):
            stack.store()

        if stub:
            id = identifier.ResourceIdentifier('test_tenant', stack.name,
                                               stack.id, '', 'wait_handle')
            self.m.StubOutWithMock(heat_wch.HeatWaitConditionHandle,
                                   'identifier')
            heat_wch.HeatWaitConditionHandle.identifier().MultipleTimes(
            ).AndReturn(id)

        if stub_status:
            self.m.StubOutWithMock(heat_wch.HeatWaitConditionHandle,
                                   'get_status')

        return stack