Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ansible/plugins/action/onie.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def run(self, tmp=None, task_vars=None):
_install = boolean(self._task.args.get('install', 'no'))
_url = self._task.args.get('url', None)
_timeout = self._task.args.get('timeout', None)
_nretry = int(self._task.args.get('retry', 3))

if _timeout is None:
_timeout = 300
Expand All @@ -43,7 +44,8 @@ def run(self, tmp=None, task_vars=None):
host=_host,
url=_url,
install=_install,
timeout=_timeout)
timeout=_timeout,
retry=_nretry)

return result

18 changes: 13 additions & 5 deletions ansible/plugins/connection/onie.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def exec_command(self, *args, **kwargs):
self.host = kwargs['host']
self.url = kwargs['url']
self.install = kwargs['install']
self.nretry = kwargs['retry']

self._build_command()

Expand Down Expand Up @@ -101,11 +102,18 @@ def exec_command(self, *args, **kwargs):
client.sendline('onie-discovery-stop')
client.expect(prompts)
stdout += client.before
client.sendline("onie-nos-install %s" % self.url)
i = client.expect(["Installed SONiC base image SONiC-OS successfully"] + prompts)
stdout += client.before
if i != 0:
raise AnsibleError("Failed to install sonic image. %s" % stdout)
attempt = 0
while attempt < self.nretry:
client.sendline("onie-nos-install %s" % self.url)
i = client.expect(["Installed SONiC base image SONiC-OS successfully"] + prompts)
stdout += client.before
if i == 0:
break
elif i == 1:
attempt += 1
self._display.vvv("Installation fails, retry %d..." % attempt, host=self.host)
else:
raise AnsibleError("Failed to install sonic image. %s" % stdout)
self._display.vvv("SONiC installed.", host=self.host)
# for some platform, e.g., DELL S6000, it will do hard reboot,
# which will not give EOF
Expand Down