Skip to content
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

404 error for advancedMalwareProtection when exporting policies due to lower() #61

Closed
sethbeauchamp opened this issue Jul 9, 2020 · 2 comments

Comments

@sethbeauchamp
Copy link

sethbeauchamp commented Jul 9, 2020

Error seems to be due to converting a string to lower case without considering advancedMalwareProtection specifically has capital letters.

(sdwan-viptela-0.3.0) Seths-MacBook-Pro:sdwan-viptela-0.3.0 seth$ vmanage --host vmanage.viptela.net --username admin --password goodpass export policies --file vManage-192-policies.json Traceback (most recent call last): File "/Users/seth/dev-projects/sdwan-viptela-0.3.0/bin/vmanage", line 33, in <module> sys.exit(load_entry_point('viptela', 'console_scripts', 'vmanage')()) File "/Users/seth/dev-projects/sdwan-viptela-0.3.0/lib/python3.7/site-packages/click/core.py", line 829, in __call__ return self.main(*args, **kwargs) File "/Users/seth/dev-projects/sdwan-viptela-0.3.0/lib/python3.7/site-packages/click/core.py", line 782, in main rv = self.invoke(ctx) File "/Users/seth/dev-projects/sdwan-viptela-0.3.0/lib/python3.7/site-packages/click/core.py", line 1259, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/Users/seth/dev-projects/sdwan-viptela-0.3.0/lib/python3.7/site-packages/click/core.py", line 1259, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/Users/seth/dev-projects/sdwan-viptela-0.3.0/lib/python3.7/site-packages/click/core.py", line 1066, in invoke return ctx.invoke(self.callback, **ctx.params) File "/Users/seth/dev-projects/sdwan-viptela-0.3.0/lib/python3.7/site-packages/click/core.py", line 610, in invoke return callback(*args, **kwargs) File "/Users/seth/dev-projects/sdwan-viptela-0.3.0/lib/python3.7/site-packages/click/decorators.py", line 33, in new_func return f(get_current_context().obj, *args, **kwargs) File "/Users/seth/dev-projects/sdwan-viptela-0.3.0/vmanage/cli/export/policies.py", line 19, in policies vmanage_files.export_policy_to_file(export_file) File "/Users/seth/dev-projects/sdwan-viptela-0.3.0/vmanage/apps/files.py", line 190, in export_policy_to_file policy_definitions_list = self.policy_data.export_policy_definition_list() File "/Users/seth/dev-projects/sdwan-viptela-0.3.0/vmanage/data/policy_data.py", line 328, in export_policy_definition_list policy_definition_list = self.policy_definitions.get_policy_definition_list(definition_type) File "/Users/seth/dev-projects/sdwan-viptela-0.3.0/vmanage/api/policy_definitions.py", line 120, in get_policy_definition_list definition_list = self.get_policy_definition_list(def_type) File "/Users/seth/dev-projects/sdwan-viptela-0.3.0/vmanage/api/policy_definitions.py", line 137, in get_policy_definition_list definition_detail = self.get_policy_definition(definition_type, definition['definitionId']) File "/Users/seth/dev-projects/sdwan-viptela-0.3.0/vmanage/api/policy_definitions.py", line 100, in get_policy_definition response = HttpMethods(self.session, url).request('GET') File "/Users/seth/dev-projects/sdwan-viptela-0.3.0/vmanage/api/http_methods.py", line 114, in request raise Exception(f"{self.url}: Error {result['status_code']} ({result['status']})") Exception: https://vmanage-1275533.viptela.net:443/dataservice/template/policy/definition/advancedmalwareprotection/7476926f-7807-41a8-a0f1-b214f8b16bd0: Error 404 (not_found)

fix:
in policy_definitions.py

for methds delete_policy_definition and update_policy_definition
replace the current url object with

if definition_type == "advancedMalwareProtection": url = f"{self.base_url}template/policy/definition/{definition_type}" else: url = f"{self.base_url}template/policy/definition/{definition_type.lower()}"

for method add_policy_definition

if policy_definition == "advancedMalwareProtection": url = f"{self.base_url}template/policy/definition/{policy_definition}" else: url = f"{self.base_url}template/policy/definition/{policy_definition.lower()}"

@sethbeauchamp sethbeauchamp changed the title 404 error for advancedMalwareProtection when exporting policies 404 error for advancedMalwareProtection when exporting policies due to lower() Jul 9, 2020
@sethbeauchamp
Copy link
Author

I submitted pull request #62 to correct this, first time contributing to some else's project. Let me know if its ok.

@mtarking
Copy link
Collaborator

mtarking commented Aug 7, 2021

PR merged. Closing issue.

@mtarking mtarking closed this as completed Aug 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants