4
4
import jsonpointer
5
5
import subprocess
6
6
from sonic_py_common import device_info
7
- from .gu_common import GenericConfigUpdaterError , HOST_NAMESPACE
7
+ from .gu_common import GenericConfigUpdaterError
8
8
from swsscommon import swsscommon
9
9
from utilities_common .constants import DEFAULT_SUPPORTED_FECS_LIST
10
10
11
- STATE_DB_NAME = 'STATE_DB'
12
- REDIS_TIMEOUT_MSECS = 0
13
11
SCRIPT_DIR = os .path .dirname (os .path .realpath (__file__ ))
14
12
GCU_TABLE_MOD_CONF_FILE = f"{ SCRIPT_DIR } /gcu_field_operation_validators.conf.json"
13
+ GET_HWSKU_CMD = "sonic-cfggen -d -v DEVICE_METADATA.localhost.hwsku"
15
14
16
15
17
- def get_asic_name (scope ):
16
+ def get_asic_name ():
18
17
asic = "unknown"
19
18
20
19
if os .path .exists (GCU_TABLE_MOD_CONF_FILE ):
@@ -29,12 +28,7 @@ def get_asic_name(scope):
29
28
if asic_type == 'cisco-8000' :
30
29
asic = "cisco-8000"
31
30
elif asic_type == 'mellanox' or asic_type == 'vs' or asic_type == 'broadcom' :
32
- get_hwsku_cmds = []
33
- if scope == HOST_NAMESPACE :
34
- get_hwsku_cmds = ["sonic-cfggen" , "-d" , "-v" , "DEVICE_METADATA.localhost.hwsku" ]
35
- else :
36
- get_hwsku_cmds = ["sonic-cfggen" , "-d" , "-n" , scope , "-v" , "DEVICE_METADATA.localhost.hwsku" ]
37
- proc = subprocess .Popen (get_hwsku_cmds , shell = False , universal_newlines = True , stdout = subprocess .PIPE )
31
+ proc = subprocess .Popen (GET_HWSKU_CMD , shell = True , universal_newlines = True , stdout = subprocess .PIPE )
38
32
output , err = proc .communicate ()
39
33
hwsku = output .rstrip ('\n ' )
40
34
if asic_type == 'mellanox' or asic_type == 'vs' :
@@ -67,8 +61,8 @@ def get_asic_name(scope):
67
61
return asic
68
62
69
63
70
- def rdma_config_update_validator (scope , patch_element ):
71
- asic = get_asic_name (scope )
64
+ def rdma_config_update_validator (patch_element ):
65
+ asic = get_asic_name ()
72
66
if asic == "unknown" :
73
67
return False
74
68
version_info = device_info .get_sonic_version_info ()
@@ -140,17 +134,17 @@ def _get_fields_in_patch():
140
134
return True
141
135
142
136
143
- def read_statedb_entry (scope , table , key , field ):
144
- state_db = swsscommon .DBConnector (STATE_DB_NAME , REDIS_TIMEOUT_MSECS , True , scope )
137
+ def read_statedb_entry (table , key , field ):
138
+ state_db = swsscommon .DBConnector ("STATE_DB" , 0 )
145
139
tbl = swsscommon .Table (state_db , table )
146
140
return tbl .hget (key , field )[1 ]
147
141
148
142
149
- def port_config_update_validator (scope , patch_element ):
143
+ def port_config_update_validator (patch_element ):
150
144
151
145
def _validate_field (field , port , value ):
152
146
if field == "fec" :
153
- supported_fecs_str = read_statedb_entry (scope , "PORT_TABLE" , port , "supported_fecs" )
147
+ supported_fecs_str = read_statedb_entry ("PORT_TABLE" , port , "supported_fecs" )
154
148
if supported_fecs_str :
155
149
if supported_fecs_str != 'N/A' :
156
150
supported_fecs_list = [element .strip () for element in supported_fecs_str .split (',' )]
@@ -162,7 +156,7 @@ def _validate_field(field, port, value):
162
156
return False
163
157
return True
164
158
if field == "speed" :
165
- supported_speeds_str = read_statedb_entry (scope , "PORT_TABLE" , port , "supported_speeds" ) or ''
159
+ supported_speeds_str = read_statedb_entry ("PORT_TABLE" , port , "supported_speeds" ) or ''
166
160
try :
167
161
supported_speeds = [int (s ) for s in supported_speeds_str .split (',' ) if s ]
168
162
if supported_speeds and int (value ) not in supported_speeds :
0 commit comments