mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-02-04 07:51:50 +00:00
[PR #11231/16d51a82 backport][stable-12] remove % templating (#11237)
remove % templating (#11231)
* remove % templating
* add changelog frag
* suggestions from review
* remove unused import
(cherry picked from commit 16d51a8233)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
721d2bd35d
commit
3033dfa27c
3 changed files with 7 additions and 6 deletions
3
changelogs/fragments/11231-perc-format.yml
Normal file
3
changelogs/fragments/11231-perc-format.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
minor_changes:
|
||||
- oneandone_server - replace ``%`` templating with f-strings or ``format()`` (https://github.com/ansible-collections/community.general/pull/11231).
|
||||
- packet_device - replace ``%`` templating with f-strings or ``format()`` (https://github.com/ansible-collections/community.general/pull/11231).
|
||||
|
|
@ -553,7 +553,7 @@ def _auto_increment_hostname(count, hostname):
|
|||
name-02, name-03, and so forth.
|
||||
"""
|
||||
if "%" not in hostname:
|
||||
hostname = "%s-%%01d" % hostname # noqa
|
||||
hostname = f"{hostname}-%01d"
|
||||
|
||||
return [hostname % i for i in range(1, count + 1)]
|
||||
|
||||
|
|
|
|||
|
|
@ -423,8 +423,7 @@ def get_hostname_list(module):
|
|||
if re.search(r"%\d{0,2}d", hostname_spec):
|
||||
hostnames = [hostname_spec % i for i in count_range]
|
||||
elif count > 1:
|
||||
hostname_spec = "%s%%02d" % hostname_spec # noqa
|
||||
hostnames = [hostname_spec % i for i in count_range]
|
||||
hostnames = [f"{hostname_spec}{i:02}" for i in count_range]
|
||||
|
||||
for hn in hostnames:
|
||||
if not is_valid_hostname(hn):
|
||||
|
|
@ -500,9 +499,8 @@ def wait_for_devices_active(module, packet_conn, watched_devices):
|
|||
if all(d.state == "active" for d in refreshed):
|
||||
return refreshed
|
||||
time.sleep(5)
|
||||
raise Exception(
|
||||
'Waiting for state "active" timed out for devices: %s' % [d.hostname for d in refreshed if d.state != "active"]
|
||||
)
|
||||
timed_out_devices = [d.hostname for d in refreshed if d.state != "active"]
|
||||
raise Exception(f'Waiting for state "active" timed out for devices: {timed_out_devices}')
|
||||
|
||||
|
||||
def wait_for_public_IPv(module, packet_conn, created_devices):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue