Commit f641e8fb authored by Boris Glimcher's avatar Boris Glimcher Committed by Tomasz Zawadzki
Browse files

schema: check schema against python cli and validate all methods present



while linting, deprecated methods found in the schema,
so removing them part of this patch.

Change-Id: I6e13158426177c85d5c795a5b114815f12bb6ecd
Signed-off-by: default avatarBoris Glimcher <Boris.Glimcher@emc.com>
Reviewed-on: https://review.spdk.io/c/spdk/spdk/+/26763


Tested-by: default avatarSPDK Automated Test System <spdkbot@gmail.com>
Reviewed-by: default avatarKonrad Sztyber <ksztyber@nvidia.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz@tzawadzki.com>
parent 1acd8052
Loading
Loading
Loading
Loading
+0 −113
Original line number Diff line number Diff line
@@ -747,63 +747,6 @@
        }
      ]
    },
    {
      "name": "bdev_compress_create",
      "params": [
        {
          "name": "base_bdev_name",
          "type": "string",
          "required": true,
          "description": "Name of the base bdev"
        },
        {
          "name": "pm_path",
          "type": "string",
          "required": true,
          "description": "Path to persistent memory"
        },
        {
          "name": "lb_size",
          "type": "int",
          "required": false,
          "description": "Compressed vol logical block size (512 or 4096)"
        },
        {
          "name": "comp_algo",
          "type": "string",
          "required": false,
          "description": "Compression algorithm for the compressed vol. Default is deflate"
        },
        {
          "name": "comp_level",
          "type": "int",
          "required": false,
          "description": "Compression algorithm level for the compressed vol. Default is 1"
        }
      ]
    },
    {
      "name": "bdev_compress_delete",
      "params": [
        {
          "name": "name",
          "type": "string",
          "required": true,
          "description": "Name of the compress bdev"
        }
      ]
    },
    {
      "name": "bdev_compress_get_orphans",
      "params": [
        {
          "name": "name",
          "type": "string",
          "required": false,
          "description": "Name of the compress bdev"
        }
      ]
    },
    {
      "name": "bdev_crypto_create",
      "params": [
@@ -5514,62 +5457,6 @@
        }
      ]
    },
    {
      "name": "blobfs_detect",
      "params": [
        {
          "name": "bdev_name",
          "type": "string",
          "required": true,
          "description": "Block device name to detect blobfs"
        }
      ]
    },
    {
      "name": "blobfs_create",
      "params": [
        {
          "name": "bdev_name",
          "type": "string",
          "required": true,
          "description": "Block device name to create blobfs"
        },
        {
          "name": "cluster_sz",
          "type": "number",
          "required": false,
          "description": "Size of cluster in bytes. Must be multiple of 4KiB page size, default and minimal value is 1M."
        }
      ]
    },
    {
      "name": "blobfs_mount",
      "params": [
        {
          "name": "bdev_name",
          "type": "string",
          "required": true,
          "description": "Block device name where the blobfs is"
        },
        {
          "name": "mountpoint",
          "type": "string",
          "required": true,
          "description": "Mountpoint path in host to mount blobfs"
        }
      ]
    },
    {
      "name": "blobfs_set_cache_size",
      "params": [
        {
          "name": "size_in_mb",
          "type": "number",
          "required": true,
          "description": "Cache size in megabytes"
        }
      ]
    },
    {
      "name": "sock_impl_get_options",
      "params": [
+15 −0
Original line number Diff line number Diff line
@@ -13,6 +13,8 @@ from pathlib import Path
from tabulate import tabulate
from jinja2 import Environment, FileSystemLoader

import rpc

# Get directory of this script
base_dir = Path(__file__).resolve().parent.parent

@@ -30,6 +32,13 @@ def lint_json_examples():
                raise


def lint_py_cli(schema):
    parser, subparsers = rpc.create_parser()
    for method in schema['methods']:
        if method['name'] not in subparsers.choices:
            raise ValueError(f"{method['name']} defined in schema, was not found in python cli")


def generate_docs(schema):
    env = Environment(loader=FileSystemLoader(base_dir / "doc"),
                      keep_trailing_newline=True,
@@ -103,6 +112,12 @@ if __name__ == "__main__":
    with open(args.schema, "r") as file:
        schema = json.load(file)

    try:
        lint_py_cli(schema)
    except ValueError as e:
        print(f"Error: {e}", file=sys.stderr)
        sys.exit(1)

    if args.doc:
        generate_docs(schema)
    if args.rpc: