Exemple #1
0
def delete_znodes(cluster_name, path, recursive=False, del_snapshots=True):
    """delete znodes' meta info in mysql
    """
    del_znode_query = del_snapshot_query = None
    if recursive:
        # monkey patch for delete znodes recursively
        target_path = path.rstrip("/") + "/"
        del_znode_query = ZdZnode.delete().where(
            (ZdZnode.cluster_name == cluster_name) &
            ((ZdZnode.path.startswith(target_path)) | (ZdSnapshot.path == path))
        )
        del_snapshot_query = ZdSnapshot.delete().where(
            (ZdSnapshot.cluster_name == cluster_name) &
            ((ZdSnapshot.path.startswith(target_path)) | (ZdSnapshot.path == path))
        )
    else:
        del_znode_query = ZdZnode.delete().where(
            (ZdZnode.cluster_name == cluster_name) &
            (ZdZnode.path == path)
        )
        del_snapshot_query = ZdSnapshot.delete().where(
            (ZdSnapshot.cluster_name == cluster_name) &
            (ZdSnapshot.path == path)
        )
    del_znode_query.execute()
    if del_snapshots:
        del_snapshot_query.execute()
Exemple #2
0
def delete_snapshots(cluster_name, path, recursive='0'):
    """删除快照数据信息
    """
    if recursive == "1":
        # monkey patch for delete snapshots recursively
        target_path = path.rstrip("/") + "/"
        del_snapshot_query = ZdSnapshot.delete().where(
            (ZdSnapshot.cluster_name == cluster_name)
            & ((ZdSnapshot.path.startswith(target_path))
               | (ZdSnapshot.path == path)))
    else:
        del_snapshot_query = ZdSnapshot.delete().where(
            (ZdSnapshot.cluster_name == cluster_name)
            & (ZdSnapshot.path == path))
    del_snapshot_query.execute()
Exemple #3
0
def delete_snapshots(cluster_name, path, recursive="0"):
    """删除快照数据信息
    """
    if recursive == "1":
        # monkey patch for delete snapshots recursively
        target_path = path.rstrip("/") + "/"
        del_snapshot_query = ZdSnapshot.delete().where(
            (ZdSnapshot.cluster_name == cluster_name)
            & ((ZdSnapshot.path.startswith(target_path)) | (ZdSnapshot.path == path))
        )
    else:
        del_snapshot_query = ZdSnapshot.delete().where(
            (ZdSnapshot.cluster_name == cluster_name) & (ZdSnapshot.path == path)
        )
    del_snapshot_query.execute()
Exemple #4
0
def delete_znodes(cluster_name, path, recursive=False, del_snapshots=True):
    """delete znodes' meta info in mysql
    """
    del_znode_query = del_snapshot_query = None
    if recursive:
        # monkey patch for delete znodes recursively
        target_path = path.rstrip("/") + "/"
        del_znode_query = ZdZnode.delete().where(
            (ZdZnode.cluster_name == cluster_name)
            & ((ZdZnode.path.startswith(target_path))
               | (ZdSnapshot.path == path)))
        del_snapshot_query = ZdSnapshot.delete().where(
            (ZdSnapshot.cluster_name == cluster_name)
            & ((ZdSnapshot.path.startswith(target_path))
               | (ZdSnapshot.path == path)))
    else:
        del_znode_query = ZdZnode.delete().where(
            (ZdZnode.cluster_name == cluster_name) & (ZdZnode.path == path))
        del_snapshot_query = ZdSnapshot.delete().where(
            (ZdSnapshot.cluster_name == cluster_name)
            & (ZdSnapshot.path == path))
    del_znode_query.execute()
    if del_snapshots:
        del_snapshot_query.execute()