Skip to content

Commit 10df5c9

Browse files
authored
Revert "[yang] Enforce yang full support in full config command (#3716)"
This reverts commit 782c33a.
1 parent 782c33a commit 10df5c9

File tree

4 files changed

+134
-31
lines changed

4 files changed

+134
-31
lines changed

config/main.py

-7
Original file line numberDiff line numberDiff line change
@@ -1402,13 +1402,6 @@ def config_file_yang_validation(filename):
14021402
fg='magenta')
14031403
raise click.Abort()
14041404

1405-
sy.tablesWithOutYang.pop('bgpraw', None)
1406-
if len(sy.tablesWithOutYang):
1407-
click.secho("Config tables are missing yang models: {}".format(str(sy.tablesWithOutYang.keys())),
1408-
fg='magenta')
1409-
raise click.Abort()
1410-
1411-
14121405
# This is our main entrypoint - the main 'config' command
14131406
@click.group(cls=clicommon.AbbreviationGroup, context_settings=CONTEXT_SETTINGS)
14141407
@click.pass_context
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
{
2+
"running_config": {
3+
"ACL_TABLE": {
4+
"DATAACL": {
5+
"policy_desc": "DATAACL",
6+
"ports": [
7+
"Ethernet4"
8+
],
9+
"stage": "ingress",
10+
"type": "L3"
11+
},
12+
"NTP_ACL": {
13+
"policy_desc": "NTP_ACL",
14+
"services": [
15+
"NTP"
16+
],
17+
"stage": "ingress",
18+
"type": "CTRLPLANE"
19+
}
20+
},
21+
"AUTO_TECHSUPPORT_FEATURE": {
22+
"bgp": {
23+
"rate_limit_interval": "600",
24+
"state": "enabled"
25+
},
26+
"database": {
27+
"rate_limit_interval": "600",
28+
"state": "enabled"
29+
}
30+
},
31+
"PORT": {
32+
"Ethernet4": {
33+
"admin_status": "up",
34+
"alias": "fortyGigE0/4",
35+
"description": "Servers0:eth0",
36+
"index": "1",
37+
"lanes": "29,30,31,32",
38+
"mtu": "9100",
39+
"pfc_asym": "off",
40+
"speed": "40000",
41+
"tpid": "0x8100"
42+
},
43+
"Ethernet8": {
44+
"admin_status": "up",
45+
"alias": "fortyGigE0/8",
46+
"description": "Servers1:eth0",
47+
"index": "2",
48+
"lanes": "33,34,35,36",
49+
"mtu": "9100",
50+
"pfc_asym": "off",
51+
"speed": "40000",
52+
"tpid": "0x8100"
53+
}
54+
}
55+
},
56+
"golden_config": {
57+
"NEW_FEATURE_TABLE": {
58+
"entry": {
59+
"field": "value",
60+
"state": "disabled"
61+
}
62+
}
63+
},
64+
"expected_config": {
65+
"ACL_TABLE": {
66+
"DATAACL": {
67+
"policy_desc": "DATAACL",
68+
"ports": [
69+
"Ethernet4"
70+
],
71+
"stage": "ingress",
72+
"type": "L3"
73+
},
74+
"NTP_ACL": {
75+
"policy_desc": "NTP_ACL",
76+
"services": [
77+
"NTP"
78+
],
79+
"stage": "ingress",
80+
"type": "CTRLPLANE"
81+
}
82+
},
83+
"AUTO_TECHSUPPORT_FEATURE": {
84+
"bgp": {
85+
"rate_limit_interval": "600",
86+
"state": "enabled"
87+
},
88+
"database": {
89+
"rate_limit_interval": "600",
90+
"state": "enabled"
91+
}
92+
},
93+
"PORT": {
94+
"Ethernet4": {
95+
"admin_status": "up",
96+
"alias": "fortyGigE0/4",
97+
"description": "Servers0:eth0",
98+
"index": "1",
99+
"lanes": "29,30,31,32",
100+
"mtu": "9100",
101+
"pfc_asym": "off",
102+
"speed": "40000",
103+
"tpid": "0x8100"
104+
},
105+
"Ethernet8": {
106+
"admin_status": "up",
107+
"alias": "fortyGigE0/8",
108+
"description": "Servers1:eth0",
109+
"index": "2",
110+
"lanes": "33,34,35,36",
111+
"mtu": "9100",
112+
"pfc_asym": "off",
113+
"speed": "40000",
114+
"tpid": "0x8100"
115+
}
116+
},
117+
"NEW_FEATURE_TABLE": {
118+
"entry": {
119+
"field": "value",
120+
"state": "disabled"
121+
}
122+
}
123+
}
124+
}

