예제 #1
0
 def test_delete_pool(self):
     ceph_utils.delete_pool('cinder', 'pool')
     _cmd = [
         'ceph', '--id', 'cinder', 'osd', 'pool', 'delete', 'pool',
         '--yes-i-really-really-mean-it'
     ]
     self.check_call.assert_called_with(_cmd)
예제 #2
0
def process_requests_v1(reqs):
    """Process v1 requests.

    Takes a list of requests (dicts) and processes each one. If an error is
    found, processing stops and the client is notified in the response.

    Returns a response dict containing the exit code (non-zero if any
    operation failed along with an explanation).
    """
    log("Processing %s ceph broker requests" % (len(reqs)), level=INFO)
    for req in reqs:
        op = req.get('op')
        log("Processing op='%s'" % op, level=DEBUG)
        # Use admin client since we do not have other client key locations
        # setup to use them for these operations.
        svc = 'admin'
        if op == "create-pool":
            pool_type = req.get('pool-type')  # "replicated" | "erasure"

            # Default to replicated if pool_type isn't given
            if pool_type == 'erasure':
                handle_erasure_pool(request=req, service=svc)
            else:
                handle_replicated_pool(request=req, service=svc)
        elif op == "create-cache-tier":
            handle_create_cache_tier(request=req, service=svc)
        elif op == "remove-cache-tier":
            handle_remove_cache_tier(request=req, service=svc)
        elif op == "create-erasure-profile":
            handle_create_erasure_profile(request=req, service=svc)
        elif op == "delete-pool":
            pool = req.get('name')
            delete_pool(service=svc, name=pool)
        elif op == "rename-pool":
            old_name = req.get('name')
            new_name = req.get('new-name')
            rename_pool(service=svc, old_name=old_name, new_name=new_name)
        elif op == "snapshot-pool":
            pool = req.get('name')
            snapshot_name = req.get('snapshot-name')
            snapshot_pool(service=svc,
                          pool_name=pool,
                          snapshot_name=snapshot_name)
        elif op == "remove-pool-snapshot":
            pool = req.get('name')
            snapshot_name = req.get('snapshot-name')
            remove_pool_snapshot(service=svc,
                                 pool_name=pool,
                                 snapshot_name=snapshot_name)
        elif op == "set-pool-value":
            handle_set_pool_value(request=req, service=svc)
        else:
            msg = "Unknown operation '%s'" % op
            log(msg, level=ERROR)
            return {'exit-code': 1, 'stderr': msg}

    return {'exit-code': 0}
예제 #3
0
def process_requests_v1(reqs):
    """Process v1 requests.

    Takes a list of requests (dicts) and processes each one. If an error is
    found, processing stops and the client is notified in the response.

    Returns a response dict containing the exit code (non-zero if any
    operation failed along with an explanation).
    """
    log("Processing %s ceph broker requests" % (len(reqs)), level=INFO)
    for req in reqs:
        op = req.get('op')
        log("Processing op='%s'" % op, level=DEBUG)
        # Use admin client since we do not have other client key locations
        # setup to use them for these operations.
        svc = 'admin'
        if op == "create-pool":
            pool_type = req.get('pool-type')  # "replicated" | "erasure"

            # Default to replicated if pool_type isn't given
            if pool_type == 'erasure':
                handle_erasure_pool(request=req, service=svc)
            else:
                handle_replicated_pool(request=req, service=svc)
        elif op == "create-cache-tier":
            handle_create_cache_tier(request=req, service=svc)
        elif op == "remove-cache-tier":
            handle_remove_cache_tier(request=req, service=svc)
        elif op == "create-erasure-profile":
            handle_create_erasure_profile(request=req, service=svc)
        elif op == "delete-pool":
            pool = req.get('name')
            delete_pool(service=svc, name=pool)
        elif op == "rename-pool":
            old_name = req.get('name')
            new_name = req.get('new-name')
            rename_pool(service=svc, old_name=old_name, new_name=new_name)
        elif op == "snapshot-pool":
            pool = req.get('name')
            snapshot_name = req.get('snapshot-name')
            snapshot_pool(service=svc, pool_name=pool,
                          snapshot_name=snapshot_name)
        elif op == "remove-pool-snapshot":
            pool = req.get('name')
            snapshot_name = req.get('snapshot-name')
            remove_pool_snapshot(service=svc, pool_name=pool,
                                 snapshot_name=snapshot_name)
        elif op == "set-pool-value":
            handle_set_pool_value(request=req, service=svc)
        else:
            msg = "Unknown operation '%s'" % op
            log(msg, level=ERROR)
            return {'exit-code': 1, 'stderr': msg}

    return {'exit-code': 0}
