def create_lv(ns, vg, name, size):
    vg = common.str2vg(ns, vg)
    service = ns.LMI_StorageConfigurationService.first_instance()
    (ret, outparams, err) = service.SyncCreateOrModifyLV(
            ElementName=name,
            Size=size,
            InPool=vg)
    if ret != 0:
        if err:
            raise LmiFailed("Cannot create the logical volume: %s." % err)
        values = service.CreateOrModifyLV.CreateOrModifyLVValues
        raise LmiFailed("Cannot create the logical volume: %s."
                % (values.value_name(ret),))

    lv = outparams['TheElement'].to_instance()
    LOG().info("Created logical volume %s", lv.Name)
    return lv
Write L{testModuleImpl} to a file.
dataset/ETHPy150Open openlmi/openlmi-scripts/commands/storage/lmi/scripts/storage/lvm.py/create_lv--crossover with--dataset/ETHPy150Open twisted/nevow/nevow/test/test_athena.py/AthenaModuleTestMixin.setUp