示例#1
0
        def handler(*args, **kwargs):
            if id_prop and not get_args:
                get_args['id'] = id_prop[0]

            if 'marker' in id_prop:
                if 'marker' not in u.get_request_args():
                    return func(*args, **kwargs)
                kwargs['marker'] = u.get_request_args()['marker']

            get_kwargs = {}
            for get_arg in get_args:
                get_kwargs[get_arg] = kwargs[get_args[get_arg]]

            obj = None
            try:
                obj = get_func(**get_kwargs)
            except Exception as e:
                cls_name = reflection.get_class_name(e, fully_qualified=False)
                if 'notfound' not in cls_name.lower():
                    raise e
            if obj is None:
                e = ex.NotFoundException(get_kwargs,
                                         _('Object with %s not found'))
                return u.not_found(e)
            if 'marker' in kwargs:
                del(kwargs['marker'])
            return func(*args, **kwargs)
示例#2
0
        def handler(*args, **kwargs):
            if id_prop and not get_args:
                get_args['id'] = id_prop[0]

            if 'marker' in id_prop:
                if 'marker' not in u.get_request_args():
                    return func(*args, **kwargs)
                kwargs['marker'] = u.get_request_args()['marker']

            get_kwargs = {}
            for get_arg in get_args:
                get_kwargs[get_arg] = kwargs[get_args[get_arg]]

            obj = None
            try:
                obj = get_func(**get_kwargs)
            except Exception as e:
                cls_name = reflection.get_class_name(e, fully_qualified=False)
                if 'notfound' not in cls_name.lower():
                    raise e
            if obj is None:
                e = ex.NotFoundException(get_kwargs,
                                         _('Object with %s not found'))
                return u.not_found(e)
            if 'marker' in kwargs:
                del (kwargs['marker'])
            return func(*args, **kwargs)
示例#3
0
def job_templates_list():
    result = api.get_job_templates(**u.get_request_args().to_dict())
    for jt in result:
        u._replace_tenant_id_project_id(jt)
        _replace_tenant_id_project_id_job_binary(jt['mains'])
        _replace_tenant_id_project_id_job_binary(jt['libs'])
    return u.render(res=result, name='job_templates')
示例#4
0
def job_templates_list():
    result = api.get_job_templates(**u.get_request_args().to_dict())
    for jt in result:
        u._replace_tenant_id_project_id(jt)
        _replace_tenant_id_project_id_job_binary(jt['mains'])
        _replace_tenant_id_project_id_job_binary(jt['libs'])
    return u.render(res=result, name='job_templates')
示例#5
0
def jobs_get(job_id):
    data = u.get_request_args()
    refresh_status = six.text_type(data.get('refresh_status',
                                            'false')).lower() == 'true'
    result = {'job': api.get_job_execution(job_id, refresh_status)}
    result['job'].pop('oozie_job_id', force=True)
    return u.render(result)
示例#6
0
def get_sorting_field():
    request_args = u.get_request_args()
    if 'sort_by' in request_args:
        sort_by = request_args['sort_by']
        if sort_by:
            sort_by = sort_by[1:] if sort_by[0] == '-' else sort_by
            return sort_by
    return None
示例#7
0
def clusters_get(cluster_id):
    data = u.get_request_args()
    show_events = six.text_type(data.get('show_progress',
                                         'false')).lower() == 'true'
    result = u.to_wrapped_dict_no_render(api.get_cluster, cluster_id,
                                         show_events)
    u._replace_hadoop_version_plugin_version(result['cluster'])
    return u.render(result)
示例#8
0
def get_sorting_field():
    request_args = u.get_request_args()
    if 'sort_by' in request_args:
        sort_by = request_args['sort_by']
        if sort_by:
            sort_by = sort_by[1:] if sort_by[0] == '-' else sort_by
            return sort_by
    return None
示例#9
0
文件: jobs.py 项目: madar010/mad
def jobs_list():
    result = api.job_execution_list(**u.get_request_args().to_dict())
    # APIv2: renaming oozie_job_id -> engine_job_id
    # once APIv1 is deprecated this can be
    # removed
    for je in result:
        je.pop('oozie_job_id', force=True)
    return u.render(res=result, name='jobs')
示例#10
0
文件: jobs.py 项目: openstack/sahara
def jobs_get(job_id):
    data = u.get_request_args()
    refresh_status = six.text_type(
        data.get('refresh_status', 'false')).lower() == 'true'
    result = {'job': api.get_job_execution(job_id, refresh_status)}
    result['job'].pop('oozie_job_id', force=True)
    u._replace_tenant_id_project_id(result['job'])
    _replace_job_id_job_template_id(result['job'])
    return u.render(result)
