Skip to content

Commit 2c4903a

Browse files
authored
Merge pull request #1451 from abhishekthukaram/development
Adding files for FW-NAT
2 parents 90947ec + 656d09c commit 2c4903a

4 files changed

Lines changed: 783 additions & 1 deletion

File tree

f5/bigip/tm/security/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from f5.bigip.tm.security.firewall import Firewall
3434
from f5.bigip.tm.security.ip_intelligence import Ip_Intelligence
3535
from f5.bigip.tm.security.log import Log
36+
from f5.bigip.tm.security.nat import Nat
3637
from f5.bigip.tm.security.protocol_inspection import Protocol_Inspection
3738

3839

@@ -47,5 +48,6 @@ def __init__(self, tm):
4748
Firewall,
4849
Ip_Intelligence,
4950
Log,
51+
Nat,
5052
Protocol_Inspection,
51-
]
53+
]

f5/bigip/tm/security/nat.py

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
# coding=utf-8
2+
#
3+
# Copyright 2015-2017 F5 Networks Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
"""BIG-IP® Advanced Firewall Manager™ (AFM®) module.
19+
20+
REST URI
21+
``http://localhost/mgmt/tm/security/nat``
22+
23+
GUI Path
24+
``Security --> Network Address Translation``
25+
26+
REST Kind
27+
``tm:security:nat:*``
28+
"""
29+
from f5.bigip.mixins import CheckExistenceMixin
30+
from f5.bigip.resource import Collection
31+
from f5.bigip.resource import OrganizingCollection
32+
from f5.bigip.resource import Resource
33+
34+
35+
class Nat(OrganizingCollection):
36+
"""BIG-IP® AFM® Nat organizing collection."""
37+
38+
def __init__(self, security):
39+
super(Nat, self).__init__(security)
40+
self._meta_data['minimum_version'] = '12.1.0'
41+
self._meta_data['allowed_lazy_attributes'] = [
42+
Policy_s,
43+
Source_Translations,
44+
Destination_Translations]
45+
46+
47+
class Rules_s(Collection):
48+
"""BIG-IP® AFM® Nat Rules sub-collection."""
49+
50+
def __init__(self, policy):
51+
super(Rules_s, self).__init__(policy)
52+
self._meta_data['required_json_kind'] = \
53+
'tm:security:nat:policy:rules:rulescollectionstate'
54+
self._meta_data['allowed_lazy_attributes'] = [Rule]
55+
self._meta_data['attribute_registry'] = \
56+
{'tm:security:nat:policy:rules:rulesstate':
57+
Rule}
58+
59+
60+
class Rule(Resource, CheckExistenceMixin):
61+
"""BIG-IP® AFM® Rule resource.
62+
63+
64+
NOTE:: The 'place-before' and 'place-after' attribute are
65+
mandatory but cannot be present with one another. Those attributes
66+
will not be visible when the class is created, they exist for the
67+
sole purpose of rule ordering in the BIGIP. The ordering of the
68+
rules corresponds to the index in the 'items' of the Rules_s
69+
sub-collection.
70+
"""
71+
72+
def __init__(self, rules_s):
73+
super(Rule, self).__init__(rules_s)
74+
self._meta_data['required_json_kind'] = \
75+
'tm:security:nat:policy:rules:rulesstate'
76+
77+
self._meta_data['exclusive_attributes'].append(
78+
('place-after', 'place-before'))
79+
self._meta_data['minimum_additional_parameters'] = {'place-before',
80+
'place-after'}
81+
82+
def update(self, **kwargs):
83+
"""We need to implement the custom exclusive parameter check."""
84+
self._check_exclusive_parameters(**kwargs)
85+
return super(Rule, self)._update(**kwargs)
86+
87+
def modify(self, **kwargs):
88+
"""We need to implement the custom exclusive parameter check."""
89+
self._check_exclusive_parameters(**kwargs)
90+
return super(Rule, self)._modify(**kwargs)
91+
92+
def load(self, **kwargs):
93+
return super(Rule, self)._load(**kwargs)
94+
95+
def delete(self, **kwargs):
96+
return super(Rule, self)._delete(**kwargs)
97+
98+
def exists(self, **kwargs):
99+
return super(Rule, self)._load(**kwargs)
100+
101+
102+
class Source_Translations(Collection):
103+
"""BIG-IP® AFM® Nat Source Translation collection"""
104+
105+
def __init__(self, nat):
106+
super(Source_Translations, self).__init__(nat)
107+
self._meta_data['allowed_lazy_attributes'] = [Source_Translation]
108+
self._meta_data['attribute_registry'] = \
109+
{'tm:security:nat:source-translation:source-translationstate':
110+
Source_Translation}
111+
112+
113+
class Source_Translation(Resource):
114+
def __init__(self, source_translations):
115+
super(Source_Translation, self).__init__(source_translations)
116+
self._meta_data['required_json_kind'] = \
117+
'tm:security:nat:source-translation:source-translationstate'
118+
self._meta_data['required_creation_parameters'].update(
119+
('partition',))
120+
self._meta_data['required_load_parameters'].update(
121+
('partition',))
122+
123+
124+
class Destination_Translations(Collection):
125+
"""BIG-IP® AFM® Nat Destination Translation collection"""
126+
127+
def __init__(self, nat):
128+
super(Destination_Translations, self).__init__(nat)
129+
self._meta_data['allowed_lazy_attributes'] = [Destination_Translation]
130+
self._meta_data['attribute_registry'] = \
131+
{'tm:security:nat:destination-translation:destination-translationstate':
132+
Destination_Translation}
133+
134+
135+
class Destination_Translation(Resource):
136+
def __init__(self, destination_translations):
137+
super(Destination_Translation, self).__init__(destination_translations)
138+
self._meta_data['required_json_kind'] = \
139+
'tm:security:nat:destination-translation:destination-translationstate'
140+
self._meta_data['required_creation_parameters'].update(
141+
('partition',))
142+
self._meta_data['required_load_parameters'].update(
143+
('partition',))
144+
145+
146+
class Policy_s(Collection):
147+
"""BIG-IP® AFM® Nat Policy collection"""
148+
149+
def __init__(self, nat):
150+
super(Policy_s, self).__init__(nat)
151+
self._meta_data['allowed_lazy_attributes'] = [Policy]
152+
self._meta_data['attribute_registry'] = \
153+
{'tm:security:nat:policy:policystate':
154+
Policy}
155+
156+
157+
class Policy(Resource):
158+
"""BIG-IP® AFM® Nat Policy resource"""
159+
160+
def __init__(self, policy_s):
161+
super(Policy, self).__init__(policy_s)
162+
self._meta_data['required_json_kind'] = \
163+
'tm:security:nat:policy:policystate'
164+
self._meta_data['required_creation_parameters'].update(('partition',))
165+
self._meta_data['required_load_parameters'].update(('partition',))
166+
self._meta_data['allowed_lazy_attributes'] = [Rules_s]
167+
self._meta_data['attribute_registry'] = \
168+
{'tm:security:nat:rules:rulescollectionstate':
169+
Rules_s}

0 commit comments

Comments
 (0)