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

time_and_locale_branch #646

Merged
merged 91 commits into from
Mar 2, 2021
Merged

time_and_locale_branch #646

merged 91 commits into from
Mar 2, 2021

Conversation

SHANDCRUZ
Copy link
Contributor

@SHANDCRUZ SHANDCRUZ commented Feb 26, 2021

Description

Refactored Appliance Time and Locale Configuration

Issues Resolved

None

Check List

  • New functionality includes testing.
    • All tests pass. ($ ./build.sh).
  • New functionality has been documented in the README if applicable.
    • New functionality has been thoroughly documented in the examples (please include helpful comments).



class ApplianceTimeAndLocaleConfigurationModule(OneViewModuleBase):
MSG_UPDATED = 'Appliance Locale and Time Configuration updated successfully.'
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing Update Msg, does this resource do not have PUT/PATCH Operation?

@@ -80,8 +81,19 @@ def __init__(self):
self.resource_client = self.oneview_client.appliance_time_and_locale_configuration
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use set_resource_object method as we follow the same part of refactoring

author:
"Thiago Miotto (@tmiotto)"
"Shanmugam M (@SHANDCRUZ)"
extends_documentation_fragment:
- oneview
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add oneview.validateetag

short_description: Retrieve the facts about the OneView appliance time configuration.
description:
- Retrieve the facts about the OneView appliance time configuration.
version_added: "2.4"
Copy link
Collaborator

Choose a reason for hiding this comment

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

change version to "2.9". This is the ansible version.

version_added: "2.4"
requirements:
- "python >= 3.4.2"
- "hpeOneView >= 5.6.0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

change hpeOneView >= 6.0.0.
Follow the same for all resources

def execute_module(self):
changed, msg, ansible_facts = False, '', {}
appliance_ssh_access = self.resource_client.get_all()
self.current_resource = appliance_ssh_access
Copy link
Collaborator

Choose a reason for hiding this comment

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

directly assign self.resource_client.get_all() to self.current_resource

class ApplianceTimeAndLocaleConfigurationModule(OneViewModuleBase):
MSG_UPDATED = 'Appliance Locale and Time Configuration updated successfully.'
class ApplianceTimeAndLocaleConfigurationModule(OneViewModule):
MSG_CREATED = 'Appliance Locale and Time Configuration created successfully.'
Copy link
Collaborator

Choose a reason for hiding this comment

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

modify the message to avoid confusion

    MSG_CREATED = 'Appliance Locale and Time Configuration configured successfully.'


def __present(self):
self.current_resource = self.resource_client.get_all()
merged_data = self.current_resource.data.copy()
Copy link
Collaborator

Choose a reason for hiding this comment

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

what if the return value of self.resource_client.get_all() is None..?
self.current_resource.data.copy() value will fail saying None type has no 'data' attribute. So add the if condition before that.

self.current_resource = self.resource_client.create(self.data)
return True, self.MSG_CREATED, dict(appliance_time_and_locale_configuration=self.current_resource.data)
else:
return False, self.MSG_ALREADY_PRESENT, dict(appliance_time_and_locale_configuration=self.current_resource.data)
Copy link
Collaborator

Choose a reason for hiding this comment

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

try the below code

    def __present(self):
        resource_data = {}
        self.current_resource = self.resource_client.get_all()
        if self.current_resource:
            resource_data = self.current_resource.data.copy()
        merged_data = resource_data.copy()
        merged_data.update(self.data)
        if not compare(resource_data, merged_data):
            self.current_resource = self.resource_client.create(self.data)
            return True, self.MSG_CREATED, dict(appliance_time_and_locale_configuration=self.current_resource.data)
        else:
            return False, self.MSG_ALREADY_PRESENT, dict(appliance_time_and_locale_configuration=resource_data)

Copy link
Collaborator

@VenkateshRavula VenkateshRavula left a comment

Choose a reason for hiding this comment

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

LGTM

@SHANDCRUZ SHANDCRUZ merged commit 82e25e5 into master Mar 2, 2021
@SHANDCRUZ SHANDCRUZ deleted the added_time_and_locale branch March 2, 2021 11:35
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.

5 participants