示例#11
0
def job_types_get():
    # We want to use flat=False with to_dict() so that
    # the value of each arg is given as a list. This supports
    # filters of the form ?type=Pig&type=Java, etc.
    request_args = u.get_request_args().to_dict(flat=False)
    if 'plugin_version' in request_args:
        request_args['hadoop_version'] = request_args['plugin_version']
        del request_args['plugin_version']
    return u.render(job_types=api.get_job_types(**request_args))
示例#12
0
def job_types_get():
    # We want to use flat=False with to_dict() so that
    # the value of each arg is given as a list. This supports
    # filters of the form ?type=Pig&type=Java, etc.
    request_args = u.get_request_args().to_dict(flat=False)
    if 'plugin_version' in request_args:
        request_args['hadoop_version'] = request_args['plugin_version']
        del request_args['plugin_version']
    return u.render(job_types=api.get_job_types(**request_args))
示例#13
0
文件: jobs.py 项目: stackhpc/sahara
def jobs_get(job_id):
    data = u.get_request_args()
    refresh_status = six.text_type(data.get('refresh_status',
                                            'false')).lower() == 'true'
    result = u.to_wrapped_dict_no_render(api.get_job_execution, job_id,
                                         refresh_status)
    result['engine_job_id'] = result['oozie_job_id']
    del result['oozie_job_id']
    return u.render(result)
示例#14
0
def cluster_templates_list():
    request_args = u.get_request_args().to_dict()
    if 'plugin_version' in request_args:
        request_args['hadoop_version'] = request_args['plugin_version']
        del request_args['plugin_version']
    result = api.get_cluster_templates(**request_args)
    for ct in result:
        u._replace_hadoop_version_plugin_version(ct)
        u._replace_tenant_id_project_id(ct)
    return u.render(res=result, name='cluster_templates')
示例#15
0
def node_group_templates_list():
    request_args = u.get_request_args().to_dict()
    if 'plugin_version' in request_args:
        request_args['hadoop_version'] = request_args['plugin_version']
        del request_args['plugin_version']
    result = api.get_node_group_templates(**request_args)
    for ngt in result:
        u._replace_hadoop_version_plugin_version(ngt)
        u._replace_tenant_id_project_id(ngt)
    return u.render(res=result, name="node_group_templates")
示例#16
0
def validate_pagination_limit():
    request_args = u.get_request_args()
    if 'limit' in request_args:
        if types.is_int(request_args['limit']):
            if not int(request_args['limit']) > 0:
                raise ex.SaharaException(
                    _("'limit' must be positive integer"), 400)
        else:
            raise ex.SaharaException(
                _("'limit' must be positive integer"), 400)
示例#17
0
文件: jobs.py 项目: openstack/sahara
def jobs_list():
    result = api.job_execution_list(**u.get_request_args().to_dict())
    # APIv2: renaming oozie_job_id -> engine_job_id
    # once APIv1 is deprecated this can be
    # removed
    for je in result:
        je.pop('oozie_job_id', force=True)
        u._replace_tenant_id_project_id(je)
        _replace_job_id_job_template_id(je)
    return u.render(res=result, name='jobs')
示例#18
0
def validate_pagination_limit():
    request_args = u.get_request_args()
    if 'limit' in request_args:
        if types.is_int(request_args['limit']):
            if not int(request_args['limit']) > 0:
                raise ex.SaharaException(_("'limit' must be positive integer"),
                                         400)
        else:
            raise ex.SaharaException(_("'limit' must be positive integer"),
                                     400)
示例#19
0
def clusters_get(cluster_id):
    data = u.get_request_args()
    show_events = six.text_type(
        data.get('show_progress', 'false')).lower() == 'true'
    result = u.to_wrapped_dict_no_render(
        api.get_cluster, cluster_id, show_events)
    u._replace_hadoop_version_plugin_version(result['cluster'])
    u._replace_tenant_id_project_id(result['cluster'])
    _replace_tenant_id_project_id_provision_steps(result['cluster'])
    return u.render(result)
示例#20
0
def node_group_templates_list():
    request_args = u.get_request_args().to_dict()
    if 'plugin_version' in request_args:
        request_args['hadoop_version'] = request_args['plugin_version']
        del request_args['plugin_version']
    result = api.get_node_group_templates(**request_args)
    for ngt in result:
        u._replace_hadoop_version_plugin_version(ngt)
        u._replace_tenant_id_project_id(ngt)
    return u.render(res=result, name="node_group_templates")
