Пример #1
0
    def test_delete_stack_wait(self):
        marker_event = fakes.make_fake_stack_event(self.stack_id,
                                                   self.stack_name,
                                                   status='CREATE_COMPLETE')
        marker_qs = 'marker={e_id}&sort_dir=asc'.format(
            e_id=marker_event['id'])
        resolve = 'resolve_outputs=False'
        self.register_uris([
            dict(method='GET',
                 uri='{endpoint}/stacks/{id}?{resolve}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT,
                     id=self.stack_id,
                     resolve=resolve),
                 status_code=302,
                 headers=dict(
                     location='{endpoint}/stacks/{name}/{id}?{resolve}'.format(
                         endpoint=fakes.ORCHESTRATION_ENDPOINT,
                         id=self.stack_id,
                         name=self.stack_name,
                         resolve=resolve))),
            dict(method='GET',
                 uri='{endpoint}/stacks/{name}/{id}?{resolve}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT,
                     id=self.stack_id,
                     name=self.stack_name,
                     resolve=resolve),
                 json={"stack": self.stack}),
            dict(method='GET',
                 uri='{endpoint}/stacks/{id}/events?{qs}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT,
                     id=self.stack_id,
                     qs='limit=1&sort_dir=desc'),
                 complete_qs=True,
                 json={"events": [marker_event]}),
            dict(method='DELETE',
                 uri='{endpoint}/stacks/{id}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT, id=self.stack_id)),
            dict(method='GET',
                 uri='{endpoint}/stacks/{id}/events?{qs}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT,
                     id=self.stack_id,
                     qs=marker_qs),
                 complete_qs=True,
                 json={
                     "events": [
                         fakes.make_fake_stack_event(self.stack_id,
                                                     self.stack_name,
                                                     status='DELETE_COMPLETE'),
                     ]
                 }),
            dict(method='GET',
                 uri='{endpoint}/stacks/{id}?{resolve}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT,
                     id=self.stack_id,
                     resolve=resolve),
                 status_code=404),
        ])

        self.assertTrue(self.cloud.delete_stack(self.stack_id, wait=True))
        self.assert_calls()
Пример #2
0
    def test_delete_stack_wait(self):
        marker_event = fakes.make_fake_stack_event(
            self.stack_id, self.stack_name, status='CREATE_COMPLETE')
        marker_qs = 'marker={e_id}&sort_dir=asc'.format(
            e_id=marker_event['id'])
        self.register_uris([
            dict(method='GET',
                 uri='{endpoint}/stacks/{id}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT,
                     id=self.stack_id),
                 status_code=302,
                 headers=dict(
                     location='{endpoint}/stacks/{name}/{id}'.format(
                         endpoint=fakes.ORCHESTRATION_ENDPOINT,
                         id=self.stack_id, name=self.stack_name))),
            dict(method='GET',
                 uri='{endpoint}/stacks/{name}/{id}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT,
                     id=self.stack_id, name=self.stack_name),
                 json={"stack": self.stack}),
            dict(method='GET',
                 uri='{endpoint}/stacks/{id}/events?{qs}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT,
                     id=self.stack_id,
                     qs='limit=1&sort_dir=desc'),
                 complete_qs=True,
                 json={"events": [marker_event]}),
            dict(method='DELETE',
                 uri='{endpoint}/stacks/{id}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT,
                     id=self.stack_id)),
            dict(method='GET',
                 uri='{endpoint}/stacks/{id}/events?{qs}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT,
                     id=self.stack_id,
                     qs=marker_qs),
                 complete_qs=True,
                 json={"events": [
                     fakes.make_fake_stack_event(
                         self.stack_id, self.stack_name,
                         status='DELETE_COMPLETE'),
                 ]}),
            dict(method='GET',
                 uri='{endpoint}/stacks/{id}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT,
                     id=self.stack_id, name=self.stack_name),
                 status_code=404),
        ])

        self.assertTrue(self.cloud.delete_stack(self.stack_id, wait=True))
        self.assert_calls()
