示例#1
0
def handle_create_erasure_profile(request, service):
    """Create an erasure profile.

    :param request: dict of request operations and params
    :param service: The ceph client to run the command under.
    :returns: dict. exit-code and reason if not 0
    """
    # "local" | "shec" or it defaults to "jerasure"
    erasure_type = request.get('erasure-type')
    # "host" | "rack" or it defaults to "host"  # Any valid Ceph bucket
    failure_domain = request.get('failure-domain')
    name = request.get('name')
    # Binary Distribution Matrix (BDM) parameters
    bdm_k = request.get('k')
    bdm_m = request.get('m')
    bdm_l = request.get('l')

    if failure_domain not in CEPH_BUCKET_TYPES:
        msg = "failure-domain must be one of {}".format(CEPH_BUCKET_TYPES)
        log(msg, level=ERROR)
        return {'exit-code': 1, 'stderr': msg}

    create_erasure_profile(service=service,
                           erasure_plugin_name=erasure_type,
                           profile_name=name,
                           failure_domain=failure_domain,
                           data_chunks=bdm_k,
                           coding_chunks=bdm_m,
                           locality=bdm_l)
示例#2
0
def handle_create_erasure_profile(request, service):
    """Create an erasure profile.

    :param request: dict of request operations and params
    :param service: The ceph client to run the command under.
    :returns: dict. exit-code and reason if not 0
    """
    # "isa" | "lrc" | "shec" | "clay" or it defaults to "jerasure"
    erasure_type = request.get('erasure-type')
    # dependent on erasure coding type
    erasure_technique = request.get('erasure-technique')
    # "host" | "rack" | ...
    failure_domain = request.get('failure-domain')
    name = request.get('name')
    # Binary Distribution Matrix (BDM) parameters
    bdm_k = request.get('k')
    bdm_m = request.get('m')
    # LRC parameters
    bdm_l = request.get('l')
    crush_locality = request.get('crush-locality')
    # SHEC parameters
    bdm_c = request.get('c')
    # CLAY parameters
    bdm_d = request.get('d')
    scalar_mds = request.get('scalar-mds')
    # Device Class
    device_class = request.get('device-class')

    if failure_domain and failure_domain not in CEPH_BUCKET_TYPES:
        msg = "failure-domain must be one of {}".format(CEPH_BUCKET_TYPES)
        log(msg, level=ERROR)
        return {'exit-code': 1, 'stderr': msg}

    create_erasure_profile(service=service,
                           erasure_plugin_name=erasure_type,
                           profile_name=name,
                           failure_domain=failure_domain,
                           data_chunks=bdm_k,
                           coding_chunks=bdm_m,
                           locality=bdm_l,
                           durability_estimator=bdm_d,
                           helper_chunks=bdm_c,
                           scalar_mds=scalar_mds,
                           crush_locality=crush_locality,
                           device_class=device_class,
                           erasure_plugin_technique=erasure_technique)

    return {'exit-code': 0}
示例#3
0
def handle_create_erasure_profile(request, service):
    # "local" | "shec" or it defaults to "jerasure"
    erasure_type = request.get('erasure-type')
    # "host" | "rack" or it defaults to "host"  # Any valid Ceph bucket
    failure_domain = request.get('failure-domain')
    name = request.get('name')
    k = request.get('k')
    m = request.get('m')
    l = request.get('l')

    if failure_domain not in CEPH_BUCKET_TYPES:
        msg = "failure-domain must be one of {}".format(CEPH_BUCKET_TYPES)
        log(msg, level=ERROR)
        return {'exit-code': 1, 'stderr': msg}

    create_erasure_profile(service=service, erasure_plugin_name=erasure_type,
                           profile_name=name, failure_domain=failure_domain,
                           data_chunks=k, coding_chunks=m, locality=l)
def handle_create_erasure_profile(request, service):
    # "local" | "shec" or it defaults to "jerasure"
    erasure_type = request.get('erasure-type')
    # "host" | "rack" or it defaults to "host"  # Any valid Ceph bucket
    failure_domain = request.get('failure-domain')
    name = request.get('name')
    k = request.get('k')
    m = request.get('m')
    l = request.get('l')

    if failure_domain not in CEPH_BUCKET_TYPES:
        msg = "failure-domain must be one of {}".format(CEPH_BUCKET_TYPES)
        log(msg, level=ERROR)
        return {'exit-code': 1, 'stderr': msg}

    create_erasure_profile(service=service,
                           erasure_plugin_name=erasure_type,
                           profile_name=name,
                           failure_domain=failure_domain,
                           data_chunks=k,
                           coding_chunks=m,
                           locality=l)
示例#5
0
def handle_create_erasure_profile(request, service):
    """Create an erasure profile.

    :param request: dict of request operations and params
    :param service: The ceph client to run the command under.
    :returns: dict. exit-code and reason if not 0
    """
    # "local" | "shec" or it defaults to "jerasure"
    erasure_type = request.get('erasure-type')
    # "host" | "rack" or it defaults to "host"  # Any valid Ceph bucket
    failure_domain = request.get('failure-domain')
    name = request.get('name')
    k = request.get('k')
    m = request.get('m')
    l = request.get('l')

    if failure_domain not in CEPH_BUCKET_TYPES:
        msg = "failure-domain must be one of {}".format(CEPH_BUCKET_TYPES)
        log(msg, level=ERROR)
        return {'exit-code': 1, 'stderr': msg}

    create_erasure_profile(service=service, erasure_plugin_name=erasure_type,
                           profile_name=name, failure_domain=failure_domain,
                           data_chunks=k, coding_chunks=m, locality=l)
