libs/tools: resolve_identifier supports ip networks, not ip addresses
This commit is contained in:
parent
6527c985a7
commit
9a2f9038c4
1 changed files with 4 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
|||
from ipaddress import ip_address, IPv4Address
|
||||
from ipaddress import ip_address, ip_network, IPv4Address, IPv4Network
|
||||
|
||||
from bundlewrap.exceptions import NoSuchGroup, NoSuchNode
|
||||
from bundlewrap.utils.text import bold, red
|
||||
|
@ -16,9 +16,9 @@ def resolve_identifier(repo, identifier):
|
|||
nodes = repo.nodes_in_group(identifier)
|
||||
except NoSuchGroup:
|
||||
try:
|
||||
ip = ip_address(identifier)
|
||||
ip = ip_network(identifier)
|
||||
|
||||
if isinstance(ip, IPv4Address):
|
||||
if isinstance(ip, IPv4Network):
|
||||
return {'ipv4': {ip}, 'ipv6': set()}
|
||||
else:
|
||||
return {'ipv4': set(), 'ipv6': {ip}}
|
||||
|
@ -29,7 +29,7 @@ def resolve_identifier(repo, identifier):
|
|||
i=identifier,
|
||||
e=str(e),
|
||||
))
|
||||
return {'ipv4': set(), 'ipv6': set()}
|
||||
raise
|
||||
|
||||
found_ips = set()
|
||||
for node in nodes:
|
||||
|
|
Loading…
Reference in a new issue