Beispiel #1
0
    def test_qos_reload_masic(self, get_cmd_module, setup_qos_mock_apis,
                              setup_multi_broadcom_masic):
        (config, show) = get_cmd_module
        runner = CliRunner()
        output_file = os.path.join(os.sep, "tmp", "qos_config_output.json")
        print("Saving output in {}<0,1,2..>".format(output_file))
        num_asic = device_info.get_num_npus()
        for asic in range(num_asic):
            try:
                file = "{}{}".format(output_file, asic)
                os.remove(file)
            except OSError:
                pass
        json_data = '{"DEVICE_METADATA": {"localhost": {}}}'
        result = runner.invoke(
            config.config.commands["qos"],
            ["reload", "--dry_run", output_file, "--json-data", json_data])
        print(result.exit_code)
        print(result.output)
        assert result.exit_code == 0

        cwd = os.path.dirname(os.path.realpath(__file__))

        for asic in range(num_asic):
            expected_result = os.path.join(cwd, "qos_config_input", str(asic),
                                           "config_qos.json")
            file = "{}{}".format(output_file, asic)
            assert filecmp.cmp(file, expected_result, shallow=False)
Beispiel #2
0
def main():

    module = AnsibleModule(argument_spec=dict(), supports_check_mode=False)

    results = {}

    try:
        results['platform'], results[
            'hwsku'] = device_info.get_platform_and_hwsku()
        results['is_multi_asic'] = device_info.is_multi_npu()
        results['num_asic'] = device_info.get_num_npus()
        results.update(device_info.get_sonic_version_info())

        # In case a image does not have /etc/sonic/sonic_release, guess release from 'build_version'
        if 'release' not in results or not results['release'] or results[
                'release'] == 'none':
            if 'build_version' in results:
                if '201811' in results['build_version']:
                    results['release'] = '201811'
                elif '201911' in results['build_version']:
                    results['release'] = '201911'
                elif 'master' in results['build_version']:
                    results['release'] = 'master'
                else:
                    results['release'] = 'unknown'

        module.exit_json(ansible_facts={'dut_basic_facts': results})
    except Exception as e:
        module.fail_json(
            msg='Gather DUT facts failed, exception: {}'.format(repr(e)))