Skip to content

Commit

Permalink
Get local state and not OMAP's for ANA processing.
Browse files Browse the repository at this point in the history
Fixes #276

Signed-off-by: Gil Bregman <[email protected]>
  • Loading branch information
gbregman committed Oct 22, 2023
1 parent 4d74dcf commit d200e45
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
5 changes: 2 additions & 3 deletions control/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,8 @@ def delete_bdev(self, args):
argument("-n", "--subnqn", help="Subsystem NQN", required=True),
argument("-s", "--serial", help="Serial number", required=False),
argument("-m", "--max-namespaces", help="Maximum number of namespaces", type=int, default=0, required=False),
argument("-a", "--ana-reporting", help="Enable ANA reporting", type=bool, default=False, required=False),
argument("-t", "--enable-ha", help="Enable automatic HA" , type=bool, default=False, required=False),
argument("-a", "--ana-reporting", help="Enable ANA reporting", action='store_true', required=False),
argument("-t", "--enable-ha", help="Enable automatic HA", action='store_true', required=False),
])
def create_subsystem(self, args):
"""Creates a subsystem."""
Expand Down
24 changes: 15 additions & 9 deletions control/grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,15 +533,21 @@ def create_listener_safe(self, request, context=None):
context.set_details(f"{ex}")
return pb2.req_status()

state = self.gateway_state.omap.get_state()
for key,val in state.items():
if (key.startswith(self.gateway_state.omap.SUBSYSTEM_PREFIX + request.nqn)):
self.logger.debug(f"values of key: {key} val: {val} \n")
req = json_format.Parse(val, pb2.create_subsystem_req())
self.logger.info(f" enable_ha :{req.enable_ha} \n")
break

if req.enable_ha:
state = self.gateway_state.local.get_state()
req = None
subsys = state.get(self.gateway_state.local.SUBSYSTEM_PREFIX + request.nqn)
if subsys:
self.logger.debug(f"value of sub-system: {subsys}")
try:
req = json_format.Parse(subsys, pb2.create_subsystem_req())
self.logger.info(f"enable_ha: {req.enable_ha}")
except Exception:
self.logger.error(f"Got exception trying to parse subsystem: {ex}")
pass
else:
self.logger.info(f"No sub-system for {request.nqn}")

if req and req.enable_ha:
for x in range (MAX_ANA_GROUPS):
try:
ret = rpc_nvmf.nvmf_subsystem_listener_set_ana_state(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_create_bdev_ana(self, caplog, gateway):


def test_create_subsystem_ana(self, caplog, gateway):
cli(["create_subsystem", "-n", subsystem, "-a", "true", "-t", "true"])
cli(["create_subsystem", "-n", subsystem, "-a", "-t"])
assert "Failed to create" not in caplog.text
cli(["get_subsystems"])
assert serial not in caplog.text
Expand Down

0 comments on commit d200e45

Please sign in to comment.