From b72455c851a29de178e5d0488d791ecbef49b006 Mon Sep 17 00:00:00 2001 From: Pawel Kaminski Date: Wed, 18 Sep 2019 04:53:32 -0400 Subject: [PATCH] rpc: Rename add_ip_address to net_interface_add_ip_address Change-Id: I6fba7f7c237497950d4f2c4e3a664fbb82e25fe7 Signed-off-by: Pawel Kaminski Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/468676 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- doc/jsonrpc.md | 2 +- lib/net/interface.c | 4 ++-- lib/net/net_internal.h | 2 +- lib/net/net_rpc.c | 10 ++++++---- scripts/rpc.py | 9 +++++---- scripts/rpc/net.py | 8 ++++++-- test/iscsi_tgt/ip_migration/ip_migration.sh | 4 ++-- test/iscsi_tgt/rpc_config/rpc_config.py | 4 ++-- 8 files changed, 25 insertions(+), 18 deletions(-) diff --git a/doc/jsonrpc.md b/doc/jsonrpc.md index 9a51ddc44..f2b1d7aef 100644 --- a/doc/jsonrpc.md +++ b/doc/jsonrpc.md @@ -243,7 +243,7 @@ Example response: "get_scsi_devices", "get_interfaces", "delete_ip_address", - "add_ip_address", + "net_interface_add_ip_address", "nbd_get_disks", "nbd_stop_disk", "nbd_start_disk", diff --git a/lib/net/interface.c b/lib/net/interface.c index 7bf01bad8..61e64c2fd 100644 --- a/lib/net/interface.c +++ b/lib/net/interface.c @@ -448,7 +448,7 @@ spdk_interface_destroy(void) } int -spdk_interface_add_ip_address(int ifc_index, char *ip_addr) +spdk_interface_net_interface_add_ip_address(int ifc_index, char *ip_addr) { uint32_t addr; @@ -485,7 +485,7 @@ spdk_interface_destroy(void) } int -spdk_interface_add_ip_address(int ifc_index, char *ip_addr) +spdk_interface_net_interface_add_ip_address(int ifc_index, char *ip_addr) { return -1; } diff --git a/lib/net/net_internal.h b/lib/net/net_internal.h index 8dbaf633c..abe045e61 100644 --- a/lib/net/net_internal.h +++ b/lib/net/net_internal.h @@ -57,7 +57,7 @@ struct spdk_interface { * * \return 0 on success, -1 on failure. */ -int spdk_interface_add_ip_address(int ifc_index, char *ip_addr); +int spdk_interface_net_interface_add_ip_address(int ifc_index, char *ip_addr); /** * Delete an ip address from the network interface. diff --git a/lib/net/net_rpc.c b/lib/net/net_rpc.c index d73aa8a45..a39d607b6 100644 --- a/lib/net/net_rpc.c +++ b/lib/net/net_rpc.c @@ -58,8 +58,8 @@ static const struct spdk_json_object_decoder rpc_ip_address_decoders[] = { }; static void -spdk_rpc_add_ip_address(struct spdk_jsonrpc_request *request, - const struct spdk_json_val *params) +spdk_rpc_net_interface_add_ip_address(struct spdk_jsonrpc_request *request, + const struct spdk_json_val *params) { struct rpc_ip_address req = {}; struct spdk_json_write_ctx *w; @@ -74,7 +74,7 @@ spdk_rpc_add_ip_address(struct spdk_jsonrpc_request *request, goto invalid; } - ret_val = spdk_interface_add_ip_address(req.ifc_index, req.ip_address); + ret_val = spdk_interface_net_interface_add_ip_address(req.ifc_index, req.ip_address); if (ret_val) { if (ret_val == -ENODEV) { spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INVALID_STATE, @@ -96,7 +96,9 @@ spdk_rpc_add_ip_address(struct spdk_jsonrpc_request *request, invalid: free_rpc_ip_address(&req); } -SPDK_RPC_REGISTER("add_ip_address", spdk_rpc_add_ip_address, SPDK_RPC_RUNTIME) +SPDK_RPC_REGISTER("net_interface_add_ip_address", spdk_rpc_net_interface_add_ip_address, + SPDK_RPC_RUNTIME) +SPDK_RPC_REGISTER_ALIAS_DEPRECATED(net_interface_add_ip_address, add_ip_address) static void spdk_rpc_delete_ip_address(struct spdk_jsonrpc_request *request, diff --git a/scripts/rpc.py b/scripts/rpc.py index a5028d792..8cca914aa 100755 --- a/scripts/rpc.py +++ b/scripts/rpc.py @@ -1508,13 +1508,14 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse p.set_defaults(func=nbd_get_disks) # net - def add_ip_address(args): - rpc.net.add_ip_address(args.client, ifc_index=args.ifc_index, ip_addr=args.ip_addr) + def net_interface_add_ip_address(args): + rpc.net.net_interface_add_ip_address(args.client, ifc_index=args.ifc_index, ip_addr=args.ip_addr) - p = subparsers.add_parser('add_ip_address', help='Add IP address') + p = subparsers.add_parser('net_interface_add_ip_address', aliases=['add_ip_address'], + help='Add IP address') p.add_argument('ifc_index', help='ifc index of the nic device.', type=int) p.add_argument('ip_addr', help='ip address will be added.') - p.set_defaults(func=add_ip_address) + p.set_defaults(func=net_interface_add_ip_address) def delete_ip_address(args): rpc.net.delete_ip_address(args.client, ifc_index=args.ifc_index, ip_addr=args.ip_addr) diff --git a/scripts/rpc/net.py b/scripts/rpc/net.py index e1ba7aa8d..1baa6fe95 100644 --- a/scripts/rpc/net.py +++ b/scripts/rpc/net.py @@ -1,4 +1,8 @@ -def add_ip_address(client, ifc_index, ip_addr): +from .helpers import deprecated_alias + + +@deprecated_alias('add_ip_address') +def net_interface_add_ip_address(client, ifc_index, ip_addr): """Add IP address. Args: @@ -6,7 +10,7 @@ def add_ip_address(client, ifc_index, ip_addr): ip_addr: ip address will be added """ params = {'ifc_index': ifc_index, 'ip_address': ip_addr} - return client.call('add_ip_address', params) + return client.call('net_interface_add_ip_address', params) def delete_ip_address(client, ifc_index, ip_addr): diff --git a/test/iscsi_tgt/ip_migration/ip_migration.sh b/test/iscsi_tgt/ip_migration/ip_migration.sh index d5e706714..1ac339d53 100755 --- a/test/iscsi_tgt/ip_migration/ip_migration.sh +++ b/test/iscsi_tgt/ip_migration/ip_migration.sh @@ -13,7 +13,7 @@ rpc_py="$rootdir/scripts/rpc.py" fio_py="$rootdir/scripts/fio.py" # Namespaces are NOT used here on purpose. This test requires changes to detect -# ifc_index for interface that was put into namespace. Needed for add_ip_address. +# ifc_index for interface that was put into namespace. Needed for net_interface_add_ip_address. ISCSI_APP="$rootdir/app/iscsi_tgt/iscsi_tgt" NETMASK=127.0.0.0/24 MIGRATION_ADDRESS=127.0.0.2 @@ -33,7 +33,7 @@ function rpc_config() { } function rpc_add_target_node() { - $rpc_py -s $1 add_ip_address 1 $MIGRATION_ADDRESS + $rpc_py -s $1 net_interface_add_ip_address 1 $MIGRATION_ADDRESS $rpc_py -s $1 iscsi_create_portal_group $PORTAL_TAG $MIGRATION_ADDRESS:$ISCSI_PORT $rpc_py -s $1 iscsi_create_target_node target1 target1_alias 'Malloc0:0' $PORTAL_TAG:$INITIATOR_TAG 64 -d } diff --git a/test/iscsi_tgt/rpc_config/rpc_config.py b/test/iscsi_tgt/rpc_config/rpc_config.py index fd52407b2..398e95588 100755 --- a/test/iscsi_tgt/rpc_config/rpc_config.py +++ b/test/iscsi_tgt/rpc_config/rpc_config.py @@ -197,7 +197,7 @@ def verify_portal_groups_rpc_methods(rpc_py, rpc_param): nics = json.loads(rpc.get_interfaces()) for x in nics: if x["ifc_index"] == 'lo': - rpc.add_ip_address(x["ifc_index"], lo_ip[1]) + rpc.net_interface_add_ip_address(x["ifc_index"], lo_ip[1]) for idx, value in enumerate(lo_ip): # The portal group tag must start at 1 tag = idx + 1 @@ -428,7 +428,7 @@ def verify_add_delete_ip_address(rpc_py): for x in nics[:2]: faked_ip = "123.123.{}.{}".format(random.randint(1, 254), random.randint(1, 254)) ping_cmd = ns_cmd + " ping -c 1 -W 1 " + faked_ip - rpc.add_ip_address(x["ifc_index"], faked_ip) + rpc.net_interface_add_ip_address(x["ifc_index"], faked_ip) verify(faked_ip in help_get_interface_ip_list(rpc_py, x["name"]), 1, "add ip {} to nic {} failed.".format(faked_ip, x["name"])) try: