22import logging
33from typing import Any , Dict , Optional
44
5+ import cherrypy
56from orchestrator import OrchestratorError
67
78from .. import mgr
@@ -386,7 +387,7 @@ def create(
386387 },
387388 )
388389 @NvmeofCLICommand ("nvmeof ns update" )
389- @empty_response
390+ @map_model ( model . Namespace , first = "namespaces" )
390391 @handle_nvmeof_error
391392 def update (
392393 self ,
@@ -400,34 +401,32 @@ def update(
400401 w_mbytes_per_second : Optional [int ] = None ,
401402 gw_group : Optional [str ] = None
402403 ):
404+ contains_failure = False
405+
403406 if rbd_image_size :
404407 mib = 1024 * 1024
405408 new_size_mib = int ((rbd_image_size + mib - 1 ) / mib )
406409
407- response = NVMeoFClient (gw_group = gw_group ).stub .namespace_resize (
410+ resp = NVMeoFClient (gw_group = gw_group ).stub .namespace_resize (
408411 NVMeoFClient .pb2 .namespace_resize_req (
409412 subsystem_nqn = nqn , nsid = int (nsid ), new_size = new_size_mib
410413 )
411414 )
412- if response .status != 0 :
413- return response
415+ if resp .status != 0 :
416+ contains_failure = True
414417
415418 if load_balancing_group :
416- response = NVMeoFClient ().stub .namespace_change_load_balancing_group (
419+ resp = NVMeoFClient ().stub .namespace_change_load_balancing_group (
417420 NVMeoFClient .pb2 .namespace_change_load_balancing_group_req (
418421 subsystem_nqn = nqn , nsid = int (nsid ), anagrpid = load_balancing_group
419422 )
420423 )
421- if response .status != 0 :
422- return response
424+ if resp .status != 0 :
425+ contains_failure = True
423426
424- if (
425- rw_ios_per_second
426- or rw_mbytes_per_second
427- or r_mbytes_per_second
428- or w_mbytes_per_second
429- ):
430- response = NVMeoFClient ().stub .namespace_set_qos_limits (
427+ if rw_ios_per_second or rw_mbytes_per_second or r_mbytes_per_second \
428+ or w_mbytes_per_second :
429+ resp = NVMeoFClient ().stub .namespace_set_qos_limits (
431430 NVMeoFClient .pb2 .namespace_set_qos_req (
432431 subsystem_nqn = nqn ,
433432 nsid = int (nsid ),
@@ -437,9 +436,13 @@ def update(
437436 w_mbytes_per_second = w_mbytes_per_second ,
438437 )
439438 )
440- if response .status != 0 :
441- return response
442-
439+ if resp .status != 0 :
440+ contains_failure = True
441+ response = NVMeoFClient (gw_group = gw_group ).stub .list_namespaces (
442+ NVMeoFClient .pb2 .list_namespaces_req (subsystem = nqn , nsid = int (nsid ))
443+ )
444+ if contains_failure :
445+ cherrypy .response .status = 202
443446 return response
444447
445448 @EndpointDoc (
0 commit comments