Exemplo n.º 1
0
def remove_disk_immediately(ring_name,
                            disk_device,
                            ip,
                            port,
                            policy_num,
                            cluster_name,
                            taskid=None):
    rm = RingManager(cluster_name)
    try:
        if not policy_num:
            ring_name = ring_name.split('.')[0]
            content = rm.remove_disk_immediately(ring_name=ring_name,
                                                 disk_device=disk_device,
                                                 ip=ip,
                                                 port=port)
        else:
            content = rm.remove_disk_immediately(disk_device=disk_device,
                                                 ip=ip,
                                                 port=port,
                                                 policy=True,
                                                 policy_num=policy_num)
        message = content
    except Exception, error:
        message = str(error)
        assert False
Exemplo n.º 2
0
def remove_disk_imm(cluster_name, datajson):
    """
    向环中立即删除磁盘
    :param ringjson:
    :return:
    """
    status = ''
    message = ''
    resp = {"status": status, "message": message}
    policy_num = ''
    ip = datajson.get('ip')
    port = datajson.get('port')
    device = datajson.get('device')
    ring_name = datajson.get('ring_name')
    ring_name = ring_name if ring_name.endswith(
        '.ring.gz') else ring_name + '.ring.gz'
    if 'object-' in ring_name:
        obj_ring, policy_num = ring_name.rstrip('.ring.gz').split('-')
    sfo_clu_nodes = SfoClusterNodesMethod.query_host_list_by_cluster_name(
        cluster_name)
    if not sfo_clu_nodes:
        raise ValueError('Not Master Node in %s' % cluster_name)
    # 建立task 任务
    rm = RingManager(cluster_name)
    try:
        if not policy_num:
            ring_name = ring_name.split('.')[0]
            content = rm.remove_disk_immediately(ring_name=ring_name,
                                                 disk_device=device,
                                                 ip=ip,
                                                 port=port)
        else:
            content = rm.remove_disk_immediately(disk_device=device,
                                                 ip=ip,
                                                 port=port,
                                                 policy=True,
                                                 policy_num=policy_num)
    except Exception, error:
        status = 501
        message = str(error)