Exemplo n.º 1
0
 def get_active_replicated_pools(self):
     ceph_api = CephAPI()
     active_pools = ceph_api.get_active_pools()
     pools_info = ceph_api.get_pools_info()
     replicated_active_pools = []
     for pool in pools_info:
         if pool.type == 'replicated' and pool.name in active_pools:
             replicated_active_pools.append(pool.name)
     return replicated_active_pools
Exemplo n.º 2
0
def test_active_clean():
    cluster_name = configuration().get_cluster_name()
    sleeps = [10, 15, 20, 25, 30, 40]
    tries = 5

    while tries:
        ceph_api = CephAPI()
        active_pools = ceph_api.get_active_pools()
        if 'rbd' in active_pools:
            logger.info('rbd pool is active')
            break
        tries -= 1
        sleep_seconds = sleeps.pop()
        logger.warning(
            'waiting %s seconds before retrying to check rbd pool status',
            sleep_seconds)
        time.sleep(sleep_seconds)
    def __get_next_disk_id(self):
        ceph_api = CephAPI()
        """
        pools = ceph_api.get_pools_info()
        ids = []
        for pool in pools:
            if not ceph_api.is_active_pool(pool.name) :
                continue
        """
        ids = []
        pools = ceph_api.get_active_pools()
        for pool in pools:
            pool_ids = ceph_api.get_disks_meta_ids(pool)
            ids.extend(pool_ids)

        consul_api = ConsulAPI()
        consul_disk_ids = consul_api.get_disk_pools().keys()
        ids.extend(consul_disk_ids)

        new_id = get_next_id(ids, 5)
        return new_id
Exemplo n.º 4
0
def remove_pool(pool_name, pool_type):
    """
    DOCSTRING : this function is called to delete a certain pool , then redirect to the page :
    'admin/pool/pools_list.html'.
    Args : pool_name (string)
    Returns : redirect to the page : 'admin/pool/pools_list.html'
    """

    if request.method == 'POST':
        try:

            manage_pool = ManagePools()
            pool_list = manage_pool.get_pools_info()
            pool_names = []
            for pool in pool_list:
                pool_names.append(pool.name)

            if pool_type == "erasure":
                delete_job_id = manage_pool.delete_pool(pool_name)


            elif pool_type == "replicated":
                ceph_api = CephAPI()
                pools = ceph_api.get_active_pools()
                if pool_name not in pools:
                    delete_job_id = manage_pool.delete_pool(pool_name)

                elif pool_name in pools:

                    meta_disk = ManageDisk().get_disks_meta_by_pool(pool_name)

                    if len(meta_disk) == 0:
                        delete_job_id = manage_pool.delete_pool(pool_name)

                    has_data_pool = 0
                    for disk in meta_disk:
                        if disk.data_pool is not None and disk.data_pool != "":
                            if disk.data_pool in pool_names:
                                has_data_pool += 1

                    if has_data_pool > 0:
                        session['err'] = "error_deleting_mata_pool"
                        return redirect(url_for('pool_controller.get_pools'))

                    else:
                        if len(meta_disk) > 0:
                            delete_job_id = manage_pool.delete_pool(pool_name)

            return redirect(url_for('pool_controller.get_pools', delete_job_id=delete_job_id, pool_name=pool_name))

        except CephException as e:
            if e.id == CephException.CONNECTION_TIMEOUT:
                session['err'] = "ui_admin_ceph_time_out"
                return redirect(url_for('pool_controller.get_pools'))

            elif e.id == CephException.GENERAL_EXCEPTION:
                session['err'] = "ui_admin_ceph_general_exception"
                return redirect(url_for('pool_controller.get_pools'))

            session['err'] = "ui_admin_ceph_general_exception"
            logger.error(e)
            return redirect(url_for('pool_controller.get_pools'))

        except Exception as e:
            session['err'] = "ui_admin_delete_pool_error"
            logger.error(e)
            return redirect(url_for('pool_controller.get_pools'))
Exemplo n.º 5
0
 def get_active_pools(self):
     ceph_api = CephAPI()
     active_pools = ceph_api.get_active_pools()
     return active_pools