26
26
so the underlying Juniper PyEZ library is utilized directly in most cases.
27
27
28
28
"""
29
- from __future__ import annotations
30
29
from operator import attrgetter
31
- from typing import List , Any , Dict , Tuple , Sequence , Optional
30
+ from typing import Any , Optional , Sequence
32
31
33
32
from django .template .loader import get_template
34
33
from napalm .base .exceptions import ConnectAuthError , ConnectionException
@@ -165,7 +164,7 @@ def junos_major_version(self) -> int:
165
164
166
165
def get_interfaces (
167
166
self , interfaces : Sequence [manage .Interface ] = None
168
- ) -> List [ Dict [str , Any ]]:
167
+ ) -> list [ dict [str , Any ]]:
169
168
vlan_map = self ._get_untagged_vlans ()
170
169
if interfaces and len (interfaces ) == 1 :
171
170
# we can use a filter if only a single interface was specified
@@ -211,7 +210,7 @@ def _get_untagged_vlans(self):
211
210
switching .get ()
212
211
return {port .ifname : port .tag for port in switching if not port .tagged }
213
212
214
- def get_netbox_vlans (self ) -> List [FantasyVlan ]:
213
+ def get_netbox_vlans (self ) -> list [FantasyVlan ]:
215
214
vlan_objects = manage .Vlan .objects .filter (
216
215
swport_vlans__interface__netbox = self .netbox
217
216
).distinct ()
@@ -234,7 +233,7 @@ def _make_vlan(vlan):
234
233
}
235
234
return sorted (result , key = attrgetter ("vlan" ))
236
235
237
- def get_netbox_vlan_tags (self ) -> List [int ]:
236
+ def get_netbox_vlan_tags (self ) -> list [int ]:
238
237
return [vlan .tag for vlan in self .vlans ]
239
238
240
239
def get_interface_native_vlan (self , interface : manage .Interface ) -> int :
@@ -244,7 +243,7 @@ def get_interface_native_vlan(self, interface: manage.Interface) -> int:
244
243
def set_native_vlan (self , interface : manage .Interface , vlan : int ):
245
244
raise NotImplementedError # This is in fact never used on Juniper!
246
245
247
- def get_native_and_trunked_vlans (self , interface ) -> Tuple [int , List [int ]]:
246
+ def get_native_and_trunked_vlans (self , interface ) -> tuple [int , list [int ]]:
248
247
if not self .is_els :
249
248
switching = EthernetSwitchingInterfaceTable (self .device .device )
250
249
switching .get (interface_name = interface .ifname )
@@ -472,7 +471,7 @@ def set_poe_state(self, interface: manage.Interface, state: PoeState):
472
471
473
472
def get_poe_states (
474
473
self , interfaces : Optional [Sequence [manage .Interface ]] = None
475
- ) -> Dict [str , Optional [PoeState ]]:
474
+ ) -> dict [str , Optional [PoeState ]]:
476
475
"""Retrieves current PoE state for interfaces on this device.
477
476
478
477
:param interfaces: Optional sequence of interfaces to filter for, as fetching
@@ -520,7 +519,7 @@ def _get_single_poe_state(self, interface: manage.Interface) -> PoeState:
520
519
521
520
def _get_poe_states_bulk (
522
521
self , interfaces : Sequence [manage .Interface ]
523
- ) -> Dict [str , Optional [PoeState ]]:
522
+ ) -> dict [str , Optional [PoeState ]]:
524
523
tree = self ._get_all_poe_interface_information ()
525
524
interface_information_elements = tree .findall (".//interface-information" )
526
525
ifname_to_state_dict = {}
@@ -558,7 +557,7 @@ def _poe_string_to_state(self, state_str: str) -> PoeState:
558
557
# dot1x authentication configuration fetchers aren't implemented yet, for lack
559
558
# of configured devices to test on
560
559
# def is_dot1x_enabled(self, interface: manage.Interface) -> bool:
561
- # def get_dot1x_enabled_interfaces(self) -> Dict [str, bool]:
560
+ # def get_dot1x_enabled_interfaces(self) -> dict [str, bool]:
562
561
# def is_port_access_control_enabled(self) -> bool:
563
562
564
563
# These are not relevant for Juniper
@@ -578,7 +577,7 @@ def is_unit(name: str) -> bool:
578
577
return len (names ) == 2
579
578
580
579
581
- def split_master_unit (name : str ) -> Tuple [str , str ]:
580
+ def split_master_unit (name : str ) -> tuple [str , str ]:
582
581
"""Splits an interface name into master and unit parts. If the name doesn't
583
582
already refer to a unit, unit 0 will be assumed.
584
583
"""
0 commit comments