Changeset 10656 in genesis for tools


Ignore:
Timestamp:
May 2, 2012, 11:06:50 PM (13 years ago)
Author:
rick
Message:

Make those very long pool names more understandable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/gformat.py

    r10655 r10656  
    10211021
    10221022
    1023   def pool_to_name(node, pool_members):
     1023  def pool_to_name(fqdn, pool_members):
    10241024    """Convert the joined name to a usable pool name"""
    10251025
    1026     # Get rid of the own entry
    1027     pool_members = list(set(pool_members) - set([fqdn]))
    1028 
    1029     target = oldname = ''
     1026    def isplit(item):
     1027      (prefix, name, number) = re.match('^(cnode|hybrid|proxy)([a-z]+)([0-9]*)$',item.lower()).group(1,2,3)
     1028      return (prefix, name, number)
     1029   
     1030    my_name = isplit(fqdn.split('.')[0])[1]
     1031
     1032    short_names = defaultdict(list)
    10301033    for node in sorted(pool_members):
    1031       (name, number) = re.match('^([A-Za-z]+)([0-9]*)$',node).group(1,2)
    1032       target += "-" + number if name == oldname else "-" + node if target else node
    1033       oldname = name
    1034 
    1035     return target
     1034      (prefix, name, number) = isplit(node)
     1035      short_names[name].append((prefix,number))
     1036
     1037    return '-'.join(sorted(short_names.keys()))
    10361038
    10371039
     
    10741076      for item in value:
    10751077        (iface_name, fqdn, ip) = item
    1076         pool_name = "2pool-" + showaddr(key).replace('.','-') + "-" + pool_to_name(fqdn,pool_members)
     1078        pool_name = "2pool-" + pool_to_name(fqdn,pool_members)
    10771079        wleiden_zone["%s.%s" % (pool_name, fqdn)].append((ip, True))
    10781080
Note: See TracChangeset for help on using the changeset viewer.