Adding fields group with hostnames
494254
protected function addgroup_hostnames(){
		$this->registerGroup(BLang::_('ADMIN_CONFIG_GENERAL_HOSTNAMES'),'hostnames',array(
			new BConfigFieldString(
				'BHOSTNAME',
				BLang::_('ADMIN_CONFIG_GENERAL_BHOSTNAME'),
				'vidido.ua'),
			new BConfigFieldString(
				'BHOSTNAME_STATIC',
				BLang::_('ADMIN_CONFIG_GENERAL_BHOSTNAME_STATIC'),
				'static.vidido.ua'),
			new BConfigFieldString(
				'BHOSTNAME_MEDIA',
				BLang::_('ADMIN_CONFIG_GENERAL_BHOSTNAME_MEDIA'),
				'media.vidido.ua')
			));
		}
1086947
def addfield(self, pkt, s, val):
        
        res = b""
        for p in val:
            res += self.i2m(pkt, p)
        if (isinstance(pkt, _GenericTLSSessionInheritance) and
            _tls_version_check(pkt.tls_session.tls_version, 0x0304) and
                not isinstance(pkt, TLS13ServerHello)):
            return s + res
        if not pkt.type:
            pkt.type = 0
        hdr = struct.pack("!B", pkt.type) + s[1:5]
        return hdr + res
773300
def add_to_fields(self):
        ''''''
        meta = self.model._meta
        meta.scalarfields.append(self)
        if self.index:
            meta.indices.append(self)
1217046
private void populateServerGroupResults(final OperationContext context, final Map<ServerIdentity, ModelNode> serverResults) {

        final Set<String> groupNames = new TreeSet<String>();
        final Map<String, Set<HostServer>> groupToServerMap = new HashMap<String, Set<HostServer>>();
        for (Map.Entry<ServerIdentity, ModelNode> entry : serverResults.entrySet()) {
            final String serverGroup = entry.getKey().getServerGroupName();
            groupNames.add(serverGroup);
            final String hostName = entry.getKey().getHostName();
            final String serverName = entry.getKey().getServerName();
            if (!groupToServerMap.containsKey(serverGroup)) {
                groupToServerMap.put(serverGroup, new TreeSet<HostServer>());
            }
            groupToServerMap.get(serverGroup).add(new HostServer(hostName, serverName, entry.getValue()));
        }

        boolean serverGroupSuccess = false;
        ModelNode failureReport = new ModelNode();
        for (String groupName : groupNames) {
            final ModelNode groupNode = new ModelNode();
            boolean groupFailure = multiphaseContext.isServerGroupRollback(groupName);
            if (groupFailure) {
                // TODO revisit if we should report this for the whole group, since the result might not be accurate
                // groupNode.get(ROLLED_BACK).set(true);
            } else {
                serverGroupSuccess = true;
            }
            for (HostServer hostServer : groupToServerMap.get(groupName)) {
                final ModelNode hostResult = hostServer.result.clone();
                if(hostResult.hasDefined(RESPONSE_HEADERS)){
                    final ModelNode responseHeaders = hostResult.get(RESPONSE_HEADERS);
                    if(responseHeaders.hasDefined(WARNINGS)){
                        responseHeaders.remove(WARNINGS);
                    }
                    if(responseHeaders.keys().size() == 0){
                        hostResult.remove(RESPONSE_HEADERS);
                    }
                }
                groupNode.get(HOST, hostServer.hostName, hostServer.serverName, RESPONSE).set(hostResult);
                if (groupFailure && hostResult.hasDefined(OUTCOME)
                        && FAILED.equals(hostResult.get(OUTCOME).asString())
                        && hostResult.hasDefined(FAILURE_DESCRIPTION)) {
                    ModelNode failDesc = hostResult.get(FAILURE_DESCRIPTION);
                    if (!CompositeOperationHandler.getUnexplainedFailureMessage().equals(failDesc.asString())) {
                        failureReport.get(SERVER_GROUP, groupName, HOST, hostServer.hostName, hostServer.serverName).set(failDesc);
                    } // else the server just reported an unexplained composite failure.
                      // We assume it's due to domain-wide rollback, which is not useful information
                      // so don't include this server in the top level failure description
                }
            }
            context.getServerResults().get(groupName).set(groupNode);
        }
        if (!serverGroupSuccess) {
            if (failureReport.isDefined()) {
                ModelNode fullFailure = new ModelNode();
                fullFailure.get(DomainControllerLogger.HOST_CONTROLLER_LOGGER.operationFailedOrRolledBackWithCause()).set(failureReport);
                context.getFailureDescription().set(fullFailure);
            } else {
                context.getFailureDescription().set(DomainControllerLogger.HOST_CONTROLLER_LOGGER.operationFailedOrRolledBack());
            }
        }
    }
378598
public void addGroupBy(String[] fieldNames)
    {
        for (int i = 0; i < fieldNames.length; i++)
        {
            addGroupBy(fieldNames[i]);
        }
    }
536735
def add_hostname_cn_ip(self, addresses):
        
        for addr in addresses:
            if addr not in self.hostname_entry['addresses']:
                self.hostname_entry['addresses'].append(addr)
871867
def _apply_section(self, section, hosts):
        
        # Add the current group name to each host that this section covers.
        if section['name'] is not None:
            for hostname in self._group_get_hostnames(section['name']):
                hosts[hostname]['groups'].add(section['name'])

        # Apply variables
        func_map = {
            "hosts": self._apply_section_hosts,
            "children": self._apply_section_children,
            "vars": self._apply_section_vars,
        }
        func = func_map[section['type']]
        func(section, hosts)
658216
def hostname(name):
    '''
    
    '''
    ret = {
        'name': name,
        'changes': {},
        'result': True,
        'comment': ''
    }

    current_hostname = __salt__['system.get_hostname']()

    if current_hostname.upper() == name.upper():
        ret['comment'] = "Hostname is already set to '{0}'".format(name)
        return ret

    out = __salt__['system.set_hostname'](name)

    if out:
        ret['comment'] = "The current hostname is '{0}', " \
                         "but will be changed to '{1}' on the next reboot".format(current_hostname, name)
        ret['changes'] = {'hostname': name}
    else:
        ret['result'] = False
        ret['comment'] = 'Unable to set hostname'

    return ret
453386
def _set_hostname_domain(self):
        """"""
        self._hostname, _, self._domain = str(self._fqdn).partition('.')
        log.debug('Hostname: %s, Domain: %s' % (self._hostname, self._domain))
320543
def linkify_hostgroups_hosts(self, hosts):
        
        for hostgroup in self:
            members = hostgroup.get_hosts()
            # The new members identifiers list
            new_members = []
            for member in members:
                # member is an host name
                member = member.strip()
                if not member:  # void entry, skip this
                    continue

                if member == '*':
                    # All the hosts identifiers list
                    new_members.extend(list(hosts.items.keys()))
                else:
                    host = hosts.find_by_name(member)
                    if host is not None:
                        new_members.append(host.uuid)
                        if hostgroup.uuid not in host.hostgroups:
                            host.hostgroups.append(hostgroup.uuid)
                    else:
                        hostgroup.add_unknown_members(member)

            # Make members unique
            new_members = list(set(new_members))

            # We find the id, we replace the names
            hostgroup.replace_members(new_members)
891858
def update_host(self, hostname, key_values, overwrite=True):
        
        default_empty_host = {
            'name': hostname,
            'hostvars': {},
        }
        host_info = self.hosts.get(hostname, default_empty_host)
        util.deepupdate(host_info, key_values, overwrite=overwrite)
        self.hosts[hostname] = host_info
