def public_interface(self):
"""
Check that all minions have an address on the public network
"""
for node in self.data.keys():
if ('roles' in self.data[node] and
'master' in self.data[node]['roles']):
continue
found = False
public_network = self.data[node].get("public_network", "")
net_list = Util.parse_list_from_string(public_network)
for address in self.grains[node]['ipv4']:
try:
for network in net_list:
addr = ipaddress.ip_address(u'{}'.format(address))
net = ipaddress.ip_network(u'{}'.format(network))
if addr in net:
found = True
except ValueError:
# Don't care about reporting a ValueError here if
# public_network is malformed, because the
# previous validation in public_network() will do that.
pass
if not found:
msg = "minion {} missing address on public network {}".format(node, public_network)
self.errors.setdefault('public_interface', []).append(msg)
self._set_pass_status('public_network')
评论列表
文章目录