From 4a3d49d359f787cae896d65fa882fbaaac6e57f2 Mon Sep 17 00:00:00 2001 From: bingwang-ms <66248323+bingwang-ms@users.noreply.github.com> Date: Thu, 27 Oct 2022 11:40:43 +0800 Subject: [PATCH] Fix exception in adding mirror_session when gre_type is absent (#2458) This PR is to fix the exception in adding mirror session when gre_type is absent. --- config/main.py | 2 ++ tests/config_mirror_session_test.py | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/config/main.py b/config/main.py index 1fbae9ebb8..6ecfcf2ccd 100644 --- a/config/main.py +++ b/config/main.py @@ -1143,6 +1143,8 @@ def validate_ipv4_address(ctx, param, ip_addr): def validate_gre_type(ctx, _, value): """A validator for validating input gre_type """ + if value is None: + return None try: base = 10 if value.lower().startswith('0x'): diff --git a/tests/config_mirror_session_test.py b/tests/config_mirror_session_test.py index 1b5b07e529..5585cab87a 100644 --- a/tests/config_mirror_session_test.py +++ b/tests/config_mirror_session_test.py @@ -85,6 +85,12 @@ def test_mirror_session_add(): ["test_session", "100.1.1.1", "2.2.2.2", "8", "63", "0", "0"]) mocked.assert_called_with("test_session", "100.1.1.1", "2.2.2.2", 8, 63, 0, 0, None) + + result = runner.invoke( + config.config.commands["mirror_session"].commands["add"], + ["test_session", "100.1.1.1", "2.2.2.2", "8", "63"]) + + mocked.assert_called_with("test_session", "100.1.1.1", "2.2.2.2", 8, 63, None, None, None) def test_mirror_session_erspan_add():