Skip to content

Commit 9c57bb4

Browse files
[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 64dc009) Co-authored-by: Alexei Znamensky <[email protected]>
1 parent f32bcd3 commit 9c57bb4

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
minor_changes:
2+
- solaris_zone - execute external commands using Ansible construct (https://github.com/ansible-collections/community.general/pull/11192).

plugins/modules/solaris_zone.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,15 @@ def boot(self):
309309
Wait until the zone's console login is running; once that's running, consider the zone booted.
310310
"""
311311

312+
zone_booted_re = re.compile(r"ttymon.*-d /dev/console")
313+
cmd_ps = ["ps", "-z", self.name, "-o", "args"]
314+
312315
elapsed = 0
313316
while True:
314317
if elapsed > self.timeout:
315318
self.module.fail_json(msg="timed out waiting for zone to boot")
316-
rc = os.system(f'ps -z {self.name} -o args|grep "ttymon.*-d /dev/console" > /dev/null 2>/dev/null')
317-
if rc == 0:
319+
rc, out, err = self.module.run_command(cmd_ps, check_rc=False)
320+
if any(zone_booted_re.match(x) for x in out.splitlines()):
318321
break
319322
time.sleep(10)
320323
elapsed += 10

0 commit comments

Comments
 (0)