Skip to content

Commit

Permalink
Version 0.7.32
Browse files Browse the repository at this point in the history
  • Loading branch information
mpenning committed Mar 17, 2024
1 parent e22affc commit bb42bd3
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 40 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
- Summary:
- Insert something here

## Version: 0.7.32

- Released: 2024-03-17
- Summary:
- Update tests

## Version: 0.7.12 - 0.7.31

- Released: 2024-03-17
Expand Down
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,20 @@ install_build:
# Install the newly-built package
pip install --force-reinstall dist/*.tar.gz

.PHONY: pypi
pypi:
.PHONY: cicd
cicd:
@echo "$(COL_CYAN)>> Use CI/CD to publish ciscoconfparse2 pypi artifacts$(COL_END)"
make clean
# upgrade packaging infra and ciscoconfparse2 dependencies...
make dep
git commit --all -m "Version $$VERSION"
# tag the repo with $$VERSION
# tag the repo with $$VERSION, upon git tag push,
# this triggers .github/workflows/cicd-publish.yml
git tag $$VERSION
git checkout main
git merge develop
git push origin main
# push tag to github origin, which triggers a github CICD action
# push tag to github origin, which triggers a github CICD action (see above)
git push origin $$VERSION
git checkout develop
git pull origin main
Expand Down Expand Up @@ -225,7 +226,7 @@ clean:
help:
@# An @ sign prevents outputting the command itself to stdout
@echo "help : You figured that out ;-)"
@echo "pypi : Build the project and push to pypi"
@echo "cicd : Git commit, build the project w/ CICD, and push to pypi"
@echo "repo-push : Build the project and push to github"
@echo "test : Run all doctests and unit tests"
@echo "dev : Get all dependencies for the dev environment"
Expand Down
49 changes: 16 additions & 33 deletions ciscoconfparse2/cli_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,20 +328,14 @@ def build_command_args_ipgrep(self) -> None:
"-n", "--show-networks",
default=False,
action='store_true',
help="Only print the network portion of subnets instead of IP hosts (implies --show-cidr). Host-networks (i.e. IPv4 /32 and IPv6 /128 are included by default).")
help="Only print the network portion of subnets instead of IP hosts (implies --show-cidr). Hosts (i.e. IPv4 /32 and IPv6 /128 networks) are also included by default.")

parser_optional.add_argument(
"-H", "--exclude-hosts",
default=False,
action='store_true',
help="Exclude all hosts from output (should be used with --show-networks).")

parser_optional.add_argument(
"-X", "--exclude-networks",
default=False,
action='store_true',
help="Exclude all network addresses from output (i.e. only hosts are shown).")

parser_optional_exclusive = parser_optional.add_mutually_exclusive_group()

parser_optional_exclusive.add_argument(
Expand Down Expand Up @@ -759,43 +753,30 @@ def find_ip46_addr_matches(self,

# Append if not already in retval...
if append_addr:
if self.check_ip46_host_exclusion_args(addr):
continue
if self.check_ip46_net_exclusion_args(addr):
continue

if self.show_networks:
if self.check_ip46_host_exclusion_args(addr):
continue
if self.check_ip46_net_exclusion_args(addr):
continue
retval.append(addr.as_cidr_net)
elif not self.show_cidr and not self.show_networks:
if self.check_ip46_host_exclusion_args(addr):
continue
if self.check_ip46_net_exclusion_args(addr):
continue
retval.append(str(addr.ip))
elif not self.show_networks and self.show_cidr:
if self.check_ip46_host_exclusion_args(addr):
continue
if self.check_ip46_net_exclusion_args(addr):
continue
retval.append(addr.as_cidr_addr)

else:
if self.check_ip46_net_exclusion_args(addr):
continue
if self.check_ip46_host_exclusion_args(addr):
continue

# Append unconditionally...
if self.show_networks:
if self.check_ip46_net_exclusion_args(addr):
continue
if self.check_ip46_host_exclusion_args(addr):
continue
retval.append(addr.as_cidr_net)
elif not self.show_cidr and not self.show_networks:
if self.check_ip46_net_exclusion_args(addr):
continue
if self.check_ip46_host_exclusion_args(addr):
continue
retval.append(str(addr.ip))
elif not self.show_networks and self.show_cidr:
if self.check_ip46_net_exclusion_args(addr):
continue
if self.check_ip46_host_exclusion_args(addr):
continue
retval.append(addr.as_cidr_addr)
return retval

Expand Down Expand Up @@ -837,8 +818,10 @@ def check_ip46_net_exclusion_args(self, addr: Union[IPv4Obj, IPv6Obj]) -> bool:
# (even though technically a /128 is also a network)
return False

# it's a network if the network address equals the ip address
elif str(addr.as_cidr_net) == str(addr.as_cidr_addr):
else:
# Since we are showing networks, any address (on the
# subnet number or not) should return True if the
# cases above did not match.
return True

return False
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[project]
name = "ciscoconfparse2"
version = "0.7.31"
version = "0.7.32"
description = "Parse, Audit, Query, Build, and Modify Cisco IOS-style and JunOS-style configs"
readme = "README.md"
license = "GPL-3.0-only"
Expand Down
22 changes: 21 additions & 1 deletion tests/test_Cli_Script.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def testValues_ccp_script_entry_cliapplication_ipgrep_14():
assert cliapp.subnets == '0.0.0.0/0'
assert cliapp.stdout == ['192.0.2.0/24',]

def testValues_ccp_script_entry_cliapplication_ipgrep_14():
def testValues_ccp_script_entry_cliapplication_ipgrep_15():
"""Ensure that CliApplication() ipgrep with --show-networks --exclude-hosts and --show-cidr is three IPv6 networks from sample_01.txt"""
cliapp = ccp_script_entry("ccp_faked ipgrep --show-networks --exclude-hosts -6 fixtures/plain_text/sample_01.txt")
assert len(cliapp.stdout) == 3
Expand All @@ -263,6 +263,26 @@ def testValues_ccp_script_entry_cliapplication_ipgrep_14():
'2001:db8::/64',
'2001:db8::/64',]

def testValues_ccp_script_entry_cliapplication_ipgrep_16():
"""Ensure that CliApplication() ipgrep with --show-networks --exclude-hosts is no IPv6 networks from sample_01.txt"""
cliapp = ccp_script_entry("ccp_faked ipgrep --exclude-hosts --show-networks -6 fixtures/plain_text/sample_01.txt")
assert len(cliapp.stdout) == 0
assert cliapp.unique is False
assert cliapp.subnets == '::/0'
assert cliapp.stdout == []

def testValues_ccp_script_entry_cliapplication_ipgrep_16():
"""Ensure that CliApplication() ipgrep with --unique --show-networks -ipv4 -ipv6 is no IPv6 networks from sample_01.txt"""
cliapp = ccp_script_entry("ccp_faked ipgrep --unique --show-networks -4 -6 fixtures/plain_text/sample_01.txt")
assert len(cliapp.stdout) == 5
assert cliapp.unique is True
assert cliapp.subnets == '0.0.0.0/0,::/0'
assert cliapp.stdout == ['2001:db8::/127',
'2001:db8::1/128',
'192.0.2.0/24',
'192.0.2.3/32',
'2001:db8::/64',]

def testValues_ccp_script_entry_cliapplication_branch_01():
"""Ensure that CliApplication() branch as original output flag set is a list of one IP address"""
cliapp = ccp_script_entry("ccp_faked branch -o original -a 'interface Null0' fixtures/configs/sample_01.ios")
Expand Down

0 comments on commit bb42bd3

Please sign in to comment.