Skip to content

Commit 374fd53

Browse files
committed
Add nokia_cmd set restart-lc-system-service for debug use
(cherry picked from commit 9bae649)
1 parent fbccffa commit 374fd53

2 files changed

Lines changed: 44 additions & 2 deletions

File tree

chassis/platform_ndk/nokia_cmd.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,11 @@ def set_reboot_linecard(slot):
11801180
logger.log_warning("nokia_cmd reboots linecard slot {}".format(slot))
11811181
nokia_common._reboot_imm(slot)
11821182

1183+
def set_restart_lc_system_service(slot, service_name):
1184+
print("nokia_cmd restart system service '{}' on linecard slot {}".format(service_name, slot))
1185+
logger.log_warning("nokia_cmd restart system service '{}' on linecard slot {}".format(service_name, slot))
1186+
nokia_common._restart_lc_system_service(slot, service_name)
1187+
11831188
def set_log_restore_default():
11841189
channel, stub = nokia_common.channel_setup(nokia_common.NOKIA_GRPC_UTIL_SERVICE)
11851190
if not channel or not stub:
@@ -2197,6 +2202,11 @@ def main():
21972202
set_reboot_linecard_parser = setsubparsers.add_parser('reboot-linecard', help='Reboot linecard from Supervisor')
21982203
set_reboot_linecard_parser.add_argument('slot', type=int, help='Linecard slot number starts from 1 to 8')
21992204
set_reboot_linecard_parser.add_argument('force', nargs='?', type=str, help='Continue without prompt for confirmation')
2205+
2206+
# set restart_lc_system_service
2207+
set_restart_lc_system_service_parser = setsubparsers.add_parser('restart-lc-system-service', help='Restart linecard system service from Supervisor')
2208+
set_restart_lc_system_service_parser.add_argument('slot', type=int, help='Linecard slot number starts from 1 to 8')
2209+
set_restart_lc_system_service_parser.add_argument('service', type=str, help='Service filename. Current support: interfaces-config.service')
22002210

22012211
set_ndk_monitor_action_parser = setsubparsers.add_parser('ndk-monitor-action', help='Change the NDK monitor_action value (warn or reboot) in starup_debug.json file')
22022212
set_ndk_monitor_action_parser.add_argument('action', nargs='?', help='Choices: warn, reboot or default')
@@ -2394,10 +2404,26 @@ def main():
23942404
if ans.strip().upper() != "Y":
23952405
print("Operation abort!")
23962406
return
2397-
2398-
set_reboot_linecard(slot)
2407+
2408+
set_reboot_linecard(slot)
2409+
elif args.setcmd == 'restart-lc-system-service':
2410+
supported_list = ["interfaces-config.service"]
2411+
if not nokia_common.is_cpm():
2412+
print('Command is only supported on Supervisor card')
2413+
return
2414+
slot = d['slot']
2415+
if slot < 1 or slot > 8:
2416+
print("Error: Invalid slot number. Linecard slot number starts from 1 to 8")
2417+
return
2418+
service_name = d['service']
2419+
if service_name not in supported_list:
2420+
print("Error: Service name \"{}\" is not in supported list".format(service_name))
2421+
print("Supported list: " + ", ".join(supported_list))
2422+
return
2423+
set_restart_lc_system_service(slot, service_name)
23992424
else:
24002425
set_parser.print_help()
2426+
24012427
elif args.cmd == 'request':
24022428
if args.reqcmd == 'devmgr-admintech':
24032429
if d['filepath'] is None:

chassis/platform_ndk/nokia_common.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,22 @@ def _reboot_imm(slot):
395395
ret = _cpm_reboot_IMMs(slot)
396396
return ret
397397

398+
def _restart_lc_system_service(imm_slot, service_file):
399+
if imm_slot < 1 or imm_slot > NOKIA_MAX_IMM_SLOTS:
400+
return
401+
channel, stub = midplane_channel_setup(NOKIA_GRPC_CHASSIS_SERVICE, imm_slot)
402+
if not channel or not stub:
403+
return False
404+
response = stub.RestartSystemService(platform_ndk_pb2.ReqModuleInfoPb(hw_slot=imm_slot, service_name=service_file))
405+
if response.response_status.status_code != platform_ndk_pb2.ResponseCode.NDK_SUCCESS:
406+
print('Failed to restart Linecard Slot {} system service \"{}\"'.format(imm_slot, service_file))
407+
rv = False
408+
else:
409+
print('Restart Linecard Slot {} system service \"{}\" success'.format(imm_slot, service_file))
410+
rv = True
411+
channel_shutdown(channel)
412+
return rv
413+
398414
def _force_reboot_imm(slot):
399415
if slot < 1 or slot > NOKIA_MAX_IMM_SLOTS:
400416
return

0 commit comments

Comments
 (0)