Changeset 9286 in genesis


Ignore:
Timestamp:
Jun 23, 2011, 7:33:04 PM (14 years ago)
Author:
rick
Message:

The pool has to be formatted smarter, else the name execed the maximum allowed characters.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/gformat.py

    r9285 r9286  
    88import sys
    99import os
     10import re
    1011sys.path.append(os.path.dirname(__file__))
    1112
     
    591592        continue
    592593
     594
     595  def pool_to_name(node, pool_members):
     596    """Convert the joined name to a usable pool name"""
     597
     598    # Get rid of the own entry
     599    pool_members = list(set(pool_members) - set([fqdn]))
     600
     601    target = oldname = ''
     602    for node in sorted(pool_members):
     603      (name, number) = re.match('^([A-Za-z]+)([0-9]*)$',node).group(1,2)
     604      target += "-" + number if name == oldname else "-" + node if target else node
     605      oldname = name
     606
     607    return target
     608
     609
    593610  # Automatic naming convention of interlinks namely 2 + remote.lower()
    594611  for (key,value) in pool.iteritems():
     
    605622      for item in value:
    606623        (iface_name, fqdn, ip) = item
    607         pool_name = "2pool-" + showaddr(key).replace('.','-') + "-" + "-".join(sorted(list(set(pool_members) - set([fqdn]))))
     624        pool_name = "2pool-" + showaddr(key).replace('.','-') + "-" + pool_to_name(fqdn,pool_members)
    608625        wleiden_zone["%s.%s" % (pool_name, fqdn)] = ip
    609626
Note: See TracChangeset for help on using the changeset viewer.