from .xlate import __mo_file__ as __xlate_mo_file__
from .xlate import XLATOR, LOCALE_DIR, DOMAIN
-__version__ = '1.3.3'
+__version__ = '1.3.4'
LOG = logging.getLogger(__name__)
SIGNAL_NAMES = {
msg = _("No {} given.").format(_('vSphere user name'))
raise ExpectedHandlerError(msg)
- for vname in self.handler.vsphere.keys():
+ for vsphere_name in self.handler.vsphere.keys():
LOG.debug(_("Setting user for vSphere {vs!r} to {usr!r}.").format(
- vs=vname, usr=self.handler.vsphere_user))
+ vs=vsphere_name, usr=self.handler.vsphere_user))
# Dirty, but else a change of fb_tools would be necessary (later)
- self.handler.vsphere[vname]._user = self.handler.vsphere_user
+ self.handler.vsphere[vsphere_name]._user = self.handler.vsphere_user
print('')
need_nl = False
if not self.handler.vsphere_password:
# Get the name of the first (and hopefully only) VSphere
- vname = None
+ vsphere_name = None
for vn in self.handler.vsphere.keys():
- vname = vn
+ vsphere_name = vn
break
if need_nl:
prompt = self.colored(_("User password of {!r}").format(
self.handler.vsphere_user), 'AQUA')
item = _('Password for user {u!r} of vSphere {n} on {h!r}').format(
- u=self.handler.vsphere_user, n=vname, h=self.config.vsphere[vname].host)
+ u=self.handler.vsphere_user, n=vsphere_name, h=self.config.vsphere[vsphere_name].host)
item = self.colored(item, 'AQUA')
self.handler.vsphere_password = self.get_secret(prompt=prompt, item_name=item)
if not self.handler.vsphere_password:
msg = _("No {} given.").format(_('password of vSphere user'))
raise ExpectedHandlerError(msg)
- for vname in self.handler.vsphere.keys():
+ for vsphere_name in self.handler.vsphere.keys():
LOG.debug(_("Setting passwort of vSphere {vs!r} user {usr!r}.").format(
- vs=vname, usr=self.handler.vsphere_user))
+ vs=vsphere_name, usr=self.handler.vsphere_user))
# Dirty, but else a change of fb_tools would be necessary (later)
- self.handler.vsphere[vname]._password = self.handler.vsphere_password
+ self.handler.vsphere[vsphere_name]._password = self.handler.vsphere_password
print('')
need_nl = False
from ..xlate import XLATOR
-__version__ = '0.2.0'
+__version__ = '0.2.1'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
LOG.info(_("Collecting all VMWare and local folders ..."))
LOG.info(_("Get vSphere datacenter ..."))
- for vname in self.vsphere:
- self.vsphere[vname].get_datacenter()
+ for vsphere_name in self.vsphere:
+ self.vsphere[vsphere_name].get_datacenter()
LOG.debug(_("Collecting used vSphere folders."))
self.vsphere_folders = []
# Test for multiple VSphere references
found_vspheres = []
for vm in self.vms:
- vname = vm.vsphere
- if vname not in found_vspheres:
- found_vspheres.append(vname)
+ vsphere_name = vm.vsphere
+ if vsphere_name not in found_vspheres:
+ found_vspheres.append(vsphere_name)
if len(found_vspheres) > 1:
yaml_file_rel = os.path.relpath(str(yaml_file), os.getcwd())
msg = _("There is only one, unique VSPhere definition allowed in a project file.")
msg += '\n'
msg += _("In {f!r} were found {nr} different VSPhere definitions:").format(
f=yaml_file_rel, nr=len(found_vspheres))
- for vname in sorted(found_vspheres, key=str.lower):
- msg += '\n * {!r}'.format(vname)
+ for vsphere_name in sorted(found_vspheres, key=str.lower):
+ msg += '\n * {!r}'.format(vsphere_name)
raise ExpectedHandlerError(msg)
self._init_vspheres()
for vm in self.vms:
if vm.vsphere in self.vsphere:
continue
- vname = vm.vsphere
- LOG.debug(_("Initializing VSphere {!r} ...").format(vname))
- if vname not in self.config.vsphere:
- msg = _("VSPhere {!r} not defined in configuration.").format(vname)
+ vsphere_name = vm.vsphere
+ LOG.debug(_("Initializing VSphere {!r} ...").format(vsphere_name))
+ if vsphere_name not in self.config.vsphere:
+ msg = _("VSPhere {!r} not defined in configuration.").format(vsphere_name)
raise ExpectedHandlerError(msg)
- if not self.vsphere_user and self.config.vsphere[vname].user:
+ if not self.vsphere_user and self.config.vsphere[vsphere_name].user:
LOG.debug(_("Setting {st} to {what!r}.").format(
- st='handler.vsphere_user', what=self.config.vsphere[vname].user))
- self.vsphere_user = self.config.vsphere[vname].user
- if not self.vsphere_password and self.config.vsphere[vname].password:
+ st='handler.vsphere_user', what=self.config.vsphere[vsphere_name].user))
+ self.vsphere_user = self.config.vsphere[vsphere_name].user
+ if not self.vsphere_password and self.config.vsphere[vsphere_name].password:
LOG.debug(_("Setting {}.").format('handler.vsphere_password'))
- self.vsphere_password = self.config.vsphere[vname].password
+ self.vsphere_password = self.config.vsphere[vsphere_name].password
try:
params = {
connect_info = VSPhereConfigInfo(
appname=self.appname, verbose=self.verbose, base_dir=self.base_dir,
- host=self.config.vsphere[vname].host, port=self.config.vsphere[vname].port,
- dc=self.config.vsphere[vname].dc, user=self.vsphere_user,
+ host=self.config.vsphere[vsphere_name].host, port=self.config.vsphere[vsphere_name].port,
+ dc=self.config.vsphere[vsphere_name].dc, user=self.vsphere_user,
password=self.vsphere_password, initialized=True)
params['connect_info'] = connect_info
LOG.debug(msg)
vsphere = VsphereConnection(**params)
- self.vsphere[vname] = vsphere
+ self.vsphere[vsphere_name] = vsphere
except VSphereExpectedError as e:
raise ExpectedHandlerError(str(e))
if self.stop_at_step == 'vmw-test':
self.incr_verbosity()
- for vname in self.vsphere.keys():
+ for vsphere_name in self.vsphere.keys():
try:
- vsphere = self.vsphere[vname]
+ vsphere = self.vsphere[vsphere_name]
vsphere.get_about()
if self.verbose > 2:
if self.stop_at_step == 'vmw-clusters':
self.incr_verbosity()
- for vname in self.vsphere:
- LOG.debug(_("Searching for clusters in VSPhere {!r} ...").format(vname))
- self.vsphere[vname].get_clusters()
+ for vsphere_name in self.vsphere:
+ LOG.debug(_("Searching for clusters in VSPhere {!r} ...").format(vsphere_name))
+ self.vsphere[vsphere_name].get_clusters()
LOG.info(_("Finished step {!r}.").format('vmw-clusters'))
if self.stop_at_step == 'vmw-clusters':
nr_total = 0
- for vname in self.vsphere:
- LOG.debug(_("Searching for datastores in VSPhere {!r} ...").format(vname))
- self.vsphere[vname].get_datastores()
- nr_total += len(self.vsphere[vname].datastores.keys())
+ for vsphere_name in self.vsphere:
+ LOG.debug(_("Searching for datastores in VSPhere {!r} ...").format(vsphere_name))
+ self.vsphere[vsphere_name].get_datastores()
+ nr_total += len(self.vsphere[vsphere_name].datastores.keys())
if nr_total:
msg = ngettext("Found one datastore.", "Found {n} datastores.", nr_total)
if self.stop_at_step == 'vmw-ds-clusters':
self.incr_verbosity()
- for vname in self.vsphere:
- LOG.debug(_("Searching for datastore clusters in VSPhere {!r} ...").format(vname))
- self.vsphere[vname].get_ds_clusters()
- nr_total += len(self.vsphere[vname].ds_clusters.keys())
+ 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()
+ nr_total += len(self.vsphere[vsphere_name].ds_clusters.keys())
if nr_total:
msg = ngettext(
if self.stop_at_step == 'vmw-networks':
self.incr_verbosity()
- for vname in self.vsphere:
- LOG.debug(_("Searching for networks in VSPhere {!r} ...").format(vname))
- self.vsphere[vname].get_networks()
+ for vsphere_name in self.vsphere:
+ LOG.debug(_("Searching for networks in VSPhere {!r} ...").format(vsphere_name))
+ self.vsphere[vsphere_name].get_networks()
if self.eval_errors:
msg = ngettext(
"Found one error in exploring vSphere {v!r} resources.",
"Found {n} errors in exploring vSphere {v!r} resources.",
- self.eval_errors).format(n=self.eval_errors, v=vname)
+ self.eval_errors).format(n=self.eval_errors, v=vsphere_name)
raise ExpectedHandlerError(msg)
LOG.info(_("Finished step {!r}.").format('vmw-networks'))
for vm in self.vms:
- vname = vm.vsphere
- if vname not in clusters:
- clusters[vname] = {}
+ vsphere_name = vm.vsphere
+ if vsphere_name not in clusters:
+ clusters[vsphere_name] = {}
if vm.cluster in clusters:
- clusters[vname][vm.cluster].append(vm.name)
+ clusters[vsphere_name][vm.cluster].append(vm.name)
else:
- clusters[vname][vm.cluster] = [vm.name]
+ clusters[vsphere_name][vm.cluster] = [vm.name]
- for vname in clusters.keys():
- for cluster in clusters[vname].keys():
+ for vsphere_name in clusters.keys():
+ for cluster in clusters[vsphere_name].keys():
- vms = clusters[vname][cluster]
+ vms = clusters[vsphere_name][cluster]
cl = str(cluster)
LOG.debug(_(
"Checking existence of computing cluster {c!r} in VSPhere {v!r} ...").format(
- c=cl, v=vname))
+ c=cl, v=vsphere_name))
- vsphere = self.vsphere[vname]
+ vsphere = self.vsphere[vsphere_name]
vmw_cluster = vsphere.get_cluster_by_name(cl)
if vmw_cluster:
if self.verbose > 1:
LOG.debug(_(
"Found computing cluster {cl!r} in VSPhere {v!r} (defined for VMs "
- "{vms}).").format(cl=vmw_cluster.name, v=vname, vms=pp(vms)))
+ "{vms}).").format(cl=vmw_cluster.name, v=vsphere_name, vms=pp(vms)))
else:
LOG.error(_(
"Computing cluster {cl!r} (defined for VMs {vms}) in VSPhere {v!r} not "
- "found.").format(cl=cl, vms=pp(vms), v=vname))
+ "found.").format(cl=cl, vms=pp(vms), v=vsphere_name))
self.eval_errors += 1
# -------------------------------------------------------------------------ยท