def itemize(self, rec: Dict) -> Dict: exp_ifn = self.source.expands["interface"] # noqa return dict( hostname=normalize_hostname(rec["hostname"]), interface=exp_ifn(rec["intName"]), portchan=exp_ifn(rec["portchan"]), )
def itemize(self, rec: Dict) -> Dict: return dict( sn=rec.get("snHw") or rec["sn"], hostname=normalize_hostname(rec["hostname"]), ipaddr=rec["loginIp"], site=self.map_field_value("site", rec["siteName"]), os_name=self.map_field_value("os_name", rec["family"]), vendor=self.map_field_value("vendor", rec["vendor"]), model=self.map_field_value("model", rec["model"]), )
def itemize(self, rec: Dict) -> Dict: attrs = rec["attributes"] return dict( sn="", hostname=normalize_hostname(rec["name"]), ipaddr=rec["ip_address"], site=attrs["Location"], os_name=attrs["OS Version"], vendor=self._vendor_normalize(rec), model="", )
def itemize(self, rec: Dict) -> Dict: try: pflen = rec["net"].split("/")[-1] except AttributeError: pflen = "32" return { "ipaddr": f"{rec['ip']}/{pflen}", "interface": self.source.expands["interface"](rec["intName"]), # noqa "hostname": normalize_hostname(rec["hostname"]), "site": rec["siteName"], }
def itemize(self, rec: Dict) -> Dict: dt = rec["device_type"] try: ipaddr = rec["primary_ip"]["address"].split("/")[0] except (TypeError, KeyError): ipaddr = "" try: os_name = rec["platform"]["slug"] except (TypeError, KeyError): os_name = "" return dict( sn=rec["serial"], hostname=normalize_hostname(rec["name"]), ipaddr=ipaddr, site=rec["site"]["slug"], os_name=os_name, vendor=dt["manufacturer"]["slug"], model=dt["slug"], status=rec["status"]["value"], )
def itemize(self, rec: Dict) -> Dict: hostname = normalize_hostname(rec['hostname']).lower( ) # hostnames always used in lowercase form. orig_if_name = rec['intName'] os_name = self.cache['devices'].items[hostname]['os_name'] # TODO: this is a bit of a hack for now, but we'll need to address how we want to # perform mapping and filtering in more of a plugin/config-file mannter. if os_name == 'exos': # if this is a physical port, it will take the form "<switch_id>:<port_id>" if (mo := _exos_port_match(orig_if_name)): sw_id, port_id = mo.groups() if_name = f'Ethernet{port_id}' if sw_id == '1' else f'Ethernet{sw_id}/{port_id}' # otherwise this is a "VLAN" port, and we only want to keep those # that have an IP address assigned. Other "VLAN ports" are just # VLANs and do not constitute a port. EXOS joy. else: if not rec['primaryIp']: return None if_name = orig_if_name
# otherwise this is a "VLAN" port, and we only want to keep those # that have an IP address assigned. Other "VLAN ports" are just # VLANs and do not constitute a port. EXOS joy. else: if not rec['primaryIp']: return None if_name = orig_if_name else: if_name = self.source.expands["interface"](orig_if_name) return { "interface": if_name, "hostname": normalize_hostname(rec["hostname"]), "description": rec["dscr"] or "", "site": rec["siteName"], } async def add_items(self, items: Dict, callback: Optional[CollectionCallback] = None): raise NotImplementedError() async def update_items(self, items: Dict, callback: Optional[CollectionCallback] = None): raise NotImplementedError() async def delete_items(self,