from .xlate import XLATOR
-__version__ = '2.9.0'
+__version__ = '2.9.1'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
try:
vm = TerraformVm.from_def(
- vm_def, name=name, is_template=True, template_vm=template_vm,
- default_cluster=self.config.vsphere_cluster, appname=self.appname,
+ vm_def, name=name, is_template=True, template_vm=template_vm, appname=self.appname,
verbose=self.verbose, base_dir=self.base_dir, simulate=self.simulate,
force=self.force, terminal_has_colors=self.terminal_has_colors)
except Exception as e:
try:
vm = TerraformVm.from_def(
- vm_def, is_template=False, template_vm=template_vm,
- default_cluster=self.config.vsphere_cluster, appname=self.appname,
+ vm_def, is_template=False, template_vm=template_vm, appname=self.appname,
verbose=self.verbose, base_dir=self.base_dir, simulate=self.simulate,
force=self.force, terminal_has_colors=self.terminal_has_colors)
except Exception as e:
from .interface import TerraformInterface
-__version__ = '1.3.1'
+__version__ = '1.4.1'
LOG = logging.getLogger(__name__)
class TerraformVm(HandlingObject):
"""A class encapsulating a VirtualMachine managed by Terraform."""
+ default_vsphere = 'life'
+
default_boot_delay = 5
default_customer = 'Pixelpark'
default_ds_type = 'sata'
customer=None, rootdisk_size=None, purpose=None, puppet_contact=None, puppet_role=None,
puppet_customer=None, puppet_project=None, puppet_tier=None, puppet_env=None,
vm_template=None, nameservers=None, has_backup=True, has_puppet=True,
- already_existing=None):
+ already_existing=None, vsphere=None):
+ self._vsphere = self.default_vsphere
self._is_template = bool(is_template)
self._name = None
self._fqdn = None
self._puppet_tier = self.default_puppet_tier
self._puppet_env = None
self._puppet_role = self.default_puppet_role
- self._vm_template = CrTfConfiguration.default_template_name
+ self._vm_template = None
self._has_backup = bool(has_backup)
self._has_puppet = bool(has_puppet)
self._already_existing = False
cluster=cluster, rootdisk_size=rootdisk_size, nameservers=nameservers, purpose=purpose,
customer=customer, ds_cluster=ds_cluster, datastore=datastore, ds_type=ds_type,
already_existing=already_existing, initialized=initialized, puppet_role=puppet_role,
- puppet_project=puppet_project,)
+ puppet_project=puppet_project, vsphere=vsphere)
# -------------------------------------------------------------------------
def _post_init(self, name=None, fqdn=None, nameservers=None, initialized=False, **kwargs):
@classmethod
def from_def(
cls, vm_def, name=None, is_template=False, template_vm=None, appname=None,
- verbose=0, base_dir=None, simulate=False, force=False, default_cluster='',
+ verbose=0, base_dir=None, simulate=False, force=False,
terminal_has_colors=False, initialized=False):
if verbose > 2:
else:
vm = cls(
appname=appname, verbose=verbose, base_dir=base_dir, simulate=simulate,
- force=force, is_template=is_template, name=name, cluster=default_cluster,
+ force=force, is_template=is_template, name=name,
terminal_has_colors=terminal_has_colors)
vm.initialized = False
vm.fqdn = value
return True
+ if key.lower() == 'vsphere' and value:
+ vm.vsphere = value
+ return
+
if key.lower() == 'cluster':
vm.cluster = value
return True
puppet_env=self.puppet_env, puppet_role=self.puppet_role, nameservers=self.nameservers,
rootdisk_size=self.rootdisk_size, has_backup=self.has_backup,
has_puppet=self.has_puppet, puppet_project=self.puppet_project,
+ vsphere=self.vsphere,
)
vm.disks = copy.copy(self.disks)
self._name = val
+ # -----------------------------------------------------------
+ @property
+ def vsphere(self):
+ """The name of the VSPhere from configuration, in which
+ the VM should be created."""
+ return self._vsphere
+
+ @vsphere.setter
+ def vsphere(self, value):
+ if value is None:
+ msg = _("The name of the vsphere may not be None.")
+ raise TerraformVmDefinitionError(msg)
+
+ val = str(value).strip()
+ if val == '':
+ msg = _("The name of the vsphere may not be empty.")
+ raise TerraformVmDefinitionError(msg)
+
+ self._vsphere = val
+
# -----------------------------------------------------------
@property
def tf_name(self):
res['rootdisk_size'] = self.rootdisk_size
res['tf_name'] = self.tf_name
res['vm_template'] = self.vm_template
+ res['vsphere'] = self.vsphere
for interface in self.interfaces:
res['interfaces'].append(interface.as_dict(short=short))