Commit f60eeb6f authored by Pawel Kaminski's avatar Pawel Kaminski Committed by Jim Harris
Browse files

scripts/rpc: Add include_aliases flag to rpc_get_methods.



It will allow to return list of RPC with aliases.

Change-Id: Iee6be1a6f4e78a11e5b81e4a7298e32851e7920c
Signed-off-by: default avatarPawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/465926


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarPaul Luse <paul.e.luse@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarBroadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
parent 139e4c07
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -53,10 +53,12 @@ if __name__ == "__main__":

    def rpc_get_methods(args):
        print_dict(rpc.rpc_get_methods(args.client,
                                       current=args.current))
                                       current=args.current,
                                       include_aliases=args.include_aliases))

    p = subparsers.add_parser('rpc_get_methods', help='Get list of supported RPC methods', aliases=['get_rpc_methods'])
    p.add_argument('-c', '--current', help='Get list of RPC methods only callable in the current state.', action='store_true')
    p.add_argument('-i', '--include-aliases', help='include RPC aliases', action='store_true')
    p.set_defaults(func=rpc_get_methods)

    def get_spdk_version(args):
@@ -77,9 +79,11 @@ if __name__ == "__main__":
    p.set_defaults(func=save_config)

    def load_config(args):
        rpc.load_config(args.client, sys.stdin)
        rpc.load_config(args.client, sys.stdin,
                        include_aliases=args.include_aliases)

    p = subparsers.add_parser('load_config', help="""Configure SPDK subsystems and targets using JSON RPC read from stdin.""")
    p.add_argument('-i', '--include-aliases', help='include RPC aliases', action='store_true')
    p.set_defaults(func=load_config)

    def save_subsystem_config(args):
+8 −4
Original line number Diff line number Diff line
@@ -32,15 +32,18 @@ def wait_subsystem_init(client):


@deprecated_alias("get_rpc_methods")
def rpc_get_methods(client, current=None):
def rpc_get_methods(client, current=None, include_aliases=None):
    """Get list of supported RPC methods.
    Args:
        current: Get list of RPC methods only callable in the current state.
        include_aliases: Include aliases in the list with RPC methods.
    """
    params = {}

    if current:
        params['current'] = current
    if include_aliases:
        params['include_aliases'] = include_aliases

    return client.call('rpc_get_methods', params)

@@ -80,7 +83,7 @@ def save_config(client, fd, indent=2):
    _json_dump(config, fd, indent)


def load_config(client, fd):
def load_config(client, fd, include_aliases=False):
    """Configure SPDK subsystems and targets using JSON RPC read from stdin.
    Args:
        fd: opened file descriptor where data will be taken from
@@ -94,7 +97,7 @@ def load_config(client, fd):
            subsystems.remove(subsystem)

    # check if methods in the config file are known
    allowed_methods = client.call('rpc_get_methods')
    allowed_methods = client.call('rpc_get_methods', {'include_aliases': include_aliases})
    if not subsystems and 'start_subsystem_init' in allowed_methods:
        start_subsystem_init(client)
        return
@@ -106,7 +109,8 @@ def load_config(client, fd):
                raise rpc_client.JSONRPCException("Unknown method was included in the config file")

    while subsystems:
        allowed_methods = client.call('rpc_get_methods', {'current': True})
        allowed_methods = client.call('rpc_get_methods', {'current': True,
                                                          'include_aliases': include_aliases})
        allowed_found = False

        for subsystem in list(subsystems):