-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathservice_patterns.py
More file actions
212 lines (197 loc) · 12.2 KB
/
service_patterns.py
File metadata and controls
212 lines (197 loc) · 12.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
"""
Module:
unicon.plugins.generic.service_patterns
Authors:
pyATS TEAM (pyats-support@cisco.com, pyats-support-ext@cisco.com)
Description:
Module for defining all the Patterns required for the
generic service implementation
"""
from unicon.patterns import UniconCorePatterns
class ReloadPatterns(UniconCorePatterns):
def __init__(self):
super().__init__()
self.savenv = r"^.*System config(uration)? has been modified\.\s*Save\?.*$"
self.confirm_reset = r'^.*Are you sure you want to reset the system\s*\(y\/n\)\?'
self.confirm_config = r'^(.*)Uncommitted changes found.*?'
self.autoinstall_dialog = r'^(.*)Would you like to terminate autoinstall\?\s*\[yes\]:\s*$'
self.module_reload = r'^.*Do you want to reload the internal AP\s?\?\s((\[yes/no\]\??)|(\[y/n\]\??)):?\s?$'
self.save_module_cfg = r'^.*Do you want to save the configuration of the AP\s?\?\s*((\[yes/no\]\??)|(\[y/n\]\??)):?\s?$'
self.reboot_confirm = r'^(.*)This command will reboot the system.\s*\(y\/n\)\?\s*\[n\]\s?$'
self.secure_passwd_std = r'^.*Do you want to enforce secure password standard(\?)?\s*\(yes\/no\)(\s*\[[yn]\])?\:\s*'
self.admin_password = r'^.*(Enter|Confirm) the password for .*admin'
self.auto_provision = r'Abort( Power On)? Auto Provisioning .*:'
self.reload_confirm_ios = r'^.*Proceed( with( quick)? reload)?\?\s*\[confirm\]'
self.reload_confirm_iosxe = r'^.*Do you wish to proceed with reload anyway\s*\[confirm\]\s*'
self.reload_confirm = r'^.*Reload node\s*\?\s*\[no,yes\]\s?$'
self.reload_confirm_nxos = r'^(.*)This command will reboot the system.\s*\(y\/n\)\?\s*\[n\]\s?$'
self.connection_closed = r'^(.*?)Connection.*? closed|disconnect: Broken pipe'
self.press_return = r'Press RETURN to get started.*'
self.config_session_locked = r'^.*Config session is locked.*user will be pushed back to exec mode'
# Traceroute patterns
class TraceroutePatterns(object):
def __init__(self):
self.protocol = r'^.*Protocol \[.+\]\s?:\s?$'
self.unknown_protocol = r'^.*Unknown protocol - .*help'
self.target = r'^.*Target IP address:\s?$'
self.ingress = r'^.*Ingress traceroute \[.+\]\s?:\s?$'
self.source_address_interface = r'^.*Source address( or interface)?:\s?$'
self.dscp = r'^.*DSCP .*\[.+\]\s?:\s?$'
self.numeric_display = r'^.*Numeric display(\?)? \[.+\]\s?:\s?$'
self.timeout_seconds = r'^.*Timeout in seconds \[.+\]\s?:\s?$'
self.probe_count = r'^.*Probe count \[.+\]\s?:\s?$'
self.minimum_ttl = r'^.*Minimum Time to Live \[.+\]\s?:\s?$'
self.maximum_ttl = r'^.*Maximum Time to Live \[.+\]\s?:\s?$'
self.port_number = r'^.*Port Number \[.+\]\s?:\s?$'
self.style = r'^.*Loose, Strict, Record, Timestamp, Verbose\[.+\]\s?:\s?$'
self.resolve_as_number = r'Resolve +AS +number +in.*'
# Ping patterns
class PingPatterns():
def __init__(self):
self.ping_loop_message = r' ^.*(% )?(Invalid source|A decimal number between|Invalid pattern|Invalid interface|No such option|Please answer).*$'
self.unkonwn_protocol = r'^.*Unknown protocol - .*help'
self.protocol = r'^.*Protocol \[.+\]\s?: $'
self.transport = r'^.*traffic-eng \[.+\]\s?: $'
self.mask = r'^.*mask: $'
self.address = r'^.*address(( of peer)|( or Hostname))?\s?: $'
self.vcid = r'^.*(VC|PW) ID \[.+\]\s?: $'
self.tunnel = r'^.*Tunnel interface number \[.+\]\s?: $'
self.repeat = r'^.*Repeat count \[.+\]\s?: $'
self.size = r'^.*Datagram size \[.+\]\s?: $'
self.verbose = r'^.*Verbose(\?)? \[.+\]\s?: $'
self.interval = r'^.*Interval in milliseconds \[.+\]: $'
self.packet_timeout = r'^.*Timeout in seconds \[.+\]\s?: $'
self.sending_interval = r'^.*Sending interval in seconds \[.+\]\s?: $'
self.novell_echo_type = r'^.*Novell Standard Echo \[.+\]\s?: $'
self.output_interface = r'^.*Output Interface(\[.+\])?\s?: $'
self.vrf = r'^.*Vrf context to use \[default\] :\s?$'
# Extended internal dialogs
self.ext_cmds = r'^.*Extended commands.+\[.+\]\s?: $'
self.ext_cmds_loop = r'ADD PING LOOP PATTERNS'
self.ipv6_source = r'^.*Source address or interface\s?: $'
self.ipv6_udp = r'^.*UDP protocol\? \[.+\]\s?: $'
self.ipv6_priority = r'^.*Priority \[.+\]\s?: $'
self.ipv6_verbose = r'^.*Verbose\? \[.+\]\s?: $ '
self.ipv6_precedence = r'^.*Precedence \[.+\]\s?: $'
self.ipv6_dscp = r'^.*DSCP \[.+\]\s?: $'
self.ipv6_hop = r'^.*Include hop by hop option\? \[.+\]\s?: $'
self.ipv6_dest = r'^.*Include destination option\? \[.+\]\s?: $'
self.ipv6_extn_header = r'^.*Include extension headers\? \[.+\]\s?: $'
self.ext_cmds_timeout = r'ADD TIMEOUT PATTERNS'
# For IPV4
self.dest_start = r'^.*destination start address\s?: $'
self.interface = r'^.*Interface (\[.+\]\s?)?: $'
self.dest_end = r'^.*Destination end address\s?: $'
self.increment = r'^.*increment\s?: $'
self.mpls_header = r'^.*EXP bits in mpls header \[.+\]\s?: $'
self.tlv_pattern = r'^.*Pad TLV pattern \[.+\]\s?: $'
self.ttl = r'^.*Time (t|T)o (L|l)ive \[.+\]\s?: $'
self.reply_mode = r'^.*Reply mode \(.+\) \[.+\]\s?: $'
self.revision = r'^.*LSP ping/trace revision \(.+\) \[.+\]\s?: $'
self.null_label = r'^.*Force explicit null label.+\[.+\]\s?: $'
self.dscp_header = r'^.*Reply (ip|IP) header DSCP bits \[.+\]\s?: $'
self.verbomode = r'^.*Verbose mode\? \[.+\]\s?: $'
self.ext_cmds_source = r'^.*Source .*address( or interface)?\s?: $'
self.tos = r'^.*Type of service \[.+\]\s?: $'
self.validate = r'^.*Validate reply data\?\s*\[.+\]:\s*$'
self.data_pattern = r'^.*Data pattern \[.+\]\s?: $'
self.dfbit_header = r'^.*Set DF bit in IP header(\?)? \[.+\]\s?: $'
self.dscp = r'^.*DSCP .*\[.+\]\s?: $'
self.lsrtv = r'^.*Loose, Strict, Record, Timestamp, Verbose\s?\[(.+)\]\s?: $'
self.qos = r'^.*Include global QOS option\? \[.+\]\s?: $'
self.packet = r'^.*Pad packet\? \[.+\]\s?: $'
# Range internal dialogs
self.range = r'^.*Sweep range of sizes.* \[.+\]\s?: $'
self.range_loop = r'ADD PING LOOP PATTERNS'
self.range_min = r'^.*Sweep min size \[.+\]\s?: $'
self.range_max = r'^.*Sweep max size \[.+\]\s?: $'
self.range_interval = r'^.*Sweep interval \[.+\]\s?: $'
self.range_timeout = r'ADD TIMEOUT PATTERNS'
self.others = r'^.*\[.+\]\s?: $'
# extd_LSRTV patterns
self.lsrtv_source = r'^.*Source route: $'
self.lsrtv_hop_count = r'^.*Number of hops \[.*\]: $'
self.lsrtv_timestamp_count = r'^.*Number of timestamps \[.*\]: $'
self.lsrtv_noroom = r'^.*No room for that option'
self.lsrtv_invalid_hop = r'^.*Invalid number of hops'
self.lsrtv_one_allowed = r'^.*% Only one source route option allowed'
# Invalid commands
self.invalid_command = r'^.*% *Invalid.*'
class CopyPatterns():
def __init__(self):
self.source_filename = r'^.*(Enter source file\s?name:.*)$'
self.copy_file = r'^.*(file to copy|Source file name|Source filename) *\[*.*\]*\?.*$'
self.file_to_write = r'^file to write.*\[*.*\]*.*$'
self.hostname = r'^.*((h|H)ost|(h|H)ostname)(.*?)\[.*\]\?( *)?$'
self.host = r'Address or name of remote host.*\?\s*$'
self.src_file = r'Name of file to copy\?\s*$'
self.dest_file = r'Destination filename.*$'
self.dest_directory = r'Destination directory.*$'
#Move this to NXOS group
self.nx_hostname = r'^.*Enter hostname for the (tftp|ftp|scp) server:\s*$'
self.partition = r'^.*Which partition\?.*$'
self.config = r'^.*Name of configuration file.*\[*.*\]*.*\?\s*$'
self.writeto = r'^.*(name to write to|[Dd]estination file ?name).*\[.*\].*$'
self.username = r'^.*username.*(\[.*\])?.*$'
self.password = r'^.*[Pp]assword.*(\[.*\])?.*$'
self.erase_before_copy = r'^.*Erase .*before (writing|copying)\?\s*\[confirm\]\s*$'
self.net_type = r'^.*Copy.*from.*\?.*\[confirm\].*$'
self.copy_confirm = r'^.*Copy.*(from|to).*\[confirm\].*$'
self.memory = r'^.* memory\?\s*\[confirm\]\s*$'
self.copy_confirm_1 = r'^.*Are you sure\?.*\[confirm\]\s*$'
self.copy_confirm_yesno = r'^.*Are you sure\?.*$'
self.copy_reconfirm = r'^.*into Flash WITH.* erase *\?.*$'
self.copy_progress = r'^.*(!!!!|####|CCCC|cccc)'
self.rcp_confirm = r'^.*(Write file|Configure using).*\?.*$'
self.copy_overwrite = r'^.*Do you want to over\s?write\?? (\(y\/n\)\?)?\[.*\].*$'
self.copy_nx_vrf = r'^.*Enter vrf \(If no input,.*default.*\):\s*$'
self.copy_proceed = r'^.*bytes.*proceed\?.*$'
self.tftp_addr =r'^.*Address or name of remote host \[\]\?\s*$'
self.copy_complete = r'^.*bank [0-9]+'
self.copy_error_message = r'\bfail\b|timed out|Timed out|Error|Login incorrect|denied|Problem' \
r'|NOT|Invalid|No memory|Failed(?! to generate persistent self-signed certificate)|mismatch|Bad|bogus|lose|abort' \
r'|Not |too big|exceeds|detected|[Nn]o route to host' \
r'|image is not allowed|Could not resolve|No such'
self.copy_retry_message = r'\bfail\b|[Tt]imed out|Error|Problem|NOT|Failed(?! to generate persistent self-signed certificate)|Bad|bogus|lose|abort|Not |too big|exceeds|detected'
self.copy_continue = r'Are you sure you want to continue connecting ((yes/no)|\((yes/no(/\[fingerprint\])?)?\))?'
self.copy_other = r'^.*\[yes\/no\]\s*\?*\s*$'
self.remote_param ='ftp:|tftp:|http:|rcp:|scp:'
self.remote_in_dest = r'(ftp:|sftp:|tftp:|http:|rcp:|scp:)/*$'
self.addr_in_remote = r'(ftp:|tftp:|http:|rcp:|scp:)\/*([\w\.\:]+)'
self.abort_copy = r'Abort Copy\? \[confirm\]\s*$'
class HaReloadPatterns(UniconCorePatterns):
def __init__(self):
super().__init__()
self.savenv = r'^.*System configuration has been modified\. Save.*$'
self.reload_proceed = r'^(.*)Proceed with( quick)? reload\?\s*\[confirm\]\s*$'
self.reload_entire_shelf = r'Reload the entire shelf\s*\[confirm\]'
self.reload_this_shelf = r'Reload this shelf\s*\[confirm\]'
self.default_prompts = r'(Router|Switch|ios|Switch-standby)(\\(boot\\))?(>|#)'
self.redundant = r'^.*REDUNDANCY mode is (RPR|SSO).*'
self.config_byte = r'Uncompressed configuration from [0-9]+ bytes to [0-9]+ bytes'
self.restriction_prompt = r'Restricted Rights Legend'
self.login_notready = r'^.*is not ready or active for login.*'
self.setup_dialog = r'^.*initial configuration dialog.*'
self.autoinstall_dialog = r'^(.*)Would you like to terminate autoinstall\?\s?\[yes\]:\s*$'
self.auto_provision = r'Abort( Power On)? Auto Provisioning.*:'
self.sso_ready = r'Terminal state reached for (SSO)'
class SwitchoverPatterns:
def __init__(self):
self.save_config = r'^.*System configuration has been modified\.\s*Save\s?\?.*$'
self.build_config = r'Building configuration'
self.prompt_switchover = r'This will reload the active unit and force switchover to standby\[confirm\]'
self.switchover_init = r'Preparing for switchover|LOGGER_FLUSHING|RELOAD|Reload'
self.switchover_reason = r'^(.*)Reset Reason'
self.switchover_fail1 = r'^(.*)Standby RP is not in RF_STANDBY_HOT state(.*)'
self.switchover_fail2 = r'% Standby not ready for switchover\.?'
self.switchover_fail3 = r'% There is no STANDBY present\.?'
self.switchover_fail4 = r'Failed to switchover'
self.switchover_cmd_issued = r'Resetting ...(.*)'
self.switchover_proceed = r'^.*Proceed with switchover to standby RP\? \[confirm\]'
class ResetStandbyPatterns:
def __init__(self):
self.reload_confirm = r'Reload peer\s*\[confirm\]'
self.reload_proceed = r'Preparing to reload peer'
self.reset_abort = r'Peer reload not performed'
self.reload_proceed1 = r'System is running in SIMPLEX mode, reload anyway\?\s*\[confirm\]'
reload_patterns = ReloadPatterns()