def version_list(): context.set_ctx(None) return api_utils.render( {"versions": [{ "id": "v1.0", "status": "CURRENT" }]})
def version_list(): context.set_ctx(None) return api_utils.render({ "versions": [ {"id": "v1.0", "status": "CURRENT"} ] })
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)
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)
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)
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)
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))
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)
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)
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)
def setUp(self): context.set_ctx(context.Context(None, None, None, None))
def teardown_request(_ex=None): context.set_ctx(None)
def setUp(self): ctx = context.Context('test_user', 'tenant_1', 'test_auth_token', {}, remote_semaphore='123') context.set_ctx(ctx)
def tearDown(self): db_api.drop_db() os.close(self.db_fd) os.unlink(self.db_path) context.set_ctx(None)
def set_tenant(self, tenant_id="tenant_1"): context.set_ctx( context.Context('test_user', tenant_id, 'test_auth_token', {}))
def setUp(self): context.set_ctx( context.Context(username='******', tenant_name='test_tenant', token='test_auth_token'))
def setUp(self): context.set_ctx( context.Context('test_user', 'test_tenant', 'test_auth_token', {'X-Tenant-Name': "test_tenant"}))