47
47
ReplaceConfigException ,
48
48
SessionLockedException ,
49
49
CommandErrorException ,
50
+ UnsupportedVersion ,
50
51
)
51
52
from napalm .eos .constants import LLDP_CAPAB_TRANFORM_TABLE
52
- from napalm .eos .pyeapi_syntax_wrapper import Node
53
53
from napalm .eos .utils .versions import EOSVersion
54
- from napalm .eos .utils .cli_syntax import cli_convert
55
54
import napalm .base .constants as c
56
55
57
56
# local modules
@@ -123,15 +122,13 @@ def __init__(self, hostname, username, password, timeout=60, optional_args=None)
123
122
self .timeout = timeout
124
123
self .config_session = None
125
124
self .locked = False
126
- self .cli_version = 1
127
125
128
126
self .platform = "eos"
129
127
self .profile = [self .platform ]
130
128
self .optional_args = optional_args or {}
131
129
132
130
self .enablepwd = self .optional_args .pop ("enable_password" , "" )
133
131
self .eos_autoComplete = self .optional_args .pop ("eos_autoComplete" , None )
134
- self .fn0039_config = self .optional_args .pop ("eos_fn0039_config" , False )
135
132
136
133
# Define locking method
137
134
self .lock_disable = self .optional_args .pop ("lock_disable" , False )
@@ -201,10 +198,6 @@ def open(self):
201
198
device_type = "arista_eos" ,
202
199
netmiko_optional_args = self .netmiko_optional_args ,
203
200
)
204
- # let's try to determine if we need to use new EOS cli syntax
205
- sh_ver = self ._run_commands (["show version" ])
206
- if EOSVersion (sh_ver [0 ]["version" ]) >= EOSVersion ("4.23.0" ):
207
- self .cli_version = 2
208
201
else :
209
202
try :
210
203
connection = self .transport_class (
@@ -216,22 +209,24 @@ def open(self):
216
209
)
217
210
218
211
if self .device is None :
219
- self .device = Node (connection , enablepwd = self .enablepwd )
212
+ self .device = pyeapi .client .Node (
213
+ connection , enablepwd = self .enablepwd
214
+ )
220
215
# does not raise an Exception if unusable
221
216
222
- # let's try to determine if we need to use new EOS cli syntax
223
- sh_ver = self .device .run_commands (["show version" ])
224
- self .cli_version = (
225
- 2 if EOSVersion (sh_ver [0 ]["version" ]) >= EOSVersion ("4.23.0" ) else 1
226
- )
227
-
228
- self .device .update_cli_version (self .cli_version )
229
217
except ConnectionError as ce :
230
218
# and this is raised either if device not avaiable
231
219
# either if HTTP(S) agent is not enabled
232
220
# show management api http-commands
233
221
raise ConnectionException (str (ce ))
234
222
223
+ # endif self.transport
224
+
225
+ sh_ver = self ._run_commands (["show version" ])
226
+ self ._eos_version = EOSVersion (sh_ver [0 ]["version" ])
227
+ if self ._eos_version < EOSVersion ("4.23.0" ):
228
+ raise UnsupportedVersion (self ._eos_version )
229
+
235
230
def close (self ):
236
231
"""Implementation of NAPALM method close."""
237
232
self .discard_config ()
@@ -263,11 +258,6 @@ def is_alive(self):
263
258
264
259
def _run_commands (self , commands , ** kwargs ):
265
260
if self .transport == "ssh" :
266
- if self .fn0039_config :
267
- if isinstance (commands , str ):
268
- commands = [cli_convert (commands , self .cli_version )]
269
- else :
270
- commands = [cli_convert (cmd , self .cli_version ) for cmd in commands ]
271
261
ret = []
272
262
for command in commands :
273
263
if kwargs .get ("encoding" ) == "text" :
@@ -463,10 +453,9 @@ def _load_config(self, filename=None, config=None, replace=True):
463
453
self ._run_commands (
464
454
commands ,
465
455
autoComplete = self .eos_autoComplete ,
466
- fn0039_transform = self .fn0039_config ,
467
456
)
468
457
else :
469
- self ._run_commands (commands , fn0039_transform = self . fn0039_config )
458
+ self ._run_commands (commands )
470
459
except pyeapi .eapilib .CommandError as e :
471
460
self .discard_config ()
472
461
msg = str (e )
@@ -691,13 +680,16 @@ def get_re_group(res, key, default=None):
691
680
except KeyError :
692
681
return default
693
682
694
- NEIGHBOR_FILTER = "bgp neighbors vrf all | include IPv[46] (Unicast|6PE):.*[0-9]+ | grep -v ' IPv[46] Unicast:/.' | remote AS |^Local AS|Desc|BGP state |remote router ID" # noqa
683
+ NEIGHBOR_FILTER = "vrf all | include IPv[46] (Unicast|6PE):.*[0-9]+ | grep -v ' IPv[46] Unicast:/.' | remote AS |^Local AS|Desc|BGP state |remote router ID" # noqa
695
684
output_summary_cmds = self ._run_commands (
696
685
["show ipv6 bgp summary vrf all" , "show ip bgp summary vrf all" ],
697
686
encoding = "json" ,
698
687
)
699
688
output_neighbor_cmds = self ._run_commands (
700
- ["show ip " + NEIGHBOR_FILTER , "show ipv6 " + NEIGHBOR_FILTER ],
689
+ [
690
+ "show ip bgp neighbors " + NEIGHBOR_FILTER ,
691
+ "show ipv6 bgp peers " + NEIGHBOR_FILTER ,
692
+ ],
701
693
encoding = "text" ,
702
694
)
703
695
@@ -831,10 +823,13 @@ def extract_temperature_data(data):
831
823
yield name , values
832
824
833
825
sh_version_out = self ._run_commands (["show version" ])
834
- is_veos = sh_version_out [0 ]["modelName" ].lower () == "veos"
835
- commands = ["show environment cooling" , "show environment temperature" ]
826
+ is_veos = sh_version_out [0 ]["modelName" ].lower () in ["veos" , "ceoslab" ]
827
+ commands = [
828
+ "show system environment cooling" ,
829
+ "show system environment temperature" ,
830
+ ]
836
831
if not is_veos :
837
- commands .append ("show environment power" )
832
+ commands .append ("show system environment power" )
838
833
fans_output , temp_output , power_output = self ._run_commands (commands )
839
834
else :
840
835
fans_output , temp_output = self ._run_commands (commands )
@@ -1527,23 +1522,12 @@ def get_route_to(self, destination="", protocol="", longer=False):
1527
1522
nexthop_interface_map [nexthop_ip ] = next_hop .get ("interface" )
1528
1523
metric = route_details .get ("metric" )
1529
1524
if _vrf not in vrf_cache .keys ():
1530
- if self .cli_version == 1 :
1531
- command = "show ip{ipv} bgp {dest} {longer} detail vrf {_vrf}" .format (
1532
- ipv = ipv ,
1533
- dest = destination ,
1534
- longer = "longer-prefixes" if longer else "" ,
1535
- _vrf = _vrf ,
1536
- )
1537
- else :
1538
- # Newer EOS can't mix longer-prefix and detail
1539
- command = (
1540
- "show ip{ipv} bgp {dest} {longer} vrf {_vrf}" .format (
1541
- ipv = ipv ,
1542
- dest = destination ,
1543
- longer = "longer-prefixes" if longer else "" ,
1544
- _vrf = _vrf ,
1545
- )
1546
- )
1525
+ command = "show ip{ipv} bgp {dest} {longer} vrf {_vrf}" .format (
1526
+ ipv = ipv ,
1527
+ dest = destination ,
1528
+ longer = "longer-prefixes" if longer else "" ,
1529
+ _vrf = _vrf ,
1530
+ )
1547
1531
vrf_cache .update (
1548
1532
{
1549
1533
_vrf : self ._run_commands ([command ])[0 ]
@@ -1656,7 +1640,11 @@ def get_snmp_information(self):
1656
1640
# Default values
1657
1641
snmp_dict = {"chassis_id" : "" , "location" : "" , "contact" : "" , "community" : {}}
1658
1642
1659
- commands = ["show snmp chassis" , "show snmp location" , "show snmp contact" ]
1643
+ commands = [
1644
+ "show snmp v2-mib chassis" ,
1645
+ "show snmp v2-mib location" ,
1646
+ "show snmp v2-mib contact" ,
1647
+ ]
1660
1648
snmp_config = self ._run_commands (commands , encoding = "json" )
1661
1649
for line in snmp_config :
1662
1650
for k , v in line .items ():
@@ -1691,7 +1679,7 @@ def _sshkey_type(sshkey):
1691
1679
1692
1680
users = {}
1693
1681
1694
- commands = ["show user-account " ]
1682
+ commands = ["show users accounts " ]
1695
1683
user_items = self ._run_commands (commands )[0 ].get ("users" , {})
1696
1684
1697
1685
for user , user_details in user_items .items ():
@@ -1950,7 +1938,7 @@ def _append(bgp_dict, peer_info):
1950
1938
summary_commands = []
1951
1939
if not neighbor_address :
1952
1940
commands .append ("show ip bgp neighbors vrf all" )
1953
- commands .append ("show ipv6 bgp neighbors vrf all" )
1941
+ commands .append ("show ipv6 bgp peers vrf all" )
1954
1942
summary_commands .append ("show ip bgp summary vrf all" )
1955
1943
summary_commands .append ("show ipv6 bgp summary vrf all" )
1956
1944
else :
@@ -1963,7 +1951,7 @@ def _append(bgp_dict, peer_info):
1963
1951
commands .append ("show ip bgp neighbors %s vrf all" % neighbor_address )
1964
1952
summary_commands .append ("show ip bgp summary vrf all" )
1965
1953
elif peer_ver == 6 :
1966
- commands .append ("show ipv6 bgp neighbors %s vrf all" % neighbor_address )
1954
+ commands .append ("show ipv6 bgp peers %s vrf all" % neighbor_address )
1967
1955
summary_commands .append ("show ipv6 bgp summary vrf all" )
1968
1956
1969
1957
raw_output = self ._run_commands (commands , encoding = "text" )
@@ -2169,18 +2157,13 @@ def _show_vrf_text(self):
2169
2157
return vrfs
2170
2158
2171
2159
def _show_vrf (self ):
2172
- if self .cli_version == 2 :
2173
- return self ._show_vrf_json ()
2174
- else :
2175
- return self ._show_vrf_text ()
2160
+ return self ._show_vrf_json ()
2176
2161
2177
2162
def _get_vrfs (self ):
2178
2163
output = self ._show_vrf ()
2179
2164
2180
2165
vrfs = [str (vrf ["name" ]) for vrf in output ]
2181
2166
2182
- vrfs .append ("default" )
2183
-
2184
2167
return vrfs
2185
2168
2186
2169
def get_network_instances (self , name = "" ):
0 commit comments