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

Add new module azure_rm_afdorigin to support Azure Frontdoor Standard and Premium #1591

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from

Conversation

jartoo
Copy link
Contributor

@jartoo jartoo commented Jun 6, 2024

SUMMARY

This module manages Frontdoor Origins for the Standard and Premium services. I propose building this as a separate module in lieu of complicating the azure_cdn_profile module so as to make the management of each of the elements easier. Azure Frontdoor is quite complex, so matching the modules with the Python SDK APIs seems to be the prudent design choice.

Continues to work on #1041 This does not complete this issue, yet.

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

Module: azure_rm_afdorigin

ADDITIONAL INFORMATION

Provides the ability to manage Origins, per the Python SDK here: https://learn.microsoft.com/en-us/python/api/azure-mgmt-cdn/azure.mgmt.cdn.operations.afdoriginsoperations?view=azure-python


@Fred-sun
Copy link
Collaborator

Fred-sun commented Jun 7, 2024

@jartoo Please help fix below errors:

ERROR: plugins/modules/azure_rm_afdorigin_info.py:21:161: E501: line too long (207 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin_info.py:64:14: W291: trailing whitespace
ERROR: plugins/modules/azure_rm_afdorigin_info.py:76:161: E501: line too long (210 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin_info.py:83:161: E501: line too long (165 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin_info.py:99:161: E501: line too long (183 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin_info.py:111:161: E501: line too long (355 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin_info.py:115:161: E501: line too long (198 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin_info.py:231:52: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin_info.py:232:52: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin_info.py:325:1: E305: expected 2 blank lines after class or function definition, found 1
ERROR: plugins/modules/azure_rm_afdorigin.py:33:161: E501: line too long (214 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin.py:40:161: E501: line too long (169 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin.py:54:161: E501: line too long (359 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin.py:58:161: E501: line too long (202 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin.py:157:161: E501: line too long (187 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin.py:177:1: E302: expected 2 blank lines, found 1
ERROR: plugins/modules/azure_rm_afdorigin.py:181:22: E251: unexpected spaces around keyword / parameter equals
ERROR: plugins/modules/azure_rm_afdorigin.py:181:24: E251: unexpected spaces around keyword / parameter equals
ERROR: plugins/modules/azure_rm_afdorigin.py:183:18: E251: unexpected spaces around keyword / parameter equals
ERROR: plugins/modules/azure_rm_afdorigin.py:183:20: E251: unexpected spaces around keyword / parameter equals
ERROR: plugins/modules/azure_rm_afdorigin.py:184:18: E251: unexpected spaces around keyword / parameter equals
ERROR: plugins/modules/azure_rm_afdorigin.py:184:20: E251: unexpected spaces around keyword / parameter equals
ERROR: plugins/modules/azure_rm_afdorigin.py:185:19: E251: unexpected spaces around keyword / parameter equals
ERROR: plugins/modules/azure_rm_afdorigin.py:185:21: E251: unexpected spaces around keyword / parameter equals
ERROR: plugins/modules/azure_rm_afdorigin.py:186:11: E251: unexpected spaces around keyword / parameter equals
ERROR: plugins/modules/azure_rm_afdorigin.py:186:13: E251: unexpected spaces around keyword / parameter equals
ERROR: plugins/modules/azure_rm_afdorigin.py:213:46: E231: missing whitespace after ','
ERROR: plugins/modules/azure_rm_afdorigin.py:214:47: E231: missing whitespace after ','
ERROR: plugins/modules/azure_rm_afdorigin.py:224:51: E231: missing whitespace after ','
ERROR: plugins/modules/azure_rm_afdorigin.py:224:70: E231: missing whitespace after ','
ERROR: plugins/modules/azure_rm_afdorigin.py:265:49: E127: continuation line over-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:266:49: E127: continuation line over-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:267:49: E127: continuation line over-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:312:161: E501: line too long (163 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin.py:315:161: E501: line too long (195 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin.py:317:161: E501: line too long (207 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin.py:319:161: E501: line too long (234 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin.py:321:161: E501: line too long (216 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin.py:323:161: E501: line too long (189 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin.py:325:1: W293: blank line contains whitespace
ERROR: plugins/modules/azure_rm_afdorigin.py:384:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:385:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:386:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:387:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:423:1: W293: blank line contains whitespace
ERROR: plugins/modules/azure_rm_afdorigin.py:426:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:427:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:428:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:429:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:445:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:446:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:447:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:465:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:466:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:467:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:478:56: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:479:56: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:487:1: E305: expected 2 blank lines after class or function definition, found 1

resource_group: myResourceGroup
state: present
origin:
host_name: "10.0.0.1"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong indentation: expected 6 but found 8

profile_name: myProfile
resource_group: myResourceGroup
state: absent

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

item = self.endpoint_client.afd_origins.get(
resource_group_name=self.resource_group, profile_name=self.profile_name, origin_group_name=self.origin_group_name, origin_name=self.name)
except Exception as exc:
self.log("Did not find resource.".format(str(exc)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too-many-format-args: Too many arguments for format string

@Fred-sun Fred-sun added question Further information is requested new_module_pr Add new modules medium_priority Medium priority work in In trying to solve, or in working with contributors labels Jun 7, 2024
@jartoo
Copy link
Contributor Author

jartoo commented Jun 10, 2024

In looking at this further, I am wondering if i should flatten the input parameters and resubmit this... Looking for architectural guidance on this. In working thru the Route module, it seems to be much cleaner when I do this and not nest the parameters under unnecessary suboptions. For example, move all of the origin suboptions, like azure_origin to the root level, reducing the nesting complexity.

@jartoo
Copy link
Contributor Author

jartoo commented Jun 10, 2024

Doing this would also help with the required_if and the attribute setting sections, which do not work well with nested layers of inputs.

Copy link
Collaborator

@Fred-sun Fred-sun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If self.origin is None, it will not be able to get the value through the dictionary method, you should first determine 'self.origin is not None', in addition, 'self.origin 'parameters are not all necessary, Therefore, it can be obtained by 'self.origination.get('***'), and then compare it if it is not' None' after obtaining it. Thank you!

self.results['id'] = response['id']
self.results['host_name'] = response['host_name']

if response['host_name'] != self.origin['host_name'] and self.origin['host_name']:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if response['host_name'] != self.origin['host_name'] and self.origin['host_name']:
if self.origin is not None:
self.origin.get('host_name') is not None and response['host_name'] != self.origin['host_name']:

@jartoo
Copy link
Contributor Author

jartoo commented Jun 11, 2024

Looking at this again after working the AFDRoute module, I think it makes sense to flatten the inputs if not in a list structure to reduce complexity and take advantage of the built-in functionality which only works at the root level, such as the required_if and required_together functions. I will rework this and submit further changes...sorry, figuring this out as I go it seems.

@jartoo
Copy link
Contributor Author

jartoo commented Jun 11, 2024

@Fred-sun Please let me know if you prefer flattened inputs, per the above comment, or hierarchical ones. I have not found yet any guidance on the approach for this. It would be helpful if I had this before I rework the other pull requests. With hierarchical you lose the ability to use required_if and required_together functions as well as setting defaults as those functions currently only run on the first level in the inputs. I can rework the other module pull requests to align...Thanks!

@Fred-sun
Copy link
Collaborator

@jartoo Thank you very much for your reply, because we will create and delete two states。 The delete states, those are not required parameters can be None, so we need to make a judgment first. Also, regarding the new module, please add it to pr-pipeline.yml and meta/runtime.yml. Thank you!

@jartoo
Copy link
Contributor Author

jartoo commented Jun 13, 2024

Let me refactor this. Put this on hold until I submit the flattened parameters...will try to get this done ASAP.

@Fred-sun
Copy link
Collaborator

@jartoo Ok, you can also add me to this branch of yours and I will work with you to solve the repo problem. Thank you!

Copy link
Collaborator

@Fred-sun Fred-sun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small change request!

plugins/modules/azure_rm_afdorigin.py Show resolved Hide resolved
@Fred-sun
Copy link
Collaborator

@xuzhang3 This PR relies on #1588 and #1590, Please merge #1588 and #1590 at first!Thanks!

@Fred-sun Fred-sun added ready_for_review The PR has been modified and can be reviewed and merged and removed question Further information is requested work in In trying to solve, or in working with contributors labels Jun 28, 2024
@xuzhang3 xuzhang3 changed the title Add new module azure_rm_afdorigin to support Azure Frontdoor Standard and Premium Add new module azure_rm_afdorigin to support Azure Frontdoor Standard and Premium Jul 1, 2024
@xuzhang3
Copy link
Collaborator

xuzhang3 commented Jul 1, 2024

@jartoo can you help resolve the file conflict.

@xuzhang3
Copy link
Collaborator

xuzhang3 commented Jul 3, 2024

test failed:

running playbook inside collection azure.azcollection
ERROR! couldn't resolve module/action 'azure_rm_afdorigingroup'. This often indicates a misspelling, missing collection, or incorrect module path.

The error appears to be in '/home/cloudtest/.ansible/ansible_collections/azure/azcollection/tests/output/.tmp/integration/azure_rm_afdorigin-wl2ok8p5-ÅÑŚÌβŁÈ/tests/integration/targets/azure_rm_afdorigin/tasks/main.yml': line 16, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- name: Create Origin Group
  ^ here
Command exited with status 4 after 0.5188372135162354 seconds.
NOTICE: To resume at this test target, use the option: --start-at azure_rm_afdorigin
FATAL: Command "ansible-playbook azure_rm_afdorigin-nqi94ery.yml -i inventory -vvvvvv" returned exit status 4.

@Fred-sun
Copy link
Collaborator

Fred-sun commented Jul 8, 2024

@jartoo You seem to have restored the changes of the dev branch, please check this PR again, thank you!

@Fred-sun Fred-sun removed the ready_for_review The PR has been modified and can be reviewed and merged label Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
medium_priority Medium priority new_module_pr Add new modules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants