Split the zone portion off from a DNS label.

    :param str server_name: The full DNS label.
    :param str zone_name: The zone name suffix.
555008
def _split_zone(server_name, zone_name):
    
    server_name = server_name.rstrip(u'.')
    zone_name = zone_name.rstrip(u'.')
    if not (server_name == zone_name or
            server_name.endswith(u'.' + zone_name)):
        raise NotInZone(server_name=server_name, zone_name=zone_name)
    return server_name[:-len(zone_name)].rstrip(u'.')
815658
def delete_host(zone, name, nameserver='127.0.0.1', timeout=5, port=53,
                **kwargs):
    '''
    
    '''
    fqdn = '{0}.{1}'.format(name, zone)
    request = dns.message.make_query(fqdn, 'A')
    answer = dns.query.udp(request, nameserver, timeout, port)
    try:
        ips = [i.address for i in answer.answer[0].items]
    except IndexError:
        ips = []

    res = delete(zone, name, nameserver=nameserver, timeout=timeout, port=port,
                 **kwargs)

    fqdn = fqdn + '.'
    for ip in ips:
        parts = ip.split('.')[::-1]
        popped = []

        # Iterate over possible reverse zones
        while len(parts) > 1:
            p = parts.pop(0)
            popped.append(p)
            zone = '{0}.{1}'.format('.'.join(parts), 'in-addr.arpa.')
            name = '.'.join(popped)
            ptr = delete(zone, name, 'PTR', fqdn, nameserver=nameserver,
                         timeout=timeout, port=port, **kwargs)
        if ptr:
            res = True
    return res
136152
def get_hostname(url):
        

        if url not in URLHelper.__cache:
            URLHelper.__cache[url] = urlparse(url)

        parts = URLHelper.__cache[url].netloc.split(".")

        if len(parts) == 1:
            return parts[0]
        else:
            return ".".join(parts[-2:-1])
1195784
static String getDNSubField(String varName, String DN) throws CertificateMapperException {
        if (varName.equals("DN")) {
            return DN; // return the whole DN
        }
        // Parse the DN looking for 'varName'
        StringTokenizer st = new StringTokenizer(DN);
        for (;;) {
            String name, value;
            try {
                name = st.nextToken(",= ");
                value = st.nextToken(",");
                if (value != null) {
                    value = value.substring(1);
                }
            } catch (NoSuchElementException e) {
                e.getMessage();
                break;
            }
            if (name.equals(varName)) {
                return value;
            }
        }

        throw new CertificateMapperException(WIMMessageKey.UNKNOWN_DN_FIELD, Tr.formatMessage(
                                                                                              tc,
                                                                                              WIMMessageKey.UNKNOWN_DN_FIELD,
                                                                                              WIMMessageHelper.generateMsgParms(varName)));
    }
501508
def get_my_hostname(self, split_hostname_on_first_period=False):
        

        hostname = self.init_config.get("os_host") or self.hostname
        if split_hostname_on_first_period:
            hostname = hostname.split('.')[0]

        return hostname
225210
def setup_zone(self):
        
        # Initialize current zone
        zones_content = self.request(self.api_url, 'get')
        try:
            if len(self.domain.split('.')) == 3:
                domain = self.domain.split('.', 1)[1]
            else:
                domain = self.domain
            zone = [zone for zone in zones_content['result'] if zone['name'] == domain][0]
        except IndexError:
            raise ZoneNotFound('Cannot find zone information for the domain {domain}.'
                               .format(domain=self.domain))
        self.zone = zone

        # Initialize dns_records of current zone
        dns_content = self.request(self.api_url + zone['id'] + '/dns_records', 'get')
        self.dns_records = dns_content['result']
1112596
public static base_response delete(nitro_service client, String zonename) throws Exception {
		dnszone deleteresource = new dnszone();
		deleteresource.zonename = zonename;
		return deleteresource.delete_resource(client);
	}
1105591
def get_zones(region=None, key=None, keyid=None, profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)

    return [z.name for z in conn.get_all_zones()]
682960
def set_mode_by_name(self, zone_name, mode):
        
        zone = self.get_zone(zone_name)
        if zone is None:
            raise RuntimeError("Unknown zone")

        return self.set_mode_by_id(zone["zoneId"], mode)
486141
public static String stripDomain(String hostname)
    {
        String ret = hostname;
        int pos = hostname.indexOf(".");
        if(pos != -1)
            ret = hostname.substring(0,pos);
        return ret;
    }
330820
def split(self):
        """"""
        key = '%s/split' % self.key
        return self._server.query(key, method=self._server._session.put)
77539
def split_name(name):
    
    s = name.rsplit('@', 1)
    if len(s) == 1:
        return s[0], None
    else:
        try:
            return s[0], int(s[1])
        except ValueError:
            raise ValueError("Invalid Filetracker filename: version must "
                             "be int, not %r" % (s[1],))
1001793
def read_name(self):
        """"""
        result = ''
        off = self.offset
        next = -1
        first = off

        while 1:
            len = ord(self.data[off])
            off += 1
            if len == 0:
                break
            t = len & 0xC0
            if t == 0x00:
                result = ''.join((result, self.read_utf(off, len) + '.'))
                off += len
            elif t == 0xC0:
                if next < 0:
                    next = off + 1
                off = ((len & 0x3F) << 8) | ord(self.data[off])
                if off >= first:
                    raise Exception(
                            "Bad domain name (circular) at " + str(off))
                first = off
            else:
                raise Exception("Bad domain name at " + str(off))

        if next >= 0:
            self.offset = next
        else:
            self.offset = off

        return result
175289
def remove_server(self, name):
        
        cmd = self.command_builder('no ntp server', value=name)
        return self.configure(cmd)
631570
def delete_host(zone, name, keyname, keyfile, nameserver, timeout, port=53,
                keyalgorithm='hmac-md5'):
    '''
    
    '''
    res = []
    if zone in name:
        name = name.replace(zone, '').rstrip('.')
    fqdn = '{0}.{1}'.format(name, zone)
    request = dns.message.make_query(fqdn, 'A')
    answer = dns.query.udp(request, nameserver, timeout, port)

    try:
        ips = [i.address for i in answer.answer[0].items]
    except IndexError:
        ips = []

    ret = delete(zone, name, keyname, keyfile, nameserver, timeout, port=port,
                 keyalgorithm=keyalgorithm)
    res.append("{0} of type \'A\'".format(ret[fqdn]))

    for ip in ips:
        parts = ip.split('.')[::-1]
        i = len(parts)
        popped = []

        # Iterate over possible reverse zones
        while i > 1:
            p = parts.pop(0)
            i -= 1
            popped.append(p)
            zone = '{0}.{1}'.format('.'.join(parts), 'in-addr.arpa.')
            name = '.'.join(popped)
            rev_fqdn = '{0}.{1}'.format(name, zone)
            ret = delete(zone, name, keyname, keyfile, nameserver, timeout,
                         'PTR', "{0}.".format(fqdn), port, keyalgorithm)

            if "Deleted" in ret[rev_fqdn]:
                res.append("{0} of type \'PTR\'".format(ret[rev_fqdn]))
                return {fqdn: res}

        res.append(ret[rev_fqdn])

    return {fqdn: res}
1081849
def cli(env, zone):
    """"""

    manager = SoftLayer.DNSManager(env.client)
    zone_id = helpers.resolve_id(manager.resolve_ids, zone, name='zone')
    env.fout(manager.dump_zone(zone_id))
158944
def split_filename(name):
    
    parts = hashed_filename_re.match(name).groupdict()
    return (parts['name'] or '', parts['hash'] or '', parts['ext'] or '')