Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧹Remove unreferenced protobuf messages #433

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ jobs:
echo $conns | grep -q "\"nqn\": \"${NQN}host\""
echo $conns | grep -q "\"trsvcid\": ${NVMEOF_IO_PORT}"
echo $conns | grep -q "\"traddr\": \"${NVMEOF_IP_ADDRESS}\""
echo $conns | grep -q "\"adrfam\": \"ipv4\""
echo $conns | grep -q "\"adrfam\": \"IPv4\""
echo $conns | grep -q "\"trtype\": \"TCP\""
con_cnt=$(echo $conns | xargs -n 1 | grep traddr | wc -l)
if [ $con_cnt -ne 1 ]; then
Expand Down
56 changes: 25 additions & 31 deletions control/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
from .utils import GatewayUtils
from .utils import GatewayEnumUtils

BASE_GATEWAY_VERSION="1.1.0"

def errprint(msg):
print(msg, file = sys.stderr)

Expand Down Expand Up @@ -229,15 +227,6 @@ def get_actions(act_list):
acts += ", '" + a["name"] + "'"
return acts[2:]

def format_adrfam(self, adrfam):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@baum why did you remove this formatting? This has nothing to do with protobuf cleanup. I wanted the output to have IPv4 and IPv6 which is the normal way to display address families. I don't understand why you insist on changing that.

adrfam = adrfam.upper()
if adrfam == "IPV4":
adrfam = "IPv4"
elif adrfam == "IPV6":
adrfam = "IPv6"

return adrfam

def get_output_functions(self, args):
if args.output == "log":
return (self.logger.info, self.logger.error)
Expand All @@ -259,24 +248,28 @@ def version(self, args):
else:
rc = 0
errmsg = os.strerror(0)

cli_ver = {
"status": rc,
"error_message": errmsg,
"version": ver
}

if args.format == "text" or args.format == "plain":
if not ver:
if rc != 0:
err_func(errmsg)
else:
out_func(f"CLI version: {ver}")
elif args.format == "json" or args.format == "yaml":
cli_ver = pb2.cli_version(status=rc, error_message=errmsg, version=ver)
out_ver = json_format.MessageToJson(cli_ver,
indent=4,
including_default_value_fields=True,
preserving_proto_field_name=True)
# Convert Python object to JSON string
out_ver = json.dumps(cli_ver)
if args.format == "json":
out_func(f"{out_ver}")
elif args.format == "yaml":
obj = json.loads(out_ver)
out_func(yaml.dump(obj))
elif args.format == "python":
return pb2.cli_version(status=rc, error_message=errmsg, version=ver)
return cli_ver
else:
assert False

Expand All @@ -301,17 +294,17 @@ def gw_get_info(self):
req = pb2.get_gateway_info_req(cli_version=ver)
gw_info = self.stub.get_gateway_info(req)
if gw_info.status == 0:
base_ver = self.parse_version_string(BASE_GATEWAY_VERSION)
assert base_ver != None
gw_ver = self.parse_version_string(gw_info.version)
cli_ver = self.parse_version_string(ver)
assert cli_ver is not None
if gw_ver == None:
gw_info.status = errno.EINVAL
gw_info.bool_status = False
gw_info.error_message = f"Can't parse gateway version \"{gw_info.version}\"."
elif gw_ver < base_ver:
elif gw_ver < cli_ver:
gw_info.status = errno.EINVAL
gw_info.bool_status = False
gw_info.error_message = f"Can't work with gateway version older than {BASE_GATEWAY_VERSION}"
gw_info.error_message = f"gateway version \"{gw_info.version}\" older than the cli version \"{ver}\""
return gw_info

def gw_info(self, args):
Expand Down Expand Up @@ -371,24 +364,27 @@ def gw_version(self, args):
except Exception as ex:
gw_info = pb2.gateway_info(status = errno.EINVAL, error_message = f"Failure getting gateway's version:\n{ex}")

gw_ver = {
"status" : gw_info.status,
"error_message" : gw_info.error_message,
"version" : gw_info.version
}

