original_docstring: Add a given container name and type to the hosts.
  
      :param assignment: ``str`` Name of container component target
      :param config: ``dict``  User defined information
      :param container_name: ``str``  Name fo container
      :param container_type: ``str``  Type of container
      :param inventory: ``dict``  Living dictionary of inventory
      :param is_metal: ``bol``  If true, a container entry will not be built
      
docstring: Add a given container name and type to the hosts.
docstring_tokens: Add a given container name and type to the hosts .
code: def _add_container_hosts(assignment, config, container_name, container_type,
                           inventory, is_metal):
      """Add a given container name and type to the hosts.
  
      :param assignment: ``str`` Name of container component target
      :param config: ``dict``  User defined information
      :param container_name: ``str``  Name fo container
      :param container_type: ``str``  Type of container
      :param inventory: ``dict``  Living dictionary of inventory
      :param is_metal: ``bol``  If true, a container entry will not be built
      """
      physical_host_type = '%s_hosts' % container_type.split('_')[0]
      # If the physical host type is not in config return
      if physical_host_type not in config:
          return
  
      for host_type in inventory[physical_host_type]['hosts']:
          container_hosts = inventory[container_name]['hosts']
  
          # If host_type is not in config do not append containers to it
          if host_type not in config[physical_host_type]:
              continue
  
          # Get any set host options
          host_options = config[physical_host_type][host_type]
          affinity = host_options.get('affinity', {})
  
          container_affinity = affinity.get(container_name, 1)
          # Ensures that container names are not longer than 63
          # This section will ensure that we are not it by the following bug:
          # https://bugzilla.mindrot.org/show_bug.cgi?id=2239
          type_and_name = '%s_%s' % (host_type, container_name)
          max_hostname_len = 52
          if len(type_and_name) > max_hostname_len:
              raise SystemExit(
                  'The resulting combination of [ "%s" + "%s" ] is longer than'
                  ' 52 characters. This combination will result in a container'
                  ' name that is longer than the maximum allowable hostname of'
                  ' 63 characters. Before this process can continue please'
                  ' adjust the host entries in your "rpc_user_config.yml" to use'
                  ' a short hostname. The recommended hostname length is < 20'
                  ' characters long.' % (host_type, container_name)
              )
  
          physical_host = inventory['_meta']['hostvars'][host_type]
          container_host_type = '%s_containers' % host_type
          if 'container_types' not in physical_host:
              physical_host['container_types'] = container_host_type
          elif physical_host['container_types'] != container_host_type:
              physical_host['container_types'] = container_host_type
  
          # Add all of the containers into the inventory
          _build_container_hosts(
              container_affinity,
              container_hosts,
              type_and_name,
              inventory,
              host_type,
              container_type,
              container_host_type,
              physical_host_type,
              config,
              is_metal,
              assignment,
          )
  
          # Add the physical host type to all containers from the built inventory
          _append_container_types(inventory, host_type)
          _append_to_host_groups(
              inventory,
              container_type,
              assignment,
              host_type,
              type_and_name,
              host_options
          )
code_tokens: def _add_container_hosts ( assignment , config , container_name , container_type , inventory , is_metal ) : physical_host_type = '%s_hosts' % container_type . split ( '_' ) [ 0 ] if physical_host_type not in config : return for host_type in inventory [ physical_host_type ] [ 'hosts' ] : container_hosts = inventory [ container_name ] [ 'hosts' ] if host_type not in config [ physical_host_type ] : continue host_options = config [ physical_host_type ] [ host_type ] affinity = host_options . get ( 'affinity' , { } ) container_affinity = affinity . get ( container_name , 1 ) type_and_name = '%s_%s' % ( host_type , container_name ) max_hostname_len = 52 if len ( type_and_name ) > max_hostname_len : raise SystemExit ( 'The resulting combination of [ "%s" + "%s" ] is longer than' ' 52 characters. This combination will result in a container' ' name that is longer than the maximum allowable hostname of' ' 63 characters. Before this process can continue please' ' adjust the host entries in your "rpc_user_config.yml" to use' ' a short hostname. The recommended hostname length is < 20' ' characters long.' % ( host_type , container_name ) ) physical_host = inventory [ '_meta' ] [ 'hostvars' ] [ host_type ] container_host_type = '%s_containers' % host_type if 'container_types' not in physical_host : physical_host [ 'container_types' ] = container_host_type elif physical_host [ 'container_types' ] != container_host_type : physical_host [ 'container_types' ] = container_host_type _build_container_hosts ( container_affinity , container_hosts , type_and_name , inventory , host_type , container_type , container_host_type , physical_host_type , config , is_metal , assignment , ) _append_container_types ( inventory , host_type ) _append_to_host_groups ( inventory , container_type , assignment , host_type , type_and_name , host_options )
short_docstring: Add a given container name and type to the hosts.
short_docstring_tokens: Add a given container name and type to the hosts .
comment: """Add a given container name and type to the hosts.
  
      :param assignment: ``str`` Name of container component target
      :param config: ``dict``  User defined information
      :param container_name: ``str``  Name fo container
      :param container_type: ``str``  Type of container
      :param inventory: ``dict``  Living dictionary of inventory
      :param is_metal: ``bol``  If true, a container entry will not be built
      """$SEP$# If the physical host type is not in config return$SEP$# If host_type is not in config do not append containers to it$SEP$# Get any set host options$SEP$# Ensures that container names are not longer than 63$SEP$# This section will ensure that we are not it by the following bug:$SEP$# https://bugzilla.mindrot.org/show_bug.cgi?id=2239$SEP$# Add all of the containers into the inventory$SEP$# Add the physical host type to all containers from the built inventory