]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Applying flake8 rules to lib/cr_vmware_tpl/handler.py
authorFrank Brehm <frank.brehm@pixelpark.com>
Tue, 24 Apr 2018 13:38:47 +0000 (15:38 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Tue, 24 Apr 2018 13:38:47 +0000 (15:38 +0200)
lib/cr_vmware_tpl/handler.py

index 39aff3d509c7f0b5dbd63143f539a5f0ed111b82..0830eafb0f4a1b055872b9c5b859b54041b7f84b 100644 (file)
@@ -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))