trigger 2.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. trigger/__init__.py +7 -0
  2. trigger/acl/__init__.py +32 -0
  3. trigger/acl/autoacl.py +70 -0
  4. trigger/acl/db.py +324 -0
  5. trigger/acl/dicts.py +357 -0
  6. trigger/acl/grammar.py +112 -0
  7. trigger/acl/ios.py +222 -0
  8. trigger/acl/junos.py +422 -0
  9. trigger/acl/models.py +118 -0
  10. trigger/acl/parser.py +168 -0
  11. trigger/acl/queue.py +296 -0
  12. trigger/acl/support.py +1431 -0
  13. trigger/acl/tools.py +746 -0
  14. trigger/bin/__init__.py +0 -0
  15. trigger/bin/acl.py +233 -0
  16. trigger/bin/acl_script.py +574 -0
  17. trigger/bin/aclconv.py +82 -0
  18. trigger/bin/check_access.py +93 -0
  19. trigger/bin/check_syntax.py +66 -0
  20. trigger/bin/fe.py +197 -0
  21. trigger/bin/find_access.py +191 -0
  22. trigger/bin/gnng.py +434 -0
  23. trigger/bin/gong.py +86 -0
  24. trigger/bin/load_acl.py +841 -0
  25. trigger/bin/load_config.py +18 -0
  26. trigger/bin/netdev.py +317 -0
  27. trigger/bin/optimizer.py +638 -0
  28. trigger/bin/run_cmds.py +18 -0
  29. trigger/changemgmt/__init__.py +352 -0
  30. trigger/changemgmt/bounce.py +57 -0
  31. trigger/cmds.py +1217 -0
  32. trigger/conf/__init__.py +94 -0
  33. trigger/conf/global_settings.py +674 -0
  34. trigger/contrib/__init__.py +7 -0
  35. trigger/exceptions.py +307 -0
  36. trigger/gorc.py +172 -0
  37. trigger/netdevices/__init__.py +1288 -0
  38. trigger/netdevices/loader.py +174 -0
  39. trigger/netscreen.py +1030 -0
  40. trigger/packages/__init__.py +6 -0
  41. trigger/packages/peewee.py +8084 -0
  42. trigger/rancid.py +463 -0
  43. trigger/tacacsrc.py +584 -0
  44. trigger/twister.py +2203 -0
  45. trigger/twister2.py +745 -0
  46. trigger/utils/__init__.py +88 -0
  47. trigger/utils/cli.py +349 -0
  48. trigger/utils/importlib.py +77 -0
  49. trigger/utils/network.py +157 -0
  50. trigger/utils/rcs.py +178 -0
  51. trigger/utils/templates.py +81 -0
  52. trigger/utils/url.py +78 -0
  53. trigger/utils/xmltodict.py +298 -0
  54. trigger-2.0.0.dist-info/METADATA +146 -0
  55. trigger-2.0.0.dist-info/RECORD +61 -0
  56. trigger-2.0.0.dist-info/WHEEL +5 -0
  57. trigger-2.0.0.dist-info/entry_points.txt +15 -0
  58. trigger-2.0.0.dist-info/licenses/AUTHORS.md +20 -0
  59. trigger-2.0.0.dist-info/licenses/LICENSE.md +28 -0
  60. trigger-2.0.0.dist-info/top_level.txt +2 -0
  61. twisted/plugins/trigger_xmlrpc.py +124 -0