def make_erasure_profile():
    name = action_get("name")
    plugin = action_get("plugin")
    failure_domain = action_get("failure-domain")

    # jerasure requires k+m
    # isa requires k+m
    # local requires k+m+l
    # shec requires k+m+c

    if plugin == "jerasure":
        k = action_get("data-chunks")
        m = action_get("coding-chunks")
        try:
            create_erasure_profile(service='admin',
                                   erasure_plugin_name=plugin,
                                   profile_name=name,
                                   data_chunks=k,
                                   coding_chunks=m,
                                   failure_domain=failure_domain)
        except CalledProcessError as e:
            log(e)
            action_fail("Create erasure profile failed with "
                        "message: {}".format(e.message))
    elif plugin == "isa":
        k = action_get("data-chunks")
        m = action_get("coding-chunks")
        try:
            create_erasure_profile(service='admin',
                                   erasure_plugin_name=plugin,
                                   profile_name=name,
                                   data_chunks=k,
                                   coding_chunks=m,
                                   failure_domain=failure_domain)
        except CalledProcessError as e:
            log(e)
            action_fail("Create erasure profile failed with "
                        "message: {}".format(e.message))
    elif plugin == "local":
        k = action_get("data-chunks")
        m = action_get("coding-chunks")
        l = action_get("locality-chunks")
        try:
            create_erasure_profile(service='admin',
                                   erasure_plugin_name=plugin,
                                   profile_name=name,
                                   data_chunks=k,
                                   coding_chunks=m,
                                   locality=l,
                                   failure_domain=failure_domain)
        except CalledProcessError as e:
            log(e)
            action_fail("Create erasure profile failed with "
                        "message: {}".format(e.message))
    elif plugin == "shec":
        k = action_get("data-chunks")
        m = action_get("coding-chunks")
        c = action_get("durability-estimator")
        try:
            create_erasure_profile(service='admin',
                                   erasure_plugin_name=plugin,
                                   profile_name=name,
                                   data_chunks=k,
                                   coding_chunks=m,
                                   durability_estimator=c,
                                   failure_domain=failure_domain)
        except CalledProcessError as e:
            log(e)
            action_fail("Create erasure profile failed with "
                        "message: {}".format(e.message))
    else:
        # Unknown erasure plugin
        action_fail("Unknown erasure-plugin type of {}. "
                    "Only jerasure, isa, local or shec is "
                    "allowed".format(plugin))
示例#7
0
def make_erasure_profile():
    name = action_get("name")
    plugin = action_get("plugin")
    failure_domain = action_get("failure-domain")
    device_class = action_get("device-class")
    k = action_get("data-chunks")
    m = action_get("coding-chunks")

    # jerasure requires k+m
    # isa requires k+m
    # local requires k+m+l
    # shec requires k+m+c

    if plugin == "jerasure":
        try:
            create_erasure_profile(service='admin',
                                   erasure_plugin_name=plugin,
                                   profile_name=name,
                                   data_chunks=k,
                                   coding_chunks=m,
                                   failure_domain=failure_domain,
                                   device_class=device_class)
        except CalledProcessError as e:
            log(e)
            action_fail("Create erasure profile failed with "
                        "message: {}".format(str(e)))
    elif plugin == "isa":
        try:
            create_erasure_profile(service='admin',
                                   erasure_plugin_name=plugin,
                                   profile_name=name,
                                   data_chunks=k,
                                   coding_chunks=m,
                                   failure_domain=failure_domain,
                                   device_class=device_class)
        except CalledProcessError as e:
            log(e)
            action_fail("Create erasure profile failed with "
                        "message: {}".format(str(e)))
    elif plugin == "lrc":
        locality_chunks = action_get("locality-chunks")
        crush_locality = action_get('crush-locality')
        try:
            create_erasure_profile(service='admin',
                                   erasure_plugin_name=plugin,
                                   profile_name=name,
                                   data_chunks=k,
                                   coding_chunks=m,
                                   locality=locality_chunks,
                                   crush_locality=crush_locality,
                                   failure_domain=failure_domain,
                                   device_class=device_class)
        except CalledProcessError as e:
            log(e)
            action_fail("Create erasure profile failed with "
                        "message: {}".format(str(e)))
    elif plugin == "shec":
        c = action_get("durability-estimator")
        try:
            create_erasure_profile(service='admin',
                                   erasure_plugin_name=plugin,
                                   profile_name=name,
                                   data_chunks=k,
                                   coding_chunks=m,
                                   durability_estimator=c,
                                   failure_domain=failure_domain,
                                   device_class=device_class)
        except CalledProcessError as e:
            log(e)
            action_fail("Create erasure profile failed with "
                        "message: {}".format(str(e)))
    elif plugin == "clay":
        d = action_get("helper-chunks")
        scalar_mds = action_get('scalar-mds')
        try:
            create_erasure_profile(service='admin',
                                   erasure_plugin_name=plugin,
                                   profile_name=name,
                                   data_chunks=k,
                                   coding_chunks=m,
                                   helper_chunks=d,
                                   scalar_mds=scalar_mds,
                                   failure_domain=failure_domain,
                                   device_class=device_class)
        except CalledProcessError as e:
            log(e)
            action_fail("Create erasure profile failed with "
                        "message: {}".format(str(e)))
    else:
        # Unknown erasure plugin
        action_fail("Unknown erasure-plugin type of {}. "
                    "Only jerasure, isa, lrc, shec or clay is "
                    "allowed".format(plugin))