示例#21
0
 def handler(*args, **kwargs):
     pagination_params = ['marker', 'limit', 'sort_by']
     func_name = func.__name__
     params = u.get_request_args()
     for param in params.keys():
         if (param not in supported_params
                 and param not in pagination_params):
             return u.invalid_param_error(
                 400, 'The only valid params for %s are %s and %s' %
                 (func_name, supported_params, pagination_params))
     return func(*args, **kwargs)
示例#22
0
文件: clusters.py 项目: wuhsh/sahara
def clusters_list():
    request_args = u.get_request_args().to_dict()
    if 'plugin_version' in request_args:
        request_args['hadoop_version'] = request_args['plugin_version']
        del request_args['plugin_version']
    result = api.get_clusters(**request_args)
    for c in result:
        u._replace_hadoop_version_plugin_version(c)
        u._replace_tenant_id_project_id(c)
        _replace_tenant_id_project_id_provision_steps(c)
    return u.render(res=result, name='clusters')
示例#23
0
 def handler(*args, **kwargs):
     pagination_params = ['marker', 'limit', 'sort_by']
     func_name = func.__name__
     params = u.get_request_args()
     for param in params.keys():
         if (param not in supported_params and
                 param not in pagination_params):
             return u.invalid_param_error(
                 400,
                 'The only valid params for %s are %s and %s' % (
                     func_name, supported_params, pagination_params))
     return func(*args, **kwargs)
示例#24
0
def clusters_get(cluster_id):
    data = u.get_request_args()
    show_events = six.text_type(
        data.get('show_progress', 'false')).lower() == 'true'
    return u.to_wrapped_dict(api.get_cluster, cluster_id, show_events)
示例#25
0
def data_sources_list():
    result = api.get_data_sources(**u.get_request_args().to_dict())
    for ds in result:
        u._replace_tenant_id_project_id(ds)
    return u.render(res=result, name='data_sources')
示例#26
0
def job_list():
    result = api.get_jobs(**u.get_request_args().to_dict())
    return u.render(res=result, name='job_templates')
示例#27
0
def job_binary_list():
    result = api.get_job_binaries(**u.get_request_args().to_dict())
    for jb in result:
        u._replace_tenant_id_project_id(jb)
    return u.render(res=result, name='binaries')
示例#28
0
def cluster_templates_list():
    return u.render(cluster_templates=[
        t.to_dict()
        for t in api.get_cluster_templates(**u.get_request_args().to_dict())
    ])
示例#29
0
def clusters_get(cluster_id):
    data = u.get_request_args()
    show_events = unicode(data.get('show_progress', 'false')).lower() == 'true'
    return u.render(api.get_cluster(cluster_id, show_events).to_wrapped_dict())
示例#30
0
def job_binary_internal_list():
    return u.render(binaries=[j.to_dict() for j in
                              api.get_job_binary_internals(
                                  **u.get_request_args().to_dict())])
示例#31
0
def node_group_templates_list():
    result = api.get_node_group_templates(**u.get_request_args().to_dict())
    return u.render(res=result, name="node_group_templates")
示例#32
0
文件: v11.py 项目: openstack/sahara
def data_sources_list():
    result = api.get_data_sources(**u.get_request_args().to_dict())
    return u.render(res=result, name='data_sources')
示例#33
0
def clusters_get(cluster_id):
    data = u.get_request_args()
    show_events = six.text_type(data.get('show_progress',
                                         'false')).lower() == 'true'
    return u.to_wrapped_dict(api.get_cluster, cluster_id, show_events)
示例#34
0
文件: v11.py 项目: openstack/sahara
def job_binary_internal_list():
    result = api.get_job_binary_internals(**u.get_request_args().to_dict())
    return u.render(res=result, name='binaries')
示例#35
0
文件: v11.py 项目: madar010/mad
def data_sources_list():
    result = api.get_data_sources(**u.get_request_args().to_dict())
    return u.render(res=result, name='data_sources')
示例#36
0
def data_sources_list():
    return u.render(
        data_sources=[ds.to_dict() for ds in api.get_data_sources(
            **u.get_request_args().to_dict())])
示例#37
0
文件: v10.py 项目: egafford/sahara
def images_list():
    tags = u.get_request_args().getlist('tags')
    name = u.get_request_args().get('name', None)
    return u.render(images=[i.dict for i in api.get_images(name, tags)])
