diff options
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | python-ttp.spec | 314 | ||||
| -rw-r--r-- | sources | 1 |
3 files changed, 316 insertions, 0 deletions
@@ -0,0 +1 @@ +/ttp-0.9.2.tar.gz diff --git a/python-ttp.spec b/python-ttp.spec new file mode 100644 index 0000000..872de04 --- /dev/null +++ b/python-ttp.spec @@ -0,0 +1,314 @@ +%global _empty_manifest_terminate_build 0 +Name: python-ttp +Version: 0.9.2 +Release: 1 +Summary: Template Text Parser +License: MIT +URL: https://github.com/dmulyalin/ttp +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/8f/46/0dfc8e2e5a656ab99ecb36d04213fa12627911b131a2af5bf555d52a4b1a/ttp-0.9.2.tar.gz +BuildArch: noarch + +Requires: python3-cerberus +Requires: python3-jinja2 +Requires: python3-pyyaml +Requires: python3-deepdiff +Requires: python3-openpyxl +Requires: python3-tabulate +Requires: python3-ttp_templates +Requires: python3-yangson +Requires: python3-n2g +Requires: python3-readthedocs-sphinx-search +Requires: python3-Sphinx +Requires: python3-sphinx_rtd_theme +Requires: python3-sphinxcontrib-applehelp +Requires: python3-sphinxcontrib-devhelp +Requires: python3-sphinxcontrib-htmlhelp +Requires: python3-sphinxcontrib-jsmath +Requires: python3-sphinxcontrib-napoleon +Requires: python3-sphinxcontrib-qthelp +Requires: python3-sphinxcontrib-serializinghtml +Requires: python3-sphinxcontrib-spelling + +%description +ucs-core-switch-1 65100 CUST-1 192.0.2.1 65101 00:12:33 300 peer-1 ipv4 RPL-1-IMPORT-v4 RPL-1-EXPORT-V4 +ucs-core-switch-1 65100 CUST-1 192.0.2.2 65102 03:55:01 idle peer-2 ipv4 RPL-2-IMPORT-V6 RPL-2-EXPORT-V6 +Run this script with "python filename.py" +</doc> +<vars> +hostname="gethostname" +chain_1 = [ + "set('vrf_name')", + "lookup('peer_ip', group='bgp_state', update=True)" +] +</vars> +<group name="bgp_state.{{ peer }}" input="bgp_state"> +{{ peer }} 4 65101 20 21 43 0 0 {{ uptime }} {{ state }} +</group> +<group name="bgp_cfg" input="bgp_config"> +router bgp {{ asn | record(asn) }} + <group name="vrfs.{{ vrf_name }}" record="vrf_name"> + vrf {{ vrf_name }} + <group name="/bgp_peers*" chain="chain_1"> + neighbor {{ peer_ip }} + {{ local_asn | set(asn) }} + {{ hostname | set(hostname) }} + remote-as {{ peer_asn }} + description {{ description }} + address-family {{ afi }} unicast + route-map {{ rpl_in }} in + route-map {{ rpl_out }} out + </group> + </group> +</group> +<output +name="tabulate_outputter" +format="tabulate" +path="bgp_peers" +returner="terminal" +headers="hostname, local_asn, vrf_name, peer_ip, peer_asn, uptime, state, description, afi, rpl_in, rpl_out" +/> +""" +data_bgp_state = """ +ucs-core-switch-1#show bgp vrf CUST-1 vpnv4 unicast summary +Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd +192.0.2.1 4 65101 32 54 42 0 0 00:12:33 300 +192.0.2.2 4 65101 11 45 99 0 0 03:55:01 idle +""" +data_bgp_config = """ +ucs-core-switch-1#show run | section bgp +router bgp 65100 + vrf CUST-1 + neighbor 192.0.2.1 + remote-as 65101 + description peer-1 + address-family ipv4 unicast + route-map RPL-1-IMPORT-v4 in + route-map RPL-1-EXPORT-V4 out + neighbor 192.0.2.2 + remote-as 65102 + description peer-2 + address-family ipv4 unicast + route-map RPL-2-IMPORT-V6 in + route-map RPL-2-EXPORT-V6 out +""" +from ttp import ttp +parser = ttp() +parser.add_template(template) +parser.add_input(data=data_bgp_state, input_name="bgp_state") +parser.add_input(data=data_bgp_config, input_name="bgp_config") +parser.parse() +``` +</details> +# Contributions +Feel free to submit an issue, report a bug or ask a question, feature requests are welcomed. Or [buy](https://paypal.me/dmulyalin) Author a coffee +# Additional resources +List of additional resources: +- Sandbox to test TTP templates - http://textfsm.nornir.tech/ by [tbotnz](https://github.com/tbotnz) +- Videos on TTP - https://pynet.twb-tech.com/videos/ttp/ttp.html by [Kirk Byers](https://github.com/ktbyers) + +%package -n python3-ttp +Summary: Template Text Parser +Provides: python-ttp +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-ttp +ucs-core-switch-1 65100 CUST-1 192.0.2.1 65101 00:12:33 300 peer-1 ipv4 RPL-1-IMPORT-v4 RPL-1-EXPORT-V4 +ucs-core-switch-1 65100 CUST-1 192.0.2.2 65102 03:55:01 idle peer-2 ipv4 RPL-2-IMPORT-V6 RPL-2-EXPORT-V6 +Run this script with "python filename.py" +</doc> +<vars> +hostname="gethostname" +chain_1 = [ + "set('vrf_name')", + "lookup('peer_ip', group='bgp_state', update=True)" +] +</vars> +<group name="bgp_state.{{ peer }}" input="bgp_state"> +{{ peer }} 4 65101 20 21 43 0 0 {{ uptime }} {{ state }} +</group> +<group name="bgp_cfg" input="bgp_config"> +router bgp {{ asn | record(asn) }} + <group name="vrfs.{{ vrf_name }}" record="vrf_name"> + vrf {{ vrf_name }} + <group name="/bgp_peers*" chain="chain_1"> + neighbor {{ peer_ip }} + {{ local_asn | set(asn) }} + {{ hostname | set(hostname) }} + remote-as {{ peer_asn }} + description {{ description }} + address-family {{ afi }} unicast + route-map {{ rpl_in }} in + route-map {{ rpl_out }} out + </group> + </group> +</group> +<output +name="tabulate_outputter" +format="tabulate" +path="bgp_peers" +returner="terminal" +headers="hostname, local_asn, vrf_name, peer_ip, peer_asn, uptime, state, description, afi, rpl_in, rpl_out" +/> +""" +data_bgp_state = """ +ucs-core-switch-1#show bgp vrf CUST-1 vpnv4 unicast summary +Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd +192.0.2.1 4 65101 32 54 42 0 0 00:12:33 300 +192.0.2.2 4 65101 11 45 99 0 0 03:55:01 idle +""" +data_bgp_config = """ +ucs-core-switch-1#show run | section bgp +router bgp 65100 + vrf CUST-1 + neighbor 192.0.2.1 + remote-as 65101 + description peer-1 + address-family ipv4 unicast + route-map RPL-1-IMPORT-v4 in + route-map RPL-1-EXPORT-V4 out + neighbor 192.0.2.2 + remote-as 65102 + description peer-2 + address-family ipv4 unicast + route-map RPL-2-IMPORT-V6 in + route-map RPL-2-EXPORT-V6 out +""" +from ttp import ttp +parser = ttp() +parser.add_template(template) +parser.add_input(data=data_bgp_state, input_name="bgp_state") +parser.add_input(data=data_bgp_config, input_name="bgp_config") +parser.parse() +``` +</details> +# Contributions +Feel free to submit an issue, report a bug or ask a question, feature requests are welcomed. Or [buy](https://paypal.me/dmulyalin) Author a coffee +# Additional resources +List of additional resources: +- Sandbox to test TTP templates - http://textfsm.nornir.tech/ by [tbotnz](https://github.com/tbotnz) +- Videos on TTP - https://pynet.twb-tech.com/videos/ttp/ttp.html by [Kirk Byers](https://github.com/ktbyers) + +%package help +Summary: Development documents and examples for ttp +Provides: python3-ttp-doc +%description help +ucs-core-switch-1 65100 CUST-1 192.0.2.1 65101 00:12:33 300 peer-1 ipv4 RPL-1-IMPORT-v4 RPL-1-EXPORT-V4 +ucs-core-switch-1 65100 CUST-1 192.0.2.2 65102 03:55:01 idle peer-2 ipv4 RPL-2-IMPORT-V6 RPL-2-EXPORT-V6 +Run this script with "python filename.py" +</doc> +<vars> +hostname="gethostname" +chain_1 = [ + "set('vrf_name')", + "lookup('peer_ip', group='bgp_state', update=True)" +] +</vars> +<group name="bgp_state.{{ peer }}" input="bgp_state"> +{{ peer }} 4 65101 20 21 43 0 0 {{ uptime }} {{ state }} +</group> +<group name="bgp_cfg" input="bgp_config"> +router bgp {{ asn | record(asn) }} + <group name="vrfs.{{ vrf_name }}" record="vrf_name"> + vrf {{ vrf_name }} + <group name="/bgp_peers*" chain="chain_1"> + neighbor {{ peer_ip }} + {{ local_asn | set(asn) }} + {{ hostname | set(hostname) }} + remote-as {{ peer_asn }} + description {{ description }} + address-family {{ afi }} unicast + route-map {{ rpl_in }} in + route-map {{ rpl_out }} out + </group> + </group> +</group> +<output +name="tabulate_outputter" +format="tabulate" +path="bgp_peers" +returner="terminal" +headers="hostname, local_asn, vrf_name, peer_ip, peer_asn, uptime, state, description, afi, rpl_in, rpl_out" +/> +""" +data_bgp_state = """ +ucs-core-switch-1#show bgp vrf CUST-1 vpnv4 unicast summary +Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd +192.0.2.1 4 65101 32 54 42 0 0 00:12:33 300 +192.0.2.2 4 65101 11 45 99 0 0 03:55:01 idle +""" +data_bgp_config = """ +ucs-core-switch-1#show run | section bgp +router bgp 65100 + vrf CUST-1 + neighbor 192.0.2.1 + remote-as 65101 + description peer-1 + address-family ipv4 unicast + route-map RPL-1-IMPORT-v4 in + route-map RPL-1-EXPORT-V4 out + neighbor 192.0.2.2 + remote-as 65102 + description peer-2 + address-family ipv4 unicast + route-map RPL-2-IMPORT-V6 in + route-map RPL-2-EXPORT-V6 out +""" +from ttp import ttp +parser = ttp() +parser.add_template(template) +parser.add_input(data=data_bgp_state, input_name="bgp_state") +parser.add_input(data=data_bgp_config, input_name="bgp_config") +parser.parse() +``` +</details> +# Contributions +Feel free to submit an issue, report a bug or ask a question, feature requests are welcomed. Or [buy](https://paypal.me/dmulyalin) Author a coffee +# Additional resources +List of additional resources: +- Sandbox to test TTP templates - http://textfsm.nornir.tech/ by [tbotnz](https://github.com/tbotnz) +- Videos on TTP - https://pynet.twb-tech.com/videos/ttp/ttp.html by [Kirk Byers](https://github.com/ktbyers) + +%prep +%autosetup -n ttp-0.9.2 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-ttp -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Tue Apr 11 2023 Python_Bot <Python_Bot@openeuler.org> - 0.9.2-1 +- Package Spec generated @@ -0,0 +1 @@ +635f5a346176941b6dca42c11d6a541d ttp-0.9.2.tar.gz |