예제 #4
0
def process_requests_v1(reqs):
    """Process v1 requests.

    Takes a list of requests (dicts) and processes each one. If an error is
    found, processing stops and the client is notified in the response.

    Returns a response dict containing the exit code (non-zero if any
    operation failed along with an explanation).
    """
    ret = None
    log("Processing {} ceph broker requests".format(len(reqs)), level=INFO)
    for req in reqs:
        op = req.get('op')
        log("Processing op='{}'".format(op), level=DEBUG)
        # Use admin client since we do not have other client key locations
        # setup to use them for these operations.
        svc = 'admin'
        if op == "create-pool":
            pool_type = req.get('pool-type')  # "replicated" | "erasure"

            # Default to replicated if pool_type isn't given
            if pool_type == 'erasure':
                ret = handle_erasure_pool(request=req, service=svc)
            else:
                ret = handle_replicated_pool(request=req, service=svc)
        elif op == "create-cephfs":
            ret = handle_create_cephfs(request=req, service=svc)
        elif op == "create-cache-tier":
            ret = handle_create_cache_tier(request=req, service=svc)
        elif op == "remove-cache-tier":
            ret = handle_remove_cache_tier(request=req, service=svc)
        elif op == "create-erasure-profile":
            ret = handle_create_erasure_profile(request=req, service=svc)
        elif op == "delete-pool":
            pool = req.get('name')
            ret = delete_pool(service=svc, name=pool)
        elif op == "rename-pool":
            old_name = req.get('name')
            new_name = req.get('new-name')
            ret = rename_pool(service=svc, old_name=old_name,
                              new_name=new_name)
        elif op == "snapshot-pool":
            pool = req.get('name')
            snapshot_name = req.get('snapshot-name')
            ret = snapshot_pool(service=svc, pool_name=pool,
                                snapshot_name=snapshot_name)
        elif op == "remove-pool-snapshot":
            pool = req.get('name')
            snapshot_name = req.get('snapshot-name')
            ret = remove_pool_snapshot(service=svc, pool_name=pool,
                                       snapshot_name=snapshot_name)
        elif op == "set-pool-value":
            ret = handle_set_pool_value(request=req, service=svc)
        elif op == "rgw-region-set":
            ret = handle_rgw_region_set(request=req, service=svc)
        elif op == "rgw-zone-set":
            ret = handle_rgw_zone_set(request=req, service=svc)
        elif op == "rgw-regionmap-update":
            ret = handle_rgw_regionmap_update(request=req, service=svc)
        elif op == "rgw-regionmap-default":
            ret = handle_rgw_regionmap_default(request=req, service=svc)
        elif op == "rgw-create-user":
            ret = handle_rgw_create_user(request=req, service=svc)
        elif op == "move-osd-to-bucket":
            ret = handle_put_osd_in_bucket(request=req, service=svc)
        elif op == "add-permissions-to-key":
            ret = handle_add_permissions_to_key(request=req, service=svc)
        else:
            msg = "Unknown operation '{}'".format(op)
            log(msg, level=ERROR)
            return {'exit-code': 1, 'stderr': msg}

    if type(ret) == dict and 'exit-code' in ret:
        return ret

    return {'exit-code': 0}
예제 #5
0
def process_requests_v1(reqs):
    """Process v1 requests.

    Takes a list of requests (dicts) and processes each one. If an error is
    found, processing stops and the client is notified in the response.

    Returns a response dict containing the exit code (non-zero if any
    operation failed along with an explanation).
    """
    ret = None
    log("Processing {} ceph broker requests".format(len(reqs)), level=INFO)
    for req in reqs:
        op = req.get('op')
        log("Processing op='{}'".format(op), level=DEBUG)
        # Use admin client since we do not have other client key locations
        # setup to use them for these operations.
        svc = 'admin'
        if op == "create-pool":
            pool_type = req.get('pool-type')  # "replicated" | "erasure"

            # Default to replicated if pool_type isn't given
            if pool_type == 'erasure':
                ret = handle_erasure_pool(request=req, service=svc)
            else:
                ret = handle_replicated_pool(request=req, service=svc)
        elif op == "create-cephfs":
            ret = handle_create_cephfs(request=req, service=svc)
        elif op == "create-cache-tier":
            ret = handle_create_cache_tier(request=req, service=svc)
        elif op == "remove-cache-tier":
            ret = handle_remove_cache_tier(request=req, service=svc)
        elif op == "create-erasure-profile":
            ret = handle_create_erasure_profile(request=req, service=svc)
        elif op == "delete-pool":
            pool = req.get('name')
            ret = delete_pool(service=svc, name=pool)
        elif op == "rename-pool":
            old_name = req.get('name')
            new_name = req.get('new-name')
            ret = rename_pool(service=svc, old_name=old_name,
                              new_name=new_name)
        elif op == "snapshot-pool":
            pool = req.get('name')
            snapshot_name = req.get('snapshot-name')
            ret = snapshot_pool(service=svc, pool_name=pool,
                                snapshot_name=snapshot_name)
        elif op == "remove-pool-snapshot":
            pool = req.get('name')
            snapshot_name = req.get('snapshot-name')
            ret = remove_pool_snapshot(service=svc, pool_name=pool,
                                       snapshot_name=snapshot_name)
        elif op == "set-pool-value":
            ret = handle_set_pool_value(request=req, service=svc)
        elif op == "rgw-region-set":
            ret = handle_rgw_region_set(request=req, service=svc)
        elif op == "rgw-zone-set":
            ret = handle_rgw_zone_set(request=req, service=svc)
        elif op == "rgw-regionmap-update":
            ret = handle_rgw_regionmap_update(request=req, service=svc)
        elif op == "rgw-regionmap-default":
            ret = handle_rgw_regionmap_default(request=req, service=svc)
        elif op == "rgw-create-user":
            ret = handle_rgw_create_user(request=req, service=svc)
        elif op == "move-osd-to-bucket":
            ret = handle_put_osd_in_bucket(request=req, service=svc)
        elif op == "add-permissions-to-key":
            ret = handle_add_permissions_to_key(request=req, service=svc)
        else:
            msg = "Unknown operation '{}'".format(op)
            log(msg, level=ERROR)
            return {'exit-code': 1, 'stderr': msg}

    if type(ret) == dict and 'exit-code' in ret:
        return ret

    return {'exit-code': 0}