Relay the inventory to the remote client.

        Args:
            inventory (neo.Network.Inventory):

        Returns:
            bool: True if relayed successfully. False otherwise.
555196
def RelayDirectly(self, inventory):
        
        relayed = False

        self.RelayCache[inventory.Hash.ToBytes()] = inventory

        for peer in self.Peers:
            relayed |= peer.Relay(inventory)

        if len(self.Peers) == 0:
            if type(BC.Default()) is TestLevelDBBlockchain:
                # mock a true result for tests
                return True

            logger.info("no connected peers")

        return relayed
485773
def HandleBlockHeadersReceived(self, inventory):
        
        try:
            inventory = IOHelper.AsSerializableWithType(inventory, 'neo.Network.Payloads.HeadersPayload.HeadersPayload')
            if inventory is not None:
                logger.debug(f"{self.prefix} received headers")
                self.heart_beat(HEARTBEAT_HEADERS)
                BC.Default().AddHeaders(inventory.Headers)

        except Exception as e:
            logger.debug(f"Error handling Block headers {e}")
717317
public static inventory get(nitro_service client, inventory resource) throws Exception
	{
		resource.validate("get");
		return ((inventory[]) resource.get_resources(client))[0];
	}
1254215
def _is_inventory_group(key, value):
    '''
    
    '''

    if (
        key.startswith('_')
        or not isinstance(value, (list, tuple, GeneratorType))
    ):
        return False

    # If the group is a tuple of (hosts, data), check the hosts
    if isinstance(value, tuple):
        value = value[0]

    # Expand any generators of hosts
    if isinstance(value, GeneratorType):
        value = list(value)

    return all(
        isinstance(item, ALLOWED_HOST_TYPES)
        for item in value
    )
365844
def root_sync(args, l, config):
    
    from requests.exceptions import ConnectionError

    all_remote_names = [ r.short_name for r in l.remotes ]

    if args.all:
        remotes = all_remote_names
    else:
        remotes = args.refs

    prt("Sync with {} remotes or bundles ".format(len(remotes)))

    if not remotes:
        return

    for ref in remotes:
        l.commit()

        try:
            if ref in all_remote_names: # It's a remote name
                l.sync_remote(l.remote(ref))

            else: # It's a bundle reference

                l.checkin_remote_bundle(ref)

        except NotFoundError as e:
            warn(e)
            continue
        except ConnectionError as e:
            warn(e)
            continue
1361761
def send(self, stat, value, backend=None):
        """"""
        client = yield from self.client(backend)
        if not client:
            return False
        client.send(stat, value)
        client.disconnect()
477701
def flush_ct_inventory(self):
        
        if hasattr(self, '_ct_inventory'):

            # skip self from update
            self._ct_inventory = None
            self.update_view = False
            self.save()
615529
def HandleInvMessage(self, payload):
        

        if self.sync_mode != MODE_MAINTAIN:
            return

        inventory = IOHelper.AsSerializableWithType(payload, 'neo.Network.Payloads.InvPayload.InvPayload')
        if not inventory:
            return

        if inventory.Type == InventoryType.BlockInt:

            ok_hashes = []
            for hash in inventory.Hashes:
                hash = hash.encode('utf-8')
                if hash not in self.myblockrequests and hash not in BC.Default().BlockRequests:
                    ok_hashes.append(hash)
                    BC.Default().BlockRequests.add(hash)
                    self.myblockrequests.add(hash)
            if len(ok_hashes):
                message = Message("getdata", InvPayload(InventoryType.Block, ok_hashes))
                self.SendSerializedMessage(message)

        elif inventory.Type == InventoryType.TXInt:
            pass
        elif inventory.Type == InventoryType.ConsensusInt:
            pass
1252778
def share(self, name, item):
        '''
        
        '''

        try:

            if isinstance(item, s_telepath.Aware):
                item.onTeleShare(self, name)

            self.shared[name] = item

        except Exception:
            logger.exception(f'onTeleShare() error for: {name}')
907333
def is_remote_added(remote):
    '''
    
    '''
    out = __salt__['cmd.run_all'](FLATPAK_BINARY_NAME + ' remotes')

    lines = out.splitlines()
    for item in lines:
        i = re.split(r'\t+', item.rstrip('\t'))
        if i[0] == remote:
            return True
    return False
410465
def _build_inventory(self, cluster):
        
        inventory_data = defaultdict(list)

        for node in cluster.get_all_nodes():
            if node.preferred_ip is None:
                log.warning(
                    "Ignoring node `{0}`: No IP address."
                    .format(node.name))
                continue
            if node.kind not in self.groups:
                # FIXME: should this raise a `ConfigurationError` instead?
                log.warning(
                    "Ignoring node `{0}`:"
                    " Node kind `{1}` not defined in cluster!"
                    .format(node.name, node.kind))
                continue

            extra_vars = ['ansible_user=%s' % node.image_user]

            ip_addr, port = parse_ip_address_and_port(node.preferred_ip)
            if port != 22:
                extra_vars.append('ansible_port=%s' % port)

            if node.kind in self.environment:
                extra_vars.extend('%s=%s' % (k, v) for k, v in
                                  self.environment[node.kind].items())
            for group in self.groups[node.kind]:
                inventory_data[group].append(
                    (node.name, ip_addr, ' '.join(extra_vars)))

        if not inventory_data:
            log.info("No inventory file was created.")
            return None

        # create a temporary file to pass to ansible, since the
        # api is not stable yet...
        if self._storage_path_tmp:
            if not self._storage_path:
                self._storage_path = tempfile.mkdtemp()
            elasticluster.log.warning(
                "Writing inventory file to tmp dir `%s`", self._storage_path)

        inventory_path = os.path.join(
            self._storage_path, (cluster.name + '.inventory'))
        log.debug("Writing Ansible inventory to file `%s` ...", inventory_path)
        with open(inventory_path, 'w+') as inventory_file:
            for section, hosts in inventory_data.items():
                # Ansible throws an error "argument of type 'NoneType' is not
                # iterable" if a section is empty, so ensure we have something
                # to write in there
                if hosts:
                    inventory_file.write("\n[" + section + "]\n")
                    for host in hosts:
                        hostline = "{0} ansible_host={1} {2}\n".format(*host)
                        inventory_file.write(hostline)
        return inventory_path
