From: Frank Brehm Date: Tue, 24 Apr 2018 13:38:47 +0000 (+0200) Subject: Applying flake8 rules to lib/cr_vmware_tpl/handler.py X-Git-Tag: 0.1.1~7^2~2 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=dc77b2d404598b4f301d6a5a099dd005407d0001;p=pixelpark%2Fcreate-vmware-tpl.git Applying flake8 rules to lib/cr_vmware_tpl/handler.py --- diff --git a/lib/cr_vmware_tpl/handler.py b/lib/cr_vmware_tpl/handler.py index 39aff3d..0830eaf 100644 --- a/lib/cr_vmware_tpl/handler.py +++ b/lib/cr_vmware_tpl/handler.py @@ -9,7 +9,6 @@ from __future__ import absolute_import, print_function # Standard module -import sys import os import logging import ssl @@ -21,7 +20,6 @@ import socket import textwrap # Third party modules -import six import pytz import paramiko @@ -32,13 +30,13 @@ from pyVim.connect import SmartConnect, Disconnect # Own modules from .common import pp, to_str -from .errors import FunctionNotImplementedError, PpError +from .errors import PpError from .obj import PpBaseObject from .config import CrTplConfiguration -__version__ = '0.7.6' +__version__ = '0.7.7' LOG = logging.getLogger(__name__) TZ = pytz.timezone('Europe/Berlin') @@ -78,7 +76,6 @@ class NoDatastoreFoundError(ExpectedHandlerError): """Special error class for the case, that no SAN based data store was with enogh free space was found.""" - # ------------------------------------------------------------------------- def __init__(self, needed_bytes): @@ -265,8 +262,7 @@ class CrTplHandler(PpBaseObject): task_list = [str(task) for task in tasks] LOG.debug("Waiting for tasks {} to finish ...".format(task_list)) # Create filter - obj_specs = [vmodl.query.PropertyCollector.ObjectSpec(obj=task) - for task in tasks] + obj_specs = [vmodl.query.PropertyCollector.ObjectSpec(obj=task) for task in tasks] property_spec = vmodl.query.PropertyCollector.PropertySpec( type=vim.Task, pathSet=[], all=True) filter_spec = vmodl.query.PropertyCollector.FilterSpec() @@ -525,7 +521,6 @@ class CrTplHandler(PpBaseObject): return if isinstance(child, vim.Datastore): - #if not child.summary.multipleHostAccess: if self.re_local_ds.match(child.summary.name): if self.verbose > 2: LOG.debug("Datastore {!r} seems to be local.".format(child.summary.name)) @@ -585,7 +580,7 @@ class CrTplHandler(PpBaseObject): disk_spec.device.backing.diskMode = 'persistent' disk_spec.device.backing.fileName = '{}template-sda.vmdk'.format(datastore_path) disk_spec.device.unitNumber = 0 - #disk_spec.device.key = 1 + # disk_spec.device.key = 1 disk_spec.device.capacityInKB = self.config.data_size_kb disk_spec.device.controllerKey = controller.key @@ -1005,8 +1000,6 @@ class CrTplHandler(PpBaseObject): LOG.info("Setting a new, randomized MAC address for template VM ...") - current_macs = [] - last_tuple1 = random.randint(1, 254) last_tuple2 = random.randint(1, 254) new_mac = self.config.mac_address_template.format(last_tuple1, last_tuple2) @@ -1104,8 +1097,7 @@ class CrTplHandler(PpBaseObject): created = templates_ts[tpl_name] ts_created = datetime.datetime.fromtimestamp(created, tz=TZ) new_name = tpl_name + '.' + ts_created.strftime('%Y-%m-%d_%H-%M-%S') - LOG.info("Renaming template {o!r} => {n!r} ...".format( - o=tpl_name, n=new_name)) + LOG.info("Renaming template {o!r} => {n!r} ...".format(o=tpl_name, n=new_name)) task = template.Rename_Task(new_name) self.wait_for_tasks([task]) LOG.debug("Successful renamed template into {!r}.".format(new_name))