Ejemplo n.º 1
0
def generate_url_and_params(app, sig, flavor):
    '''
    Digest command signature from cluster; generate an absolute
    (including app.ceph_baseurl) endpoint from all the prefix words,
    and a list of non-prefix param descs
    '''

    url = ''
    params = []
    # the OSD command descriptors don't include the 'tell <target>', so
    # tack it onto the front of sig
    if flavor == 'tell':
        tellsig = parse_funcsig(
            ['tell', {
                'name': 'target',
                'type': 'CephOsdName'
            }])
        sig = tellsig + sig

    for desc in sig:
        # prefixes go in the URL path
        if desc.t == CephPrefix:
            url += '/' + desc.instance.prefix
        else:
            # tell/<target> is a weird case; the URL includes what
            # would everywhere else be a parameter
            if flavor == 'tell' and ((desc.t, desc.name)
                                     == (CephOsdName, 'target')):
                url += '/<target>'
            else:
                params.append(desc)

    return app.ceph_baseurl + url, params
Ejemplo n.º 2
0
def generate_url_and_params(app, sig, flavor):
    '''
    Digest command signature from cluster; generate an absolute
    (including app.ceph_baseurl) endpoint from all the prefix words,
    and a list of non-prefix param descs
    '''

    url = ''
    params = []
    # the OSD command descriptors don't include the 'tell <target>', so
    # tack it onto the front of sig
    if flavor == 'tell':
        tellsig = parse_funcsig(['tell',
                                {'name': 'target', 'type': 'CephOsdName'}])
        sig = tellsig + sig

    for desc in sig:
        # prefixes go in the URL path
        if desc.t == CephPrefix:
            url += '/' + desc.instance.prefix
        else:
            # tell/<target> is a weird case; the URL includes what
            # would everywhere else be a parameter
            if flavor == 'tell' and ((desc.t, desc.name) ==
               (CephOsdName, 'target')):
                url += '/<target>'
            else:
                params.append(desc)

    return app.ceph_baseurl + url, params
Ejemplo n.º 3
0
def generate_url_and_params(app, sig, flavor):
    '''
    Digest command signature from cluster; generate an absolute
    (including app.ceph_baseurl) endpoint from all the prefix words,
    and a list of non-prefix param descs
    '''

    url = ''
    params = []
    # the OSD command descriptors don't include the 'tell <target>', so
    # tack it onto the front of sig
    if flavor == 'tell':
        tellsig = parse_funcsig(
            ['tell', {
                'name': 'target',
                'type': 'CephOsdName'
            }])
        sig = tellsig + sig

    for desc in sig:
        # prefixes go in the URL path
        if desc.t == CephPrefix:
            url += '/' + desc.instance.prefix
        # CephChoices with 1 required string (not --) do too, unless
        # we've already started collecting params, in which case they
        # too are params
        elif desc.t == CephChoices and \
             len(desc.instance.strings) == 1 and \
             desc.req and \
             not str(desc.instance).startswith('--') and \
             not params:
            url += '/' + str(desc.instance)
        else:
            # tell/<target> is a weird case; the URL includes what
            # would everywhere else be a parameter
            if flavor == 'tell' and  \
              (desc.t, desc.name) == (CephOsdName, 'target'):
                url += '/<target>'
            else:
                params.append(desc)

    return app.ceph_baseurl + url, params
Ejemplo n.º 4
0
def generate_url_and_params(app, sig, flavor):
    '''
    Digest command signature from cluster; generate an absolute
    (including app.ceph_baseurl) endpoint from all the prefix words,
    and a list of non-prefix param descs
    '''

    url = ''
    params = []
    # the OSD command descriptors don't include the 'tell <target>', so
    # tack it onto the front of sig
    if flavor == 'tell':
        tellsig = parse_funcsig(['tell',
                                {'name': 'target', 'type': 'CephOsdName'}])
        sig = tellsig + sig

    for desc in sig:
        # prefixes go in the URL path
        if desc.t == CephPrefix:
            url += '/' + desc.instance.prefix
        # CephChoices with 1 required string (not --) do too, unless
        # we've already started collecting params, in which case they
        # too are params
        elif (desc.t == CephChoices and
              len(desc.instance.strings) == 1 and
              desc.req and
              not str(desc.instance).startswith('--') and
              not params):
            url += '/' + str(desc.instance)
        else:
            # tell/<target> is a weird case; the URL includes what
            # would everywhere else be a parameter
            if flavor == 'tell' and ((desc.t, desc.name) ==
               (CephOsdName, 'target')):
                url += '/<target>'
            else:
                params.append(desc)

    return app.ceph_baseurl + url, params