Skip to content

Commit fefb62a

Browse files
feat: panos_logical_router, panos_logical_router_vrf and panos_logical_router_vrf_static support #649
1 parent 1049566 commit fefb62a

File tree

4 files changed

+409
-0
lines changed

4 files changed

+409
-0
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/usr/bin/python
2+
# -*- coding: utf-8 -*-
3+
4+
# Copyright 2018 Palo Alto Networks, Inc
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
from __future__ import absolute_import, division, print_function
19+
20+
__metaclass__ = type
21+
22+
DOCUMENTATION = """
23+
---
24+
module: panos_logical_router
25+
short_description: Manage a Virtual Router
26+
description:
27+
- Manage PANOS Logical Routers. Note that for the use of logical routers on PAN-OS NGFW devices, you must enable
28+
"advanced routing" under device->setup->management->General Settings.
29+
author:
30+
- Joshua Colson (@freakinhippie)
31+
- Garfield Lee Freeman (@shinmog)
32+
version_added: '1.0.0'
33+
requirements:
34+
- pan-python can be obtained from PyPI U(https://pypi.python.org/pypi/pan-python)
35+
- pandevice can be obtained from PyPI U(https://pypi.python.org/pypi/pandevice)
36+
extends_documentation_fragment:
37+
- paloaltonetworks.panos.fragments.transitional_provider
38+
- paloaltonetworks.panos.fragments.network_resource_module_state
39+
- paloaltonetworks.panos.fragments.gathered_filter
40+
- paloaltonetworks.panos.fragments.vsys_import
41+
- paloaltonetworks.panos.fragments.full_template_support
42+
- paloaltonetworks.panos.fragments.deprecated_commit
43+
notes:
44+
- Checkmode is supported.
45+
- Panorama is supported.
46+
options:
47+
name:
48+
description:
49+
- Name of virtual router
50+
type: str
51+
default: 'default'
52+
"""
53+
54+
EXAMPLES = """
55+
- name: Create Logical Router
56+
paloaltonetworks.panos.panos_logical_router:
57+
provider: '{{ provider }}'
58+
name: lr-1
59+
commit: true
60+
"""
61+
62+
RETURN = """
63+
# Default return values
64+
"""
65+
66+
from ansible.module_utils.basic import AnsibleModule
67+
from ansible_collections.paloaltonetworks.panos.plugins.module_utils.panos import (
68+
get_connection,
69+
)
70+
71+
from panos.network import LogicalRouter
72+
73+
def main():
74+
helper = get_connection(
75+
template=True,
76+
template_stack=True,
77+
with_network_resource_module_state=True,
78+
with_gathered_filter=True,
79+
with_classic_provider_spec=True,
80+
with_commit=True,
81+
sdk_cls=("network", "LogicalRouter"),
82+
sdk_params=dict(
83+
name=dict(required=True)
84+
),
85+
)
86+
87+
module = AnsibleModule(
88+
argument_spec=helper.argument_spec,
89+
supports_check_mode=True,
90+
required_one_of=helper.required_one_of,
91+
)
92+
93+
helper.process(module)
94+
95+
96+
if __name__ == "__main__":
97+
main()
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#!/usr/bin/python
2+
# -*- coding: utf-8 -*-
3+
4+
# Copyright 2018 Palo Alto Networks, Inc
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
from __future__ import absolute_import, division, print_function
19+
20+
__metaclass__ = type
21+
22+
DOCUMENTATION = """
23+
---
24+
module: panos_logical_router_vrf
25+
short_description: Manage Logical Router VRFs
26+
description:
27+
- Manage PANOS Logical Router VRFs.
28+
author:
29+
- Joshua Colson (@freakinhippie)
30+
- Garfield Lee Freeman (@shinmog)
31+
version_added: '1.0.0'
32+
requirements:
33+
- pan-python can be obtained from PyPI U(https://pypi.python.org/pypi/pan-python)
34+
- pandevice can be obtained from PyPI U(https://pypi.python.org/pypi/pandevice)
35+
extends_documentation_fragment:
36+
- paloaltonetworks.panos.fragments.transitional_provider
37+
- paloaltonetworks.panos.fragments.network_resource_module_state
38+
- paloaltonetworks.panos.fragments.gathered_filter
39+
- paloaltonetworks.panos.fragments.vsys_import
40+
- paloaltonetworks.panos.fragments.full_template_support
41+
- paloaltonetworks.panos.fragments.deprecated_commit
42+
notes:
43+
- Checkmode is supported.
44+
- Panorama is supported.
45+
options:
46+
name:
47+
description:
48+
- Name of virtual router
49+
type: str
50+
default: 'default'
51+
logical_router:
52+
description:
53+
- Name of the logical router to add this interface to
54+
type: str
55+
default: 'default'
56+
vrf:
57+
description:
58+
- Name of the VRF to add this interface to
59+
default: 'default'
60+
interfaces:
61+
description:
62+
- List of interfaces to associate with the logical router
63+
type: list
64+
"""
65+
66+
EXAMPLES = """
67+
- name: Add ethernet1/1 to VRF "default" on logical router "default"
68+
paloaltonetworks.panos.panos_logical_router_vrf:
69+
provider: '{{ provider }}'
70+
logical_router: default
71+
name: default
72+
interfaces:
73+
- ethernet1/1
74+
"""
75+
76+
RETURN = """
77+
# Default return values
78+
"""
79+
80+
from ansible.module_utils.basic import AnsibleModule
81+
from ansible_collections.paloaltonetworks.panos.plugins.module_utils.panos import (
82+
get_connection,
83+
)
84+
85+
from panos.network import Vrf
86+
87+
def main():
88+
helper = get_connection(
89+
template=True,
90+
template_stack=True,
91+
with_network_resource_module_state=True,
92+
with_gathered_filter=True,
93+
with_classic_provider_spec=True,
94+
with_commit=True,
95+
sdk_cls=("network", "Vrf"),
96+
parents=(("network", "LogicalRouter", "logical_router", "default"),),
97+
sdk_params=dict(
98+
name=dict(required=True),
99+
interface=dict(type="list", elements="str"),
100+
),
101+
)
102+
103+
module = AnsibleModule(
104+
argument_spec=helper.argument_spec,
105+
supports_check_mode=True,
106+
required_one_of=helper.required_one_of,
107+
)
108+
109+
helper.process(module)
110+
111+
112+
if __name__ == "__main__":
113+
main()
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
#!/usr/bin/python
2+
# -*- coding: utf-8 -*-
3+
4+
# Copyright 2018 Palo Alto Networks, Inc
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
from __future__ import absolute_import, division, print_function
19+
20+
__metaclass__ = type
21+
22+
DOCUMENTATION = """
23+
---
24+
module: panos_logical_router_vrf_static_route
25+
short_description: Manage logical router static routes
26+
description:
27+
- Manage PANOS Logical Routers Static Routes.
28+
author:
29+
- Joshua Colson (@freakinhippie)
30+
- Garfield Lee Freeman (@shinmog)
31+
version_added: '1.0.0'
32+
requirements:
33+
- pan-python can be obtained from PyPI U(https://pypi.python.org/pypi/pan-python)
34+
- pandevice can be obtained from PyPI U(https://pypi.python.org/pypi/pandevice)
35+
extends_documentation_fragment:
36+
- paloaltonetworks.panos.fragments.transitional_provider
37+
- paloaltonetworks.panos.fragments.network_resource_module_state
38+
- paloaltonetworks.panos.fragments.gathered_filter
39+
- paloaltonetworks.panos.fragments.vsys_import
40+
- paloaltonetworks.panos.fragments.full_template_support
41+
- paloaltonetworks.panos.fragments.deprecated_commit
42+
notes:
43+
- Checkmode is supported.
44+
- Panorama is supported.
45+
options:
46+
logical_router:
47+
description:
48+
- The parent logical router
49+
type: str
50+
vrf:
51+
description:
52+
- The parent VRF to insert the route into
53+
type: str
54+
name:
55+
description:
56+
- Static route name
57+
type: str
58+
destination:
59+
description:
60+
- Destination network
61+
type: str
62+
nexthop_type:
63+
description:
64+
- ip-address, discard, or next-vr
65+
type: str
66+
nexthop:
67+
description:
68+
- Next hop IP address or Next VR Name
69+
type: str
70+
interface:
71+
description:
72+
- Next hop interface
73+
type: str
74+
admin_dist:
75+
description:
76+
- Administrative distance
77+
type: str
78+
metric:
79+
description:
80+
- Metric
81+
type: int
82+
default: 10
83+
enable_path_monitor:
84+
description:
85+
- Enable Path Monitor
86+
type: bool
87+
failure_condition:
88+
description:
89+
- Path Monitor failure condition set 'any' or 'all'
90+
type: str
91+
preemptive_hold_time:
92+
description:
93+
- Path Monitor Preemptive Hold Time in minutes
94+
type: int
95+
bfd_profile:
96+
description:
97+
- Name of the BRD profile
98+
type: str
99+
"""
100+
101+
EXAMPLES = """
102+
- name: Create Logical Router
103+
paloaltonetworks.panos.panos_logical_router_vrf_static_route:
104+
provider: '{{ provider }}'
105+
name: lr-1
106+
commit: true
107+
destination: 1.1.1.1/32
108+
nexthop: 192.168.10.1
109+
nexthop_type: ip-address
110+
"""
111+
112+
RETURN = """
113+
# Default return values
114+
"""
115+
116+
from ansible.module_utils.basic import AnsibleModule
117+
from ansible_collections.paloaltonetworks.panos.plugins.module_utils.panos import (
118+
get_connection,
119+
)
120+
121+
def main():
122+
helper = get_connection(
123+
template=True,
124+
template_stack=True,
125+
with_network_resource_module_state=True,
126+
with_gathered_filter=True,
127+
with_classic_provider_spec=True,
128+
with_commit=True,
129+
sdk_cls=("network", "VrfStaticRoute"),
130+
parents=(
131+
("network", "LogicalRouter", "logical_router"),
132+
(
133+
"network", "Vrf", "vrf_name"
134+
),
135+
),
136+
sdk_params=dict(
137+
name=dict(required=True),
138+
destination=dict(required=True),
139+
nexthop_type=dict(choices=["ip-address", "discard", "next-lr"]),
140+
nexthop=dict(),
141+
interface=dict(),
142+
admin_dist=dict(),
143+
metric=dict(type="int", default=10),
144+
enable_path_monitor=dict(type="bool"),
145+
failure_condition=dict(),
146+
preemptive_hold_time=dict(),
147+
bfd_profile=dict()
148+
),
149+
)
150+
151+
module = AnsibleModule(
152+
argument_spec=helper.argument_spec,
153+
supports_check_mode=True,
154+
required_one_of=helper.required_one_of,
155+
)
156+
157+
helper.process(module)
158+
159+
160+
if __name__ == "__main__":
161+
main()

0 commit comments

Comments
 (0)