예제 #1
0
파일: main.py 프로젝트: joelmathew/savanna
 def version_list():
     context.set_ctx(None)
     return api_utils.render(
         {"versions": [{
             "id": "v1.0",
             "status": "CURRENT"
         }]})
예제 #2
0
파일: main.py 프로젝트: akshayms/savanna
 def version_list():
     context.set_ctx(None)
     return api_utils.render({
         "versions": [
             {"id": "v1.0", "status": "CURRENT"}
         ]
     })
예제 #3
0
    def terminate_unneeded_clusters(self, ctx):
        LOG.debug('Terminating unneeded clusters')
        ctx = context.get_admin_context()
        if CONF.use_identity_api_v3:
            LOG.debug('Terminating unneeded clusters')
        context.set_ctx(ctx)
        for cluster in conductor.cluster_get_all(ctx, status='Active'):
            if not cluster.is_transient:
                continue

            jc = conductor.job_execution_count(ctx,
                                               end_time=None,
                                               cluster_id=cluster.id)

            if jc > 0:
                continue
            if CONF.use_identity_api_v3:
                trusts.use_os_admin_auth_token(cluster)
                api.terminate_cluster(cluster.id)
                LOG.debug('Terminated cluster %s with id %s' %
                          (cluster.name, cluster.id))
            else:
                if cluster.status != 'AwaitingTermination':
                    conductor.cluster_update(
                        ctx,
                        cluster,
                        {'status': 'AwaitingTermination'})
        context.set_ctx(None)
예제 #4
0
파일: api.py 프로젝트: akshayms/savanna
            def handler(**kwargs):
                context.set_ctx(None)

                LOG.debug("Rest.route.decorator.handler, kwargs=%s", kwargs)

                _init_resp_type(file_upload)

                # update status code
                if status:
                    flask.request.status_code = status

                kwargs.pop("tenant_id")

                ctx = context.Context(
                    flask.request.headers['X-User-Id'],
                    flask.request.headers['X-Tenant-Id'],
                    flask.request.headers['X-Auth-Token'],
                    flask.request.headers)
                context.set_ctx(ctx)

                if flask.request.method in ['POST', 'PUT']:
                    kwargs['data'] = request_data()

                try:
                    return func(**kwargs)
                except ex.SavannaException as e:
                    return bad_request(e)
                except Exception as e:
                    return internal_error(500, 'Internal Server Error', e)
예제 #5
0
            def handler(**kwargs):
                context.set_ctx(None)

                LOG.debug("Rest.route.decorator.handler, kwargs=%s", kwargs)

                _init_resp_type(file_upload)

                # update status code
                if status:
                    flask.request.status_code = status

                kwargs.pop("tenant_id")

                ctx = context.Context(flask.request.headers['X-User-Id'],
                                      flask.request.headers['X-Tenant-Id'],
                                      flask.request.headers['X-Auth-Token'],
                                      flask.request.headers)
                context.set_ctx(ctx)

                if flask.request.method in ['POST', 'PUT']:
                    kwargs['data'] = request_data()

                try:
                    return func(**kwargs)
                except ex.SavannaException as e:
                    return bad_request(e)
                except Exception as e:
                    return internal_error(500, 'Internal Server Error', e)
예제 #6
0
 def test_is_auth_capable_for_user_ctx(self):
     existing_ctx = context.ctx()
     try:
         ctx = context.Context('test_user', 'tenant_1', 'test_auth_token',
                               {"network": "aURL"}, remote_semaphore='123')
         self.assertTrue(ctx.is_auth_capable())
     finally:
         context.set_ctx(existing_ctx)
예제 #7
0
 def test_is_auth_capable_for_user_ctx(self):
     existing_ctx = context.ctx()
     try:
         ctx = context.Context('test_user', 'tenant_1', 'test_auth_token',
                               {"network": "aURL"}, remote_semaphore='123')
         self.assertTrue(ctx.is_auth_capable())
     finally:
         context.set_ctx(existing_ctx)
