Skip to content

Conversation

LeisureZhao
Copy link

@LeisureZhao LeisureZhao commented Feb 5, 2025

Compared to Cisco switches, H3C switches are too slow in executing
commands because the value of the pattern is not set in the
check_config_mode function. This function is called twice in both
the config_mode and exit_config_mode, each time using read_channel_timing
instead of read_until_pattern, which greatly extends the duration.
This commit set default pattern of hp_comware to save time when
checking the config mode.

@ktbyers
Copy link
Owner

ktbyers commented Feb 5, 2025

@LeisureZhao What would be the value of explicit_pattern here?

@LeisureZhao
Copy link
Author

@LeisureZhao What would be the value of explicit_pattern here?

I tried to set explicit_pattern to r"[>]|]", which means that when a pattern with > or ] appears, the read will stop. The configuration example is as follows:

switch_config = {
'device_type': 'hp_comware',
'host': xxx,
'username': xxx,
'password': xxx,
'explicit_pattern': r"[>]|]"
}

Considering the need to be compatible with past usage habits, the code logic remains unchanged when the explicit_pattern is not set. If it is deemed that the execution time of the command is too long, you can set the explicit_pattern configuration item for hp_comware. The pattern can be customized according to the actual switch.

@ktbyers
Copy link
Owner

ktbyers commented Feb 6, 2025

@LeisureZhao I think we should implement this as a defined pattern on check_config_mode and not as an argument that we pass in via __init__.py.

Does that sound reasonable.

Can you restructure the PR to implement that?

@LeisureZhao LeisureZhao force-pushed the develop branch 2 times, most recently from 7c2ba37 to 3addabb Compare February 7, 2025 00:48
Compared to Cisco switches, H3C switches are too slow in executing
commands because the value of the pattern is not set in the
check_config_mode function. This function is called twice in both
the config_mode and exit_config_mode, each time using read_channel_timing
instead of read_until_pattern, which greatly extends the duration.
This commit set default pattern of hp_comware to save time when
checking the config mode.
@LeisureZhao
Copy link
Author

@LeisureZhao I think we should implement this as a defined pattern on check_config_mode and not as an argument that we pass in via __init__.py.

Does that sound reasonable.

Can you restructure the PR to implement that?

Completed modifications, please review.


def check_config_mode(
self, check_string: str = "]", pattern: str = "", force_regex: bool = False
self, check_string: str = "]", pattern: str = r"[>]|]", force_regex: bool = False
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LeisureZhao Why the | (pipe character) here?

@ktbyers
Copy link
Owner

ktbyers commented Feb 7, 2025

Superseded by #3573

@ktbyers ktbyers closed this Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants