Return a device name that associated network communication direction.
430272
def get_tc_device(self):
        

        if self.direction == TrafficDirection.OUTGOING:
            return self.device

        if self.direction == TrafficDirection.INCOMING:
            return self.ifb_device

        raise ParameterError(
            "unknown direction", expected=TrafficDirection.LIST, value=self.direction
        )
897415
def get_device_topology(self, id_or_uri):
        
        uri = self._client.build_uri(id_or_uri) + "/deviceTopology"
        return self._client.get(uri)
1142275
def _payload(self):
        """"""
        return self.tcp or self.udp or self.icmpv4 or self.icmpv6
340970
def name(self) -> str:
        """"""
        return next(
            attr['Value'] for attr in self._device_json.get('Attributes', [])
            if attr.get('AttributeDisplayName') == 'desc')
766016
def getaddrinfo_wrapper(host, port, family=socket.AF_INET, socktype=0, proto=0, flags=0):
    """"""
    return orig_getaddrinfo(host, port, family, socktype, proto, flags)
381002
def device_id(self):
        
        if self.is_block:
            for filename in self._P.Block.Symlinks:
                parts = decode_ay(filename).split('/')
                if parts[-2] == 'by-id':
                    return parts[-1]
        elif self.is_drive:
            return self._assocdrive._P.Drive.Id
        return ''
1003773
def lookup_forward(name):
    """"""
    ip_addresses = {}

    addresses = list(set(str(ip[4][0]) for ip in socket.getaddrinfo(
        name, None)))

    if addresses is None:
        return ip_addresses

    for address in addresses:
        if type(ipaddress.ip_address(address)) is ipaddress.IPv4Address:
            ip_addresses['ipv4'] = address
        if type(ipaddress.ip_address(address)) is ipaddress.IPv6Address:
            ip_addresses['ipv6'] = address

    return ip_addresses
1227123
def get_device_by_name(self, device_name):
        

        # Find the device for the vera device name we are interested in
        found_device = None
        for device in self.get_devices():
            if device.name == device_name:
              found_device = device
              # found the first (and should be only) one so we will finish
              break

        if found_device is None:
            logger.debug('Did not find device with {}'.format(device_name))

        return found_device
134222
def getNetworkName(self):
        """"""
        print '%s call getNetworkname' % self.port
        networkName = self.__sendCommand(WPANCTL_CMD + 'getprop -v Network:Name')[0]
        return self.__stripValue(networkName)
1362641
def list_hosting_devices_hosting_routers(self, client, router_id,
                                             **_params):
        """"""
        return client.get((client.router_path + L3_ROUTER_DEVICES) %
                          router_id, params=_params)
919911
def _net(self):
        """"""
        data = psutil.network_io_counters(pernic=True)
        if self.device not in data:
            raise CommandError("Unknown device: {0}".format(self.device))

        # Network bytes sent
        value = data[self.device].bytes_sent
        metric("net-{0}-sent".format(self.device), value, category=self.category)
        gauge("net-{0}-sent".format(self.device), value)

        # Network bytes received
        value = data[self.device].bytes_recv
        metric("net-{0}-recv".format(self.device), value, category=self.category)
546682
def _extract_device_name_from_event(event):
  """"""
  plugin_data_content = json.loads(
      tf.compat.as_str(event.summary.value[0].metadata.plugin_data.content))
  return plugin_data_content['device']
509274
def find_device_by_name(name):
    """"""
    if not name:
        return DEFAULT_DEV
    with DEV_LOCK:
        for dev in DEVS:
            if dev.name == name:
                return dev
    return None
208306
def list_routers_on_hosting_device(self, client, hosting_device_id,
                                       **_params):
        """"""
        res_path = hostingdevice.HostingDevice.resource_path
        return client.get((res_path + DEVICE_L3_ROUTERS) %
                          hosting_device_id, params=_params)
432231
def get_device_element(self, ain):
        """"""
        elements = self.get_device_elements()
        for element in elements:
            if element.getAttribute('identifier') == ain:
                return element
        return None
1037814
def get_network_name(self):
        
        start = self.network.find('network')
        end = self.network.find('}\n', start)
        # Creating a network attribute
        network_attribute = Suppress('network') + Word(alphanums + '_' + '-') + '{'
        network_name = network_attribute.searchString(self.network[start:end])[0][0]

        return network_name
841172
def _tag_net_direction(data):
        """"""

        # IP or IPv6
        src = data['packet']['src_domain']
        dst = data['packet']['dst_domain']
        if src == 'internal':
            if dst == 'internal' or 'multicast' in dst or 'broadcast' in dst:
                return 'internal'
            else:
                return 'outgoing'
        elif dst == 'internal':
            return 'incoming'
        else:
            return None