def enabled(self) -> bool:
     shutdown = jh.query('shutdown."#standalone"', self.yy.native)
     if shutdown:
         return False
     else:
         return True
Exemple #2
0
 def _remove_subinterfaces(self, interface: Dict[str, Any]) -> None:
     subifaces = jh.query("subinterfaces.subinterface[]",
                          interface) or []
     for subiface in subifaces:
         self.root_result.add_command(
             f"no interface {self.key}.{subiface['index']}")
 def trunk_vlans(self) -> Optional[List[str]]:
     v = jh.query('switchport.trunk.allowed.vlan."#text"', self.yy.native)
     if v is not None:
         return cast(List[str], v.split(","))
     return None
 def description(self) -> Optional[str]:
     return cast(Optional[str],
                 jh.query('description."#text"', self.yy.native))
 def access_vlan(self) -> Optional[int]:
     v = jh.query('switchport.access.vlan."#text"', self.yy.native)
     if v is not None:
         return int(v)
     return None
 def interface_mode(self) -> Optional[str]:
     v = jh.query('switchport.mode."#text"', self.yy.native)
     if v is not None:
         return cast(str, v.upper())
     else:
         return None
 def active(self) -> bool:
     return not jh.query('shutdown."#standalone"', self.yy.native)
 def name(self) -> Optional[str]:
     v = jh.query('name."#text"', self.yy.native)
     if v is not None:
         return str(v)
     else:
         return None
 def extract_elements(self) -> Iterator[Tuple[str, Dict[str, Any]]]:
     for k, v in jh.query("vlan", self.native, default={}).items():
         if k == "#text":
             continue
         yield k, cast(Dict[str, Any], v)