Пример #3
0
    def test_create_stack_wait(self):

        test_template = tempfile.NamedTemporaryFile(delete=False)
        test_template.write(fakes.FAKE_TEMPLATE.encode('utf-8'))
        test_template.close()

        self.register_uris([
            dict(method='POST',
                 uri='{endpoint}/stacks'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT),
                 json={"stack": self.stack},
                 validate=dict(
                     json={
                         'disable_rollback': False,
                         'environment': {},
                         'files': {},
                         'parameters': {},
                         'stack_name': self.stack_name,
                         'tags': self.stack_tag,
                         'template': fakes.FAKE_TEMPLATE_CONTENT,
                         'timeout_mins': 60
                     })),
            dict(method='GET',
                 uri='{endpoint}/stacks/{name}/events?sort_dir=asc'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT,
                     name=self.stack_name),
                 json={
                     "events": [
                         fakes.make_fake_stack_event(self.stack_id,
                                                     self.stack_name,
                                                     status='CREATE_COMPLETE',
                                                     resource_name='name'),
                     ]
                 }),
            dict(method='GET',
                 uri='{endpoint}/stacks/{name}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT,
                     name=self.stack_name),
                 status_code=302,
                 headers=dict(location='{endpoint}/stacks/{name}/{id}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT,
                     id=self.stack_id,
                     name=self.stack_name))),
            dict(method='GET',
                 uri='{endpoint}/stacks/{name}/{id}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT,
                     id=self.stack_id,
                     name=self.stack_name),
                 json={"stack": self.stack}),
        ])
        self.cloud.create_stack(self.stack_name,
                                tags=self.stack_tag,
                                template_file=test_template.name,
                                wait=True)

        self.assert_calls()
Пример #4
0
    def test_create_stack_wait(self):

        test_template = tempfile.NamedTemporaryFile(delete=False)
        test_template.write(fakes.FAKE_TEMPLATE.encode('utf-8'))
        test_template.close()

        self.register_uris([
            dict(
                method='POST', uri='{endpoint}/stacks'.format(
                    endpoint=fakes.ORCHESTRATION_ENDPOINT),
                json={"stack": self.stack},
                validate=dict(
                    json={
                        'disable_rollback': False,
                        'environment': {},
                        'files': {},
                        'parameters': {},
                        'stack_name': self.stack_name,
                        'template': fakes.FAKE_TEMPLATE_CONTENT,
                        'timeout_mins': 60}
                )),
            dict(
                method='GET',
                uri='{endpoint}/stacks/{name}/events?sort_dir=asc'.format(
                    endpoint=fakes.ORCHESTRATION_ENDPOINT,
                    name=self.stack_name),
                json={"events": [
                    fakes.make_fake_stack_event(
                        self.stack_id, self.stack_name,
                        status='CREATE_COMPLETE',
                        resource_name='name'),
                ]}),
            dict(
                method='GET',
                uri='{endpoint}/stacks/{name}'.format(
                    endpoint=fakes.ORCHESTRATION_ENDPOINT,
                    name=self.stack_name),
                status_code=302,
                headers=dict(
                    location='{endpoint}/stacks/{name}/{id}'.format(
                        endpoint=fakes.ORCHESTRATION_ENDPOINT,
                        id=self.stack_id, name=self.stack_name))),
            dict(
                method='GET',
                uri='{endpoint}/stacks/{name}/{id}'.format(
                    endpoint=fakes.ORCHESTRATION_ENDPOINT,
                    id=self.stack_id, name=self.stack_name),
                json={"stack": self.stack}),
        ])
        self.cloud.create_stack(
            self.stack_name,
            template_file=test_template.name,
            wait=True)

        self.assert_calls()
Пример #5
0
    def test_delete_stack_wait_failed(self):
        failed_stack = self.stack.copy()
        failed_stack['stack_status'] = 'DELETE_FAILED'
        marker_event = fakes.make_fake_stack_event(self.stack_id,
                                                   self.stack_name,
                                                   status='CREATE_COMPLETE')
        marker_qs = 'marker={e_id}&sort_dir=asc'.format(
            e_id=marker_event['id'])
        resolve = 'resolve_outputs=False'
        self.register_uris([
            dict(method='GET',
                 uri='{endpoint}/stacks/{id}?{resolve}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT,
                     id=self.stack_id,
                     resolve=resolve),
                 status_code=302,
                 headers=dict(
                     location='{endpoint}/stacks/{name}/{id}?{resolve}'.format(
                         endpoint=fakes.ORCHESTRATION_ENDPOINT,
                         id=self.stack_id,
                         name=self.stack_name,
                         resolve=resolve))),
            dict(method='GET',
                 uri='{endpoint}/stacks/{name}/{id}?{resolve}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT,
                     id=self.stack_id,
                     name=self.stack_name,
                     resolve=resolve),
                 json={"stack": self.stack}),
            dict(method='GET',
                 uri='{endpoint}/stacks/{id}/events?{qs}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT,
                     id=self.stack_id,
                     qs='limit=1&sort_dir=desc'),
                 complete_qs=True,
                 json={"events": [marker_event]}),
            dict(method='DELETE',
                 uri='{endpoint}/stacks/{id}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT, id=self.stack_id)),
            dict(method='GET',
                 uri='{endpoint}/stacks/{id}/events?{qs}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT,
                     id=self.stack_id,
                     qs=marker_qs),
                 complete_qs=True,
                 json={
                     "events": [
                         fakes.make_fake_stack_event(self.stack_id,
                                                     self.stack_name,
                                                     status='DELETE_COMPLETE'),
                     ]
                 }),
            dict(method='GET',
                 uri='{endpoint}/stacks/{id}?resolve_outputs=False'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT, id=self.stack_id),
                 status_code=302,
                 headers=dict(
                     location='{endpoint}/stacks/{name}/{id}?{resolve}'.format(
                         endpoint=fakes.ORCHESTRATION_ENDPOINT,
                         id=self.stack_id,
                         name=self.stack_name,
                         resolve=resolve))),
            dict(method='GET',
                 uri='{endpoint}/stacks/{name}/{id}?{resolve}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT,
                     id=self.stack_id,
                     name=self.stack_name,
                     resolve=resolve),
                 json={"stack": failed_stack}),
        ])

        with testtools.ExpectedException(shade.OpenStackCloudException):
            self.cloud.delete_stack(self.stack_id, wait=True)

        self.assert_calls()
Пример #6
0
    def test_delete_stack_wait_failed(self):
        failed_stack = self.stack.copy()
        failed_stack['stack_status'] = 'DELETE_FAILED'
        marker_event = fakes.make_fake_stack_event(
            self.stack_id, self.stack_name, status='CREATE_COMPLETE')
        marker_qs = 'marker={e_id}&sort_dir=asc'.format(
            e_id=marker_event['id'])
        self.register_uris([
            dict(method='GET',
                 uri='{endpoint}/stacks/{id}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT,
                     id=self.stack_id),
                 status_code=302,
                 headers=dict(
                     location='{endpoint}/stacks/{name}/{id}'.format(
                         endpoint=fakes.ORCHESTRATION_ENDPOINT,
                         id=self.stack_id, name=self.stack_name))),
            dict(method='GET',
                 uri='{endpoint}/stacks/{name}/{id}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT,
                     id=self.stack_id, name=self.stack_name),
                 json={"stack": self.stack}),
            dict(method='GET',
                 uri='{endpoint}/stacks/{id}/events?{qs}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT,
                     id=self.stack_id,
                     qs='limit=1&sort_dir=desc'),
                 complete_qs=True,
                 json={"events": [marker_event]}),
            dict(method='DELETE',
                 uri='{endpoint}/stacks/{id}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT,
                     id=self.stack_id)),
            dict(method='GET',
                 uri='{endpoint}/stacks/{id}/events?{qs}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT,
                     id=self.stack_id,
                     qs=marker_qs),
                 complete_qs=True,
                 json={"events": [
                     fakes.make_fake_stack_event(
                         self.stack_id, self.stack_name,
                         status='DELETE_COMPLETE'),
                 ]}),
            dict(method='GET',
                 uri='{endpoint}/stacks/{id}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT,
                     id=self.stack_id, name=self.stack_name),
                 status_code=302,
                 headers=dict(
                     location='{endpoint}/stacks/{name}/{id}'.format(
                         endpoint=fakes.ORCHESTRATION_ENDPOINT,
                         id=self.stack_id, name=self.stack_name))),
            dict(method='GET',
                 uri='{endpoint}/stacks/{name}/{id}'.format(
                     endpoint=fakes.ORCHESTRATION_ENDPOINT,
                     id=self.stack_id, name=self.stack_name),
                 json={"stack": failed_stack}),
        ])

        with testtools.ExpectedException(shade.OpenStackCloudException):
            self.cloud.delete_stack(self.stack_id, wait=True)

        self.assert_calls()