if args.format == "text" or args.format == "plain":
if gw_info.status == 0:
out_func(f"Gateway's version: {gw_info.version}")
else:
err_func(f"{gw_info.error_message}")
elif args.format == "json" or args.format == "yaml":
gw_ver = pb2.gw_version(status=gw_info.status, error_message=gw_info.error_message, version=gw_info.version)
out_ver = json_format.MessageToJson(gw_ver,
indent=4,
including_default_value_fields=True,
preserving_proto_field_name=True)
# Convert Python object to JSON string
out_ver = json.dumps(gw_ver)
if args.format == "json":
out_func(f"{out_ver}")
elif args.format == "yaml":
obj = json.loads(out_ver)
out_func(yaml.dump(obj))
elif args.format == "python":
return pb2.gw_version(status=gw_info.status, error_message=gw_info.error_message, version=gw_info.version)
return gw_ver
else:
assert False

Expand Down Expand Up @@ -860,9 +856,7 @@ def listener_list(self, args):
if listeners_info.status == 0:
listeners_list = []
for l in listeners_info.listeners:
adrfam = GatewayEnumUtils.get_key_from_value(pb2.AddressFamily, l.adrfam)
adrfam = self.format_adrfam(adrfam)
listeners_list.append([l.gateway_name, l.trtype, adrfam, f"{l.traddr}:{l.trsvcid}"])
listeners_list.append([l.gateway_name, l.trtype, l.adrfam, f"{l.traddr}:{l.trsvcid}"])
if len(listeners_list) > 0:
if args.format == "text":
table_format = "fancy_grid"
Expand Down
13 changes: 3 additions & 10 deletions control/grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1900,16 +1900,9 @@ def list_connections_safe(self, request, context):
addr = qp["listen_address"]
traddr = addr["traddr"]
trsvcid = int(addr["trsvcid"])
try:
trtype = addr["trtype"].upper()
except Exception:
pass
try:
adrfam = addr["adrfam"].lower()
except Exception:
pass
break
except Exception:
trtype = addr["trtype"]
adrfam = addr["adrfam"]
except Exception as ex:
self.logger.exception(f"Got exception while parsing qpair: {qp}")
pass
one_conn = pb2.connection(nqn=hostnqn, connected=True,
Expand Down
26 changes: 7 additions & 19 deletions control/proto/gateway.proto
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,17 @@ service Gateway {
// List subsystems
rpc list_subsystems(list_subsystems_req) returns(subsystems_info_cli) {}

// Gets subsystems
rpc get_subsystems(get_subsystems_req) returns(subsystems_info) {}
// Gets subsystems
rpc get_subsystems(get_subsystems_req) returns(subsystems_info) {}

// Set gateway ANA states
rpc set_ana_state(ana_info) returns(req_status) {}

// Gets spdk nvmf log flags and level
rpc get_spdk_nvmf_log_flags_and_level(get_spdk_nvmf_log_flags_and_level_req) returns(spdk_nvmf_log_flags_and_level_info) {}

// Disables spdk nvmf logs
rpc disable_spdk_nvmf_logs(disable_spdk_nvmf_logs_req) returns(req_status) {}
// Disables spdk nvmf logs
rpc disable_spdk_nvmf_logs(disable_spdk_nvmf_logs_req) returns(req_status) {}

// Set spdk nvmf logs
rpc set_spdk_nvmf_logs(set_spdk_nvmf_logs_req) returns(req_status) {}
Expand Down Expand Up @@ -336,22 +336,10 @@ message gateway_info {
uint32 load_balancing_group = 11;
}

message cli_version {
int32 status = 1;
string error_message = 2;
string version = 3;
}

message gw_version {
int32 status = 1;
string error_message = 2;
string version = 3;
}

message listener_info {
string gateway_name = 1;
string trtype = 2;
AddressFamily adrfam = 3;
string adrfam = 3;
string traddr = 4;
uint32 trsvcid = 5;
}
Expand All @@ -378,8 +366,8 @@ message connection {
string nqn = 1;
string traddr = 2;
uint32 trsvcid = 3;
string trtype = 4;
AddressFamily adrfam = 5;
string trtype = 4;
string adrfam = 5;
bool connected = 6;
int32 qpairs_count = 7;
int32 controller_id = 8;
Expand Down
Loading