mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-02-04 07:51:50 +00:00
[PR #11192/64dc009e backport][stable-12] solaris_zone: replace os.system() with run_command() (#11207)
solaris_zone: replace os.system() with run_command() (#11192)
* solaris_zone: replace os.system() with run_command()
* add changelog frag
(cherry picked from commit 64dc009ea7)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
f32bcd34ef
commit
9c57bb4f60
2 changed files with 7 additions and 2 deletions
2
changelogs/fragments/11192-solaris-zone-os-system.yml
Normal file
2
changelogs/fragments/11192-solaris-zone-os-system.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
minor_changes:
|
||||
- solaris_zone - execute external commands using Ansible construct (https://github.com/ansible-collections/community.general/pull/11192).
|
||||
|
|
@ -309,12 +309,15 @@ class Zone:
|
|||
Wait until the zone's console login is running; once that's running, consider the zone booted.
|
||||
"""
|
||||
|
||||
zone_booted_re = re.compile(r"ttymon.*-d /dev/console")
|
||||
cmd_ps = ["ps", "-z", self.name, "-o", "args"]
|
||||
|
||||
elapsed = 0
|
||||
while True:
|
||||
if elapsed > self.timeout:
|
||||
self.module.fail_json(msg="timed out waiting for zone to boot")
|
||||
rc = os.system(f'ps -z {self.name} -o args|grep "ttymon.*-d /dev/console" > /dev/null 2>/dev/null')
|
||||
if rc == 0:
|
||||
rc, out, err = self.module.run_command(cmd_ps, check_rc=False)
|
||||
if any(zone_booted_re.match(x) for x in out.splitlines()):
|
||||
break
|
||||
time.sleep(10)
|
||||
elapsed += 10
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue