import copy
import os
import logging
+import random
import re
import stat
import sys
from fb_tools.errors import HandlerError, ExpectedHandlerError
from fb_tools.handling_obj import HandlingObject, CalledProcessError
from fb_tools.handler import BaseHandler
+from fb_tools.spinner import CycleList
# Own modules
from ..errors import ConsulApiNotFoundError
from ..xlate import XLATOR
-__version__ = '4.3.2'
+__version__ = '4.4.0'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
print(_("and enter: {}").format(self.colored('terraform apply', 'GREEN')))
print()
+ # -------------------------------------------------------------------------
+ def get_spinner_name(self):
+ """
+ Return the name of a valid spinner.
+
+ If the configured spinner is 'random', then a random name from the list
+ of all available spinners will be returned.
+ """
+ if self.config and self.config.spinner != 'random':
+ return self.config.spinner
+
+ randomizer = random.SystemRandom()
+ return randomizer.choice(list(CycleList.keys()))
+
# -------------------------------------------------------------------------
def exit(self, retval=-1, msg=None):
"""Exit the current application."""
# Third party modules
from fb_tools.common import pp
-from fb_tools.errors import HandlerError, ExpectedHandlerError
-from fb_vmware.errors import VSphereExpectedError
+from fb_tools.errors import ExpectedHandlerError
+from fb_tools.errors import HandlerError
+from fb_tools.spinner import Spinner
+
from fb_vmware.config import VSPhereConfigInfo
from fb_vmware.connect import VsphereConnection
+from fb_vmware.errors import VSphereExpectedError
# Own modules
from ..errors import AbortExecution
from ..xlate import XLATOR
-__version__ = '1.1.0'
+__version__ = '1.2.0'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
self.incr_verbosity()
nr_total = 0
+ spinner_name = self.get_spinner_name()
for vsphere_name in self.vsphere:
- LOG.debug(_("Searching for datastores in VSPhere {!r} ...").format(vsphere_name))
- self.vsphere[vsphere_name].get_datastores()
+ msg = _('Searching for datastores in VSPhere {!r} ...').format(vsphere_name)
+ if self.verbose:
+ LOG.debug(msg)
+ self.vsphere[vsphere_name].get_datastores()
+ else:
+ with Spinner(msg + ' ', spinner_name):
+ self.vsphere[vsphere_name].get_datastores()
+
nr_total += len(self.vsphere[vsphere_name].datastores.keys())
if nr_total:
def exec_vmw_ds_clusters(self):
nr_total = 0
+ spinner_name = self.get_spinner_name()
if self.stop_at_step == 'vmw-ds-clusters':
self.incr_verbosity()
for vsphere_name in self.vsphere:
- LOG.debug(_("Searching for datastore clusters in VSPhere {!r} ...").format(
- vsphere_name))
- self.vsphere[vsphere_name].get_ds_clusters()
+ msg = _("Searching for datastore clusters in VSPhere {!r} ...").format(vsphere_name)
+ if self.verbose:
+ LOG.debug(msg)
+ self.vsphere[vsphere_name].get_ds_clusters()
+ else:
+ with Spinner(msg + ' ', spinner_name):
+ self.vsphere[vsphere_name].get_ds_clusters()
nr_total += len(self.vsphere[vsphere_name].ds_clusters.keys())
if nr_total:
if self.stop_at_step == 'vmw-networks':
self.incr_verbosity()
+ spinner_name = self.get_spinner_name()
+
for vsphere_name in self.vsphere:
- LOG.debug(_("Searching for networks in VSPhere {!r} ...").format(vsphere_name))
- self.vsphere[vsphere_name].get_networks()
+ msg = _("Searching for networks in VSPhere {!r} ...").format(vsphere_name)
+ if self.verbose:
+ LOG.debug(msg)
+ self.vsphere[vsphere_name].get_networks()
+ else:
+ with Spinner(msg + ' ', spinner_name):
+ self.vsphere[vsphere_name].get_networks()
+
if self.eval_errors:
msg = ngettext(
"Found one error in exploring vSphere {v!r} resources.",
total_vms = 0
slim_vms = []
slim_verbose = 3
+ re_vm = re.compile(r'.*')
+
+ spinner_name = self.get_spinner_name()
+
+ def _do_get_vms(vsphere_name):
+ return self.vsphere[vsphere_name].get_vms(re_vm, as_obj=True, stop_at_found=False)
for vsphere_name in self.vsphere:
if vsphere_name not in self.vsphere_vm_cache:
self.vsphere_vm_cache[vsphere_name] = []
- re_vm = re.compile(r'.*')
- vm_list = self.vsphere[vsphere_name].get_vms(re_vm, as_obj=True, stop_at_found=False)
+ msg = _('Getting all VSPhere VMs and templates from {!r} ...').format(vsphere_name)
+
+ if self.verbose:
+ LOG.debug(msg)
+ vm_list = _do_get_vms(vsphere_name)
+ else:
+ with Spinner(msg + ' ', spinner_name):
+ vm_list = _do_get_vms(vsphere_name)
for vm in vm_list:
self.vsphere_vm_cache[vsphere_name].append(vm)