Example #1
0
def remove_volumes(cinder_client, default_volumes):
    logger.debug("Removing Cinder volumes...")
    volumes = os_utils.get_volumes(cinder_client)
    if volumes is None or len(volumes) == 0:
        logger.debug("No volumes found.")
        return

    for volume in volumes:
        volume_id = getattr(volume, 'id')
        volume_name = getattr(volume, 'display_name')
        logger.debug("'%s', ID=%s " % (volume_name, volume_id))
        if (volume_id not in default_volumes
                and volume_name not in default_volumes.values()):
            logger.debug("Removing cinder volume %s ..." % volume_id)
            if os_utils.delete_volume(cinder_client, volume_id):
                logger.debug("  > Done!")
            else:
                logger.debug("Trying forced removal...")
                if os_utils.delete_volume(cinder_client,
                                          volume_id,
                                          forced=True):
                    logger.debug("  > Done!")
                else:
                    logger.error("There has been a problem removing the "
                                 "volume %s..." % volume_id)
        else:
            logger.debug("   > this is a default volume and will "
                         "NOT be deleted.")
def remove_volumes(cinder_client, default_volumes):
    logger.info("Removing Cinder volumes...")
    volumes = os_utils.get_volumes(cinder_client)
    if volumes is None or len(volumes) == 0:
        logger.debug("No volumes found.")
        return

    for volume in volumes:
        volume_id = getattr(volume, 'id')
        volume_name = getattr(volume, 'display_name')
        logger.debug("'%s', ID=%s " % (volume_name, volume_id))
        if volume_id not in default_volumes:
            logger.debug("Removing cinder volume %s ..." % volume_id)
            if os_utils.delete_volume(cinder_client, volume_id):
                logger.debug("  > Done!")
            else:
                logger.debug("Trying forced removal...")
                if os_utils.delete_volume(cinder_client,
                                          volume_id,
                                          forced=True):
                    logger.debug("  > Done!")
                else:
                    logger.error("There has been a problem removing the "
                                 "volume %s..." % volume_id)
        else:
            logger.debug("   > this is a default volume and will "
                         "NOT be deleted.")
def get_volumes(cinder_client):
    logger.debug("Getting volumes...")
    dic_volumes = {}
    volumes = os_utils.get_volumes(cinder_client)
    if volumes is not None:
        for volume in volumes:
            dic_volumes.update({volume.id: volume.display_name})
    return {'volumes': dic_volumes}
Example #4
0
def get_volumes(cinder_client):
    logger.debug("Getting volumes...")
    dic_volumes = {}
    volumes = os_utils.get_volumes(cinder_client)
    if volumes is not None:
        for volume in volumes:
            dic_volumes.update({volume.id: volume.display_name})
    return {'volumes': dic_volumes}