Commit cd5e1feb authored by Boris Glimcher's avatar Boris Glimcher Committed by Jim Harris
Browse files

python/rpc: call client functions directly



Replaced generic call() usage with direct function calls.
This makes the code more explicit, Pythonic, and easier to maintain.

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


Reviewed-by: default avatarTomasz Zawadzki <tomasz@tzawadzki.com>
Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
Reviewed-by: default avatarKarol Latecki <karol.latecki@nutanix.com>
Tested-by: default avatarSPDK Automated Test System <spdkbot@gmail.com>
parent e942c023
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ From a Python interpreter:
>>> from spdk.rpc.client import JSONRPCClient

>>> client = JSONRPCClient(server_addr, port)
>>> client.call("rpc_get_methods")
>>> client.rpc_get_methods()
```

For more information, see <https://spdk.io/doc/jsonrpc.html>
+7 −8
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ def save_config(client, fd, indent=2, subsystems=None):
        'subsystems': []
    }

    subsystems_json = client.call('framework_get_subsystems')
    subsystems_json = client.framework_get_subsystems()

    # Build a dictionary of all subsystems to their fully expanded set of
    # dependencies.
@@ -68,7 +68,7 @@ def save_config(client, fd, indent=2, subsystems=None):
    for elem in filter(_print, subsystems_json):
        cfg = {
            'subsystem': elem['subsystem'],
            'config': client.call('framework_get_config', {"name": elem['subsystem']})
            'config': client.framework_get_config(name=elem['subsystem'])
        }
        config['subsystems'].append(cfg)

@@ -89,7 +89,7 @@ def load_config(client, fd, include_aliases=False):
            subsystems.remove(subsystem)

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

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

        for subsystem in list(subsystems):
@@ -138,7 +137,7 @@ def save_subsystem_config(client, fd, indent=2, name=None):
    """
    cfg = {
        'subsystem': name,
        'config': client.call('framework_get_config', {"name": name})
        'config': client.framework_get_config(name=name)
    }

    _json_dump(cfg, fd, indent)
@@ -154,13 +153,13 @@ def load_subsystem_config(client, fd):
    if not subsystem['config']:
        return

    allowed_methods = client.call('rpc_get_methods')
    allowed_methods = client.rpc_get_methods()
    config = subsystem['config']
    for elem in list(config):
        if 'method' not in elem or elem['method'] not in allowed_methods:
            raise rpc_client.JSONRPCException("Unknown method was included in the config file")

    allowed_methods = client.call('rpc_get_methods', {'current': True})
    allowed_methods = client.rpc_get_methods(current=True)
    for elem in list(config):
        if 'method' not in elem or elem['method'] not in allowed_methods:
            continue