def create_vg(ns, devices, name, extent_size=None):
    devs = [common.str2device(ns, device) for device in devices]
    args = { 'InExtents': devs,
            'ElementName': name}
    goal = None

    try:
        if extent_size:
            # create (and use) VGStorageSetting
            caps = ns.LMI_VGStorageCapabilities.first_instance()
            (ret, outparams, err) = caps.CreateVGStorageSetting(
                    InExtents=devs)
            if ret != 0:
                if err:
                    raise LmiFailed("Cannot create setting for the volume " \
                            "group: %s." % err)
                vals = caps.CreateVGStorageSetting.CreateVGStorageSettingValues
                raise LmiFailed("Cannot create setting for the volume group:" \
                        " %s." % (vals.value_name(ret),))
            goal = outparams['Setting']
            goal = goal.to_instance()
            goal.ExtentSize = extent_size
            (ret, outparams, err) = goal.push()
            if ret != 0:
                if err:
                    raise LmiFailed("Cannot modify setting for the volume " \
                            "group: %s." % err)
                raise LmiFailed("Cannot modify setting for the volume group:" \
                        " %d." % ret)
            args['Goal'] = goal

        service = ns.LMI_StorageConfigurationService.first_instance()
        (ret, outparams, err) = service.SyncCreateOrModifyVG(**args)
        if ret != 0:
            if err:
                raise LmiFailed("Cannot create the volume group: %s." % err)
            values = service.CreateOrModifyVG.CreateOrModifyVGValues
            raise LmiFailed("Cannot create the volume group: %s."
                    % (values.value_name(ret),))
    finally:
        if goal:
            goal.delete()

    pool = outparams['Pool'].to_instance()
    LOG().info("Created volume group %s", pool.Name)
    return pool
Create new Volume Group from given devices.
dataset/ETHPy150Open openlmi/openlmi-scripts/commands/storage/lmi/scripts/storage/lvm.py/create_vg