diff --git a/src/sonic-config-engine/config_samples.py b/src/sonic-config-engine/config_samples.py index 1b38276524..f5188e9f6a 100644 --- a/src/sonic-config-engine/config_samples.py +++ b/src/sonic-config-engine/config_samples.py @@ -42,13 +42,7 @@ def generate_empty_config(data): return new_data def generate_l2_config(data): - if not data['DEVICE_METADATA']['localhost'].has_key('hostname'): - data['DEVICE_METADATA']['localhost']['hostname'] = 'sonic' - if not data['DEVICE_METADATA']['localhost'].has_key('type'): - data['DEVICE_METADATA']['localhost']['type'] = 'ToRRouter' data['VLAN'] = {'Vlan1000': {'vlanid': '1000'}} - vp = natsorted(data['PORT'].keys()) - data['VLAN']['Vlan1000'].setdefault('members', vp) data['VLAN_MEMBER'] = {} for port in natsorted(data['PORT'].keys()): data['PORT'][port].setdefault('admin_status', 'up') diff --git a/src/sonic-config-engine/tests/test_j2files.py b/src/sonic-config-engine/tests/test_j2files.py index 2d4dd47aa3..0298605889 100644 --- a/src/sonic-config-engine/tests/test_j2files.py +++ b/src/sonic-config-engine/tests/test_j2files.py @@ -89,12 +89,15 @@ class TestJ2Files(TestCase): assert filecmp.cmp(sample_output_file, self.output_file) def test_l2switch_template(self): - argument = '-k Mellanox-SN2700 -t ' + os.path.join(self.test_dir, '../data/l2switch.j2') + ' -p ' + self.t0_port_config + ' > ' + self.output_file - self.run_script(argument) + argument = '-k Mellanox-SN2700 --preset l2 -p ' + self.t0_port_config + output = self.run_script(argument) + output_json = json.loads(output) sample_output_file = os.path.join(self.test_dir, 'sample_output', 'l2switch.json') + with open(sample_output_file) as sample_output_fd: + sample_output_json = json.load(sample_output_fd) - self.assertTrue(filecmp.cmp(sample_output_file, self.output_file)) + self.assertTrue(json.dumps(sample_output_json, sort_keys=True) == json.dumps(output_json, sort_keys=True)) def test_qos_arista7050_render_template(self): arista_dir_path = os.path.join(self.test_dir, '..', '..', '..', 'device', 'arista', 'x86_64-arista_7050_qx32s', 'Arista-7050-QX-32S')