Commit 5e9dbb5e authored by Karol Latecki's avatar Karol Latecki Committed by Daniel Verkamp
Browse files

scripts/rpc.py: pass named arguments to pmem.py



Also move "num_blocks" parameter calculation
outside of the create_pmem_pool function to keep it
consistent with rest of similar functions.
Add docstrings while at it.

Change-Id: I024abf0ed450f51d67a6acdb3927b06e205102d8
Signed-off-by: default avatarKarol Latecki <karol.latecki@intel.com>
Reviewed-on: https://review.gerrithub.io/415740


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
parent 21d2dac7
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -1049,7 +1049,11 @@ if __name__ == "__main__":
    # pmem
    @call_cmd
    def create_pmem_pool(args):
        rpc.pmem.create_pmem_pool(args.client, args)
        num_blocks = int((args.total_size * 1024 * 1024) / args.block_size)
        rpc.pmem.create_pmem_pool(args.client,
                                  pmem_file=args.pmem_file,
                                  num_blocks=num_blocks,
                                  block_size=args.block_size)

    p = subparsers.add_parser('create_pmem_pool', help='Create pmem pool')
    p.add_argument('pmem_file', help='Path to pmemblk pool file')
@@ -1059,7 +1063,8 @@ if __name__ == "__main__":

    @call_cmd
    def pmem_pool_info(args):
        print_dict(rpc.pmem.pmem_pool_info(args.client, args))
        print_dict(rpc.pmem.pmem_pool_info(args.client,
                                           pmem_file=args.pmem_file))

    p = subparsers.add_parser('pmem_pool_info', help='Display pmem pool info and check consistency')
    p.add_argument('pmem_file', help='Path to pmemblk pool file')
@@ -1067,7 +1072,8 @@ if __name__ == "__main__":

    @call_cmd
    def delete_pmem_pool(args):
        rpc.pmem.delete_pmem_pool(args.client, args)
        rpc.pmem.delete_pmem_pool(args.client,
                                  pmem_file=args.pmem_file)

    p = subparsers.add_parser('delete_pmem_pool', help='Delete pmem pool')
    p.add_argument('pmem_file', help='Path to pmemblk pool file')
+21 −9
Original line number Diff line number Diff line
def create_pmem_pool(client, args):
    # truncate to the nearest block.
    num_blocks = int((args.total_size * 1024 * 1024) / args.block_size)
    params = {'pmem_file': args.pmem_file,
def create_pmem_pool(client, pmem_file, num_blocks, block_size):
    """Create pmem pool at specified path.
    Args:
        pmem_file: path at which to create pmem pool
        num_blocks: number of blocks for created pmem pool file
        block_size: block size for pmem pool file
    """
    params = {'pmem_file': pmem_file,
              'num_blocks': num_blocks,
              'block_size': args.block_size}
              'block_size': block_size}
    return client.call('create_pmem_pool', params)


def pmem_pool_info(client, args):
    params = {'pmem_file': args.pmem_file}
def pmem_pool_info(client, pmem_file):
    """Get details about pmem pool.
    Args:
        pmem_file: path to pmem pool
    """
    params = {'pmem_file': pmem_file}
    return client.call('pmem_pool_info', params)


def delete_pmem_pool(client, args):
    params = {'pmem_file': args.pmem_file}
def delete_pmem_pool(client, pmem_file):
    """Delete pmem pool.
    Args:
        pmem_file: path to pmem pool
    """
    params = {'pmem_file': pmem_file}
    return client.call('delete_pmem_pool', params)