493174
def getHostsFromFile(filename):
    """"""
    valid_hostname = r"^[^ /\t=\n]+"
    workers = r"\d+"
    hostname_re = re.compile(valid_hostname)
    worker_re = re.compile(workers)
    hosts = []
    with open(filename) as f:
        for line in f:
            # check to see if it is a SLURM grouping instead of a
            # regular list of hosts
            if re.search('[\[\]]', line):
                hosts = hosts + parseSLURM(line.strip())
            else:
                host = hostname_re.search(line.strip())
                if host:
                    hostname = host.group()
                    n = worker_re.search(line[host.end():])
                    if n:
                        n = n.group()
                    else:
                        # Automatically assign based on CPU count
                        n = 0
                    hosts.append((hostname, int(n)))
    return hosts
711355
public function addGroupBy($field)
    {
        $alias = self::DEFAULT_TABLE_ALIAS;
        if (strpos($field, '.') > 0) {
            //monta os joins
            $newAliasField = $this->associationQueryFields($field);
        }
        if (count($this->queryFields) > 0) {
            foreach ($this->queryFields as $item) {
                $parts = [];
                if (strpos($item, ' AS ')) {
                    $item = str_replace(')', '', str_replace('(', '', $item));
                    $parts = explode('AS', $item);
                    $item = trim($parts[0]);
                }
                if (!in_array($item, $this->groupFields)) {
                    $this->queryBuilder->addGroupBy($item);
                    $this->groupFields[] = $item;
                }
            }
        }

        return $this;
    }
729799
public function addParamsGrouping($fields = [])
    {
        if (is_array($fields) && !empty($fields))
        {
            $this->groupingParams = array_merge(is_array($this->groupingParams) ? $this->groupingParams : [], $fields);
        }
    }
912516
def fields_from_names(fields, names=None):
    

    if names is None:
        return fields
    if isinstance(names, string_types):
        names = [names]
    aliases_to_names = aliases_from_fields(fields)
    names_to_aliases = dict(zip(aliases_to_names.values(),
        aliases_to_names.keys()))
    outfields = {}
    for name in names:
        try:
            outfields[name] = fields[name]
        except KeyError:
            if name in aliases_to_names:
                key = (name, aliases_to_names[name])
            elif name in names_to_aliases:
                key = (names_to_aliases[name], name)
            else:
                raise KeyError('default fields has no field %s' % name)
            outfields[key] = fields[key]
    return outfields
231743
def add(self, host, **kwargs):
        
        if host in self.hosts_:
            raise ValueError("Host %s: exists (use update)." % host)
        self.hosts_.add(host)
        self.lines_.append(ConfigLine(line="", host=None))
        self.lines_.append(ConfigLine(line="Host %s" % host, host=host, key="Host", value=host))
        for k, v in kwargs.items():
            if type(v) not in [list, tuple]:
                v = [v]
            mapped_k = _remap_key(k)
            for value in v:
                self.lines_.append(ConfigLine(line="  %s %s" % (mapped_k, str(value)), host=host, key=mapped_k, value=value))
        self.lines_.append(ConfigLine(line="", host=None))
305373
public function addField($field, $fieldset = null, $group = null)
    {
        $field = FieldHelper::create($field);

        $fieldset = $fieldset ?: $this->wrap['fieldset'];
        $group = $group ?: $this->wrap['group'];

        if ($fieldset) {
            $field->setFieldset($fieldset);
        }

        if ($group) {
            $field->setGroup($group);
        }

        $group = $field->getGroup();
        $fieldset = $field->getFieldset();

        if ($group && !in_array($group, $this->groups)) {
            $this->groups[] = $group;
        }

        if ($fieldset && !in_array($fieldset, $this->fieldsets)) {
            $this->fieldsets[] = $fieldset;
        }

        $field->setControl($this->control)
            ->setForm($this);

        $this->fields[$field->getName(true)] = $field;

        return $field;
    }