tests/config_override_test.py

+10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
DATA_DIR = os.path.join(SCRIPT_DIR, "config_override_input")
1515
EMPTY_INPUT = os.path.join(DATA_DIR, "empty_input.json")
1616
PARTIAL_CONFIG_OVERRIDE = os.path.join(DATA_DIR, "partial_config_override.json")
17+
NEW_FEATURE_CONFIG = os.path.join(DATA_DIR, "new_feature_config.json")
1718
FULL_CONFIG_OVERRIDE = os.path.join(DATA_DIR, "full_config_override.json")
1819
PORT_CONFIG_OVERRIDE = os.path.join(DATA_DIR, "port_config_override.json")
1920
EMPTY_TABLE_REMOVAL = os.path.join(DATA_DIR, "empty_table_removal.json")
@@ -124,6 +125,15 @@ def test_golden_config_db_partial(self):
124125
db, config, read_data['running_config'], read_data['golden_config'],
125126
read_data['expected_config'])
126127

128+
def test_golden_config_db_new_feature(self):
129+
"""Golden Config append NEW_FEATURE_TABLE"""
130+
db = Db()
131+
with open(NEW_FEATURE_CONFIG, "r") as f:
132+
read_data = json.load(f)
133+
self.check_override_config_table(
134+
db, config, read_data['running_config'], read_data['golden_config'],
135+
read_data['expected_config'])
136+
127137
def test_golden_config_db_full(self):
128138
"""Golden Config makes change to every table in configDB"""
129139
db = Db()

tests/config_test.py

-24
Original file line numberDiff line numberDiff line change
@@ -1192,30 +1192,6 @@ def read_json_file_side_effect(filename):
11921192
assert result.exit_code != 0
11931193
assert "Authentication with 'tacacs+' is not allowed when passkey not exists." in result.output
11941194

1195-
@mock.patch('sonic_py_common.device_info.get_paths_to_platform_and_hwsku_dirs',
1196-
mock.MagicMock(return_value=("dummy_path", None)))
1197-
def test_load_minigraph_no_yang_failure(self, get_cmd_module):
1198-
def is_file_side_effect(filename):
1199-
return True if 'golden_config' in filename else False
1200-
1201-
def read_json_file_side_effect(filename):
1202-
return {
1203-
"NEW_FEATURE": {
1204-
"global": {
1205-
"state": "enable"
1206-
}
1207-
}
1208-
}
1209-
1210-
with mock.patch("utilities_common.cli.run_command", mock.MagicMock(side_effect=mock_run_command_side_effect)), \
1211-
mock.patch('os.path.isfile', mock.MagicMock(side_effect=is_file_side_effect)), \
1212-
mock.patch('config.main.read_json_file', mock.MagicMock(side_effect=read_json_file_side_effect)):
1213-
(config, _) = get_cmd_module
1214-
runner = CliRunner()
1215-
result = runner.invoke(config.config.commands["load_minigraph"], ["--override_config", "-y"])
1216-
assert result.exit_code != 0
1217-
assert "Config tables are missing yang models: dict_keys(['NEW_FEATURE'])" in result.output
1218-
12191195
@mock.patch('sonic_py_common.device_info.get_paths_to_platform_and_hwsku_dirs', mock.MagicMock(return_value=("dummy_path", None)))
12201196
def test_load_minigraph_with_traffic_shift_away(self, get_cmd_module):
12211197
with mock.patch("utilities_common.cli.run_command", mock.MagicMock(side_effect=mock_run_command_side_effect)) as mock_run_command:

0 commit comments

Comments
 (0)