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 content_template module #26

Merged
merged 1 commit into from
Jun 4, 2024

Conversation

machacekondra
Copy link
Collaborator

Module to create template in content library from virtual machine.

@machacekondra machacekondra requested a review from bardielle May 23, 2024 09:19
)

result = {'failed': False, 'changed': False}
vmware_contentlib_create = VmwareContentCreateTemplate(module)
Copy link
Collaborator

Choose a reason for hiding this comment

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

what about deleting and updating template?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added deleting, updating support only notes and name, which is not really needed imho.

@machacekondra machacekondra changed the title Add content_create_template module Add content_template module May 27, 2024
@machacekondra machacekondra force-pushed the create_template branch 3 times, most recently from 60c54d1 to 43f06f9 Compare May 27, 2024 10:37
def create_template_from_vm(self):
template = self.get_library_item_from_content_library_name(self.template, self.library)
if template:
self.result['template_info'] = dict(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will be an error? I think we should throw an error if it's update case

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This shouldn't be error. This should return changed=False and info that the template already exists.

Copy link
Collaborator

@bardielle bardielle May 28, 2024

Choose a reason for hiding this comment

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

if this is the same object I agree with you, but what about editing some fields?
we should block that

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What fields do you mean? Name can be updated, and in future, would be nice to support it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean if user will apply changes in name or library it will not change nothing but will response that everything is good

Copy link
Collaborator

Choose a reason for hiding this comment

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

If the user changes something in the placement spec but keeps the name that same, I think this module will give them a confusing result. It will return OK when in reality the template does not have the configuration they expect

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As far as I understand the placement is used only for the import process. So after import is done, it really doesn't make sense to change the field. So IMHO it's better to succed, as nothing was really changed then to fail, but makes sense to document it well, so users understand.

def create_template_from_vm(self):
template = self.get_library_item_from_content_library_name(self.template, self.library)
if template:
self.result['template_info'] = dict(
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the user changes something in the placement spec but keeps the name that same, I think this module will give them a confusing result. It will return OK when in reality the template does not have the configuration they expect

plugins/module_utils/vmware_rest_client.py Show resolved Hide resolved
@mikemorency mikemorency self-requested a review June 3, 2024 15:27
@bardielle
Copy link
Collaborator

@machacekondra fix the rebase-conflicts and merge your PR :)

Module to manage template in content library from virtual machine.

Signed-off-by: Ondra Machacek <[email protected]>
@bardielle bardielle merged commit 618d576 into ansible-collections:main Jun 4, 2024
9 checks passed
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

Successfully merging this pull request may close these issues.

3 participants