예제 #8
0
파일: base.py 프로젝트: mshabdiz/savanna
 def setup_context(self, username="******", tenant_id="tenant_1",
                   token="test_auth_token", tenant_name='test_tenant',
                   **kwargs):
     self.addCleanup(context.set_ctx,
                     context.ctx() if context.has_ctx() else None)
     context.set_ctx(context.Context(
         username=username, tenant_id=tenant_id,
         token=token, service_catalog={},
         tenant_name=tenant_name, **kwargs))
예제 #9
0
파일: main.py 프로젝트: akshayms/savanna
    def teardown_request(_ex=None):
        # TODO(slukjanov): how it'll work in case of exception?
        if context.has_ctx():
            if flask.request.path != '/':
                try:
                    session = context.session()
                    if session.transaction:
                        session.transaction.commit()
                except Exception as e:
                    return api_utils.internal_error(
                        500, 'Internal Server Error', e)

        context.set_ctx(None)
예제 #10
0
    def terminate_unneeded_clusters(self, ctx):
        LOG.debug('Terminating unneeded clusters')
        ctx = context.Context()
        for cluster in conductor.cluster_get_all(ctx, status='Active'):
            if not cluster.is_transient:
                continue

            jc = conductor.job_execution_count(ctx,
                                               end_time=None,
                                               cluster_id=cluster.id)

            if jc > 0:
                continue

            #TODO(akuznetsov) setup trust token and shutdown cluster
            LOG.debug('Terminated cluster %s with id %s' %
                      (cluster.name, cluster.id))
        context.set_ctx(None)
예제 #11
0
 def update_job_statuses(self, ctx):
     LOG.debug('Updating job statuses')
     ctx = context.get_admin_context()
     context.set_ctx(ctx)
     job_manager.update_job_statuses()
     context.set_ctx(None)
예제 #12
0
 def setUp(self):
     context.set_ctx(context.Context(None, None, None, None))
예제 #13
0
파일: main.py 프로젝트: joelmathew/savanna
 def teardown_request(_ex=None):
     context.set_ctx(None)
예제 #14
0
 def setUp(self):
     ctx = context.Context('test_user',
                           'tenant_1',
                           'test_auth_token', {},
                           remote_semaphore='123')
     context.set_ctx(ctx)
예제 #15
0
 def setUp(self):
     ctx = context.Context('test_user', 'tenant_1', 'test_auth_token', {},
                           remote_semaphore='123')
     context.set_ctx(ctx)
예제 #16
0
파일: base.py 프로젝트: joelmathew/savanna
 def tearDown(self):
     db_api.drop_db()
     os.close(self.db_fd)
     os.unlink(self.db_path)
     context.set_ctx(None)
예제 #17
0
파일: base.py 프로젝트: joelmathew/savanna
 def set_tenant(self, tenant_id="tenant_1"):
     context.set_ctx(
         context.Context('test_user', tenant_id, 'test_auth_token', {}))
예제 #18
0
파일: main.py 프로젝트: joelmathew/savanna
 def teardown_request(_ex=None):
     context.set_ctx(None)
예제 #19
0
파일: base.py 프로젝트: hguemar/sahara
 def set_tenant(self, tenant_id="tenant_1"):
     context.set_ctx(
         context.Context('test_user', tenant_id, 'test_auth_token', {}))
예제 #20
0
 def setUp(self):
     context.set_ctx(
         context.Context(username='******',
                         tenant_name='test_tenant',
                         token='test_auth_token'))
예제 #21
0
 def setUp(self):
     context.set_ctx(context.Context(None, None, None, None))
예제 #22
0
파일: base.py 프로젝트: hguemar/sahara
 def tearDown(self):
     db_api.drop_db()
     os.close(self.db_fd)
     os.unlink(self.db_path)
     context.set_ctx(None)
예제 #23
0
 def setUp(self):
     context.set_ctx(
         context.Context('test_user', 'test_tenant', 'test_auth_token',
                         {'X-Tenant-Name': "test_tenant"}))