Skip to content

[WIP] Start of flexible duration specification #36878

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

Draft
wants to merge 8 commits into
base: devel
Choose a base branch
from

Conversation

sivel
Copy link
Member

@sivel sivel commented Feb 28, 2018

SUMMARY

This PR aims to provide a more flexible duration spec for use in user input, instead of relying on the user providing an integer defining seconds, or in cases where a module accepts seconds and minutes as exclusive parameters.

Using this, a module could define:

from ansible.module_utils.parsing.duration import duration

module = AnsibleModule(
    argument_spec=dict(
        duration=dict(type=duration)
    )
)

The user would provide something like the following:

duration: 5m5s
duration: 1d
duration: 1m
duration: 60

The duration type function, returns a datetime.timedelta object, and if the module needs seconds it can rely on params['duration'].total_seconds()

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

lib/ansible/module_utils/parsing/duration.py

ANSIBLE VERSION
devel
ADDITIONAL INFORMATION

The human_time_delta and timedelta_to_dict functions probably don't belong in parsing, eventually they should move to text.format

@sivel sivel added this to the 2.7.0 milestone Feb 28, 2018
@ansibot ansibot added WIP This issue/PR is a work in progress. Nevertheless it was shared for getting input from peers. feature_pull_request needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Feb 28, 2018
@sivel sivel removed the needs_triage Needs a first human triage before being processed. label Feb 28, 2018
@ansibot
Copy link
Contributor

ansibot commented Feb 28, 2018

@ansibot ansibot added the module This issue/PR relates to a module. label Feb 28, 2018
@ansibot
Copy link
Contributor

ansibot commented Feb 28, 2018

The test ansible-test sanity --test pylint [explain] failed with 2 errors:

lib/ansible/module_utils/parsing/duration.py:9:0: anomalous-backslash-in-string Anomalous backslash in string: '\.'. String constant might be missing an r prefix.
lib/ansible/module_utils/parsing/duration.py:49:0: dangerous-default-value Dangerous default value [] as argument

click here for bot help

@ansibot ansibot added the feature This issue/PR relates to a feature request. label Mar 1, 2018
@rackergs
Copy link

rackergs commented Mar 1, 2018

looks legit to me but I'm pretty sure my +1 doesnt do anything in the system 😁

@sivel
Copy link
Member Author

sivel commented Mar 1, 2018

@rackergs thanks! and sorry for the ping. Meant to have the bot skip this for the time being.

@sivel
Copy link
Member Author

sivel commented Mar 1, 2018

bot_skip

@sivel sivel removed this from the 2.7.0 milestone Feb 20, 2019
@sivel sivel mentioned this pull request Jun 5, 2020
@sivel sivel marked this pull request as draft August 9, 2021 20:51
@detobel36
Copy link

Any news about this ?

@webknjaz
Copy link
Member

/azp run

@azure-pipelines
Copy link

Pull request contains merge conflicts.

@webknjaz
Copy link
Member

/azp run

@azure-pipelines
Copy link

Pull request contains merge conflicts.

@webknjaz webknjaz added ci_verified Changes made in this PR are causing tests to fail. needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html labels Oct 31, 2022
@sivel sivel added the unimportant_ci This PR does not need to have healthy CI status and should be ignored by the CI infra maintainers. label Jun 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci_verified Changes made in this PR are causing tests to fail. feature This issue/PR relates to a feature request. module This issue/PR relates to a module. needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html support:core This issue/PR relates to code supported by the Ansible Engineering Team. unimportant_ci This PR does not need to have healthy CI status and should be ignored by the CI infra maintainers. WIP This issue/PR is a work in progress. Nevertheless it was shared for getting input from peers.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants