If ssh-keyscan fails, we would hang forever. Stop that nonsense, and
give up eventually, print a warning, and move on.
Signed-off-by: Zack Cerza <zack@redhat.com>
import re
import collections
import os
-import time
import requests
import urllib
from distutils.spawn import find_executable
from . import misc
from . import provision
from .config import config
+from .contextutil import safe_while
from .lockstatus import get_status
log = logging.getLogger(__name__)
if not status:
status_info = get_status(name)
if status_info['is_vm']:
- ssh_key = None
- while not ssh_key:
- time.sleep(10)
- ssh_key = ssh_keyscan([name])
+ with safe_while(sleep=10, tries=3, _raise=False,
+ action='ssh-keyscan') as proceed:
+ while proceed():
+ ssh_key = ssh_keyscan([name])
+ if ssh_key:
+ break
updated = {}
if description is not None:
updated['description'] = description