[go: nahoru, domu]

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

VPS Display Name Module - Supports Changed/Ok/Error #77

Merged
merged 2 commits into from
Jun 12, 2024

Conversation

armorica
Copy link
Contributor

Hi,

First code for an Ansible module for setting the Display Name of OVH VPS system.

  • Take the Service Name and Display Name as parameters.
  • Check the current value of Display Name for Service Name via GET.
  • Set Display Name for Service Name if given value is different.

It was started as a "copy from" the dedicated_server_display_name.py but as that code failed to do anything for my VPS-es I created my own logic. In order to be able to report Changed/Ok/Error it has to do a GET first and then, if necessary do the PUT.

Not sure if the if/then/else catches all possible errors (esp. from the GET).

Regards,

Paul Tap (armorica)

Ansible module for setting the Display Name of OVH VPS system.
- Take the Service Name and Display Name as parameters.
- Check the current value of Display Name for Service Name via GET.
- Set Display Name for Service Name if given value is different.
Copy link
Contributor
@tortuegenialez tortuegenialez left a comment

Choose a reason for hiding this comment

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

Could you please change the camelcase, thanks

'displayName': display_name
}

# Retrieve the current values for displayName, keymap and netbootMode
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you retrieving those three parameters?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not all 3. comment is based on the OVH doc. Changed to only mention the displayName.

module.exit_json(
msg="displayName succesfully set to {} for {} !".format(display_name, service_name),
changed=True)
else:
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if the putResult fails it will be catched in the try/except in the module_utils part 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't aware of this. It does, but the error it throws is not clear (looks like an authentication issue, instead of the real problem). Yet, I changed my code to use it.


# Retrieve the current values for displayName, keymap and netbootMode

getResult=client.wrap_call(
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use snakecase instead of camelcase: get_result

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did that.

# Now check if the value is different and if necessary set it

if getResult['displayName'] != display_name:
putResult=client.wrap_call(
Copy link
Contributor

Choose a reason for hiding this comment

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

Snakecase too: put_result

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Took the variable out, as it is no longer needed.

@armorica
Copy link
Contributor Author

Sorry for reacting this late. Got occupied by other things and as I am pretty new to git, github and the project code, I needed a bit of time to dive in. Please let me know if you need further changes. If not, I will try to find time to write modules for other VPS endpoints, as I need them for my VPSes.

@tortuegenialez tortuegenialez merged commit 9b25b1f into synthesio:master Jun 12, 2024
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.

2 participants