From 433f6209058c477484ad724a72eb14e6be231655 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Mon, 28 Nov 2016 20:00:20 +0100 Subject: [PATCH] If a VMware command fail retry Ref #1671 --- gns3server/compute/vmware/__init__.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/gns3server/compute/vmware/__init__.py b/gns3server/compute/vmware/__init__.py index bf6bd0b9..cd36d741 100644 --- a/gns3server/compute/vmware/__init__.py +++ b/gns3server/compute/vmware/__init__.py @@ -359,15 +359,21 @@ class VMware(BaseManager): @asyncio.coroutine def execute(self, subcommand, args, timeout=120, log_level=logging.INFO): - try: - return (yield from self._execute(subcommand, args, timeout=timeout, log_level=log_level)) - except VMwareError as e: - # We can fail to detect that it's VMware player instead of Workstation (due to marketing change Player is now Player Workstation) - if self.host_type == "ws" and "VIX_SERVICEPROVIDER_VMWARE_WORKSTATION" in str(e): - self._host_type = "player" + trial = 2 + + while trial: + try: return (yield from self._execute(subcommand, args, timeout=timeout, log_level=log_level)) - else: - raise e + except VMwareError as e: + # We can fail to detect that it's VMware player instead of Workstation (due to marketing change Player is now Player Workstation) + if self.host_type == "ws" and "VIX_SERVICEPROVIDER_VMWARE_WORKSTATION" in str(e): + self._host_type = "player" + return (yield from self._execute(subcommand, args, timeout=timeout, log_level=log_level)) + else: + if trial <= 0: + raise e + trial -= 1 + yield from asyncio.sleep(0.5) @asyncio.coroutine def _execute(self, subcommand, args, timeout=120, log_level=logging.INFO):