Example #1
0
def create_cloned_cg(client, cg_name, src_cg_name, pool_name, lun_sizes,
                     lun_names, src_lun_names, specs_list):
    cg_snap_name = utils.construct_tmp_cg_snap_name(cg_name)
    return create_cg_from_cg_snapshot(client,
                                      cg_name,
                                      src_cg_name,
                                      cg_snap_name,
                                      None,
                                      pool_name,
                                      lun_sizes,
                                      lun_names,
                                      src_lun_names,
                                      specs_list,
                                      copy_snap=False)
Example #2
0
def create_cloned_cg(client, cg_name, src_cg_name, pool_name, lun_sizes, lun_names, src_lun_names, specs_list):
    cg_snap_name = utils.construct_tmp_cg_snap_name(cg_name)
    return create_cg_from_cg_snapshot(
        client,
        cg_name,
        src_cg_name,
        cg_snap_name,
        None,
        pool_name,
        lun_sizes,
        lun_names,
        src_lun_names,
        specs_list,
        copy_snap=False,
    )
Example #3
0
def create_cg_from_cg_snapshot(
    client,
    cg_name,
    src_cg_name,
    cg_snap_name,
    src_cg_snap_name,
    pool_name,
    lun_sizes,
    lun_names,
    src_lun_names,
    specs_list,
    copy_snap=True,
):
    prepare_tasks = []
    store_spec = {}

    if copy_snap:
        flow_name = "create_cg_from_cg_snapshot"
        temp_cg_snap = utils.construct_tmp_cg_snap_name(cg_name)
        snap_name = temp_cg_snap
        store_spec.update({"snap_name": src_cg_snap_name, "new_snap_name": snap_name})
        prepare_tasks.append(CopySnapshotTask())
        prepare_tasks.append(AllowReadWriteTask(rebind={"snap_name": "new_snap_name"}))
    else:
        flow_name = "create_cg_from_cg"
        snap_name = cg_snap_name
        store_spec.update({"cg_name": src_cg_name, "cg_snap_name": snap_name})
        prepare_tasks.append(CreateCGSnapshotTask())

    work_flow = linear_flow.Flow(flow_name)
    work_flow.add(*prepare_tasks)
    new_src_id_template = "new_src_id_%s"
    new_dst_id_template = "new_dst_id_%s"
    new_dst_wwn_template = "new_dst_wwn_%s"

    common_store_spec = {"client": client, "pool_name": pool_name, "ignore_thresholds": True, "new_cg_name": cg_name}
    store_spec.update(common_store_spec)

    # Create LUNs for CG
    for i, lun_name in enumerate(lun_names):
        sub_store_spec = {
            "lun_name": utils.construct_tmp_lun_name(lun_name),
            "lun_size": lun_sizes[i],
            "provision": specs_list[i].provision,
            "tier": specs_list[i].tier,
            "base_lun_name": src_lun_names[i],
            "smp_name": lun_name,
            "snap_name": snap_name,
        }
        work_flow.add(
            CreateSMPTask(name="CreateSMPTask_%s" % i, inject=sub_store_spec, provides=new_src_id_template % i),
            AttachSnapTask(name="AttachSnapTask_%s" % i, inject=sub_store_spec),
            CreateLunTask(
                name="CreateLunTask_%s" % i,
                inject=sub_store_spec,
                provides=(new_dst_id_template % i, new_dst_wwn_template % i),
            ),
            MigrateLunTask(
                name="MigrateLunTask_%s" % i,
                inject=sub_store_spec,
                rebind={"src_id": new_src_id_template % i, "dst_id": new_dst_id_template % i},
                wait_for_completion=False,
            ),
        )

    # Wait all migration session finished
    work_flow.add(
        WaitMigrationsTask(new_src_id_template, new_dst_id_template, new_dst_wwn_template, len(lun_names)),
        CreateConsistencyGroupTask(new_src_id_template, len(lun_names)),
    )
    engine = taskflow.engines.load(work_flow, store=store_spec)
    engine.run()
    # Fetch all created LUNs and add them into CG
    lun_id_list = []
    for i, lun_name in enumerate(lun_names):
        lun_id = engine.storage.fetch(new_src_id_template % i)
        lun_id_list.append(lun_id)

    client.delete_cg_snapshot(snap_name)
    return lun_id_list
Example #4
0
def create_cg_from_cg_snapshot(client,
                               cg_name,
                               src_cg_name,
                               cg_snap_name,
                               src_cg_snap_name,
                               pool_name,
                               lun_sizes,
                               lun_names,
                               src_lun_names,
                               specs_list,
                               copy_snap=True):
    prepare_tasks = []
    store_spec = {}

    if copy_snap:
        flow_name = 'create_cg_from_cg_snapshot'
        temp_cg_snap = utils.construct_tmp_cg_snap_name(cg_name)
        snap_name = temp_cg_snap
        store_spec.update({
            'snap_name': src_cg_snap_name,
            'new_snap_name': snap_name
        })
        prepare_tasks.append(CopySnapshotTask())
        prepare_tasks.append(
            AllowReadWriteTask(rebind={'snap_name': 'new_snap_name'}))
    else:
        flow_name = 'create_cg_from_cg'
        snap_name = cg_snap_name
        store_spec.update({'cg_name': src_cg_name, 'cg_snap_name': snap_name})
        prepare_tasks.append(CreateCGSnapshotTask())

    work_flow = linear_flow.Flow(flow_name)
    work_flow.add(*prepare_tasks)
    new_src_id_template = 'new_src_id_%s'
    new_dst_id_template = 'new_dst_id_%s'
    new_dst_wwn_template = 'new_dst_wwn_%s'

    common_store_spec = {
        'client': client,
        'pool_name': pool_name,
        'ignore_thresholds': True,
        'new_cg_name': cg_name
    }
    store_spec.update(common_store_spec)

    # Create LUNs for CG
    for i, lun_name in enumerate(lun_names):
        sub_store_spec = {
            'lun_name': utils.construct_tmp_lun_name(lun_name),
            'lun_size': lun_sizes[i],
            'provision': specs_list[i].provision,
            'tier': specs_list[i].tier,
            'base_lun_name': src_lun_names[i],
            'smp_name': lun_name,
            'snap_name': snap_name,
        }
        work_flow.add(
            CreateSMPTask(name="CreateSMPTask_%s" % i,
                          inject=sub_store_spec,
                          provides=new_src_id_template % i),
            AttachSnapTask(name="AttachSnapTask_%s" % i,
                           inject=sub_store_spec),
            CreateLunTask(name="CreateLunTask_%s" % i,
                          inject=sub_store_spec,
                          provides=(new_dst_id_template % i,
                                    new_dst_wwn_template % i)),
            MigrateLunTask(name="MigrateLunTask_%s" % i,
                           inject=sub_store_spec,
                           rebind={
                               'src_id': new_src_id_template % i,
                               'dst_id': new_dst_id_template % i
                           },
                           wait_for_completion=False))

    # Wait all migration session finished
    work_flow.add(
        WaitMigrationsTask(new_src_id_template, new_dst_id_template,
                           new_dst_wwn_template, len(lun_names)),
        CreateConsistencyGroupTask(new_src_id_template, len(lun_names)))
    engine = taskflow.engines.load(work_flow, store=store_spec)
    engine.run()
    # Fetch all created LUNs and add them into CG
    lun_id_list = []
    for i, lun_name in enumerate(lun_names):
        lun_id = engine.storage.fetch(new_src_id_template % i)
        lun_id_list.append(lun_id)

    client.delete_cg_snapshot(snap_name)
    return lun_id_list