@@ -0,0 +1,146 @@
1
+ Metadata-Version: 2.4
2
+ Name: trigger
3
+ Version: 2.0.0
4
+ Summary: Network automation toolkit for managing network devices
5
+ Author-email: Jathan McCollum <jathan@gmail.com>
6
+ License-Expression: BSD-3-Clause
7
+ Classifier: Development Status :: 6 - Mature
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Framework :: Twisted
12
+ Requires-Python: <3.12,>=3.10
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE.md
15
+ License-File: AUTHORS.md
16
+ Requires-Dist: IPy>=1.01
17
+ Requires-Dist: cryptography>=41.0.0
18
+ Requires-Dist: Twisted>=22.10.0
19
+ Requires-Dist: crochet>=2.0.0
20
+ Requires-Dist: pyasn1>=0.4.8
21
+ Requires-Dist: pyparsing>=3.1.0
22
+ Requires-Dist: pytz>=2023.3
23
+ Requires-Dist: SimpleParse>=2.2.0
24
+ Requires-Dist: textfsm>=1.1.0
25
+ Requires-Dist: redis>=5.0.0
26
+ Requires-Dist: PTable>=0.9.2
27
+ Requires-Dist: peewee>=3.17.0
28
+ Requires-Dist: service-identity>=23.1.0
29
+ Requires-Dist: bcrypt>=4.0.0
30
+ Requires-Dist: packaging>=21.0
31
+ Provides-Extra: dev
32
+ Requires-Dist: pytest>=7.4.0; extra == "dev"
33
+ Requires-Dist: pytest-twisted>=1.14.0; extra == "dev"
34
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
35
+ Requires-Dist: python-semantic-release>=9.0.0; extra == "dev"
36
+ Dynamic: license-file
37
+
38
+ # What is Trigger?
39
+
40
+ [![Tests](https://github.com/trigger/trigger/workflows/Tests/badge.svg)](https://github.com/trigger/trigger/actions)
41
+ [![Join the chat at https://gitter.im/trigger/trigger](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/trigger/trigger?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
42
+
43
+ Trigger is a robust network automation toolkit written in Python that was
44
+ designed for interfacing with network devices and managing network
45
+ configuration and security policy. It increases the speed and efficiency of
46
+ managing large-scale networks while reducing the risk of human error.
47
+
48
+ Started by the AOL Network Security team in 2006, Trigger was originally
49
+ designed for security policy management on firewalls, routers, and switches. It
50
+ has since been expanded to be a full-featured network automation toolkit.
51
+
52
+ With the high number of network devices on the AOL network this application is
53
+ invaluable to performance and reliability. We hope you'll find it useful on
54
+ your network and consider participating!
55
+
56
+ ## Supported Platforms
57
+
58
+ * Cisco IOS, NX-OS, and ASA software
59
+ * Juniper Junos and ScreenOS
60
+ * Force10 router and switch platforms running FTOS
61
+ * Arista Networks 7000-family switches
62
+ * ... and more!
63
+
64
+ Refer to the [official docs](https://trigger.readthedocs.io/en/latest/#supported-platforms) for the full list.
65
+
66
+ ## Key Features
67
+
68
+ Trigger is designed to work at scale and can support hundreds or thousands of
69
+ network devices with ease. Here are some of things that make Trigger tick:
70
+
71
+ + Support for SSH, Telnet, and Juniper's Junoscript XML API.
72
+ + Easily get an interactive shell or execute commands asynchronously.
73
+ + Leverage advanced event-driven functionality to manage any number of
74
+ jobs in parallel and handle output or errors as they return.
75
+ + Powerful metadata interface for performing complex queries to group and
76
+ associate network devices by name, manufacturer, type, location, and more.
77
+ + Encrypted storage of login credentials so you can interact without constantly
78
+ being prompted to enter your password.
79
+ + Flexible access-list & firewall policy parser that can test access if access
80
+ is permitted, or easily convert ACLs from one format to another.
81
+ + Detailed support for timezones and maintenance windows.
82
+ + A suite of tools for simplifying many common tasks.
83
+
84
+ New in version 1.2:
85
+
86
+ + Import your metadata from an existing [RANCID](http://shrubbery.net/rancid/) installation to get up-and-running quickly!
87
+
88
+ New in version 1.3:
89
+
90
+ + Import your metadata from a CSV file and get up-and-running even quicker!
91
+
92
+ ## Getting Started
93
+
94
+ The best way to get started is to read the documentation hosted by [Read the
95
+ Docs](http://readthedocs.org) at [https://trigger.readthedocs.io](https://trigger.readthedocs.io). There you will find everything you need to
96
+ get going including usage examples, installation and configuration
97
+ instructions, and more!
98
+
99
+ ### Python Version Requirements
100
+
101
+ **Trigger v2.0.0+** requires **Python 3.10 or 3.11**. Python 3.12+ is not yet supported due to SimpleParse C extension compatibility issues.
102
+
103
+ **Python 2.7 support ended with v1.6.0** (the last Python 2.7 compatible release).
104
+
105
+ #### Installation
106
+
107
+ ```bash
108
+ # Install the latest version
109
+ pip install trigger
110
+
111
+ # Install in development mode
112
+ pip install -e ".[dev]"
113
+
114
+ # Using uv (faster)
115
+ uv pip install trigger
116
+ ```
117
+
118
+ For users still requiring Python 2.7, use the v1.6.0 release:
119
+ ```bash
120
+ pip install trigger==1.6.0
121
+ ```
122
+
123
+ ### Upgrading from v1.6.0?
124
+
125
+ See the [Migration Guide](https://trigger.readthedocs.io/en/latest/migration.html) for detailed upgrade instructions.
126
+
127
+ ### Before you begin
128
+
129
+ + The [develop](https://github.com/trigger/trigger/tree/develop) branch is
130
+ the default branch that will be active when you clone this repository. While
131
+ it is generally stable this branch is not considered production-ready. Use at
132
+ your own risk!
133
+ + The [master](https://github.com/trigger/trigger/tree/master) branch is
134
+ the stable branch, and will reflect the latest production-ready changes. It
135
+ is recommended that this is the branch you use if you are installing Trigger
136
+ for the first time.
137
+ + Each point release of Trigger is maintained as a [tag branch](https://github.com/trigger/trigger/tags). If you require a
138
+ specific Trigger version, please refer to these.
139
+
140
+ ### Get in touch!
141
+
142
+ If you run into any snags, have questions, feedback, or just want to talk shop:
143
+ [contact us](https://trigger.readthedocs.io/en/latest/#getting-help)!
144
+
145
+ **Pro tip**: Find us on IRC at `#trigger` on Freenode
146
+ ([irc://irc.freenode.net/trigger](irc://irc.freenode.net/trigger)).
@@ -0,0 +1,61 @@
1
+ trigger/__init__.py,sha256=154bEsu646qx3Aaj7vJyNgSfEtzPtikaHsxqa-koYOY,214
2
+ trigger/cmds.py,sha256=eZf5uGt02-557KAJST714s0hOr_jpi_0cIMlBUEtmh0,41536
3
+ trigger/exceptions.py,sha256=lvDGybaTlt7S_nsCFk0QFOa9EkMVeOb_BgerUuZ-yXs,7503
4
+ trigger/gorc.py,sha256=yj8Bls1wp85LIOsokUJ3YEgHYJvcYDvG8INccKyg0oo,4654
5
+ trigger/netscreen.py,sha256=5YrvJUb_F7S1MXg2ScHA6WpNzoX6j5rAKvhu1nBmXUM,33767
6
+ trigger/rancid.py,sha256=ctvFVHyr2dm5W0ptMttHcAMjcUwfuj2XxhXI15hQQFk,13896
7
+ trigger/tacacsrc.py,sha256=bVAGd0g6_tU6luZrtZ0cOYHO-EuYuQ-cffDdzx65tfM,19993
8
+ trigger/twister.py,sha256=En9s4BwEgyGhKo-c-Fzqj7AeOF1SIQNqmMbfk0PjNaE,74324
9
+ trigger/twister2.py,sha256=rygZVvBxsZUFxJTTvu-N87NtnRcDiXQsIdHpm3oaJl8,25212
10
+ trigger/acl/__init__.py,sha256=k2V4YfEBJ7adN5zSJH-bSmbc73XYt1yVx5PMv8q3QAw,783
11
+ trigger/acl/autoacl.py,sha256=iFXlZtEEwxSy1rBkbhYB-q7f90EAD40mvpaKKgoZyj0,2654
12
+ trigger/acl/db.py,sha256=jWX116VVSFZmvB6YHww-80gTpzXA8HXQfEJBd2Jr0TM,9924
13
+ trigger/acl/dicts.py,sha256=2RrnruLwJz3EN2zT3tNiMJfFkstYDmLk_eGjaHYaAXc,9100
14
+ trigger/acl/grammar.py,sha256=gbkGt6lYPnNb6zzmswC5r2XEPGY9Iecf5YUzK1Shm2s,3452
15
+ trigger/acl/ios.py,sha256=AOs_SwNDiZ6cUaY0fjOkShzxCgxBnwB7apnsf4Sde28,7714
16
+ trigger/acl/junos.py,sha256=gBgX0U_XZtgU_04A6-5ZhgAiS3S1TLvR3DspviOJvWg,14720
17
+ trigger/acl/models.py,sha256=YG_OQyxK-T6ihbtTKbTm8ky8nKsR2HgQJJUa8V3KrLA,3197
18
+ trigger/acl/parser.py,sha256=VuxiVANz0xvvS5-wRw6snkoAGZS1asm3z9n-Ud0u5-c,4490
19
+ trigger/acl/queue.py,sha256=eft8IN93m1Jd81CvtIjjMnTnL-DAHor_sB8LOfua_20,8639
20
+ trigger/acl/support.py,sha256=4YGW9EDknwgkYYk05ucipWB8LyVkSWcSvjxsL-re1TQ,47470
21
+ trigger/acl/tools.py,sha256=u84Zj0an_J7BdfFS6i0nutDF7E9v7BiZITRkpUTYMlU,23724
22
+ trigger/bin/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
+ trigger/bin/acl.py,sha256=ipSs_NXgpOvsExjUVIFmH3rdpt0grcykxKYFtFgn37Q,6705
24
+ trigger/bin/acl_script.py,sha256=yirMn171ifWWOuk6DMrGYnwlpUM0y3WUhdXGK1cw7jw,18210
25
+ trigger/bin/aclconv.py,sha256=2EeBLlBusmYP4tzIjPGK2tlWveBlplpAjobF-wMbvI0,2241
26
+ trigger/bin/check_access.py,sha256=Nk1ltw5s41Xfiba1ujLJ3LWd3Ma-v3elfd59zaqIFXc,2364
27
+ trigger/bin/check_syntax.py,sha256=OxNxSuTcYO0Smzk4IpCnibwsLY7KON_nTDRASPcb5aQ,1614
28
+ trigger/bin/fe.py,sha256=zPq6vPHzajcYTxo7bJl5L7LhKbfDY4_mdpaWE9MKKx4,6173
29
+ trigger/bin/find_access.py,sha256=mm1Yr77ZkFHCud1PzcyLMukwgc7csiih-mkXt5Ylu2U,5414
30
+ trigger/bin/gnng.py,sha256=IetWGKMy7CyS_SDia7jewjR6APJRNJ5yv1M5a7raEMY,11740
31
+ trigger/bin/gong.py,sha256=yvGY8rnhPbZ5yxcAfIGg-oyX4u6CKBy4ZDnPtg3o5bw,2163
32
+ trigger/bin/load_acl.py,sha256=kGgf_hpd-LXhCxZD-Nsfga8czGue-rp2w8xE0Mx0nHU,26985
33
+ trigger/bin/load_config.py,sha256=XaxWLHic-UwThi-kEjlPdjbq1DLf9FKRDM9ggHwuWjQ,351
34
+ trigger/bin/netdev.py,sha256=G1L911c9aFC70j6DNRvvjhx9sKr2pSNUVzPMVPYMvE4,8821
35
+ trigger/bin/optimizer.py,sha256=lcCn8pOtGgHYVWCBtrAIF8XRlyoq0rTGX-7ItS3hOAc,17820
36
+ trigger/bin/run_cmds.py,sha256=978IpvA3Mh1d7pK7KsAEDnAQBcf4hy2mh2v3sGCdDno,354
37
+ trigger/changemgmt/__init__.py,sha256=9QeinKfMXQHmg91Zbtz80LXrpwhz0r2dHVSFRwdlR38,11340
38
+ trigger/changemgmt/bounce.py,sha256=R4kA8mxsQ0_aq_c3d8TiqiyS4s52vXMpRxURtJHnsCQ,1795
39
+ trigger/conf/__init__.py,sha256=-VJPOb_SOrVS8sb1mYus5Gv07nDcD11OHnClRsLxBLo,3111
40
+ trigger/conf/global_settings.py,sha256=My8NYxhFwGG2OHM0NNwL4Npnknp2RGAVimDg8hD84ig,22468
41
+ trigger/contrib/__init__.py,sha256=-CDXmrlP76rcnRYzJgzloFayXL6-JBOxFeJRk3wZRW0,129
42
+ trigger/netdevices/__init__.py,sha256=eMYRFJf1P038gNZrZat-911mWX1gP1pBJxCdqbn7iKo,42169
43
+ trigger/netdevices/loader.py,sha256=53A-RbJDluYt7ZX27q_1Zzi7mpRY5HOHfibTEvg84KI,5854
44
+ trigger/packages/__init__.py,sha256=AiAjoqy2HHAetDIq0WopWa-YcB8EhuUEFrsle_Z-808,191
45
+ trigger/packages/peewee.py,sha256=bbh0_O7_b0IfTNH7u-UDKzfbW4-oC-V2AHZx3AJH7Zk,277280
46
+ trigger/utils/__init__.py,sha256=DBLxL_JCBKq6KDB-KnO_D3RZNmGz8491Qotr1NEBX90,2244
47
+ trigger/utils/cli.py,sha256=Z76h72g8Q3ljetWA8shLeb3CMoF6n2edlxiJORxtElo,10466
48
+ trigger/utils/importlib.py,sha256=r8JeIrKFjleBuJT_mS1PG1XpKQyi1OWmDX7dpnwY-jM,2280
49
+ trigger/utils/network.py,sha256=4DQeq_CMrliAa-ENF8Y-brM8S6cJ3DhgD95oMJKrqUM,3858
50
+ trigger/utils/rcs.py,sha256=jB_qBqfDAZRfQxRwL3oRZcznqoLl7gsgyXQb7mEbu-U,4803
51
+ trigger/utils/templates.py,sha256=0gbFmgzna74q9PDd6OcM8QMwJZzYz1gis3wZsOVcAc4,1957
52
+ trigger/utils/url.py,sha256=-ziDnNcAvYP0vHu8_p1rZlzluDrWOmuQpMMDyl8zjVU,2041
53
+ trigger/utils/xmltodict.py,sha256=ZKVzDwX7dT_5qrGxwZYKrB_FPdcU8Abs60kn5pdyKB0,9384
54
+ trigger-2.0.0.dist-info/licenses/AUTHORS.md,sha256=hm1qgRgs74WmWYmIboWm9tjxqEM_xQQRX5nWoMffk3E,750
55
+ trigger-2.0.0.dist-info/licenses/LICENSE.md,sha256=jYSVs3QOgMIPqM7q9_XqYiRc_ePdk2OFOPGOm36CvEE,1493
56
+ twisted/plugins/trigger_xmlrpc.py,sha256=3UlSxH4nYIUI85k7KHapAcPrdZFJJJ6hfAtIeHfJMSo,3742
57
+ trigger-2.0.0.dist-info/METADATA,sha256=zDtmv_CbQVX0Ol6bx6HpRpb-AEZ7q-WKzpCzZG7x57Y,5844
58
+ trigger-2.0.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
59
+ trigger-2.0.0.dist-info/entry_points.txt,sha256=EJFGPV2HoErL-9qYDJgkW4s0C9EH-RpMZftJdCK4W68,526
60
+ trigger-2.0.0.dist-info/top_level.txt,sha256=cBf70dFY3f8zRO1frLHpQuSkxG2FCfiZKRKRZtGnMOM,16
61
+ trigger-2.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.10.2)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,15 @@
1
+ [console_scripts]
2
+ acl = trigger.bin.acl:main
3
+ acl_script = trigger.bin.acl_script:main
4
+ aclconv = trigger.bin.aclconv:main
5
+ check_access = trigger.bin.check_access:main
6
+ check_syntax = trigger.bin.check_syntax:main
7
+ fe = trigger.bin.fe:main
8
+ find_access = trigger.bin.find_access:main
9
+ gnng = trigger.bin.gnng:main
10
+ gong = trigger.bin.gong:main
11
+ load_acl = trigger.bin.load_acl:main
12
+ load_config = trigger.bin.load_config:main
13
+ netdev = trigger.bin.netdev:main
14
+ optimizer = trigger.bin.optimizer:main
15
+ run_cmds = trigger.bin.run_cmds:main
@@ -0,0 +1,20 @@
1
+ # Contributors
2
+
3
+ The following people have contributed to Trigger at some point during its
4
+ lifetime:
5
+
6
+ - [Jathan McCollum](https://github.com/jathanism)
7
+ - [Eileen Watson](https://github.com/watsonator)
8
+ - [Mark Ellzey Thomas](https://github.com/ellzey)
9
+ - Michael Shields
10
+ - Jeff Sullivan (for the best error message ever)
11
+ - [Nick Sinopoli](https://github.com/NSinopoli) (for graciously giving us the
12
+ name Trigger!)
13
+ - [Jason Long](https://github.com/sh0x)
14
+ - [Michael Harding](https://github.com/mvh)
15
+ - William White
16
+ - [Allan Feid](https://github.com/crazed)
17
+ - [Mike Biancaniello](https://github.com/chepazzo)
18
+ - [Murat Ezbiderli](https://github.com/mezbiderli)
19
+ - [Johannes Erdfelt](https://github.com/jerdfelt)
20
+ - [Codey Oxley](https://github.com/coxley)
@@ -0,0 +1,28 @@
1
+ # License
2
+
3
+ Copyright (c) 2006-2012, AOL Inc.
4
+
5
+ All rights reserved.
6
+
7
+ Redistribution and use in source and binary forms, with or without
8
+ modification, are permitted provided that the following conditions are met:
9
+
10
+ * Redistributions of source code must retain the above copyright notice, this
11
+ list of conditions and the following disclaimer.
12
+ * Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+ * Neither the name of the AOL Inc. nor the names of its contributors may
16
+ be used to endorse or promote products derived from this software without
17
+ specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,2 @@
1
+ trigger
2
+ twisted
@@ -0,0 +1,124 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ """
4
+ # trigger_xmlrpc.py - Twisted twistd server plugin for Trigger
5
+ """
6
+
7
+ import warnings
8
+
9
+ from twisted.application.internet import TCPServer, SSLServer
10
+ from twisted.application.service import IServiceMaker, MultiService
11
+ from twisted.conch.manhole_tap import makeService as makeConsoleService
12
+ from twisted.plugin import IPlugin
13
+ from twisted.python.rebuild import rebuild
14
+ from twisted.python import usage
15
+ from twisted.web import server, xmlrpc
16
+
17
+ try:
18
+ from twisted.internet import ssl
19
+ except ImportError:
20
+ # If no ssl, complain loudly.
21
+ warnings.warn(
22
+ "SSL support disabled for Trigger XMLRPC Server: PyOpenSSL required.",
23
+ RuntimeWarning,
24
+ )
25
+ ssl = None
26
+ from zope.interface import implements
27
+
28
+ from trigger.contrib.xmlrpc.server import TriggerXMLRPCServer
29
+
30
+
31
+ # Defaults
32
+ XML_PORT = 8000
33
+ SSH_PORT = 8001
34
+ SSH_USERS = "users.txt"
35
+ SSL_KEYFILE = "server.key"
36
+ SSL_CERTFILE = "cacert.pem"
37
+ SSH_KEYDIR = "."
38
+ SSH_KEYNAME = "ssh_host_key"
39
+ SSH_KEYSIZE = 4096
40
+ LISTEN_ADDRESS = "0.0.0.0"
41
+
42
+
43
+ class Options(usage.Options):
44
+ optParameters = [
45
+ ["listen-address", "a", LISTEN_ADDRESS, "Address to listen on"],
46
+ ["port", "p", XML_PORT, "Listening port for XMLRPC"],
47
+ ["ssh-port", "s", SSH_PORT, "Listening port for SSH manhole"],
48
+ [
49
+ "ssh-users",
50
+ "u",
51
+ SSH_USERS,
52
+ "Path to a passwd(5)-format username/password file",
53
+ ],
54
+ ["ssl-keyfile", "k", SSL_KEYFILE, "Path to a file containing a private key"],
55
+ [
56
+ "ssl-certfile",
57
+ "c",
58
+ SSL_CERTFILE,
59
+ "Path to a file containing a CA certificate",
60
+ ],
61
+ [
62
+ "ssh-keydir",
63
+ "d",
64
+ SSH_KEYDIR,
65
+ "The folder that the SSH server key will be kept",
66
+ ],
67
+ ["ssh-keyname", "n", SSH_KEYNAME, "The filename of the key."],
68
+ ["ssh-keysize", "z", SSH_KEYSIZE, "The size of the key, in bits."],
69
+ ]
70
+
71
+
72
+ class TriggerXMLRPCServiceMaker(object):
73
+ implements(IServiceMaker, IPlugin)
74
+ tapname = "trigger-xmlrpc"
75
+ description = "Trigger XMLRPC Server"
76
+ options = Options
77
+
78
+ def makeService(self, options):
79
+ rpc = TriggerXMLRPCServer(allowNone=True, useDateTime=True)
80
+ xmlrpc.addIntrospection(rpc)
81
+ site_factory = server.Site(rpc)
82
+
83
+ # Try to setup SSL
84
+ if ssl is not None:
85
+ ctx = ssl.DefaultOpenSSLContextFactory(
86
+ options["ssl-keyfile"], options["ssl-certfile"]
87
+ )
88
+ xmlrpc_service = SSLServer(
89
+ int(options["port"]),
90
+ site_factory,
91
+ ctx,
92
+ interface=options["listen-address"],
93
+ )
94
+ # Or fallback to clear-text =(
95
+ else:
96
+ xmlrpc_service = TCPServer(
97
+ int(options["port"]), site_factory, interface=options["listen-address"]
98
+ )
99
+
100
+ # SSH Manhole service
101
+ console_service = makeConsoleService(
102
+ {
103
+ "sshPort": "tcp:%s:interface=%s"
104
+ % (options["ssh-port"], options["listen-address"]),
105
+ "sshKeyDir": options["ssh-keydir"],
106
+ "sshKeyName": options["ssh-keyname"],
107
+ "sshKeySize": options["ssh-keysize"],
108
+ "telnetPort": None,
109
+ "passwd": options["ssh-users"],
110
+ "namespace": {
111
+ "service": rpc,
112
+ "rebuild": rebuild,
113
+ "factory": site_factory,
114
+ },
115
+ }
116
+ )
117
+
118
+ svc = MultiService()
119
+ xmlrpc_service.setServiceParent(svc)
120
+ console_service.setServiceParent(svc)
121
+ return svc
122
+
123
+
124
+ serviceMaker = TriggerXMLRPCServiceMaker()