示例#38
0
def images_list():
    tags = u.get_request_args().getlist('tags')
    name = u.get_request_args().get('name', None)
    return u.render(images=[i.dict for i in api.get_images(name, tags)])
示例#39
0
文件: v11.py 项目: openstack/sahara
def job_list():

    result = api.get_jobs(**u.get_request_args().to_dict())

    return u.render(res=result, name='jobs')
示例#40
0
文件: v11.py 项目: frgaudet/sahara
def job_types_get():
    # We want to use flat=False with to_dict() so that
    # the value of each arg is given as a list. This supports
    # filters of the form ?type=Pig&type=Java, etc.
    return u.render(job_types=api.get_job_types(
        **u.get_request_args().to_dict(flat=False)))
示例#41
0
文件: v11.py 项目: openstack/sahara
def job_executions_list():
    result = api.job_execution_list(
        **u.get_request_args().to_dict())
    return u.render(res=result, name='job_executions')
示例#42
0
文件: v11.py 项目: frgaudet/sahara
def job_executions_list():
    job_executions = [je.to_dict() for je in api.job_execution_list(
        **u.get_request_args().to_dict())]
    return u.render(job_executions=job_executions)
示例#43
0
文件: v10.py 项目: qinweiwei/sahara
def images_list():
    tags = u.get_request_args().getlist('tags')
    return u.render(images=[i.dict for i in api.get_images(tags)])
示例#44
0
def node_group_templates_list():
    result = api.get_node_group_templates(**u.get_request_args().to_dict())
    return u.render(res=result, name="node_group_templates")
示例#45
0
def job_list():
    return u.render(jobs=[j.to_dict() for j in api.get_jobs(
        **u.get_request_args().to_dict())])
示例#46
0
def job_executions_list():
    result = api.job_execution_list(**u.get_request_args().to_dict())
    return u.render(res=result, name='jobs')
示例#47
0
def job_executions_list():
    job_executions = [je.to_dict() for je in api.job_execution_list(
        **u.get_request_args().to_dict())]
    return u.render(job_executions=job_executions)
示例#48
0
def job_binary_list():
    result = api.get_job_binaries(**u.get_request_args().to_dict())
    for jb in result:
        u._replace_tenant_id_project_id(jb)
    return u.render(res=result, name='binaries')
示例#49
0
def clusters_list():
    return u.render(clusters=[c.to_dict() for c in api.get_clusters(
        **u.get_request_args().to_dict())])
示例#50
0
def job_types_get():
    # We want to use flat=False with to_dict() so that
    # the value of each arg is given as a list. This supports
    # filters of the form ?type=Pig&type=Java, etc.
    return u.render(job_types=api.get_job_types(**u.get_request_args().to_dict(
        flat=False)))
示例#51
0
文件: v11.py 项目: frgaudet/sahara
def job_list():
    return u.render(jobs=[j.to_dict() for j in api.get_jobs(
        **u.get_request_args().to_dict())])
示例#52
0
def node_group_templates_list():
    return u.render(
        node_group_templates=[t.to_dict()
                              for t in api.get_node_group_templates(
                              **u.get_request_args().to_dict())])
示例#53
0
文件: v11.py 项目: frgaudet/sahara
def job_binary_internal_list():
    return u.render(binaries=[j.to_dict() for j in
                              api.get_job_binary_internals(
                                  **u.get_request_args().to_dict())])
示例#54
0
def job_binary_list():
    result = api.get_job_binaries(**u.get_request_args().to_dict())
    return u.render(res=result, name='binaries')
示例#55
0
文件: v11.py 项目: frgaudet/sahara
def data_sources_list():
    return u.render(
        data_sources=[ds.to_dict() for ds in api.get_data_sources(
            **u.get_request_args().to_dict())])
示例#56
0
def node_group_templates_list():
    return u.render(node_group_templates=[
        t.to_dict()
        for t in api.get_node_group_templates(**u.get_request_args().to_dict())
    ])
示例#57
0
def cluster_templates_list():
    return u.render(
        cluster_templates=[t.to_dict() for t in api.get_cluster_templates(
            **u.get_request_args().to_dict())])
示例#58
0
def images_list():
    tags = u.get_request_args().getlist('tags')
    return u.render(images=[i.dict for i in api.get_images(tags)])
示例#59
0
def cluster_templates_list():
    result = api.get_cluster_templates(**u.get_request_args().to_dict())
    return u.render(res=result, name='cluster_templates')
示例#60
0
def clusters_list():
    return u.render(clusters=[
        c.to_dict() for c in api.get_clusters(**u.get_request_args().to_dict())
    ])