Several updates:

- Implemented option to translate sitecode to domainname.
- Added filter: Skip nodes if they are already in the target domain.
- Several minor changes.
This commit is contained in:
Simon Wüllhorst 2017-08-19 23:25:30 +02:00
commit 8d4021f122
5 changed files with 44 additions and 21 deletions

View file

@ -3,7 +3,7 @@ class Filter(object):
self.__args__ = args
self.__filters__ = self.__getFilters()
def filterLocalGraphs(self, localGraphs):
def filterLocalGraphs(self, domain, localGraphs):
filteredGraphs = []
for localGraph in localGraphs:
if localGraph.isAutoupdaterEnabledOnAllNodes() == False:
@ -21,8 +21,14 @@ class Filter(object):
def __getFilters(self):
return [] if self.__args__.filters == None else self.__args__.filters
def filterNodes(self, nodes):
def filterNodes(self, domain, nodes):
filteredNodes = []
for node in nodes:
if 'domain_transitions_only' in self.__filters__:
try:
if domain.name == node.domName:
continue
except:
pass
filteredNodes.append(node)
return filteredNodes

View file

@ -17,9 +17,9 @@ class NginxConfGen(object):
def __genDomain__(self, domain):
nodes = {}
for localGraph in self.__filter__.filterLocalGraphs(domain.localGraphs):
for localGraph in self.__filter__.filterLocalGraphs(domain, domain.localGraphs):
try:
for node in self.__filter__.filterNodes(localGraph.getNodesWithNoDependencies()):
for node in self.__filter__.filterNodes(domain, localGraph.getNodesWithNoDependencies()):
nodes[node.nodeID] = {
'hostname' : node.hostname,
'ipv6_addresses' : node.publicIPv6Addresses