Example #1
0
def run_migration_taskflow(client,
                           lun_id,
                           lun_name,
                           lun_size,
                           pool_name,
                           provision,
                           tier,
                           rate=const.MIGRATION_RATE_HIGH):
    # Step 1: create target LUN
    # Step 2: start and migrate migration session
    tmp_lun_name = utils.construct_tmp_lun_name(lun_name)
    flow_name = 'migrate_lun'
    store_spec = {
        'client': client,
        'pool_name': pool_name,
        'lun_name': tmp_lun_name,
        'lun_size': lun_size,
        'provision': provision,
        'tier': tier,
        'ignore_thresholds': True,
        'src_id': lun_id,
    }
    work_flow = linear_flow.Flow(flow_name)
    work_flow.add(CreateLunTask(),
                  MigrateLunTask(rebind={'dst_id': 'new_lun_id'}))
    engine = taskflow.engines.load(work_flow, store=store_spec)
    engine.run()
Example #2
0
def run_migration_taskflow(
    client, lun_id, lun_name, lun_size, pool_name, provision, tier, rate=const.MIGRATION_RATE_HIGH
):
    # Step 1: create target LUN
    # Step 2: start and migrate migration session
    tmp_lun_name = utils.construct_tmp_lun_name(lun_name)
    flow_name = "migrate_lun"
    store_spec = {
        "client": client,
        "pool_name": pool_name,
        "lun_name": tmp_lun_name,
        "lun_size": lun_size,
        "provision": provision,
        "tier": tier,
        "ignore_thresholds": True,
        "src_id": lun_id,
    }
    work_flow = linear_flow.Flow(flow_name)
    work_flow.add(CreateLunTask(), MigrateLunTask(rebind={"dst_id": "new_lun_id"}))
    engine = taskflow.engines.load(work_flow, store=store_spec)
    engine.run()
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