def run(self, subnet, exclude, include, node=None):
if exclude and include:
raise InvalidCommand('Can\'t specify both -e and -i')
if include:
to_include = ippool.IpAddrPool().parse_autoblock(include)
net = IPv4Network(unicode(subnet))
hosts = {str(i) for i in net.hosts()}
# Do not include network and broadcast IP address
# TODO: Fix according to AC-4044
hosts.add(str(net.network_address))
hosts.add(str(net.broadcast_address))
exclude = ','.join(hosts - to_include)
ippool.IpAddrPool().create({
'network': subnet.decode(),
'autoblock': exclude,
'node': node
})
评论列表
文章目录