forked from sonic-net/sonic-utilities
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchassis_modules.py
More file actions
45 lines (37 loc) · 1.48 KB
/
Copy pathchassis_modules.py
File metadata and controls
45 lines (37 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/sbin/env python
import click
import utilities_common.cli as clicommon
from utilities_common import constants
#
# 'chassis_modules' group ('config chassis_modules ...')
#
@click.group(cls=clicommon.AliasedGroup)
def chassis_modules():
"""Configure chassis-modules options"""
pass
#
# 'shutdown' subcommand ('config chassis_modules shutdown ...')
#
@chassis_modules.command('shutdown')
@clicommon.pass_multi_asic_db
@click.argument('chassis_module_name', metavar='<module_name>', required=True)
def shutdown_chassis_module(db, chassis_module_name):
"""Chassis-module shutdown of module"""
config_db = db.cfgdb[constants.DEFAULT_NAMESPACE]
ctx = click.get_current_context()
if not chassis_module_name.startswith("SUPERVISOR") and \
not chassis_module_name.startswith("LINE-CARD") and \
not chassis_module_name.startswith("FABRIC-CARD"):
ctx.fail("'module_name' has to begin with 'SUPERVISOR', 'LINE-CARD' or 'FABRIC-CARD'")
fvs = {'admin_status': 'down'}
config_db.set_entry('CHASSIS_MODULE', chassis_module_name, fvs)
#
# 'startup' subcommand ('config chassis_modules startup ...')
#
@chassis_modules.command('startup')
@clicommon.pass_multi_asic_db
@click.argument('chassis_module_name', metavar='<module_name>', required=True)
def startup_chassis_module(db, chassis_module_name):
"""Chassis-module startup of module"""
config_db = db.cfgdb[constants.DEFAULT_NAMESPACE]
config_db.set_entry('CHASSIS_MODULE', chassis_module_name, None)