Skip to content

Commit

Permalink
Merge pull request #176 from zhenzhenc/private/czz/312596
Browse files Browse the repository at this point in the history
when connect xapi fail will retry 10 times and call wait_for_hosts(session) behind session established
  • Loading branch information
DeliZhangX authored Jul 30, 2019
2 parents 82602c5 + 7ea8170 commit ec49357
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
3 changes: 3 additions & 0 deletions autocertkit/ack_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,9 @@ def main(config, test_run_file):

session = get_xapi_session(config)

# Ensure that all hosts in the pool have booted up.
utils.wait_for_hosts(session)

# Start Logger
utils.init_ack_logging(session)

Expand Down
1 change: 0 additions & 1 deletion autocertkit/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ def run_tests_from_file(test_file):
"""Open the testfile, retrieve the next un-executed to completion test"""

session = get_local_xapi_session()

# Ensure that all hosts in the pool have booted up. (for the case where
# we have had to reboot to switch backend).
wait_for_hosts(session)
Expand Down
16 changes: 12 additions & 4 deletions autocertkit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,10 +597,18 @@ def validate_rec(self, rec):

def get_local_xapi_session():
"""Login to Xapi locally. This will only work if this script is being run
on Dom0. For this, no credentials are required."""
session = XenAPI.xapi_local()
session.login_with_password("", "")
return session
on Dom0. For this, no credentials are required. Wait until session connected successfully."""
for i in range(10):
if i > 0:
time.sleep(15)
try:
session = XenAPI.xapi_local()
session.login_with_password("", "")
return session
except Exception as e:
log.debug("Get xapi session error: '%s', retry: %d" % (e, i))
else:
raise e


def get_pool_master(session):
Expand Down

0 comments on commit ec49357

Please sign in to comment.