@@ -2468,5 +2468,41 @@ def feature_status(name, state):
2468
2468
2469
2469
config_db .mod_entry ('FEATURE' , name , {'status' : state })
2470
2470
2471
+ #
2472
+ # 'container' group ('config container ...')
2473
+ #
2474
+ @config .group (name = 'container' , invoke_without_command = False )
2475
+ def container ():
2476
+ """Modify configuration of containers"""
2477
+ pass
2478
+
2479
+ #
2480
+ # 'feature' group ('config container feature ...')
2481
+ #
2482
+ @container .group (name = 'feature' , invoke_without_command = False )
2483
+ def feature ():
2484
+ """Modify configuration of container features"""
2485
+ pass
2486
+
2487
+ #
2488
+ # 'autorestart' subcommand ('config container feature autorestart ...')
2489
+ #
2490
+ @feature .command (name = 'autorestart' , short_help = "Configure the status of autorestart feature for specific container" )
2491
+ @click .argument ('container_name' , metavar = '<container_name>' , required = True )
2492
+ @click .argument ('autorestart_status' , metavar = '<autorestart_status>' , required = True , type = click .Choice (["enabled" , "disabled" ]))
2493
+ def autorestart (container_name , autorestart_status ):
2494
+ config_db = ConfigDBConnector ()
2495
+ config_db .connect ()
2496
+ container_feature_table = config_db .get_table ('CONTAINER_FEATURE' )
2497
+ if not container_feature_table :
2498
+ click .echo ("Unable to retrieve container feature table from Config DB." )
2499
+ return
2500
+
2501
+ if not container_feature_table .has_key (container_name ):
2502
+ click .echo ("Unable to retrieve features for container '{}'" .format (container_name ))
2503
+ return
2504
+
2505
+ config_db .mod_entry ('CONTAINER_FEATURE' , container_name , {'auto_restart' : autorestart_status })
2506
+
2471
2507
if __name__ == '__main__' :
2472
2508
config ()
0 commit comments