503673
def add_to_inventory(self):
        """"""
        if not self.server_attrs:
            return
        for addy in self.server_attrs[A.server.PUBLIC_IPS]:
            self.stack.add_host(addy, self.groups, self.hostvars)
95463
def inventory(host, port, time, report_every_n_tags, antennas, tx_power,
              tari, session, mode_identifier,
              tag_population, reconnect, tag_filter_mask,
              impinj_extended_configuration,
              impinj_search_mode, impinj_reports, impinj_fixed_freq):
    """"""
    # XXX band-aid hack to provide many args to _inventory.main
    Args = namedtuple('Args', ['host', 'port', 'time', 'every_n', 'antennas',
                               'tx_power', 'tari', 'session',
                               'population', 'mode_identifier',
                               'reconnect', 'tag_filter_mask',
                               'impinj_extended_configuration',
                               'impinj_search_mode',
                               'impinj_reports',
                               'impinj_fixed_freq'])
    args = Args(host=host, port=port, time=time, every_n=report_every_n_tags,
                antennas=antennas, tx_power=tx_power,
                tari=tari, session=session, population=tag_population,
                mode_identifier=mode_identifier,
                reconnect=reconnect, tag_filter_mask=tag_filter_mask,
                impinj_extended_configuration=impinj_extended_configuration,
                impinj_search_mode=impinj_search_mode,
                impinj_reports=impinj_reports,
                impinj_fixed_freq=impinj_fixed_freq)
    logger.debug('inventory args: %s', args)
    _inventory.main(args)
1230103
def network_info(host=None,
                 admin_username=None,
                 admin_password=None,
                 module=None):
    '''
    
    '''

    inv = inventory(host=host, admin_username=admin_username,
                    admin_password=admin_password)
    if inv is None:
        cmd = {}
        cmd['retcode'] = -1
        cmd['stdout'] = 'Problem getting switch inventory'
        return cmd

    if module not in inv.get('switch') and module not in inv.get('server'):
        cmd = {}
        cmd['retcode'] = -1
        cmd['stdout'] = 'No module {0} found.'.format(module)
        return cmd

    cmd = __execute_ret('getniccfg', host=host,
                        admin_username=admin_username,
                        admin_password=admin_password,
                        module=module)

    if cmd['retcode'] != 0:
        log.warning('racadm returned an exit code of %s', cmd['retcode'])

    cmd['stdout'] = 'Network:\n' + 'Device = ' + module + '\n' + \
                    cmd['stdout']
    return __parse_drac(cmd['stdout'])
799609
def run
      if PryNav.current_remote_server
        raise 'Already running a pry-remote session!'
      else
        PryNav.current_remote_server = self
      end

      setup
      Pry.start @object, {
        :input  => client.input_proxy,
        :output => client.output,
        :pry_remote => true
      }
    end
826690
def _relay(self, **kwargs):
        """"""
        retval = None
        delay_time = 2  # For connection retries
        read_attempts = 0  # For reading from socket
        while retval is None:  # Evict can return False
            sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            sock_fp = sock.makefile('rwb')  # Used for pickle
            try:
                sock.connect((self.host, self.port))
                cPickle.dump(kwargs, sock_fp, cPickle.HIGHEST_PROTOCOL)
                sock_fp.flush()
                retval = cPickle.load(sock_fp)
            except:  # pylint: disable=W0702
                exc_type, exc, _ = sys.exc_info()
                socket_error = exc_type is socket.error
                if socket_error and exc.errno == 111:  # Connection refused
                    sys.stderr.write('Cannot connect to multiprocess server. I'
                                     's it running? Retrying in {0} seconds.\n'
                                     .format(delay_time))
                    time.sleep(delay_time)
                    delay_time = min(64, delay_time * 2)
                elif exc_type is EOFError or socket_error and exc.errno == 104:
                    # Failure during socket READ
                    if read_attempts >= 3:
                        raise ClientException('Successive failures reading '
                                              'from the multiprocess server.')
                    sys.stderr.write('Lost connection with multiprocess server'
                                     ' during read. Trying again.\n')
                    read_attempts += 1
                else:
                    raise
            finally:
                sock_fp.close()
                sock.close()
        if isinstance(retval, Exception):
            raise retval  # pylint: disable=E0702
        return retval
1113415
def save_inventory(inventory, hosts_file=HOSTS_FILE):
    '''
    '''
    with open(hosts_file, 'w') as f:
        inventory.write(f)