-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix dos profile #2425
Merged
Merged
fix dos profile #2425
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
745f83d
fix dos profile
RavinderReddyF5 fb44935
fix lint issues
RavinderReddyF5 f5b9992
fixing lint issues
RavinderReddyF5 ea5af10
fix issue
RavinderReddyF5 3fdc62b
fixing unicode issues
RavinderReddyF5 f1ae999
removed commented code
urohit011 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
ansible_collections/f5networks/f5_modules/changelogs/fragments/issue_2419_2421.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
minor_changes: | ||
- bigip_device_info - virtual-servers - return per_flow_request_access_policy if defined. | ||
- bigip_virtual_server - set per_flow_request_access_policy and stay idempotent. | ||
- bigip_asm_dos_application - add support for creating dos profile. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1136,7 +1136,21 @@ def profile_exists(self): | |
raise F5ModuleError(str(ex)) | ||
|
||
if resp.status == 404 or 'code' in response and response['code'] == 404: | ||
return False | ||
uri = "https://{0}:{1}/mgmt/tm/security/dos/profile".format( | ||
self.client.provider['server'], | ||
self.client.provider['server_port'], | ||
) | ||
payload = {'name': self.want.profile, 'partition': self.want.partition} | ||
resp = self.client.api.post(uri, json=payload) | ||
try: | ||
response = resp.json() | ||
except ValueError as ex: | ||
raise F5ModuleError(str(ex)) | ||
# response = resp.json() | ||
if resp.status == 404 or 'code' in response and response['code'] == 404: | ||
return False | ||
if resp.status in [200, 201] or 'code' in response and response['code'] in [200, 201]: | ||
return True | ||
if resp.status in [200, 201] or 'code' in response and response['code'] in [200, 201]: | ||
return True | ||
|
||
|
@@ -1148,16 +1162,15 @@ def profile_exists(self): | |
|
||
def exists(self): | ||
errors = [401, 403, 409, 500, 501, 502, 503, 504] | ||
if not self.profile_exists(): | ||
raise F5ModuleError( | ||
'Specified DOS profile: {0} on partition: {1} does not exist.'.format( | ||
self.want.profile, self.want.partition) | ||
) | ||
uri = "https://{0}:{1}/mgmt/tm/security/dos/profile/{2}/application/{3}".format( | ||
# if not self.profile_exists(): | ||
# raise F5ModuleError( | ||
# 'Specified DOS profile: {0} on partition: {1} does not exist.'.format( | ||
# self.want.profile, self.want.partition) | ||
# ) | ||
uri = "https://{0}:{1}/mgmt/tm/security/dos/profile/{2}".format( | ||
self.client.provider['server'], | ||
self.client.provider['server_port'], | ||
transform_name(self.want.partition, self.want.profile), | ||
self.want.profile | ||
) | ||
resp = self.client.api.get(uri) | ||
try: | ||
|
@@ -1169,7 +1182,6 @@ def exists(self): | |
return False | ||
if resp.status in [200, 201] or 'code' in response and response['code'] in [200, 201]: | ||
return True | ||
|
||
if resp.status in errors or 'code' in response and response['code'] in errors: | ||
if 'message' in response: | ||
raise F5ModuleError(response['message']) | ||
|
@@ -1179,6 +1191,19 @@ def exists(self): | |
def create_on_device(self): | ||
params = self.changes.api_params() | ||
params['name'] = self.want.profile | ||
uri = "https://{0}:{1}/mgmt/tm/security/dos/profile".format( | ||
self.client.provider['server'], | ||
self.client.provider['server_port'], | ||
) | ||
payload = {'name': self.want.profile, 'partition': self.want.partition} | ||
|
||
resp = self.client.api.post(uri, json=payload) | ||
try: | ||
response = resp.json() | ||
except ValueError as ex: | ||
raise F5ModuleError(str(ex)) | ||
if resp.status == 404 or 'code' in response and response['code'] == 404: | ||
raise F5ModuleError(resp.content) | ||
uri = "https://{0}:{1}/mgmt/tm/security/dos/profile/{2}/application/".format( | ||
self.client.provider['server'], | ||
self.client.provider['server_port'], | ||
|
@@ -1213,11 +1238,18 @@ def update_on_device(self): | |
raise F5ModuleError(resp.content) | ||
|
||
def remove_from_device(self): | ||
uri = "https://{0}:{1}/mgmt/tm/security/dos/profile/{2}/application/{3}".format( | ||
# uri = "https://{0}:{1}/mgmt/tm/security/dos/profile/{2}/application/{3}".format( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Plaese remove the commented code. |
||
# self.client.provider['server'], | ||
# self.client.provider['server_port'], | ||
# transform_name(self.want.partition, self.want.profile), | ||
# self.want.profile | ||
# ) | ||
# response = self.client.api.delete(uri) | ||
# time.sleep(5) | ||
uri = "https://{0}:{1}/mgmt/tm/security/dos/profile/{2}/".format( | ||
self.client.provider['server'], | ||
self.client.provider['server_port'], | ||
transform_name(self.want.partition, self.want.profile), | ||
self.want.profile | ||
) | ||
response = self.client.api.delete(uri) | ||
if response.status == 200: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
ansible>=8.5.0 | ||
q | ||
invoke~=1.7.3 | ||
Jinja2~=3.1.2 | ||
invoke==2.2.0 | ||
pycodestyle==2.12.1 | ||
flake8==7.1.1 | ||
nose | ||
mock | ||
semver | ||
pytest | ||
pytest-cov | ||
coverage | ||
packaging | ||
semver~=2.13.0 | ||
pytest~=7.2.0 | ||
PyYAML~=6.0 | ||
netaddr~=0.8.0 | ||
packaging~=21.3 | ||
ordereddict~=1.1 | ||
cryptography~=42.0.8 | ||
objectpath~=0.6.1 | ||
antsibull-changelog | ||
ansible-lint | ||
paramiko | ||
jinja2 | ||
netaddr | ||
objectpath | ||
PyYAML | ||
ordereddict | ||
cryptography |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the commented out code here and on line 1241, rest looks good.