from __future__ import absolute_import, print_function
# Standard module
-import sys
import os
import logging
import ssl
import textwrap
# Third party modules
-import six
import pytz
import paramiko
# 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')
"""Special error class for the case, that no SAN based data store was with
enogh free space was found."""
-
# -------------------------------------------------------------------------
def __init__(self, needed_bytes):
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()
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))
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
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)
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))